1. Printing Text
Let's print something else. Go ahead and print your name and year of birth. To do this,
just write two more calls to the print()
function. It might look something like this:
print("Alexander")
print(1985)
Numbers can be printed without quotes. Quotes are part of the text, but not part of the
print()
function.
Here's what I got:
2. Advanced Printing
You can also print several objects on one line by listing them separated by commas.
It might look something like this:
print("Galaxy", "NGC", 1300, "was discovered in", 1835)
This command will output: "Galaxy NGC 1300 was discovered in 1835". Which, by the way, is a historical fact 😊
You can also print not only text but entire expressions. For example: "I was born in 1990, so today I'm X years old". Here's how you can print that:
print("Today I'm", 2024-1990, "years old")
By the way, do you like cats? Just remembered a funny internet meme:
3. Cats and Boxes
How to catch a cat:
- Get an empty box.
- Wait.
Just kidding :)
Well, maybe you can stuff as many cats as you like into a box, but in a variable, you can only store one value. Which is what we're gonna talk about next.
GO TO FULL VERSION