Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
Learning Laboratory Automation…
sponsored by: Lab Automation Tool - Ads
Python Quiz Results
Score: 11 of 25
44% Correct:
Question 1:
What is a correct syntax to output "Hello World" in Python?
print("Hello World") Your answer
echo "Hello World"
echo("Hello World");
p("Hello World")
Question 2:
How do you insert COMMENTS in Python code?
#This is a comment Your answer
/*This is a comment*/
//This is a comment
Tutorials
Question 3:
Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
Which one is NOT a legal variable name?
_myvar Your answer
my_var
Myvar
my-var Correct answer
Question 4:
How do you create a variable with the numeric value 5?
x=5 Your answer
x = int(5)
Both the other answers are correct Correct answer
Question 5:
What is the correct file extension for Python files?
.py Your answer
.pyt
.pt
.pyth
Question 6:
Tutorials Exercises Services Sign Up Log in
How do CSS
HTML you create a variable with the
JAVASCRIPT SQLfloating number 2.8?
PYTHON JAVA PHP HOW TO W3.CSS C
x = 2.8 Your answer
x = float(2.8)
Both the other answers are correct Correct answer
Question 7:
What is the correct syntax to output the type of a variable or object in Python?
print(typeof(x)) Your answer
print(typeof x)
print(type(x)) Correct answer
print(typeOf(x))
Question 8:
What is the correct way to create a function in Python?
create myFunction(): Your answer
def myFunction(): Correct answer
function myfunction():
Question 9:
In Python, 'Hello', is the same as "Hello"
False
Tutorials Exercises Services Your
Sign Upanswer
Log in
HTML
True
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOWCorrect
TO answer
W3.CSS C
Question 10:
What is a correct syntax to return the first character in a string?
x = "Hello".sub(0, 1) Your answer
x = sub("Hello", 0, 1)
x = "Hello"[0] Correct answer
Question 11:
Which method can be used to remove any whitespace from both the beginning and the end of a
string?
ptrim() Your answer
len()
trim()
strip() Correct answer
Question 12:
Which method can be used to return a string in upper case letters?
uppercase() Your answer
upperCase()
toUpperCase()
Tutorials Exercises Services Sign Up Log in
HTML
upper()
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOWCorrect
TO answer
W3.CSS C
Question 13:
Which method can be used to replace parts of a string?
replaceString() Your answer
repl()
replace() Correct answer
switch()
Question 14:
Which operator is used to multiply numbers?
* Your answer
Question 15:
Which operator can be used to compare two values?
>< Your answer
=
<>Tutorials Exercises Services Sign Up Log in
HTML
==CSS JAVASCRIPT SQL PYTHON JAVA PHP HOWCorrect
TO answer
W3.CSS C
Question 16:
Which of these collections defines a LIST?
["apple", "banana", "cherry"] Your answer
("apple", "banana", "cherry")
{"apple", "banana", "cherry"}
{"name": "apple", "color": "green"}
Question 17:
Which of these collections defines a TUPLE?
["apple", "banana", "cherry"] Your answer
{"apple", "banana", "cherry"}
("apple", "banana", "cherry") Correct answer
{"name": "apple", "color": "green"}
Question 18:
Which of these collections defines a SET?
{"apple", "banana", "cherry"} Your answer
{"name": "apple", "color": "green"}
["apple", "banana",
Tutorials "cherry"]
Exercises Services Sign Up Log in
HTML
("apple",
CSS "banana", "cherry")
JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
Question 19:
Which of these collections defines a DICTIONARY?
{"name": "apple", "color": "green"} Your answer
["apple", "banana", "cherry"]
("apple", "banana", "cherry")
{"apple", "banana", "cherry"}
Question 20:
Which collection is ordered, changeable, and allows duplicate members?
LIST Your answer
SET
TUPLE
DICTIONARY
Question 21:
Which collection does not allow duplicate members?
TUPLE Your answer
SET Correct answer
LIST
Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
Question 22:
How do you start writing an if statement in Python?
if x > y: Your answer
if x > y then:
if (x > y)
Question 23:
How do you start writing a while loop in Python?
while x > y: Your answer
x > y while {
while (x > y)
while x > y {
Question 24:
How do you start writing a for loop in Python?
for x in y: Your answer
for x > y:
for each x in y:
Question 25:
Tutorials Exercises Services Sign Up Log in
Which statement
HTML CSS is used to stop a SQL
JAVASCRIPT loop? PYTHON JAVA PHP HOW TO W3.CSS C
exit Your answer
break Correct answer
return
stop
Study Python in our Python Tutorial
Kickstart your career
Get certified by completing a
course
Get certified w3schoo
l
s
CE
RT
I
20
2
FI
ED
.
Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
W3schools Pathfinder
Track your progress - it's free! Sign Up Log in
ADVERTISEMENT
COLOR PICKER
ADVERTISEMENT
Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
SPACES UPGRADE AD-FREE
NEWSLETTER GET CERTIFIED CONTACT US
Top Tutorials Top References
HTML Tutorial HTML Reference
CSS Tutorial CSS Reference
JavaScript Tutorial JavaScript Reference
How To Tutorial SQL Reference
SQL Tutorial Python Reference
Python Tutorial W3.CSS Reference
W3.CSS Tutorial Bootstrap Reference
Bootstrap Tutorial PHP Reference
PHP Tutorial HTML Colors
Java Tutorial Java Reference
C++ Tutorial Angular Reference
jQuery Tutorial jQuery Reference
Top Examples Get Certified
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate
FORUM ABOUT CLASSROOM
W3Schools is optimized for learning and training. Examples might be simplified to improve reading
and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full
correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie
and privacy policy.
Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.
Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C