Python Quiz

¡Supera tus tareas y exámenes ahora con Quizwiz!

How do you create a variable with the numeric value 5? x = int(5) :set num (5) All of these var = num = (5) x = 5

x = int(5) x = 5

What is a correct syntax to return the first character in a string? get first ("Hello") x = "Hello".sub(0, 1) x = "Hello"[0]" x = sub("Hello", 0, 1)

x = "Hello"[0]

What is a correct syntax to output "Hello World" in Python? echo("Hello World"); p("Hello World") echo -e "Hello, World" print("Hello World")

print("Hello World")

Which collection does not allow duplicate members? TUPLE LIST DICTIONARY SET

SET

Which operator is used to multiply numbers? % mul X *

*

Which of these collections defines a DICTIONARY? {"name": "apple", "color": "green"} {"apple", "banana", "cherry"} ("apple", "banana", "cherry") ["apple", "banana", "cherry"]

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

What is the correct file extension for Python files? .pyth .py .pt .pyth

.py

Which of these collections defines a TUPLE? ["apple", "banana", "cherry"] {"apple", "banana", "cherry"} {"name": "apple", "color": "green"} ("apple", "banana", "cherry")

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

Which one is NOT a legal variable name? my_var _myvar Myvar my-var

my-var

Which of these collections defines a SET? ["apple", "banana", "cherry"] {"name": "apple", "color": "green"} {"apple", "banana", "cherry"} ("apple", "banana", "cherry"):

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

Python can be used to write Java Scripts when there is no Java compliler available. True False

False

Which of these collections defines a LIST? {"name": "apple", "color": "green"} ["apple", "banana", "cherry"] {"apple", "banana", "cherry"} ("apple", "banana", "cherry"):

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

What is the correct way to create a function in Python? function myfunction(): create myFunction(): def myFunction(): getthefunk:()

def myFunction():

Which method can be used to return a string in upper case letters? upperCase(): upper() toUpperCase() uppercase()

upper()

How do you start writing a while loop in Python? x > y while { while x > y { while x > y: while (x > y)

while x > y:

How do you create a variable with the floating number 2.8? x = int(2.8) x = 2.8 All of these var = num = (2.8) x = 2.8 (float)

x = int(2.8) x = 2.8

Which statement is used to stop a loop? return stop exit break

break

How do you start writing an if statement in Python? if x > y then: if (x > y) if "x > y": if x > y:

if x > y:

What is the correct syntax to output the type of a variable or object in Python? print(typeof(x)) print(type(x)) print(typeOf(x)) print(typeof x):

print(type(x))

Which method can be used to replace parts of a string? repl() replaceString() switch() replace()

replace()

Which method can be used to remove any whitespace from both the beginning and the end of a string? strip() trim() stripwhtspc() len()

strip()

Which collection is ordered, changeable, and allows duplicate members? TUPLE LIST DICTIONARY SET

LIST

How do you insert COMMENTS in Python code? %This is a comment /*This is a comment*\ #This is a comment $This is a comment

#This is a comment

Which operator can be used to compare two values? >< = == <>

==

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

True

How do you start writing a for loop in Python? for in count = x +1 for x in y: for x > y: for each x in y:

for x in y:


Conjuntos de estudio relacionados

Ch. 22: Nursing Management of the Postpartum Woman at Risk

View Set

Audit 1 - Exam 2 - Chapters 5,6,7

View Set

PRP201_CÓ LÀM THÌ MỚI CÓ ĂN

View Set

Genetics Exam 2 (Chapter 8)1. List the different types of chromosome mutations and define each one.

View Set

Chapter 4: Taxes, Retirement, and Other Insurance concepts

View Set