LAB
Estimated time
5-10 minutes
Level of difficulty
Easy
Objectives
Scenario
Write a one-line piece of code, using the print() function, as well as the newline and escape characters, to match the expected result outputted on three lines.
swiftCopy code
print("I'm\n\"learning\"\n\"\"\"Python\"\"\"")
Output:
rustCopy code
I'm "learning" """Python"""
Explanation:
Key takeaways
EXTRA
There is one more, special literal that is used in Python: the None literal. This literal is a so called NoneType object, and it is used to represent the absence of a value. We'll tell you more about it soon.
Exercise 1
What types of literals are the following two examples?
"Hello", "007"
They're both strings/string literals.
Exercise 2
What types of literals are the following four examples?
"1.5", 2.0, 528, False
String, numerical literal (a float), the third is a numerical literal (an integer) and the fourth is a boolean literal.
Exercise 3
What is the decimal value of the following binary number?
1011
It's 11, because (2**0) +(2**1) + (2**3)=11