W3Schools Python Quiz

0.0(0)
studied byStudied by 1 person
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/24

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

25 Terms

1
New cards

What is a correct syntax to output "Hello World" in Python?

print("Hello World")

2
New cards

How do you insert COMMENTS in Python code?

#This is a comment

3
New cards

Which one is NOT a legal variable name?

my-var

4
New cards

How do you create a variable with the numeric value 5?

Both the other answers are correct

5
New cards

What is the correct file extension for Python files?

.py

6
New cards

How do you create a variable with the floating number 2.8?

Both the other answers are correct

7
New cards

What is the correct syntax to output the type of a variable or object in Python?

print(type(x))

8
New cards

What is the correct way to create a function in Python?

def myFunction();

9
New cards

In Python, 'Hello', is the same as "Hello"

True

10
New cards

What is a correct syntax to return the first character in a string?

x = "Hello"[0]

11
New cards

Which method can be used to remove any whitespace from both the beginning and the end of a string?

strip()

12
New cards

Which method can be used to return a string in upper case letters?

upper()

13
New cards

Which method can be used to replace parts of a string?

replace()

14
New cards

Which operator is used to multiply numbers?

*

15
New cards

Which operator can be used to compare two values?

==

16
New cards

Which of these collections defines a LIST?

["apple", "banana", "cherry"]

17
New cards

Which of these collections defines a TUPLE?

("apple", "banana", "cherry")

18
New cards

Which of these collections defines a SET?

{"apple", "banana", "cherry"}

19
New cards

Which of these collections defines a DICTIONARY?

{"name" : "apple", "color" : "green"}

20
New cards

Which collection is ordered, changeable, and allows duplicate members?

LIST

21
New cards

Which collection does not allow duplicate members?

SET

22
New cards

How do you start writing an if statement in Python?

if x > y:

23
New cards

How do you start writing a while loop in Python?

while x > y:

24
New cards

How do you start writing a for loop in Python?

for x in y:

25
New cards

Which statement is used to stop a loop?

break