1 - Variables and DataTypes
1 - Variables and DataTypes
Hello Innominion,
• Some other topics are required to solve some questions. don't panic.
Basics of Python
Question: Print your name
# CODE HERE
print('My name is Innomatics')
My name is Innomatics
WRITE HERE
• Variables are noting but place holders to store the lieral Values.Variables can be
accessed by their names and some rules have to be followed while naming variables
• A Variable name can only contain Alphabets, Numbers and Underscore
• A variable name can only start with an under score or an alphabet
• A variable name can't be the same as any keyword( Key words are sequences of
characyters which have some special meaning to them)
• A Variable name can't have any spaces between the various parts of the variable. If
we want t distinguish them we can use an under score or make the variable name
# Code Here
a=1
b=2
c=a+b
print(c)
width=17
height=12.0
delimeter='.'
print('width/2 = ',width/2)
print('width/2.0 =',width/2.0)
print('height/3 = ',height/3)
print(1+2*5)
print(delimeter*5)
width/2 = 8.5
width/2.0 = 8.5
height/3 = 4.0
11
.....
Question: Add two number by taking variable names as first and seccond
#CODE HERE
First_Number=int(input('First Number : '))
Second_Number=int(input('Second Number : '))
Addition=First_Number+Second_Number
print('Addition of Two Number is : ',Addition)
print('10 - ',type(10))
print("'10'",type('10'))
print('True - ',type(True))
print('10.5 -',type(10.5))
10 - <class 'int'>
'10' <class 'str'>
True - <class 'bool'>
10.5 - <class 'float'>
10 - <class 'int'>
'10' - <class 'str'>
True - <class 'bool'>
10.5 - <class 'float'>
Question:
• num_int = 123
• num_str = "456"
• Add num_int and num_str
• hint: first need to convert num_str into integer
# CODE HERE
num_int=123
num_str="456"
num_str=int(num_str)
print('Addition of 123 and 456 is :',num_int+num_str)
Question: Suppose the cover price of a book is Rs.24.95, but bookstores get a
40% discount. Shipping costs Rs.3 for the first copy and 75 paise for each
additional copy. What is the total wholesale cost for 60 copies?
# CODE HERE
cover_price=24.95
discounted_price=cover_price*(1-0.4)
Total_book_price=60*discounted_price
shipping_cost=3+(59*0.75)
Total_cost=Total_book_price+shipping_cost