NEW
Font size
WorksheetsPython Basics
Total questions: 25
Worksheet time: 8mins
What is a correct syntax to output "Hello World" in Python?
printf("Hello World");
print("Hello World")
echo "Hello World"
print("Hello World"):
What is the purpose of using Python?
Python is used for various purposes such as web development, data analysis, artificial intelligence, scientific computing, automation, and more.
Python is primarily used for video editing
Python is only used for gaming development
Python is exclusively used for accounting purposes
How do you insert COMMENTS in Python code?
//This is a comment
#This is a comment
/*This is a comment*/
"This is a comment"
What is the output of 'print(5 + 3)'?
7
10
8
2
Which one is NOT a legal variable name?
_myvar
my_var
Myvar
my-var
What is the keyword used for defining a function in Python?
function
define
func
def
What is the result of '5 == 5'?
error
true
10
false
How do you check the length of a list in Python?
length(your_list_name)
size(your_list_name)
count(your_list_name)
len(your_list_name)
What is the output of 'print('Hello' + 'World')'?
Hello World
HelloWorldd
WorldHello
HelloWorld
What is the purpose of 'if' statement in Python?
To define a function
Conditional execution
To print output
To loop through a list
How do you create a variable with the numeric value 5?
Both the other answers are correct
Conditional executionx = int(5)
x = 5
What is the correct file extension for Python files?
.py
.pyt
.pt
.pyth
How do you create a variable with the floating number 2.8?
x = 2.8
Both the other answers are correct
x = float(2.8)
What is the correct syntax to output the type of a variable or object in Python?
print(typeof(x))
print(type(x))
print(typeof x)
print(typeOf(x))
What is the correct way to create a function in Python?
function myfunction():
def myFunction():
create myFunction():
def myFunction()
In Python, 'Hello', is the same as "Hello"
False
True
What is a correct syntax to return the first character in a string?
x = "Hello"[0]
x = sub("Hello", 0, 1)
x = "Hello".sub(0, 1)
x = "Hello[0]"
How do you remove an item from a list in Python?
list.remove(item)
list.delete(item)
list.pop(item)
list.discard(item)
Which method can be used to remove any whitespace from both the beginning and the end of a string?
trim()
strip()
len()
ptrim()
Which method can be used to return a string in upper case letters?
toUpperCase()
upperCase()
uppercase()
upper()
Which method can be used to replace parts of a string?
repl()
replaceString()
switch()
replace()
Which operator is used to multiply numbers?
%
*
x
**
Which operator can be used to compare two values?
=
==
<>
All of these.
Which of these collections defines a LIST?
("apple", "banana", "cherry")
{"name": "apple", "color": "green"}
["apple", "banana", "cherry"]
{"apple", "banana", "cherry"}
Which of these collections defines a TUPLE?
{"name": "apple", "color": "green"}
["apple", "banana", "cherry"]
{"apple", "banana", "cherry"}
("apple", "banana", "cherry")
