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

1 - Variables and DataTypes

The document provides instructions for an assignment on basics of Python. It includes: - Several questions to help learn Python concepts like variables, data types, operators etc. and asks to write code snippets as answers. - Hints that some questions require topics not covered yet and to join mentoring sessions for support. - The last section includes more advanced questions on calculations involving math formulas and discounts. Students are instructed to code out the answers.

Uploaded by

Laxmi Potnuru
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)
47 views

1 - Variables and DataTypes

The document provides instructions for an assignment on basics of Python. It includes: - Several questions to help learn Python concepts like variables, data types, operators etc. and asks to write code snippets as answers. - Hints that some questions require topics not covered yet and to join mentoring sessions for support. - The last section includes more advanced questions on calculations involving math formulas and discounts. Students are instructed to code out the answers.

Uploaded by

Laxmi Potnuru
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/ 4

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

Basics of Python
Question: Print your name
# CODE HERE
print('My name is Innomatics')

My name is Innomatics

Question: What is a variable? Write a Few words about Variables. Create a


Variable with an Example.

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)

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
# CODE HERE

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)

First Number : 100


Second Number : 200
Addition of Two Number is : 300

first number is : 100


second number is : 200
Addition of two numbers are : 300

Question: Add your first name and second name


# CODE HERE
first_name='Sachin '
second_name='Tendulkar'
print('My first name is :',first_name)
print('My second name is :',second_name)
print('My full Name is : ',first_name+second_name)
My first name is : Sachin
My second name is : Tendulkar
My full Name is : Sachin Tendulkar

My first name is : Sachin


My second name is : Tendulkar
My full name is : Sachin Tendulkar

Question: print the datatypes of the following


• 10,'10',True,10.5
# CODE HERE

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)

Addition of 123 and 456 is : 579

Addition of 123 and 456 is : 579


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?
# CODE HERE
r=5
v=4/3*(3.1415*r*r*r)
print('Volume of Sphere is : ',v)

Volume of Sphere is : 523.5833333333334

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

print('Total Whole sale cost: ',Total_cost)

Total Whole sale cost: 945.4499999999999

Innomatics Research Labs


www.innomatics.in

You might also like