Advance Python Quiz 2

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

NAME :

CLASS :
Advanced python for CLASS 10 AI
DATE :
64 Questions

1. Select a valid string in python?

a) var = " string" b) var == string


c) var =! string d) var ["string"]

2. Whats is the datatype of print(type(10))

a) Float b) Integer
c) Complex d) None of the above

3. ______ data types store values of more than one data type

a) List b) Tuple

c) Float d) Dictionary

4. Choose the immutable data type.

a) Tuples b) List
c) Set d) Dictionaries

5. Is Python case sensitive when dealing with identi ers?

a) Yes b) No

6. Which of the following has more precedance?

a) / b) +
c) () d) -

7. Which one is NOT a legal variable name?

a) my-var b) my_var
c) Myvar d) _myvar
How do you create a variable with the numeric value 5?
8.
a) x = int(5)
b) x = 5 c) Both the other answers are correct

9. How do you create a variable with the oating number 2.8?

a) x = 2.8 b) x = oat(2.8)
c) Both the other answers are correct

10. What is the correct syntax to output the type of a variable


or object in Python?

a) print(typeof(x)) b) print(typeOf(x))
c) print(type(x)) d) print(typeof x)

11. Which operator can be used to compare two values?

a) == b) <>
c) >< d) =

12. How do you start writing an if statement in Python?

a) if x > y: b) if x > y then:


c) if (x > y)

13. Which statement is used to stop a loop?

a) break b) stop
c) exit d) return

14. Which of the following is an invalid variable?

a) my_string_1 b) b) 1st_string
c) foo d) _

15. Which of the following is an invalid statement?

a) abc = 1,000,000 b) a b c = 1000 2000 3000


c) a,b,c = 1000, 2000, 3000 d) a_b_c = 1,000,000
16. What is answer of this expression, 22 % 3 is?

a) 7 b) 1
c) 5 d) 0

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

a) _var b) var_name
c) 11var d) var11

18. what is the output of the below code snippet?


num1=10num2=7//2num2*=num1print(num2)

a) 10 b) 35.0
c) 30 d) 30.0

19. What is the output of the below code?num_list =


[10.5,30.5,-1.20,10.10]num_list.insert(-3,
-10.5)num_list.pop(0)print(num_list[0])

a) 30.5 b) -10.5
c) 10.1 d) -1.2

20. Which of the following is valid arithmetic operator in


python?

a) // b) ?
c) < d) and

21. Identify the type of token-


if

a) identi er b) keyword
c) operator d) literal

22. Identify the type of token -


roll_no

a) identi er b) keyword
c) literal d) operator
Select the logical operators-
23.
a) or
b) not c) and
d) in

24. What is the result of 4+4/2+2

a) 4 b) 6
c) 8 d) 5

25. Write the output of the following code

a) 30 b) -10
c) 10 d) -30

26. Output of the code-

a) mywork b) my work
c) work my d) workmy

27. How many variables are there in this program?

a) 2 b) 3
c) 4 d) 5

28. What data type represents a whole number?

a) Float b) Int
c) Boolean d) String
29. What data type represents only two possible outcomes?

a) Float b) Int
c) Boolean d) String

30. If you executed var = '01234567' , what would be the result


of print(var[::2])?

a) 0246 b) 01234
c) 1234 d) 7531

31. what is the result of the following operation '1'+'2'

a) 3 b) 1
c) 2 d) 12

32. In programming, what is iteration?


a) The repetition of steps within a program b) The order in which instructions are carried
out
c) A decision point in a program d) Testing a program to make sure it works

33. Which two statements are used to implement iteration?


a) IF and WHILE b) ELSE and WHILE
c) FOR and WHILE d) IF and ELSE

34. Which of the following symbols is used in Python to mean


"Equal to"?
a) = b) !=
c) == d) >=

35. Which of the following symbols is used in Python to mean


"Not equal to"?
a) == b) !=

c) <> d) ><
36. Which of the following symbols is used in Python to mean
"Greater than or equal to"?
a) <= b) >>
c) >= d) =>

37.

a) 5 b) 4
4 3
3 2
2 1
1 0
c) 5 4 3 2 1 d) 4 3 2 1 0

38.

a) Hello world! b) Hello world


c) Hello world! d) Error
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)

39. A condition is

a) a statement that is either True or False b) a string


c) an integer d) a list

40. Which kind of loop would be used?


I need a program that will keep letting me add a monthly
payment for 12 months.

a) FOR Loop b) WHILE Loop


Which kind of loop would be used?
41.
I need a guessing game program that will let me keep
guessing until I get the right answer.

a) FOR Loop b) WHILE Loop

42. In for i in range (a, n, k) which letter indicates the start?

a) i b) k
c) a d) n

43. What will be the output of this code?

a) odd numbers up to 20 b) even numbers up to 20


c) "Wrong input" d) all numbers up to 20

44. In for i in range (a, n, k) which letter indicates the step?

a) i b) n
c) a d) k

45. Which character indicates the end of a command block?

a) ; b) :
c) . d) ,
46. Which of these codes will print all the numbers from a
given number subtracted by 5 until it reaches 0.

a) b)

c) d)

47. What will be the output of this code? sum=?

a) 5 b) 15
c) 20 d) 25

48. Which of these codes will print numbers from 1 to 10,


including 10.

a) b)

c) both d) none of the above

49. What will be the output of this code?

a) 1,2,3,4,5,6,7,8,9,10,11,12 b) 0,2,4,6,8,10
c) 2,4,6,8,10,12 d) 2,4,6,8,10
50. What does the '#' allow you to do?

a) Repeat code b) Comment on code


c) Print code d) End code

51. The result of this program:Friday = Falseif Friday: print


"Jeans day!"else: print "Uniform day"

a) Jeans day b) Today is Friday


c) Uniform day d) Not Friday

52. What is the output?

a) condition b) True
c) Program has a syntax error. d) 3 > 2

53. What is the output of the following loop:-for l in 'Jhon': if l


== 'o': pass print(l, end=", ")

a) J, h, n, b) J, h, o, n,
c) Error d) None of the given Options

54. What is the output of the following range() function?


for num in range(2,-5,-1): print(num, end=", ")

a) 2, 1, 0 b) 2, 1, 0, -1, -2, -3, -4, -5


c) 2, 1, 0, -1, -2, -3, -4 d) 0

55. elif can be considered to be abbreviation of

a) nested if b) if..else
c) else if d) if..elif

56. Which of the following function is used in python for loop to


specify the initial, nal and increment values?

a) range b) print
c) format d) input
57. _____ statement is used to skip the remaining part of the
loop and start with next iteration.

a) Pass b) break
c) continue d) range

58. Choose the output.for i in range (10,13):print (i*i)

a) 100121144 b) 100121144169
c) 100121 d) 100169

59. Name the two membership operators in python.

a) in, in not b) in, not in

60. Check the output.Print(10 in [1,2,3,4,10,12])

a) true b) false

61. Is python an interpreter or compiler programming


language?

a) Compiler b) Interpreter

62. 102 = 100


Which of the following is used in Python to calculate ten
squared?
a) 10 ** 2 b) 10 * 2
c) 10 % 2 d) 10 ** 10

63. It is possible to execute both the statements under if and


else at the same time.

a) TRUE b) FALSE
64. >>>list1= ["Kathak", "Kathakali", "Odissi", "Manipuri",
"Kuchipudi"]>>>list2=[100, 200, 300, 400, 500,600]>>>list3=
list1[:]>>>list4= list2[2:5]

a) ['Kathak', 'Kathakali', 'Odissi', 'Manipuri'] b) ['Kathak', 'Kathakali', 'Odissi', 'Manipuri',


[300, 400, 500] 'Kuchipudi'][300, 400, 500]
c) [ ][300, 400, 500,600] d) Error
Answer Key
1. a 17. c 33. c 49. b
2. b 18. c 34. c 50. b
3. a,b,d 19. b 35. b 51. c
4. a 20. a 36. c 52. b
5. a 21. b 37. b 53. b
6. c 22. a 38. c 54. c
7. a 23. a,b,c 39. a 55. c
8. c 24. c 40. a 56. a
9. c 25. b 41. b 57. c
10. c 26. d 42. c 58. a
11. a 27. c 43. b 59. b
12. a 28. b 44. d 60. a
13. a 29. c 45. b 61. b
14. b 30. a 46. a 62. a
15. b 31. d 47. b 63. b
16. b 32. a 48. c 64. b

You might also like