Lessons · Coding · beginner · Programming with Mosh

Python for Beginners - Learn Coding with Python in 1 Hour

The video “Python for Beginners - Learn Coding with Python in 1 Hour” by Programming with Mosh as 8 lessons, with the idea explained, the code from the screen, steps to try in the practice terminal, practice problems with solutions and a quiz that leads back to the moment.

8lessons
21pieces of code
4formulas
19exercises
60min of video
Open the lessons →Lesson 1 is free · Beyond Pass opens all
Python for Beginners - Learn Coding with Python in 1 Hour, video by Programming with Mosh▶ 1:00:05 · Programming with Mosh
12345678
0:008 lessons across the whole video1:00:05

You will be able to

  • Install Python and run a first program from the terminal or an editor
  • Create variables and choose appropriate data types for numbers, strings, and booleans
  • Write conditionals and loops to control program flow
  • Use lists, tuples, and dictionaries to store and organize data
  • Define and call functions with parameters and return values
  • Build a small complete Python program that combines these concepts

Good to know first

  • Basic comfort using a computer and opening files
  • Ability to install software or follow setup instructions

Syllabus

8 lessons and a final project

  1. 1

    Setting up Python and writing a first program Free

    0:00–7:007 min of video

    You will install Python and PyCharm, create a project and a Python file, and run your first lines of code with print(). You will also see how a variable stores a value that print() can show.

    2 code7 build steps2 exercises3 questions
  2. 2

    Variables and data types Beyond Pass

    7:00–15:008 min of video

    You will learn how to store values in variables, the basic data types Python uses (integers, floats, strings and booleans), and how to get input from the user and convert it to a number. By the end you can write a small program that asks for a birth year and calculates an age.

    3 code3 build steps3 exercises3 questions
  3. 3

    Strings and getting user input Beyond Pass

    15:00–21:006 min of video

    You will learn how input() asks the user for text and why every value it returns is a string. You will also learn how to convert strings to numbers with float() and back to text with str(), and how a string's methods are used with a dot.

    2 code3 build steps2 exercises3 questions
  4. 4

    Conditionals and comparisons Beyond Pass

    21:00–28:007 min of video

    This lesson shows how Python checks text and numbers with the in operator and the % remainder operator, and how it works out the order of operations in a line of code. It also shows the shorthand operators like += and -=.

    2 code3 build steps2 exercises3 questions
  5. 5

    Conditions in Python: if, elif and the logic behind them Beyond Pass

    28:00–35:007 min of video

    This lesson shows how Python checks conditions with comparison and logical operators, and how if, elif and else choose which code runs. You will write and test small programs that make decisions based on a value.

    3 code3 formulas3 build steps2 exercises3 questions
  6. 6

    Conditionals in Practice: elif, else and a Weight Converter Beyond Pass

    35:00–42:007 min of video

    This lesson shows how to chain several conditions with elif and finish with a catch-all else. It then builds a small weight converter that asks for a value and a unit and picks the right calculation.

    2 code1 formula4 build steps3 exercises4 questions
  7. 7

    Writing and Calling Functions in Python Beyond Pass

    42:00–49:007 min of video

    You will learn what a function is, how to define one with def, and how to call it. You will see how a function can take inputs (parameters) and be reused many times.

    2 code2 build steps3 exercises3 questions
  8. 8

    Dictionaries and a mini project Beyond Pass

    49:00–1:00:0511 min of video

    This lesson covers the list and tuple tools the video shows, such as checking membership with "in", looping with for, using range, and counting items with count(). It ends with the start of a mini project, and the transcript for this chapter is short, so the lesson sticks to what the frames show.

    5 code2 build steps2 exercises3 questions

Final project

Pocket Expense Tracker: a Complete Python Console Program

Build a small command-line expense tracker that stores entries in lists, tuples and dictionaries, asks the user for input with input() and converts it with float(), makes decisions with if/elif/else, and reuses logic through functions. It pulls together every outcome of the course in one working program, and it mirrors the weight-converter style of lesson 6 but for money. The result shows that the course's small building blocks compose into a real tool.

Its 7 tasks open with Beyond Pass.

Free preview · Lesson 1 in full

Setting up Python and writing a first program

You will install Python and PyCharm, create a project and a Python file, and run your first lines of code with print(). You will also see how a variable stores a value that print() can show.

0:00 to 7:00 in the video

Practice terminal

Type the lesson's commands, break things, and see why.

Playground

Run and change the code, with real Python and JavaScript.

Scratchpad

Draw and write next to the video.

The idea

To write Python you need two things: the Python interpreter, which runs your code, and an editor where you type it. The video installs Python from the official Python installer (on macOS it shows Python 3.8.1 for macOS 10.9 or later) and then installs PyCharm Community Edition, a free editor made for Python. You drag PyCharm into the Applications folder like any other Mac app.

Next, open PyCharm and create a new project, here named HelloWorld. A project is a folder that holds your Python files. Inside it, right-click the project and choose New, then Python file. Name the file app.py. The .py ending tells the computer this file contains Python code.

Your first program is one line: print("Hello World"). The word print is a built-in instruction that shows whatever you put inside the brackets on the screen. The text inside the quotation marks is a string, which is a piece of text. Run the program from the Run menu (Run...), and the output Hello World appears in the panel at the bottom.

Print can also show a value stored in a variable. A variable is a name that holds a value. The line age = 20 creates a variable called age and stores the number 20 in it. The line print(age) then shows 20. Notice the difference: print("age") would show the word age, while print(age) shows the value stored under that name.

In short, you install Python and an editor, make a project and a .py file, write instructions, and run them. Each run executes the file from top to bottom, one line after another.

Key points

  • Python needs an interpreter (installed from the Python installer) and an editor such as PyCharm Community Edition. 1:51
  • A project is a folder for your files; a Python file ends with .py, for example app.py. 4:00
  • print("Hello World") shows the text Hello World; the text inside the quotes is a string. 5:01
  • Run... in the Run menu executes the file, and the output appears at the bottom of the window. 5:01
  • print(age) shows the value stored in the variable age, which is 20 after age = 20. 6:40

Code from the screen

First programpython 5:01 on screen
print("Hello World")

Save as app.py in your PyCharm project and press Run.

Printing a variablepython 6:40 on screen
age = 20
print(age)

Save as app.py in your PyCharm project and press Run.

Build along in the practice terminal

  1. Download and run the Python installer from python.org and click Continue through the steps until it finishes. 1:51You should see: Python is installed on your computer.
  2. Drag PyCharm CE into the Applications folder, then open PyCharm. 3:01You should see: PyCharm opens and is ready to create a project.
  3. Create a new project called HelloWorld. 4:00You should see: The HelloWorld project appears in the Project panel.
  4. Right-click the project, choose New, then Python file, and name it app.py. 4:00You should see: app.py opens in the editor.
  5. Type print("Hello World") into app.py. 5:01
    $ print("Hello World")
    You should see: The line is shown in the editor.
  6. Choose Run from the Run menu (or press the run button). 5:01You should see: The output Hello World appears at the bottom.
  7. Replace the code with age = 20 and print(age), then run again. 6:40
    $ print(age)
    You should see: The output shows 20.

Practice

Code Solution checked

Create a variable called name that stores the text "Sara" and print it.

# Write your code below
Hint

Strings go in quotes. A variable is made with name = value, and print(name) shows its value.

Solution
  1. Create the variable: name = "Sara".
  2. Print the variable: print(name).
  3. Running it shows Sara (no quotes, because print shows the value).
name = "Sara"
print(name)

Sara

Calculate Solution checked

A file has these lines: age = 20, then print(age), then age = 25, then print(age). What are the two numbers printed, added together?

Hint

Lines run from top to bottom, so the second print sees the new value of age.

Solution
  1. The first print(age) runs when age is 20, so it prints 20.
  2. Then age becomes 25, and the second print(age) prints 25.
  3. 20 + 25 = 45.

45

On your scratchpad

Draw a box labelled age, and write 20 inside it. Next to it, sketch what print(age) puts on the screen.

Quiz

  1. What does the file ending .py tell the computer?

    1. The file is a picture
    2. The file contains Python code
    3. The file is a folder
    4. The file is encrypted
    Show the answer

    B. The file contains Python code · Files ending in .py hold Python code that the interpreter can run.

    4:00 watch the moment
  2. After age = 20, what does print(age) show?

    1. age
    2. 20
    3. age = 20
    4. an error
    Show the answer

    B. 20 · print(age) shows the value stored in the variable age, which is 20.

    6:40 watch the moment
  3. Which editor does the video install to write Python?

    1. Word
    2. PyCharm Community Edition
    3. Excel
    4. Photoshop
    Show the answer

    B. PyCharm Community Edition · The video installs PyCharm Community Edition, a free Python editor.

    3:01 watch the moment

Open lesson 1, with the video →

Lessons 2–8 and the final project

They open with Beyond Pass: every lesson of every course, in full. One payment: $14.99 for 90 days or $29 for a year. No subscription.

Made by Beyond from the video “Python for Beginners - Learn Coding with Python in 1 Hour” by Programming with Mosh. The video plays in YouTube's own player. Watch it on YouTube · All lessons