Programming · Free course

CS50's Introduction to Programming with Python

A comprehensive guide to Python programming, covering everything from basic syntax to object-oriented design. Perfect for beginners looking to build a strong foundation in software development.

by freeCodeCamp.org · Watch the original on YouTube

  • beginner
  • 74 lessons
  • 16 hours of video
  • 35 days at 30 min/day

Loading course start…

What you’ll learn

  • Write and debug Python programs
  • Understand core programming concepts like loops and conditionals
  • Utilize libraries and APIs for data manipulation
  • Design object-oriented code structures

Your daily curriculum

A plan for about 30 minutes a day, including time for notes and questions. Adjust your pace in your own copy.

Day 1 · about 31 min · 0:00 – 25:13

  1. 1. Introduction to Python and Hello World (part 1 of 2)

    0:00 – 8:39

    Learn how to set up your environment and write your first Python program.

    • Python files end with the .py extension. 6:03
  2. 2. Introduction to Python and Hello World (part 2 of 2)

    8:39 – 16:58

    Learn how to set up your environment and write your first Python program.

    • Computers interpret code top to bottom, left to right. 8:39
    • The print function displays text on the screen. 11:46
    • A 'bug' is a mistake in code that needs debugging. 11:46
  3. 3. Interactive Input and Variables (part 1 of 2)

    16:58 – 25:13

    Make programs interactive by accepting user input and storing it in variables.

    • The input function prompts the user for information. 19:34
    • Variables act as placeholders to store user data. 19:34

Day 2 · about 31 min · 25:13 – 49:35

  1. 4. Interactive Input and Variables (part 2 of 2)

    25:13 – 36:03

    Make programs interactive by accepting user input and storing it in variables.

    • Comments (using #) help explain code to humans. 25:13
    • Pseudocode helps structure logic before writing actual code. 27:50
  2. 5. Print Parameters and Escape Characters

    36:03 – 49:35

    Master the print function's advanced features and formatting.

    • Strings are sequences of text data. 36:03
    • The print function accepts multiple arguments. 38:37
    • Backslash-n (\n) creates a new line. 41:12
    • The 'sep' parameter changes the default separator. 41:12

Day 3 · about 31 min · 49:35 – 1:14:16

  1. 6. String Methods and Formatting

    49:35 – 1:03:11

    Manipulate strings using built-in methods for cleaner output.

    • Methods are functions attached to specific data types. 52:10
    • The .strip() method removes whitespace. 52:10
    • The .title() method capitalizes the first letter of words. 55:17
    • F-strings allow dynamic variable insertion into text. 57:55
  2. 7. Calculators and Integer Arithmetic (part 1 of 2)

    1:03:11 – 1:14:16

    Perform mathematical operations and convert data types.

    • The Python interpreter can run code interactively. 1:06:20
    • The int() function converts strings to integers. 1:11:36

Day 4 · about 21 min · 1:14:16 – 1:30:51

  1. 8. Calculators and Integer Arithmetic (part 2 of 2)

    1:14:16 – 1:28:17

    Perform mathematical operations and convert data types.

    • Concatenation joins strings; addition adds numbers. 1:14:16
  2. 9. Floats and Precision

    1:28:17 – 1:30:51

    Handle decimal numbers and rounding in Python.

    • Float data types handle numbers with decimals. 1:28:17
    • The round() function rounds numbers to the nearest integer. 1:28:17
    • Format strings can control decimal precision. 1:28:17

Day 5 · about 37 min · 1:30:51 – 2:00:50

  1. 10. Defining Custom Functions

    1:30:51 – 1:47:00

    Create reusable blocks of code using the 'def' keyword.

    • Use 'def' to define your own functions. 1:33:27
    • Parameters allow functions to accept input. 1:36:02
    • The 'main' function is a convention for the entry point. 1:41:48
  2. 11. Conditionals and If-Else Logic (part 1 of 2)

    1:47:00 – 2:00:50

    Control program flow by making decisions based on conditions.

    • Indentation is mandatory in Python for code blocks. 1:55:21
    • The 'if' statement checks for true conditions. 1:55:21

Day 6 · about 31 min · 2:00:50 – 2:25:41

  1. 12. Conditionals and If-Else Logic (part 2 of 2)

    2:00:50 – 2:14:39

    Control program flow by making decisions based on conditions.

    • The 'else' keyword handles the default case. 2:06:22
  2. 13. Complex Boolean Logic

    2:14:39 – 2:25:41

    Chain multiple conditions together for more robust logic.

    • Logical operators like 'and' combine conditions. 2:17:16
    • Python allows chaining comparisons (e.g., 90 <= score <= 100). 2:19:54
    • Conditions must be mutually exclusive to avoid logic errors. 2:23:03

Day 7 · about 28 min · 2:25:41 – 2:47:50

  1. 14. Modulo and Even/Odd Checks

    2:25:41 – 2:36:41

    Use the modulo operator to determine remainders.

    • The % operator returns the remainder of division. 2:25:41
    • Even numbers have a remainder of 0 when divided by 2. 2:30:59
    • Functions can return Boolean values (True/False). 2:30:59
  2. 15. Match Statements

    2:36:41 – 2:47:50

    Use match statements for cleaner multi-case logic.

    • The 'match' statement compares a value against multiple cases. 2:41:56
    • Each 'case' defines a specific pattern to match. 2:41:56
    • Match statements are often more readable than long if-elif chains. 2:45:00

Day 8 · about 32 min · 2:47:50 – 3:13:34

  1. 16. While Loops

    2:47:50 – 3:03:58

    Repeat code execution using while loops.

    • While loops repeat as long as a condition is true. 2:53:06
    • Infinite loops occur if the condition never becomes false. 2:53:06
    • Always ensure loop variables are updated. 2:53:06
  2. 17. For Loops and Lists (part 1 of 2)

    3:03:58 – 3:13:34

    Iterate over sequences and manage lists of data.

    • For loops iterate over a sequence of values. 3:03:58
    • Lists are zero-indexed, meaning they start at 0. 3:03:58
    • The range() function generates a sequence of numbers. 3:07:06

Day 9 · about 29 min · 3:13:34 – 3:36:42

  1. 18. For Loops and Lists (part 2 of 2)

    3:13:34 – 3:23:10

    Iterate over sequences and manage lists of data.

    • 19. Dictionaries (part 1 of 2)

      3:23:10 – 3:36:42

      Store data in key-value pairs for efficient lookup.

      Day 10 · about 38 min · 3:36:42 – 4:06:57

      1. 20. Dictionaries (part 2 of 2)

        3:36:42 – 3:48:09

        Store data in key-value pairs for efficient lookup.

        • Dictionaries use keys to access values. 3:36:42
        • Curly braces {} define dictionaries. 3:36:42
        • Dictionaries can be nested within lists. 3:45:01
      2. 21. Abstraction and Nested Loops (part 1 of 2)

        3:48:09 – 3:55:54

        Create complex patterns and abstractions using nested loops.

        • 22. Abstraction and Nested Loops (part 2 of 2)

          3:55:54 – 4:06:57

          Create complex patterns and abstractions using nested loops.

          • Abstraction simplifies complex logic into reusable functions. 3:55:54
          • Nested loops allow for multi-dimensional iteration. 4:01:40
          • Print() with no arguments adds a newline. 4:04:20

        Day 11 · about 38 min · 4:06:57 – 4:36:58

        1. 23. Error Handling with Try/Except (part 1 of 3)

          4:06:57 – 4:17:54

          Anticipate and handle runtime errors gracefully.

          • 24. Error Handling with Try/Except (part 2 of 3)

            4:17:54 – 4:26:08

            Anticipate and handle runtime errors gracefully.

            • The 'try' block attempts code execution. 4:17:54
            • The 'except' block catches specific errors. 4:17:54
          • 25. Error Handling with Try/Except (part 3 of 3)

            4:26:08 – 4:36:58

            Anticipate and handle runtime errors gracefully.

            • Use 'else' to execute code only if no errors occurred. 4:26:08

          Day 12 · about 31 min · 4:36:58 – 5:01:26

          1. 26. Libraries and Modules (part 1 of 3)

            4:36:58 – 4:48:43

            Extend Python's functionality by importing external libraries.

            • 27. Libraries and Modules (part 2 of 3)

              4:48:43 – 5:01:26

              Extend Python's functionality by importing external libraries.

              • The 'import' keyword loads external modules. 4:56:18
              • The random library provides random number generation. 4:56:18

            Day 13 · about 35 min · 5:01:26 – 5:28:57

            1. 28. Libraries and Modules (part 3 of 3)

              5:01:26 – 5:12:14

              Extend Python's functionality by importing external libraries.

              • Modules prevent naming conflicts by scoping functions. 5:01:26
            2. 29. Command Line Arguments (part 1 of 2)

              5:12:14 – 5:28:57

              Pass information to programs via the command line.

              • sys.argv stores command line arguments. 5:15:19
              • The first argument (index 0) is the program name. 5:15:19

            Day 14 · about 27 min · 5:28:57 – 5:50:47

            1. 30. Command Line Arguments (part 2 of 2)

              5:28:57 – 5:37:20

              Pass information to programs via the command line.

              • sys.exit() terminates the program early. 5:28:57
            2. 31. APIs and JSON (part 1 of 2)

              5:37:20 – 5:50:47

              Interact with external web services and parse JSON data.

              • APIs allow programs to talk to external services. 5:45:06
              • JSON is a standard format for exchanging data. 5:48:11

            Day 15 · about 38 min · 5:50:47 – 6:21:04

            1. 32. APIs and JSON (part 2 of 2)

              5:50:47 – 6:01:46

              Interact with external web services and parse JSON data.

              • The requests library fetches data from URLs. 5:50:47
            2. 33. Unit Testing (part 1 of 3)

              6:01:46 – 6:12:41

              Automate code verification using unit tests.

              • Unit tests should be small and focused. 6:01:46
            3. 34. Unit Testing (part 2 of 3)

              6:12:41 – 6:21:04

              Automate code verification using unit tests.

              Day 16 · about 35 min · 6:21:04 – 6:48:49

              1. 35. Unit Testing (part 3 of 3)

                6:21:04 – 6:34:32

                Automate code verification using unit tests.

                • The 'assert' keyword checks if a condition is true. 6:21:04
                • Pytest automates the running of multiple tests. 6:28:51
              2. 36. File I/O (part 1 of 4)

                6:34:32 – 6:48:49

                Read from and write to files on your computer.

                Day 17 · about 33 min · 6:48:49 – 7:15:34

                1. 37. File I/O (part 2 of 4)

                  6:48:49 – 7:07:15

                  Read from and write to files on your computer.

                  • 38. File I/O (part 3 of 4)

                    7:07:15 – 7:15:34

                    Read from and write to files on your computer.

                    • The open() function accesses files. 7:07:15
                    • 'w' mode overwrites files; 'a' mode appends to them. 7:09:53

                  Day 18 · about 36 min · 7:15:34 – 7:44:40

                  1. 39. File I/O (part 4 of 4)

                    7:15:34 – 7:31:40

                    Read from and write to files on your computer.

                    • Always close files or use 'with' to manage them. 7:15:34
                  2. 40. CSV Data Handling (part 1 of 4)

                    7:31:40 – 7:44:40

                    Process structured data using CSV files.

                    Day 19 · about 31 min · 7:44:40 – 8:10:07

                    1. 41. CSV Data Handling (part 2 of 4)

                      7:44:40 – 8:01:48

                      Process structured data using CSV files.

                      • 42. CSV Data Handling (part 3 of 4)

                        8:01:48 – 8:10:07

                        Process structured data using CSV files.

                        • The CSV module simplifies reading/writing CSV files. 8:01:48
                        • CSV readers can automatically parse rows. 8:04:22

                      Day 20 · about 34 min · 8:10:07 – 8:37:20

                      1. 43. CSV Data Handling (part 4 of 4)

                        8:10:07 – 8:23:38

                        Process structured data using CSV files.

                        • DictReader allows accessing columns by name. 8:10:07
                      2. 44. Regular Expressions (part 1 of 6)

                        8:23:38 – 8:37:20

                        Use patterns to validate and manipulate text strings.

                        Day 21 · about 34 min · 8:37:20 – 9:04:44

                        1. 45. Regular Expressions (part 2 of 6)

                          8:37:20 – 8:48:00

                          Use patterns to validate and manipulate text strings.

                          • The 're' module provides regular expression support. 8:45:24
                        2. 46. Regular Expressions (part 3 of 6)

                          8:48:00 – 9:04:44

                          Use patterns to validate and manipulate text strings.

                          • '+' means one or more repetitions. 8:48:00
                          • Escape characters (\) match literal special symbols. 8:59:02

                        Day 22 · about 34 min · 9:04:44 – 9:32:08

                        1. 47. Regular Expressions (part 4 of 6)

                          9:04:44 – 9:18:26

                          Use patterns to validate and manipulate text strings.

                          • The '^' and '$' anchors match start and end of strings. 9:13:07
                        2. 48. Regular Expressions (part 5 of 6)

                          9:18:26 – 9:32:08

                          Use patterns to validate and manipulate text strings.

                          Day 23 · about 36 min · 9:32:08 – 10:00:43

                          1. 49. Regular Expressions (part 6 of 6)

                            9:32:08 – 9:45:50

                            Use patterns to validate and manipulate text strings.

                            • 50. Object-Oriented Programming (part 1 of 25)

                              9:45:50 – 10:00:43

                              Model real-world entities using classes and objects.

                              Day 24 · about 38 min · 10:00:43 – 10:30:28

                              1. 51. Object-Oriented Programming (part 2 of 25)

                                10:00:43 – 10:15:35

                                Model real-world entities using classes and objects.

                                • 52. Object-Oriented Programming (part 3 of 25)

                                  10:15:35 – 10:30:28

                                  Model real-world entities using classes and objects.

                                  Day 25 · about 38 min · 10:30:28 – 11:00:13

                                  1. 53. Object-Oriented Programming (part 4 of 25)

                                    10:30:28 – 10:45:20

                                    Model real-world entities using classes and objects.

                                    • 54. Object-Oriented Programming (part 5 of 25)

                                      10:45:20 – 11:00:13

                                      Model real-world entities using classes and objects.

                                      Day 26 · about 37 min · 11:00:13 – 11:29:58

                                      1. 55. Object-Oriented Programming (part 6 of 25)

                                        11:00:13 – 11:18:35

                                        Model real-world entities using classes and objects.

                                        • Classes are blueprints for creating objects. 11:10:15
                                      2. 56. Object-Oriented Programming (part 7 of 25)

                                        11:18:35 – 11:29:58

                                        Model real-world entities using classes and objects.

                                        • The __init__ method initializes object attributes. 11:18:35

                                      Day 27 · about 40 min · 11:29:58 – 12:02:08

                                      1. 57. Object-Oriented Programming (part 8 of 25)

                                        11:29:58 – 11:48:41

                                        Model real-world entities using classes and objects.

                                        • 58. Object-Oriented Programming (part 9 of 25)

                                          11:48:41 – 12:02:08

                                          Model real-world entities using classes and objects.

                                          • Methods are functions defined inside a class. 11:48:41

                                        Day 28 · about 35 min · 12:02:08 – 12:29:28

                                        1. 59. Object-Oriented Programming (part 10 of 25)

                                          12:02:08 – 12:14:35

                                          Model real-world entities using classes and objects.

                                          • Properties allow controlled access to attributes. 12:02:08
                                        2. 60. Object-Oriented Programming (part 11 of 25)

                                          12:14:35 – 12:29:28

                                          Model real-world entities using classes and objects.

                                          Day 29 · about 38 min · 12:29:28 – 12:59:13

                                          1. 61. Object-Oriented Programming (part 12 of 25)

                                            12:29:28 – 12:44:20

                                            Model real-world entities using classes and objects.

                                            • 62. Object-Oriented Programming (part 13 of 25)

                                              12:44:20 – 12:59:13

                                              Model real-world entities using classes and objects.

                                              Day 30 · about 38 min · 12:59:13 – 13:28:58

                                              1. 63. Object-Oriented Programming (part 14 of 25)

                                                12:59:13 – 13:14:05

                                                Model real-world entities using classes and objects.

                                                • 64. Object-Oriented Programming (part 15 of 25)

                                                  13:14:05 – 13:28:58

                                                  Model real-world entities using classes and objects.

                                                  Day 31 · about 38 min · 13:28:58 – 13:58:43

                                                  1. 65. Object-Oriented Programming (part 16 of 25)

                                                    13:28:58 – 13:43:50

                                                    Model real-world entities using classes and objects.

                                                    • 66. Object-Oriented Programming (part 17 of 25)

                                                      13:43:50 – 13:58:43

                                                      Model real-world entities using classes and objects.

                                                      Day 32 · about 38 min · 13:58:43 – 14:28:28

                                                      1. 67. Object-Oriented Programming (part 18 of 25)

                                                        13:58:43 – 14:13:35

                                                        Model real-world entities using classes and objects.

                                                        • 68. Object-Oriented Programming (part 19 of 25)

                                                          14:13:35 – 14:28:28

                                                          Model real-world entities using classes and objects.

                                                          Day 33 · about 38 min · 14:28:28 – 14:58:13

                                                          1. 69. Object-Oriented Programming (part 20 of 25)

                                                            14:28:28 – 14:43:20

                                                            Model real-world entities using classes and objects.

                                                            • 70. Object-Oriented Programming (part 21 of 25)

                                                              14:43:20 – 14:58:13

                                                              Model real-world entities using classes and objects.

                                                              Day 34 · about 38 min · 14:58:13 – 15:27:58

                                                              1. 71. Object-Oriented Programming (part 22 of 25)

                                                                14:58:13 – 15:13:05

                                                                Model real-world entities using classes and objects.

                                                                • 72. Object-Oriented Programming (part 23 of 25)

                                                                  15:13:05 – 15:27:58

                                                                  Model real-world entities using classes and objects.

                                                                  Day 35 · about 38 min · 15:27:58 – 15:57:43

                                                                  1. 73. Object-Oriented Programming (part 24 of 25)

                                                                    15:27:58 – 15:42:50

                                                                    Model real-world entities using classes and objects.

                                                                    • 74. Object-Oriented Programming (part 25 of 25)

                                                                      15:42:50 – 15:57:43

                                                                      Model real-world entities using classes and objects.

                                                                      This course is built from a free YouTube video by freeCodeCamp.org. The videos play on YouTube, and the lessons, summaries and quizzes are Notelify’s own study notes. Notelify isn’t affiliated with YouTube or the creator. Creators can ask us to remove a course at support@notelifyapp.com.