Introduction to Python (10 Questions)Who developed Python?
a) Dennis Ritchie b) Guido van Rossum c) James Gosling d) Bjarne Stroustrup
Answer: bWhich year was Python created?
a) 1989 b) 1991 c) 2000 d) 2010
Answer: bWhat type of language is Python?
a) Compiled b) Interpreted c) Assembly d) Machine
Answer: bWhich is the correct extension for Python files?
a) .py b) .java c) .txt d) .exe
Answer: aWhat is the first command used to print in Python?
a) print() b) echo() c) console.log() d) output()
Answer: aPython is named after:
a) A snake b) Monty Python's Flying Circus c) A programmer d) A city
Answer: bWhich symbol is used to comment in Python?
a) // b) -- c) # d) /*
Answer: cWhat does PEP stand for in Python?
a) Python Enhancement Proposal b) Python Easy Programming c) Programming Environment Protocol d) Programmer’s Education Path
Answer: aWhich IDE is commonly used for Python coding?
a) Visual Studio Code b) Eclipse c) PyCharm d) Notepad
Answer: cWhat will print("Hello") output?
a) Hello b) "Hello" c) print("Hello") d) Error
Answer: aVariables & Data Types (15 Questions)Which is a valid variable name?
a) 1var b) var_1 c) var-2 d) @var
Answer: bChoose the correct data type for: 45
a) String b) Integer c) Float d) Boolean
Answer: bTrue or False values are called:
a) Strings b) Booleans c) Integers d) Floats
Answer: bWhat will type("Hello") return?
a) int b) float c) str d) bool
Answer: cWhich of these is a floating-point number?
a) 10 b) ‘10’ c) 10.5 d) True
Answer: cHow to take input from user in Python?
a) input() b) scan() c) get() d) read()
Answer: aWhat is the value of variable x after x = 5 + 2?
a) 7 b) "7" c) 52 d) Error
Answer: aCan variable names start with a number?
a) Yes b) No
Answer: bWhich is NOT a Python data type?
a) List b) Set c) Number d) Array
Answer: dIs Python case-sensitive in variable names?
a) Yes b) No
Answer: aWhat does the statement x = "10" do?
a) Assigns integer 10 to x b) Assigns string "10" to x c) Creates a list d) Causes error
Answer: bWhat would print(type(3.14)) show?
a) <class ‘int’> b) <class ‘float’> c) <class ‘str’> d) <class ‘bool’>
Answer: bWhich symbol is used for exponentiation in Python?
a) ^ b) ** c) ^^ d) %
Answer: bWhat value does bool(0) have?
a) True b) False c) 0 d) 1
Answer: bWhich keyword is used to declare a variable?
a) var b) let c) No keyword needed d) int
Answer: cOperators (10 Questions)What is 5 + 2 * 3 in Python?
a) 21 b) 11 c) 16 d) 7
Answer: bWhich operator is modulus?
a) % b) // c) / d) *
Answer: aWhat does “==” operator do?
a) Assign b) Equals to c) Not equals d) Greater than
Answer: bWhich operator means "not equal"?
a) != b) =! c) == d) ><
Answer: aWhat is the result of 7 // 2?
a) 3 b) 3.5 c) 4 d) Error
Answer: aWhich logical operator means OR?
a) and b) or c) not d) ||
Answer: bWhat is the output of 10 > 5 and 5 < 3?
a) True b) False c) 10 d) 5
Answer: bWhich operator is used for string concatenation?
a) + b) & c) * d) %
Answer: aWhat is the output of 3 ** 2?
a) 6 b) 9 c) 8 d) 5
Answer: bWhat operator is used for floor division?
a) / b) // c) % d) ^
Answer: bControl Structures (15 Questions)What keyword starts a conditional statement?
a) if b) else c) then d) for
Answer: aWhat does else mean?
a) If not b) Loop c) Function d) End
Answer: aWhich of these is correct syntax for if in Python?
a) if x > 0: b) if x > 0 then c) if (x > 0) d) if x > 0 endif
Answer: aWhat is the output of this code?if 10 > 5:
print("Yes")
else:
print("No") a) Yes b) No c) Error d) Nothing
Answer: aWhat will this output?if 3 == 3:
print("Equal") a) Equal b) Not Equal c) Error d) No output
Answer: aWhat is elif used for?
a) As an additional if condition b) Looping c) Ending program d) Printing
Answer: aCan if statement be used without else?
a) Yes b) No
Answer: aWhat is the output?x = 10
if x > 5 and x < 15:
print("OK") a) OK b) Error c) Nothing d) 10
Answer: aWhich keyword is NOT used in control flow?
a) if b) else c) elif d) else if
Answer: dWhat will this print?if False:
print("Hi")
else:
print("Bye") a) Hi b) Bye c) Nothing d) Error
Answer: bWhat will this code do?if 5 > 3:
print("Five")
elif 5 == 3:
print("Three")
else:
print("Other") a) Five b) Three c) Other d) Error
Answer: aWhat is the proper indentation level after if statement?
a) 2 spaces b) 4 spaces c) 1 space d) No indentation needed
Answer: bWhich symbol does Python use to indicate a block of code?
a) {} b) ; c) : d) ()
Answer: cWhat is wrong with this?if x = 5:
print(x) a) Wrong operator (= instead of ==) b) Missing indentation c) Missing else d) Nothing
Answer: aWhich of these can be used to check multiple conditions?
a) if b) elif c) else d) for
Answer: bLoops (10 Questions)How many times will this loop run?for i in range(4):
print(i) a) 3 b) 4 c) 5 d) Error
Answer: bWhich keyword starts a while loop?
a) while b) loop c) for d) until
Answer: aWhat will this print?i = 1
while i <= 3:
print(i)
i += 1 a) 1 2 3 b) 1 c) Infinite loop d) Error
Answer: aWhich loop runs at least once?
a) for b) while c) do-while d) if
Answer: c (Note: Python doesn’t have do-while but this is general knowledge)What does break do in a loop?
a) Ends the loop b) Continues next iteration c) Restarts the loop d) Pauses the loop
Answer: aWhich loop would you use to iterate over a list?
a) for b) while c) until d) loop
Answer: aWhat will this output?for i in range(1, 5):
if i == 3:
break
print(i) a) 1 2 3 b) 1 2 c) 3 d) Error
Answer: bWhat is the output?count = 0
while count < 3:
count += 1
if count == 2:
continue
print(count) a) 1 3 b) 1 2 3 c) 2 3 d) 1 2
Answer: aWhich of these increments a variable by 1?
a) x = x + 1 b) x += 1 c) Both a and b d) None
Answer: cHow to stop a loop from running?
a) stop b) break c) exit d) leave
Answer: bLists (10 Questions)What type is ���?
a) String b) List c) Tuple d) Dictionary
Answer: bHow do you access the second item in list a = [5,6,7]?
a) a� b) a(1) c) a{1} d) a.second
Answer: aWhich method adds an item to a list?
a) add() b) append() c) insert() d) push()
Answer: bWhat will print(len(���)) output?
a) 3 b) 2 c) 1 d) 0
Answer: aWhat will this return?a = [1,2,3]
print(a[0]) a) 1 b) 2 c) 3 d) Error
Answer: aWhich method removes an item from a list?
a) delete() b) remove() c) pop() d) both b and c
Answer: dCan lists store different data types?
a) Yes b) No
Answer: aWhat data structure does a = [] create?
a) Empty list b) Empty dictionary c) Empty tuple d) None
Answer: aWhat is the index of last element in list a = ���?
a) 2 b) 3 c) -1 d) a and c are correct
Answer: dHow to check if an item exists in a list?
a) in b) exists c) has d) find
Answer: aFunctions (10 Questions)How to define a function?
a) def myfunc(): b) function myfunc() c) func myfunc() d) define myfunc()
Answer: aWhat keyword exits a function?
a) return b) exit c) stop d) end
Answer: aHow do you call a function named greet?
a) call greet() b) greet() c) run greet() d) execute greet()
Answer: bWhat is the default return value of a function without return?
a) None b) 0 c) Error d) ""
Answer: aCan functions have parameters?
a) Yes b) No
Answer: aWhat does this code print?def f():
print("Hi")
f() a) Hi b) f c) Error d) None
Answer: aWhich of these is a built-in function?
a) def() b) print() c) function() d) var()
Answer: bHow to send info into a function?
a) Arguments b) Parameters c) Inputs d) Both a and b
Answer: dWhat is the output?def add(a, b):
return a + b
print(add(2,3)) a) 5 b) 23 c) None d) Error
Answer: aCan functions return multiple values?
a) Yes b) No
Answer: aProjects and Fun Activities (10 Questions)Which module helps in drawing shapes?
a) turtle b) draw c) graphics d) paint
Answer: aWhat is a simple project idea for beginners?
a) Calculator b) Operating system c) Database d) Web browser
Answer: aWhich helps create interactive quizzes?
a) input() b) print() c) loops d) all of these
Answer: dWhat does the turtle.forward() command do?
a) Moves turtle forward b) Turns turtle right c) Pauses program d) Changes color
Answer: aWhat structure stores quiz questions?
a) List b) Tuple c) String d) Integer
Answer: aWhat can you use to track scores?
a) Variable b) List c) Function d) Module
Answer: aTurtle graphics is used for:
a) Drawing b) Networking c) File handling d) Calculations
Answer: aWhat command clears the screen in turtle?
a) turtle.clear() b) turtle.reset() c) turtle.erase() d) turtle.clean()
Answer: bWhich function pauses turtle graphics window?
a) turtle.exitonclick() b) turtle.pause() c) turtle.stop() d) turtle.wait()
Answer: aHow to repeat commands in a project?
a) Loop b) Function c) Variable d) List
Answer: a
Comments
Post a Comment