Welcome to the examples section! You will notice that each topic has it’s own page for examples. Check it out on the contents panel on the left.
Since we’re starting with the absolute basics, these examples are kept very simple. But as you progress through more topics, you get more storylines and a chance to brush up on earlier concepts.
Kay Skunt has been traveling across the universe for years and just entered a new galaxy. He wants to communicate with the locals but does not know how. He knows though that the locals understand python! Help Kay print a ‘Hello World’ statement.
1 2 3 4 | Output: Hello world Hello world Hello world |
Kay has stored his name, age and origin in python as variables (name = ‘Kay’, age = 13, origin = ‘Earth’). How can he output that in one print statement so that the aliens read it? Write a single statement that prints ‘Hi, I am Kay, I am 13 years old and I am from Earth!’.
1 2 | Output: Hi, I'm Kay , I am 13 years old and I am from Earth |
Kay has met Jay, who is 17 years old, and May who is 23 years old. He now needs to print his friends’ names and ages in three different lines. How can he do that using one single print statement?
1 2 3 | Output: Meet Jay. He's 17years old. Meet May. She's 23years old. |
Kay now needs to print his and his friends’ ages (13, 17 and 23) in a way so that people read it fast. He wants to print in one single line and each number needs to be connected with the next with a hyphen ‘-‘ symbol as if it were a telephone number. How can he do that?
1 2 | Output: 13 - 17 - 23 |