WorksheetsIedc Coders Club Programming Quiz
Total questions: 25
Worksheet time: 13mins
What is a correct syntax to output "Hello World" in Python?
echo "Hello world"
print("Hello world")
echo("Hello world")
p("Hello world")
How do you insert COMMENTS in Python code
// This is a comment
#this is a comment
/*Thisi s a comment*/
Which is not a legal variable name ?
Myvar
my-var
my_var
_myvar
How do you create a varaiable with numeric value 5 ?
x = 5
Both answers are correct
x = int(5)
What is the correct extension for Python Files ?
.pyt
.py
.pyth
.pt
Create a floating variable 2.8 to x ?
Both of the answers are correct
x = float(2.8)
x = 2.8
What is the correct syntax to output the type of a variable or object in Python
print(typeof x)
print(typeof(x))
print(typeOf(x))
print(type(x))
What is the correct way to decalre a function
func myfunc():
function myfunc():
def myfunc():
create myfunc():
In Python 'Hello' is same as "Hello"
True
False
What is the correct syntax to return the first character in a string
x = sub("Hello", 0, 1)
x = "Hello"[0]
x = "Hello".sub(0,1)
Which method is used for removing whitespaces from both the beginning and the end of the string ?
strip()
trim()
len()
ptrim()
Which method is used to return a string in upper case letters ?
uppercase()
upperCase()
toUpperCase()
upper()
Which method is used for replacing parts of a string ?
switch()
replaceString()
replace()
repl()
Which operator is used for multiplication of numbers ?
#
*
x
%
Which operator is used for compairing two values
=
><
<>
==
Which of the following is defined as a list ?
{"apple", "banana", "cherry"}
{"name":"apple", "color":"red"}
("apple", "banana", "cherry")
["apple", "banana", "cherry"]
Which of the following is defined as a tuple ?
{"apple", "banana", "cherry"}
{"name":"apple", "color":"red"}
("apple", "banana", "cherry")
["apple", "banana", "cherry"]
which of the following collection is ordered, chageable and allows duplicate members
SET
TUPLE
DICTIONARY
LIST
How do you write a if statement in python ?
if (x>y)
if x>y then:
if x>y :
How to write a loop in python ?
while x>y:
x>y while {
while(x>y)
for i in range(x):
Is Python code compiled or intrepreted
Python code is both compiled and interpreted
Python code is neither compiled nor interpreted
Python code is only compiled
Python code is only interpreted
What will be the value of the following Python expression?
4 + 3 % 5
7
2
4
1
What will be the output of the following Python expression?
round(4.576)
4
4.6
5
4.5
Identify the error in this code:
x = [1, 2, 3];
print(x)
Syntax error in variable x
Missing parenthesis in print
Missing bracket in x
No error
In which programming language, Python was written?
Java
Python
JavaScript
C
