W3Reference.com
Toggle Menu
Home
Online Rust Compiler
Tutorials
Python Tutorial
Java Tutorial
Rust Tutorial
TypeScript Tutorial
ReactJS Tutorial
HTML & CSS Basics
Docker Containers Guide
Kubernetes Tutorial
Software Design Patterns
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
var1
@var
2. Which of the following are immutable data types in Python?
list
string
tuple
dictionary
3. In Python, the 'and' operator returns True only if both operands are True.
True
False
4. What is the output of the following code: print(2 + 3 * 2)?
5. What is the data type of the value 3.14 in Python?
int
float
str
bool
6. Which of the following are valid ways to create a list in Python?
[1, 2, 3]
list(1, 2, 3)
[1, 'two', 3.0]
(1, 2, 3)
7. The '==' operator in Python checks for identity (memory location) of objects.
True
False
8. What keyword is used to define a function in Python?
9. What will be the output of: print('Hello' + ' ' + 'World')?
HelloWorld
Hello World
Error
Hello+World
10. Which of the following loops are available in Python?
for
while
do-while
repeat-until
11. A list in Python can contain elements of different data types.
True
False
12. What symbol is used to denote a single-line comment in Python?
13. What is the result of '5' + '3' in Python?
8
'8'
'53'
53
14. Which of the following are valid comparison operators in Python?
==
!=
<=
&&
15. The 'if' statement in Python must be followed by a colon (:).
True
False
16. What built-in function is used to get user input in Python?
17. Which data type is immutable in Python?
list
dict
tuple
set
18. Which of the following are valid ways to initialize a string in Python?
'hello'
"hello"
'''hello'''
123
19. Python uses indentation to define code blocks.
True
False
20. What is the output of len([1, 2, 3, 4])?
Reset
Answered 0 of 0 — 0 correct