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

python

Python

Uploaded by

Jasmine D
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

python

Python

Uploaded by

Jasmine D
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

1.What will be the value of the following Python expression?

4+3%5
a) 7
b) 2
c) 4
d) 1

2. Which keyword is used for function in Python language?


a) Function
b) def
c) Fun
d) Define

3.Which of the following character is used to give single-line comments in Python?


a) //
b) #
c) !
d) /*

4.What will be the output of the following Python code?


i=1
while True:
if i%3 == 0:
break
print(i)
i+=1
a) 1 2 3
b) error
c) 1 2
d) none of the mentioned

5. What are the values of the following Python expressions?

2*(3*2)
(2*3)*2
2*3*2
a) 512, 64, 512
b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64
6. What will be the output of the following Python function?
min(max(False,-3,-4), 2,7)
a) -4
b) -3
c) 2
d) False

7. What will be the output of the following Python function?


len(["hello",2, 4, 6])
a) Error
b) 6
c) 4
d) 3

8. What will be the output of the following Python code?


x = 'abcd'
for i in x:
print(i.upper())
a)
a
B
C
D
b) a b c d
c) error
d)
A
B
C
D

9. What will be the output of the following Python code?

x = 'abcd'
for i in range(len(x)):
print(i)
a) error
b) 1 2 3 4
c) a b c d
d) 0 1 2 3
10. What will be the output of the following Python program?

def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))
a) 5
b) 8
c) 2
d) 1

11. Which of the following declarations is incorrect?


a. _x = 2
b. __x = 3
c. _xyz_ = 5
d. None of these

12. Which of the following precedence order is correct in Python?


a. Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
b. Multiplication, Division, Addition, Subtraction, Parentheses, Exponential
c. Division, Multiplication, Addition, Subtraction, Parentheses, Exponential
d. Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

13.How do you create a variable with the numeric value 5?


14.Python provides a Boolean data type. Objects of Boolean type may have one of two values,
1. Which one of the following is correct way of declaring and initialising
a variable, x with value 5?
A. int x
x=5
B. int x=5
C. x=5
D. declare x=5

2. Which of the following is not valid variable name in Python?


A. _var
B. var_name
C. var11
D. 11var

3. Which one is false regarding local variables?


A. These can be accessed only inside owning function
B. Any changes made to local variables does not reflect outside the
function.
C. These remain in memory till the program ends
D. None of the above

4. Which one is false regarding global variables?


A. Global variables can only be read inside the function declaring the
variable as global inside the function.
B. Global variables remain in memory till the end of the program
C. Global variables are those which are declared in global scope.
D. None of the above

8. What will be the value of variable y after execution of following Python


code?
x="55"

y=x + str(9)
A. 64
B. 9
C. 559
D. Error

9. Which of the following is incorrect regarding variables in Python?


A. Variable names in Python cannot start with number. However, it
can contain number in any other position of variable name.
B. Variable names can start with an underscore.
C. Data type of variable names should not be declared
D. None of the above

10. Which of the following will give error?


A. a=b=c=1
B. a,b,c=1
C. a,b,c=1, python, 1.5
D. None of the above

14. Which of the following statment is False?


A. Variable names can be arbitrarily long.
B. They can contain both letters and numbers.
C. Variable name can begin with underscore.
D. Variable name can begin with number.

15. Which of the following is a valid variable?


A. var@
B. 32var
C. class
D. abc_a_c

16. Why are local variable names beginning with an underscore


discouraged?
A. they confuse the interpreter
B. they are used to indicate a private variables of a class
C. they are used to indicate global variables
D. they slow down execution

17. Which of these are keyword?


A. in
B. is
C. assert
D. All of the above

18. What is the output of the following code : print 5//2


A. 2
B. 2.5
C. 2.0
D. Error

19. Arrange this in order of Precedence.


1. Exponentiation
2. Parentheses
3. Multiplication and Division
4. Addition and Subtraction
A. 1,2,3,4
B. 2,1,3,4
C. 1,2,4,3
D. 2,3,1,4

20. Which of this statment will give an error?


A. a++
B. ++a
C. a+=1
D. Both A and B

21. Which operator is used to calculate power of x raise to y.


A. x^y
B. x*y
C. x**y
D. None of the above

23. "in" is a operator in python?


A. True
B. False
C. Neither true nor false
D. None of the above

24. What will be the output of statment 2**2**2**2


A. 16
B. 256
C. 32768
D. 65536

25. What will be the output of the following code


a = 1

b = ++a

print(b is a)
A. True
B. False
C. Error
D. None of the above

You might also like