Python Basics MCQ
Test your fundamentals of Python programming with this beginner-friendly quiz covering variables, data types, loops, and functions.
10 Questions
beginner
Quiz Questions
-
What is the correct way to declare a variable in Python?
-
var x = 5
-
int x = 5
-
x = 5
-
declare x = 5
-
Which of the following is a valid Python data type?
-
integer
-
string
-
list
-
All of the above
-
What will print(type(3.14)) output?
-
<class 'int'>
-
<class 'float'>
-
<class 'double'>
-
<class 'decimal'>
-
How do you create a comment in Python?
-
// comment
-
/* comment */
-
# comment
-
<!-- comment -->
-
What is the output of len('Hello')?
-
Which keyword is used to define a function in Python?
-
What will be the output of 2 ** 3?
-
Which of the following is used to get user input in Python 3?
-
scanf()
-
input()
-
read()
-
get()
-
What does the range(5) function return?
-
[1, 2, 3, 4, 5]
-
[0, 1, 2, 3, 4]
-
[0, 1, 2, 3, 4, 5]
-
A range object from 0 to 4
-
How do you check if a key exists in a dictionary?
-
key.exists(dict)
-
dict.has(key)
-
key in dict
-
dict.contains(key)