PythonFan.org
Toggle Menu
Home
Online Python Compiler
Tutorials
Python FastAPI
Python Pandas
Python PyTorch
Python Seaborn
Blog
All Posts
Python Basics For Beginner
Check your understanding of Python basics.
1. What is the output of print(2 + 3 * 2)?
10
8
7
2. Which of the following is a valid variable name in Python?
1var
var-1
var_1
var@1
3. What data type is the value True in Python?
String
Boolean
Integer
Float
4. Which loop is used to iterate over a sequence (e.g., list, string) in Python?
for
while
do-while
repeat
5. What symbol is used for single-line comments in Python?
//
/* */
#
--
6. Which function is used to receive input from the user in Python?
get()
input()
read()
scanf()
7. What is the result of '5' + '3' in Python?
8
"8"
"53"
53
8. Which of these is an immutable data type in Python?
List
Dictionary
Tuple
Set
9. Which of the following are basic data types in Python? (Select all that apply)
Integer
String
Array
Float
Object
10. Which operators can be used for comparison in Python? (Select all that apply)
==
=
>
<
&&
11. Which are valid ways to create a list in Python? (Select all that apply)
[1, 2, 3]
list(1, 2, 3)
(1, 2, 3)
list([1, 2, 3])
{1, 2, 3}
12. What are valid ways to define a function in Python? (Select all that apply)
def my_func():
function my_func():
lambda x: x + 1
func my_func():
13. Which are True about Python strings? (Select all that apply)
Strings are immutable
Strings can be indexed
Strings can be modified with append()
Strings support slicing
Strings are stored as lists
14. Python uses indentation to define code blocks.
True
False
15. The 'if' statement in Python requires parentheses around the condition.
True
False
16. A tuple can be modified after creation.
True
False
17. The 'and' operator returns True only if both operands are True.
True
False
18. What keyword is used to define a function in Python?
19. What data type is returned by the input() function?
20. What symbol is used to assign a value to a variable in Python?
Reset
Answered 0 of 0 — 0 correct