assignment-1-variables-and-datatypes
assignment-1-variables-and-datatypes
August 8, 2024
1 Assignment Instructions
Hello Innominion,
• Try to attempt all the questions in every possible way.
• Some other topics are required to solve some questions. don’t panic.
• Those questions can be answered after the topics are taught.
• Join Mentoring Session for the Support/Doubts Resolving with Our Technical
Mentors (2.00 PM - 6.00 PM Mon-Sat)
Happy Learning !!!
indra
Question: What is a variable? Write a Few words about Variables. Create a Variable
with an Example.
[4]: variable it stores data or values
[2]: a="indra"
print(a)
indra
Question: Assume that we execute the following assignment statements: width = 17
height = 12.0 delimiter = ‘.’ For each of the following expressions, write the value of
the expression and the type (of the value of the expression). 1. width/2 2. width/2.0
3. height/3 4. 1 + 2 * 5 5. delimiter * 5
[ ]: width = 17
height = 12.0
delimiter = '.'
1
[3]: width = 17
a=width/2
print(a)
type(a)
8.5
[3]: float
[5]: width = 17
a=width/2.0
print(a)
type(a)
8.5
[5]: float
4.0
[6]: float
[7]: c=1 + 2 * 5
print(c)
type(c)
11
[7]: int
[9]: str
Question: Add two number by taking variable names as first and seccond
[10]: a=100
b=200
2
a+b
[10]: 300
[ ]:
[17]: a=10
type(a)
[17]: int
[18]: b='10'
type(b)
[18]: str
[19]: c=True
type(c)
[19]: bool
[20]: d=10.5
type(d)
[20]: float
Question: > - num_int = 123 > - num_str = “456” > - Add num_int and num_str - hint:
first need to convert num_str into integer
3
[22]: num_str = '456'
a=int(num_str)
a
[22]: 456
[24]: 579
523.8095238095237
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?
[36]: price_of_a_book = 24.95
discount = 0.60
shipping_cost_for_first_copy = 3
shipping_cost_for_additional_copy = 0.75
total_copies = 60
[37]: 898.1999999999999
total_shipping_cost
[38]: 132.75
4
[39]: 1030.9499999999998