Mod 2 Flashcards
What is the output of:
print(“The itsy bitsy spider climbed up the waterspout.”)
print()
print(“Down came the rain and washed the spider out.”)
The itsy bitsy spider climbed up the waterspout.
Down came the rain and washed the spider out.
What is the output of:
print(“The itsy bitsy spider\nclimbed up the waterspout.”)
print()
print(“Down came the rain\nand washed the spider out.”)
The itsy bitsy spider
climbed up the waterspout.
Down came the rain
and washed the spider out.
How do you print one backslash?
print(“\”)
this will return an error: print(“")
What is the output of:
print(“The itsy bitsy spider” , “climbed up” , “the waterspout.”)
The itsy bitsy spider climbed up the waterspout.
What is the output of:
print(“My name is”, “Python.”, end=” “)
print(“Monty Python.”)
My name is Python. Monty Python.
What is the output of:
print(“My name is”, “Python.”, end=”\n”)
print(“Monty Python.”)
My name is Python.
Monty Python.
What is the output of:
print(“My name is “, end=””)
print(“Monty Python.”)
My name is Monty Python.
What is the output of:
print(“My”, “name”, “is”, “Monty”, “Python.”, sep=””)
MynameisMontyPython.
What is the output of:
print(“My”, “name”, “is”, sep=”_”, end=””)
print(“Monty”, “Python.”, sep=””, end=”*\n”)
My_name_isMontyPython.*
What are Literals and what are the two types?
String and integer number. A literal is data whose values are determined by the literal itself
Two ways of writing 11 million
11000000 or 11_000_000 (anything else is prohibited)
Example of an octal number and how to convert it
Example of an hexadecimal number and how to convert it.
0o123 or 0O123, print(0o123)
0x123 or 0X123, print(0x123)
Write the “to the power of 10” expression to output 1 million
1E6 or 1e6
1 is the base, 6 is the exponent
How to print(2):
I like “Monty Python”
print('I like "Monty Python"') #OR print("I like \"Monty Python\"")
what are the outputs: print(6 / 3) print(6 / 3.) print(6. / 3) print(6. / 3.)
- 0
- 0
- 0
- 0