Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Class XI

Computer Science(083)
CH 7 : PYTHON FUNDAMENTALS
ASSIGNMENT-2

SECTION A(Multiple Choice Questions)


1. Is Python case sensitive when dealing with identifiers?
a) yes b) no

c) machine dependent d) none of the mentioned

2. What is the maximum possible length of an identifier?

a) 31 characters b) 63 characters

c) 79 characters d) none of the mentioned

3. Python uses_________ to accept input in a variable:

a) input(variable) b) input( )

c) Input( ) d) print ( )

4. Python programs are typed in ____________ mode:

a) Interactive mode b) Script mode

c) Combination of (a) and (b) d) All of theses

5. Which of the following is invalid?

a) _a = 1 b) __a = 1

c) __str__ = 1 d) none of the mentioned

6. Which of the following is an invalid variable?

a) my_string_1 b) 1st_string

c) foo d) _

7. Which of the following is not a keyword?

a) eval b) assert

c) nonlocal d) pass
1
8. All keywords in Python are in

a) lower case b) UPPER CASE

c) Capitalized d) None of the mentioned

9.Which of the following is true for variable names in Python?

a) unlimited length

b) all private members must have leading and trailing underscores

c) underscore and ampersand are the only two special characters allowed

d) none of the mentioned Ans : a) unlimited length

10. Which of the following is an invalid statement?

a) abc = 1000000 b) a b c = 1000 2000 3000

c) a,b,c = 1000, 2000, 3000 d) a_b_c = 1000000

11. Which of the following cannot be a variable?

a) __init__ b) in

c) it d) on

12. Which of the following is the valid variable name?

a) global b) 99flag

c) sum d) an$wer

13.What will the output be from the following code?


print("Hello world!\nHello world!")
a) Hello world! Hello world! b) Hello world!
Hello world!
c) Hello world! d) SyntaxError

2
14.What is the output of this expression, 3*1**3? (1)3
a) 27 b) 9
c) 3 d) 1

15. Which input statements are correct?

a) a = input ( ) b) a = raw_inputi (“enter a number”)

c) a = raw_imput (enter your name)

SECTION B(Very short answer)

1. Create following variables:

i) mystring to contain “hello‟ ii) myfloat to contain “2.5‟

iii) myint to contain “10‟

mystring=”hello”

2. Write the value justification:

i) 2*(3+4)=14 ii) 2*3+4=10 iii) 2+3*4=14

3. What is the data type of the result of the given statement:

i) 1+2.0+3

4. 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) Python does not have any keywords

v) The equal to condition is written by using the == operator

5. Identify valid and invalid variable names from the following:-


percentage%, 12class, final-exam, Class, For, _subjects

3
6. Identify which of the following expressions are correct:
a) x,y,z=12.5, 170, 'Samarth'
b) x,y,z=12.5, 170, 'Samarth', k
c) x=y=z=100
d) x,y = 10,10, z = 10
e) x,y = 10

7. Observe the following script and enlist all the tokens used in it.
#Identify tokens in the script
name="Fatima"
cl=eval(input("Enter class: "))
print (name,"studies in”, cl,"class")

8. Write a Python script to display the message “Python is interesting”, in different ways.

You might also like