Basic Python Naveen: Notes by
Basic Python Naveen: Notes by
Basic Python
Notes By
Naveen
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 1
What is Python?
Python is an easy to learn, powerful programming language.
E-mail processing.
Education
Python is a superb language for teaching programming, both at the
introductory level and in more advanced courses.
Desktop GUIs
The Tk GUI library is included with most binary distributions of
Python.
wxWidgets
GTK+
Software Development
Python is often used as a support language for software developers,
for build control and management, testing, and in many other ways.
Business Applications
Python is also used to build ERP and e-commerce systems:
Automated Testing
Image Processing and OCR
Machine Learning Applications
Audio and Video Applications
Blockchain Applications
Artificial Intelligence
Data Science
Devops
etc., ....
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 5
Python With Naveen
1st Screen
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 6
Python With Naveen
2nd Screen
3rd Screen
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 7
Python With Naveen
3. In IDLE menu select "File" and "New File" and write the
program into the new file
Save the above file, (While saving we can give any name but
the extension must be ".py" only)
Note: Save the python files properly into a particular location.
4. ".py" stands for Python File.
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 8
Python With Naveen
Note: If python path is not set you cannot run in the command
prompt.
Naming Styles
The table below outlines some of the common naming styles in
Python code and when you should use them:
Out of 35 keywords 3 keywords like False, True and None will begin
with capital letter and rest of the 32 keywords will begin with small
letter.
Identifier
Identifier is a name given to an entity like Class, Function (or)
Method and Variable.
Assignment
1) What is Identifier
2) What is the purpose of identifier
3) Can we declare variables/functions/classes without identifier
4) Can we declare Identifier with space
5) Can we declare identifier with starting character as ‘_’
6) Can we declare identifier with starting character as number
7) Can we declare keywords as identifier
8) Can we declare identifier with symbols
9) Can we declare 2 identifiers with same name
10) Identify In-valid identifier in the following list
Tell the below statements are valid identifiers are not.
11) customer name
12) salary
13) sub1_marks
14) _eid
15) 7bc
16) true
17) loanAmount
18) Else
19) no.of.seats
20) if
21) discount_Amount
22) gstAmt
23) calTotalMarks
24) Employee
25) Loan
26) interest-Amount
27) customer2
28) pid
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 12
Python With Naveen
5. print(“Core\tAdvanced”) 6. print(“Sathya@'Naveen' ”)
Output:- Output:-
Data types
Syntax:
variable_name = value
Example:
name = "Ravi"
salary = 185000.00
status = False
Important point
In Python variables are dynamic typed it means the type of a variable
is decided at run time.
Assignment
1) What is variable
6) a = 10
a = 20
7) bill = 250.50
discountAmount = 50
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 16
Python With Naveen
v) p=5
q = 10
p+q=r
vi) x = 10
vii) age = 25
viii) gender = M
ix) rollno_ = 200
x) mno = 9052492329
xi) pin no=1234
xii) marks = 98.95
xiii) salary = 25478.35
xiv) pnr@no=1234567895
xv) email="pythonwithnaveen@gmail.com"
xvi) pnr_status=true
xvii) interest$rate = 8.2
xviii) creditcard1
xix) $aadharno
xx) break = 10
xxi) Break = 10
xxii) 3000 = x
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 17
Python With Naveen
Output:- Output:-
3. a = 5 4. a = 5
b=6 b=6
print("a+b") print("a"+b)
Output:- Output:-
5. a = 5 6. a = 15
b=6
b=6
c=a-b
print(a+b) print(c)
Ouptut:- Output:-
7. a = 5 8. a = 5
b=6 b=6
c=a+b c=a+b
print("Sum is : ",c) print(c,"is Your Result")
Output:- Output:-
9. a = 5 10.a = 5
b=6 b=6
c=a+b c=a+b
print("Sum ",c,"is your Result") print(a,"and",b,"sum is",c)
Output:- Output:-
11.cost = 2500 12.a = 10
discount = 10 b = 20
discAmt = (cost /100) * discount a=a+b
print(discAmt) b=a-b
a=a–b
Output:-
print(a, “\t”, b)
Output:-
13.a = 20 14.a = 2
a = "Naveen" b=a
print(a) print(b)
Output:- Output:-
Output:- Output:-
17. a=7 2. a = 7
b=5 b=5
a=a*b c=a
b = a // b a=b
a = a // b b=c
print(a,"\t",b) print(a,"\t",b)
Output:- Output:-
3. n = 12 4. c1 = "Advance"
sum = 0 c2 = " Django"
r = n % 10 c3 = " Project"
n = n // 10 c4 = c1 + c3 + c2 + c3
sum = sum + r print(c4)
r = n % 10
Output:-
n = n // 10
sum = sum + r
print(n,"\t",sum)
Output:-
5. a = 5 6. p = 5
b= 7 q=3
a,b = b,a r=7
print(a,"\t",b) print(p,"\t",q,"\t",r)
Output:- Output:-
7. p = 5 8. p = 5
q=3 q=3
r=7 r=7
print(p,q,r) print(p,q,r,sep=",")
Output:- Output:-
9. p = 5 10.p = 5
q=3 q=3
r=7 r=7
print(p,q,r,sep="$") print(p,q,r,sep="-->")
Output:- Output:-
11.p = 5 12.p = 5
q=3 q=3
r=7 print(p,end="\t")
print(p,q,r,sep="V") print(q)
Output: Output:-
13.p = 5 14.p = 5
q=3 q=3
print(p) print(p,end="-")
print(q) print(q)
Output:- Output:-
Output:- Output:-
17.a = 8 18.a = 8
b = 4 print("%d%d"% b = 4 print("%d\t%d"%
(a,b)) (a,b))
Output:- Output:-
Output:- Output:-
Output:- Output:-
23.a = 6 24.a = 6
print("A value is :{0}".format(a)) b=3
print("{0}\t{1}".format(a,b))
Output:-
Output:-
gst amount is 30
Types of Operator's
1) Arithmetic Operators
Operator Operator Name Example
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 24
Python With Naveen
2) Relational Operators
Operator Operator Name Example
== Equal to I = 20, J = 20
(I == J) is True
!= Not Equal to I = 20, J = 20
(I == J) is False
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 25
Python With Naveen
3) Assignment Operator
Operator Operator Description Example
Name
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 26
Python With Naveen
5) Logical Operators
Operator Operator Name Example
6) Membership Operators
Operator Example
in my_friends = ["Kapil","Bhanu","Srikanth","Naveen"]
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 27
Python With Naveen
I = 10 and J = 20
I = 10 = 00001010
J = 20 = 00010100
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 28
Python With Naveen
Assignment
1. How many types of operators in python.
5. Output of print(9//2)
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 29
Python With Naveen
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 31
Python With Naveen
Type Conversion
The process of converting a data type into another data type is
known as type conversion.
Function Description
a = int(no1) b
= int(no2)
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 35
Python With Naveen
print("Sum = ",no1+no2)
print("Sum = ",no1+no2)
# Legacy printing
x = 256.641484135541
print("Python-Lang Format :",x)
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 36
Python With Naveen
This function will read int, float, str, bool, list, set, tuple, dictionary
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 37
Python With Naveen
Assignment
1. How to read data dynamically
2. What is the default data type for input( )
3. Is it possible to convert String type to int type
4. How to convert string data into int type
5. How to convert string data into float type
6. What is the purpose of eval( )
7. WAP to Display Welcome To Sathya Technologies
8. WAP to accept the Student Name and Display a message
Welcome Student Name
9. WAP to accept two numbers and perform
addition, Subtraction, Multiplication and Division
10. WAP to find the type Of a Variable
11. WAP to accept student first name and last name and
Display the student full Name
12. WAP to accept a str value and convert the string value
to int and print int value.
13. WAP to accept a str value and convert the str value
to float and print double value.
14. WAP to accept student no, student name, marks1,
marks2, marks3 and calculate total marks, average marks
and print.
15. WAP to input two numbers and swap those values.
16. Sunitha Went to market, Purchased 4 sim cards. Read sim
cost dynamically then calculate and display total bill.
Youtube : https://www.youtube.com/c/pythonwithnaveen
Facebook : https://www.facebook.com/groups/pythonwithnaveen/ Page 38
Python With Naveen
int(123.654) str(10.5)
int(False) str(True)
int("10") str(False)
int("10.5") z = float("3")
float(10) print(10 == 9)
float(True) float("ten")
float(False) bool(0)
float("10") bool(1)
float("10.5") bool(10)