14 questions
Python accepts single ('), double (") and triple (''' or """) quotes to denote strings. Which of the following is NOT acceptable Python syntax?
print('Hello World')
print("Hello World")
print('Hello World")
print(""'Hello World'"")
What is printed by the following statement?
print("P" not in "APCSP")
True
False
Error
What is printed by the following statement?
print("A" in "APCSP")
True
False
Error
Evaluate the following expression:
"dog" < "Dog"
They are the same word
True
False
For strings, the + operator represents
Concatenation
Addition
Appending
Recantation
data = "No Way!" The expression len(data) evaluates to:
7
9
8
6
Which operator returns True if target string is somewhere in the search string; otherwise it returns False.
==
!=
in
is
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
\l
/
\\n
\n
Which is the most appropriate data type for: "13th December"
Float
Boolean
Integer
String
What will the output be from the following code?
print("Hello world!" * 2)
TypeError
Hello world world!
Hello world!Hello world!
Hello world! * 2
What will the output be from the following code?
print("Hello world!\nHello world!")
Hello world! Hello world!
Hello world!
Hello world!
SyntaxError
Hello world!
What will the output be from the following code?
print("3+4")
7
34
3+4
SyntaxError
print("12"*3)
What would this print?
121212
36
24
12*3
What will the output be from the following code?
print("Hello world!")
SyntaxError
Hello world!
"Hello world!"
print(Hello world!)