Você está na página 1de 2

UNIT 1 – Introduction to Python

Topic: GETTING STARTED


WORKSHEET

1 Mark Questions(Very Short Questions):

1)Create following Variables


i) „mystring‟ to contain „hello‟
ii) „myfloat‟ to contain „2.5‟
iii) „myint‟ to contain „10‟

2) True or False
i) Character Data type values should be delimited by using the single quote.
ii) None is one of the data type in python
iii) The += operator is used to add the right hand side value to the left hand side
variable.
iv) The data type double is not a valid python data type.
v) Python does not have any keywords
vi) The equal to condition is written by using the == operator

3)I want to divide 1 by 3 and get a result like: 0.333333333333. What is the exact command to
do this?

4)What will be the output of the following:


a. i=30*15/3
b. i=30/15*3

5)What is the result of the following expression :


p>=q && (p+q) > p
a. P=3,q=0
b. P=5,q=5

6) Predict the output of :


a. print(type("17"))
b. print(type("3.2"))
7) What will be the output of :
a. print(2 ** 3 ** 2)
b. print((2 ** 3) ** 2)
8)What is the order of the arithmetic operations in the following expression. Evaluate the
expression.
2 + (3 - 1) * 10 / 5 * (2 + 3)
9) What will be the type of the following result :

i. 3.14 * 7 * 7
ii. Hello * 26

1
10)Write a program to calculate volume and surface of a cylinder whose radius is
given by the user.
11) What is type casting and how is implemented in python

12)What is printed when the following statements execute?


day = "Thursday"
day = 32.5
day = 19
print(day)

13)Evaluate the following expressions:


a) 3*(3*(3*len(“ab”)))
b) (60<110/0) and (15<150)
c) Len(“helloworld”)==100/10
d) Len(“helloworld”)==100/10 and 200/20

Programming questions
1) Write a program to find roots of a quadratic equation.
2) Write a program to find whether a number entered by the user is positive or negative.
3) Rohit gets a basic pay of Rs.8000. His dearness Allowance is 40% of basic salary and house
rent allowance is 20% of the basic salary. Calculate his gross salary.
4) Write a program to calculate simple interest.
5) Many people keep time using a 24 hour clock (11 is 11am and 23 is 11pm, 0 is midnight). If
it is currently 13 and you set your alarm to go off in 50 hours, it will be 15 (3pm). Write a
Python program to the above problem. Ask the user for the time now (in hours), and then ask
for the number of hours to wait for the alarm. Your program should output what the time will
be on the clock when the alarm goes off.
6) Write a program to calculate area of a triangle using hero’s formula.
7) Write a program to calculate volume and surface area of a cuboid whose length, breadth and
height are given.
8) Name the days of the week from 0-6 where day 0 is Sunday and day 6 is Saturday. If you go
on a holiday leaving on day number 3 (a Wednesday) and you return home after 10 nights.
Write a program which asks for the starting day number, and the length of your stay, and it
will tell you the number of day of the week you will return on.
9) Use IDLE to do the following:
i. Calculate total and average of marks scored in five subjects
ii. Find whether a number is even or odd.
iii. Find whether a number is divisible by 3 .

Você também pode gostar