0% found this document useful (0 votes)
11 views

assignment-1-variables-and-datatypes

The document provides assignment instructions for a Python programming task, encouraging students to attempt all questions and seek help during mentoring sessions. It includes basic and advanced questions related to variables, data types, and calculations in Python. Examples of code snippets and their outputs are provided to illustrate the concepts discussed.

Uploaded by

Mbg Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

assignment-1-variables-and-datatypes

The document provides assignment instructions for a Python programming task, encouraging students to attempt all questions and seek help during mentoring sessions. It includes basic and advanced questions related to variables, data types, and calculations in Python. Examples of code snippets and their outputs are provided to illustrate the concepts discussed.

Uploaded by

Mbg Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

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 !!!

1.1 Basics of Python


Question: Print your name
[1]: print("indra")

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

[6]: height = 12.0


b=height/3
print(b)
type(b)

4.0

[6]: float

[7]: c=1 + 2 * 5
print(c)
type(c)

11

[7]: int

[9]: delimiter = '.'


d=delimiter * 5
print(d)
type(d)

[9]: str

Question: Add two number by taking variable names as first and seccond
[10]: a=100
b=200

2
a+b

[10]: 300

Question: Add your first name and second name


[14]: a="indra"
b="reddy"
a +" "+ b

[14]: 'indra reddy'

[ ]:

Question: print the datatypes of the following - 10,‘10’,True,10.5


[12]: a=10
b='10'
c=True
d=10.5

[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

[14]: num_int = 123


num_str = "456"

3
[22]: num_str = '456'
a=int(num_str)
a

[22]: 456

[24]: num_int = 123


a = 456
num_int+a

[24]: 579

1.1.1 Advanced Questions


Question: The volume of a sphere with radius r is 4/3�r3 . What is the volume of a
sphere with radius 5?
[31]: r=5
pi=22/7
volume_of_sphere= (4/3)*pi*r**3
print(volume_of_sphere)

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]: total_discount = total_copies * price_of_a_book * discount


total_discount

[37]: 898.1999999999999

[38]: total_shipping_cost = shipping_cost_for_first_copy *␣


↪shipping_cost_for_additional_copy * 59

total_shipping_cost

[38]: 132.75

[39]: total_wholesale_cost = total_discount + total_shipping_cost


total_wholesale_cost

4
[39]: 1030.9499999999998

2 Innomatics Research Labs


www.innomatics.in

You might also like