Part 2: Objects, Variables, and Datatypes
5. Python Objects
Lecture VideoCode Snippet
6. Variables in Python
Lecture VideoCode Snippet
name = "Sachin"
rollno = 101
score1 = 60
score2 = 80
score3 = 70
print("Name:", name)
total = score1+score2+score3
print("Total score:", total)
#Calculator
a = 20
b = 4
print("Simple Calculator")
print("Addition:", a+b)
print("Subtraction:", a-b)
print("Multiplication:", a*b)
print("Division:", a/b)
#Reassignment
print("Reassignment")
a = 10
print(a)
a = 20
print(a)
#Datatype of variable
print("Datatype of variable")
a = 5
print(a, type(a))
a = "Hello"
print(a, type(a))
#Ways of assigning values to variables
print("Ways of assigning values to variables")
a, b, c = 10, "Hello", 6.5
print(a, b, c)
a = b = c = 10
print(a,b,c)
7. Naming Variables
Lecture VideoCode Snippet
8. Scalar datatypes in Python
Lecture VideoCode Snippet
#Integers
age = 25
batch_size = 100
no_of_items = 30
print(age, type(age))
a = 2345272788282929
b = 76547657465476547564
print(a+b)
#floats
price = 10.99
gpa = 3.8
temperature = 22.7
print(price, type(price))
#Complex numbers
cnum = 3+4j
print(cnum, type(cnum))
#boolean datatype
email_verified = False
if email_verified:
print("You can access the website")
else:
print("Please complete email verification to get access")
is_item_available = True
print(is_item_available, type(is_item_available))
#None datatype
email = None
print(email, type(email))