Skip to content

Latest commit

 

History

History
38 lines (23 loc) · 1.28 KB

first-program.md

File metadata and controls

38 lines (23 loc) · 1.28 KB

Your first Python program

Русский · Python section

Calculate the cost of three tickets at 50 rubles each. If your computer does not have Python 3 yet, install Python.

Run the program

Save these three lines in a file named tickets.py in a folder of your choice. You can also download the complete file.

ticket_price = 50
tickets = 3
print(ticket_price * tickets)

Open a terminal in the folder that contains the file. Run this command.

python3 tickets.py

On Windows with the Python launcher installed, use py tickets.py.

The program prints 150. The first line sets the ticket price and the second sets the number of tickets. The * operator multiplies the two values. The print() function displays the result.

Change one number

Change tickets = 3 to tickets = 4. What number will the program print now? Save the file and run the same command again.

Check your prediction

The program prints 200. Each ticket still costs 50 rubles, and there are now four tickets.

Next, try removing duplicates from a list of languages.