Welcome to Python!
Python is one of the most popular programming languages in the world. It’s used for web development, data science, automation, and much more. This course will teach you the fundamentals through interactive, hands-on exercises that run right in your browser - no installation required!
Each section below includes interactive code editors. Try running the examples, then modify them to experiment and learn!
Module 1: Python Basics
Variables and Data Types
In Python, variables are used to store information. You don’t need to declare variable types - Python figures it out automatically!
Basic Arithmetic
Python can perform all standard mathematical operations.
Exercise: Create Your Own Variables
Now it’s your turn! Create variables for your name, age, and favorite number, then print them out.
Module 2: Lists
Working with Lists
Lists are used to store multiple items in a single variable. Lists are ordered, changeable, and allow duplicate values.
List Methods
Lists have built-in methods that let you modify them.
Exercise: Build Your Own List
Create a list of your top 5 favorite movies, then use list methods to add one more and sort them alphabetically.
Module 3: Functions
Built-in Functions
Python comes with many useful built-in functions that you can use right away.
Creating Custom Functions
You can create your own functions using the def
keyword. Functions help you reuse code!
Exercise: Create Your Own Function
Write a function that takes a temperature in Celsius and converts it to Fahrenheit. Formula: F = (C × 9/5) + 32
Module 4: Control Flow
Conditional Statements
Use if
, elif
, and else
to make decisions in your code.
For Loops
Loops let you repeat code multiple times. The for
loop is perfect for iterating over lists.
While Loops
While loops repeat code as long as a condition is true.
Exercise: FizzBuzz Challenge
Write a program that prints numbers from 1 to 20, but:
- For multiples of 3, print “Fizz” instead of the number
- For multiples of 5, print “Buzz” instead of the number
- For multiples of both 3 and 5, print “FizzBuzz”
Final Challenge: Putting It All Together
Create a simple program that:
- Creates a list of numbers
- Defines a function to check if a number is even or odd (returns “even” or “odd”)
- Uses a loop to check each number and print the result in the format:
x is even
ory is odd
Example output:
2 is even
3 is odd
4 is even
Congratulations!
You’ve completed the Introduction to Python Fundamentals course! You now know:
- How to work with variables and data types
- How to use and manipulate lists
- How to use built-in functions and create your own
- How to control program flow with if statements and loops
Next Steps
Keep practicing! Here are some ideas:
- Build a simple calculator program
- Create a guessing game
- Write a program to analyze text (count words, find longest word, etc.)
- Explore more advanced Python topics like dictionaries, file handling, and object-oriented programming
Happy coding!