Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Write a program that asks for your name and your city and shows a small card. Then explain how you would save and run it as a file called card.py.
A program is a text file that ends in .py. Run it from the editor or from a terminal.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
The program. It reads two answers with input() and shows them between two lines of equal signs. Try it in the code box first: type your name and your city in the Input box, one on each line.
Save it. In IDLE: File, New File, type the program, File, Save, and name it card.py.
Run it.
python card.py on Windows (or py card.py), and python3 card.py on macOS and Linux. The program waits. Type your name, press Enter, type your city, and press Enter.Log in to join the discussion.
Loading…