CodeStudy.net
Toggle Menu
Home
Online Java Compiler
Tutorials
Java Tutorial
Python Tutorial
SQL Database Design
Blog
All Posts
Python Basics For Beginner
Check your understanding of Python basics.
1. Which of the following is a valid variable name in Python?
1var
var-1
var_1
var@1
2. What is the output of: print(5 // 2)?
2.5
2
3
0
3. Python uses indentation (spaces/tabs) to define code blocks (e.g., inside loops or conditionals).
True
False
4. What keyword is used to define a function in Python?
5. What data type is the value '3.14' in Python?
int
float
str
bool
6. Which of the following are primitive (basic built-in) data types in Python? (Select all that apply)
int
list
str
tuple
7. What is the result of 'Py' + 'thon' in Python?
Py thon
Python
Py+thon
Error
8. A tuple in Python is mutable (can be modified after creation).
True
False
9. What symbol is used to write a single-line comment in Python?
10. If my_list = [10, 20, 30, 40], what is the value of my_list[1]?
10
20
30
40
11. Which loop types are available in Python? (Select all that apply)
for
while
do-while
repeat
12. Which keyword starts an alternative block in an if statement?
else
elif
otherwise
alternate
13. What is the output of: print('Hello' + ' ' + 'Python')
14. The 'and' logical operator returns True only if both operands are True.
True
False
15. 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(range(3))
16. What is x after: x = 10; x += 5
10
5
15
20
17. Name the data type that stores key-value pairs (e.g., {'name': 'Alice', 'age': 30}).
18. Which method converts a string to lowercase?
lower()
tolower()
lowercase()
casefold()
19. Which method adds an element to the end of a list?
add()
append()
insert()
extend()
20. What does the input() function return by default?
integer
float
string
boolean
Reset
Answered 0 of 0 — 0 correct