python

Ace your homework & exams now with Quizwiz!

Which collection does not allow duplicate members?

SET

Which of these collections defines a LIST?

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

Which one is NOT a legal variable name?

my-var

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

upper()

What is the correct file extension for Python files?

.py

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

x = 5

Which operator is used to multiply numbers?

*

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

def myFunction():

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

x = "Hello"[0]

How do you insert COMMENTS in Python code?

#This is a comment

Which statement is used to stop a loop?

break

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

LIST

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

replace()

Which of these collections defines a TUPLE?

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

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

print(type(x))

Which operator can be used to compare two values?

==

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

True

How do you start writing a while loop in Python?

while x > y:

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

x = float(2.8)

Which of these collections defines a SET?

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

Which of these collections defines a DICTIONARY?

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

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:

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

print("Hello World")

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

strip()


Related study sets

Network+ Guide to Networks 7th Edition Chapter 9

View Set

Public Speaking: Chapter 8 - Supporting Your Ideas

View Set

IMPACT Lesson 1: WHAT DO YOU CONSIDER LETHAL?, IMPACT Lesson 2: RU LETHAL?, IMPACT Lesson 3: IT CAN HAPPEN TO YOU!, IMPACT Lesson 4: DISTRACTED DRIVING KILLS!, IMPACT Lesson 5: TEXTS CAUSE WRECKS!, IMPACT Lesson 6: InTEXTicated or InTOXicated, IMPACT...

View Set

Exam 1: questions from: ch 1, 2, 3, 4, 5 (so far)

View Set

english: hey come on out/turtles; test: 2/16/23

View Set

SIE missed exam questions (day before pt4)

View Set

Probability of Simple, Independent, & Dependent Events

View Set

NU373 Week 3 EAQ: Oxygenation (Asthma, COPD, RSV)

View Set