PFCS Python

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

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 of these collections defines a TUPLE? ["apple", "banana", "cherry"] {"apple", "banana", "cherry"} {"name": "apple", "color": "green"} ("apple", "banana", "cherry")

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

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

*

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

.py

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

==

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

False

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

LIST

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

SET

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

True

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():

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:

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:

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

my-var

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

replace()

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? (pick two) 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

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

x = int(5) x = 5

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

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

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

break

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

strip()

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]"

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 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")

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))


Set pelajaran terkait

Chapter 1 Fundamentals of Nursing Theory

View Set

3.12 Mid-Unit Test: Cell Biology - Part 1

View Set

Lesson 3 Achieving Academic Excllence: Written Communication

View Set

Chapters 1-8 Review: The Catcher in the Rye.

View Set

Chapter 7 Skeletal System Test Review

View Set