Several print statements
Up until now, we have experimented with single-line programs which had only a single
print()statement. Real-world programs usually have many lines of code and we will write our first multi-line program in this exercise.
Programs can have multiple print statements. In that case, each print statement outputs the content on a separate line.
print(98234539) print('is a big number')
This program prints
98234539on the first line and
is a big numberon the second line. Resulting in the following output:
98234539 is a big number
We can have many print statements one after another and Python will execute each of those sequentially. It will first print the contents of the first print statement, after that it will print the contents of the second print statement, then the third one, and so on.
So, the program is executed line-by-line and each statement is executed after the previous one.
print('Hi, this is Alice') print('Hi Alice, how are you doing?') print('I am great! What about you?') print('Great! Thanks!')
This program will print the first print statement, then the second one, then the print on the third line, and finally the fourth. This will result in the following output:
Hi, this is Alice Hi Alice, how are you doing? I am great! What about you? Great! Thanks!
Write a program that would print
Bob is 19 years old.on the first line and
Alice is older than Bob.on the second line.
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB