W3Schools Python Quiz

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

How do you insert COMMENTS in Python code?

#This is a comment

Which of these collections defines a TUPLE?

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

Which operator is used to multiply numbers?

*

What is the correct file extension for Python files?

.py

Which operator can be used to compare two values?

==

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

Both the other answers are correct

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

Both the other answers are correct

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

LIST

Which collection does not allow duplicate members?

SET

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

True

Which of these collections defines a LIST?

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

Which statement is used to stop a loop?

break

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

def myFunction();

How do you start writing a for loop in Python?

for x in y:

How do you start writing an if statement in Python?

if x > y:

Which one is NOT a legal variable name?

my-var

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

print("Hello World")

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

print(type(x))

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

replace()

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

strip()

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

upper()

How do you start writing a while loop in Python?

while x > y:

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

x = "Hello"[0]

Which of these collections defines a SET?

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

Which of these collections defines a DICTIONARY?

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


Set pelajaran terkait

Fluid, Electrolyte, and Acid Base Regulation Assessment

View Set

Pharm Pain - Opioid Analgesics (ch 10)

View Set

CH 1: Completing the Application, Underwriting, and Delivering the Policy

View Set

Chapter 10, 11, 12, 13, 14, 17 canvas and chapter quizzes

View Set

US History - Chapter 10 Study Guide

View Set