9b9c1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

AMITY INTERNATIONAL SCHOOL SAKET

WORKSHEET- GETTING STARTED WITH PYTHON


CLASS-XI

Multiple Choice Questions(MCQ) 1 Mark:

1. Which of the following is an invalid variable?


a. my_string_1 b. 1st_string c. Foo

2. What is the return type of id() function?


a. Bool b. list c. int d. double

3. Predict the output:


a=str(6/4)
b="6/4"
print(a==b)
a. True b. False

4. What is the output of this expression, 3*1**3?


a. 27 b. 9 c. 3 d. 1

5. Select all options that can print


hello-how-are-you
a. print(‘hello’, ‘how’, ‘are’, ‘you’)
b. print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c. print(‘hello-‘ + ‘how-are-you’)
d. print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ +‘-‘+‘you’)

6. Identify any false statement:


(i)Compile time errors are usually easier to detect and to correct than run-time errors.
(ii) Logical errors can usually be detected by the compiler.
a. (i) b. (ii) c. none

7. State True or False.


(i) Python shows an error whenever you assign a numeric value with comma in it.
(ii) Assignment of same value to multiple variables in a single statement is allowed in
python.
(iii) In python ‘is’ and ‘is not’ are two membership operators.
(iv) If a = ‘Small’, b = ‘World’ then the expression a and not b will yield ‘Small’

a. (i) True (ii) False (iii) False (iv) True


b. (i) True (ii) False (iii) True (iv) False
c. (i) False (ii) True (iii) False (iv) True
d. (i) False (ii) False (iii) True (iv) True

8. The extension of Python file is given as –


a. .ppt b. .py c. .pdoc d. .ppp

9. Which of the following is an invalid statement ?

1
a. I=J=K=50 b. I,J,K=50,60,70 c. I J K =50 60 70 d. I_J_K=70

10. What will be the output of the following code ?


x,y=2,6
x,y=y,x+2
print(x,y)
a. 6 6 b. 4 4 c. 4 6 d. 6 4

11. The reserved words used by Python interpreter to recognize the structure of a program are
termed as
a. Keywords b. Identifiers c. Tokens d. Literals

12. Operators that act upon two operands are referred as …..
a. Unary operator b. Binary Operator c. Assignment Operator d. None

13. The Error that occurs during the execution of the program is known as ….
a. syntax error b. Semantic error c. Run time error d. none

14. Single Line comments in Python begin with …… symbol.


a. # b. % c. ; d. “ “

15. Which of the following operator is floor division ?


a. > b. / c. // d. %

ASSERTION and REASONING( 1 Mark)

16. Assertion : Data type in Python are bound to a variable at compile time
Reasoning : Python supports dynamic typing
a. Both Assertion and Reasoning are correct
b. Assertion is correct but explanation provided is incorrect
c. Assertion is incorrect but the reasoning is valid in Python
d. Both Assertion and Reasoning are incorrect

17. Assertion – type(0b1001) will return a string


Reasoning – a string is a combination of alpha numeric characters
a) Both Assertion and reasoning are correct
b) Assertion is correct but reasoning is not the reason for it
c) Both Assertion and Reasoning are incorrect
d) Assertion is not true but Reasoning is true in Python

18. Assertion: Data type in python are bound to the variable at compile time
Reason: Python supports dynamic typing
a) Both Assertion and reasoning are correct
b) Assertion is correct but reasoning is not the reason for it
c) Both Assertion and Reasoning are incorrect
d) Assertion is not true but Reasoning is true in Python

Very Short Questions (1 Mark Questions):

2
1) Write a statement to assign the value of (a*a) + (b*b) to a variable.
2) I want to divide 1 by 3 and get a result like: 0.333333333333. What is the exact command to
do this?
3) What will be the output of 15.0/3?
4) What does the modulus operator do?
5) Mention the use of following escape sequence
a. \n
b. \t
6) If a=70 and b=10 then determine the result of the following:
a. a/b
b. a% b
7) What is the purpose of using comments in a program?
8) What is an assignment statement?
9) What will be the output of the following:
a. i=30*15/3
b. i=30/15*3
10) What is the result of the following expression :
p>=q && (p+q) > p
a. P=3,q=0
b. P=5,q=5
11) Predict the output of :
a. print(type("17"))
b. print(type("3.2"))
12) How can you determine the type of a variable in python?
13) Is the following a legal variable name in Python : A_good_grade_is_A+

14) What is printed when the following statements execute?

n = input("Enter your age: ")


# user enters a value of 16
print ( type(n) )

15) What will be the output of :


a. print(2 ** 3 ** 2)
b. print((2 ** 3) ** 2)

16) What will be the value of variables a and b in the following code:
a=5
b=a
print(a,b)
a=3
print(a,b)

17) What does the >>> prompt indicates?


18 ) What is the order of the arithmetic operations in the following expression. Evaluate the
expression.
2 + (3 - 1) * 10 / 5 * (2 + 3)
19) Add parenthesis to the expression 6 * 1 - 2 to change its value from 4 to -6.
20) Take the sentence: All work and no play makes Jack a dull boy. Store each word in a
separate variable, then print out the sentence on one line using print.
3
Short Questions(2 Marks)

1) What is a python IDLE?


2) What is a variable? What are the rules to name a variable.
3) What is an expression? Explain with examples.
4) What will be the type of the following result :
i. 3.14 * 7 * 7
ii. Hello * 26
5) If a car travels at a speed of 10 Km/hr, how much distance will it cover in 50 mins. If the
driver increases the speed to 15 Km/hr then how much distance can be covered.
6) What is the difference between = and == operators.
7) For any two given int values, return their sum. If the two values are the
same, then return double their sum.
8) What is an operator? Explain with the help of examples.
9) Write a program in script mode to add two numbers and print their sum and product.
10) Write Statements to calculate the following:
i. Area of circle with radius 12.
ii. Volume of a sphere of radius 7.
iii. Area of room whose length is 40.53 and breadth is 34.56
iv. A book has a price of 425 Rs and shopkeeper is offering a discount of 15%.
Calculate its price after discount.
11) What is a keyword in Python? In what colour is it displayed in code editor window?
12) Write a program to calculate volume and surface of a cylinder whose radius is given by the
user.
13) What will be the output of the following statements if the value of variable str=”HelloWorld”
i. Print str
ii. Print str[0]
iii. Print str[2:5]
iv. Print str[2:]
v. Print str *2
14) What will be the output of the following statements if the value of variable
list=[‘abcd’,786,’xyzw’,’892’]
i. print list[]
ii. print list[0]
iii. print list[1:3]
iv. print list[2:]
15) Can we convert a string data type to integer. If yes, how?
16) What is a statement? Explain by giving examples.
17) What is concatenation, and on what type of variables (integers/floats/strings) does it operate
on?
18) Differentiate between the following with suitable examples :
 Variable and constant
 Number and string data type

19) What is printed when the following statements execute?


day = "Thursday"
day = 32.5

4
day = 19
print(day)

20) What value is printed when the following statement executes?


a. print (18 / 4)
b. print (18 % 4)
c. print (18 // 4)

Long Answer Questions (3 Marks)

1) Differentiate between the following:


i. Mutable and immutable variables
ii. A statement and an expression.
2) Explain the importance of data types.
3) Mention the rules for naming an identifier. Give appropriate examples.
4) Which of the following are invalid variable names and why?
a) MarksSecured
b) Mr_obt
c) 123subj
d) subj-sc
e) TOTAL
f) mark in math
g) perc%
h) $name
5) Why are comments placed in a C++ program? What are the various ways in which comments
can be added to a program?
6) Write codes to do the following :
a) Assign values 5,10,15 to variables x,y,z in a single statement.
b) Accept input from the user in three different variables in a single statement.
7) Write a program to convert Celsius temperature into Fahrenheit temperature.
8) Write a program to convert Fahrenheit temperature into Celsius temperature.
9) Write a program to find the larger of two numbers.
10) 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

11) What will be the output of the following if my_age=29 and my_height=104
a. print “I am %s inches tall” % my_heigth
b. print “ My age is %d” % my_age
c. print “There are %d days in a week” %7
12) Write a program to find roots of a quadratic equation.
13) Write a program to find whether a number entered by the user is positive or negative.
14) 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.
15) Write a program to calculate simple interest.
16) 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
5
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.
17) Write a program to calculate area of a triangle using hero’s formula.
18) Write a program to calculate volume and surface area of a cuboid whose length, breadth and
height are given.
19) 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.
20) 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 .

CASE BASED STUDY QUESTIONS(4 Marks)

1. (a) What are escape sequences? Name any one escape sequence.
(b) How do you print escape sequences as printable characters?
(c ) Based on your concepts in a) and b) what will be the output of the below statement?
print('c:\naveen\temp\a jpg'.'fi lc is opened',sep='\n')

2. Harshit has written a program to calculate in how many days a work will be completed by
three persons A, B and C together. A, B, C take x days, y days and z days respectively to
do the job alone. The formula to calculate the number of days if they work together is
xyz / (xy +yz +xz) days where x, y, and z are given as input to the program.

HOTS Question(5 Marks):

1) The following statement produces no output when not run in the shell.
3.14 * 6 * 6
Modify it to produce output.

2) What's the difference between input() and raw_input() ?

3) The following statement produced an output of 13 and not 20. Explain the reason.
x=7+3*2

4) Why is Python called a strongly object oriented language.

6
5) Enter the following code on the prompt:

>>> 1 == 1
>>> "1" == "1"
>>> 1 == "1"

Why does the third line returns false, while the first 2 lines are true?

You might also like