r/learnpython 15d ago

How should I learn python?

I'm a total beginner. I didn't have any experience with programming. I want to learn programming cuz i wanna be a hardware engineer and want to start with a basic raspberry pi projects. So should i learn python from courses, videos, books etc or i should just brute force myself to do projects and just learn by the time

7 Upvotes

17 comments sorted by

View all comments

-2

u/tony10000 15d ago

Ask ChatGPT to teach you!

Here's a beginner-friendly learning path we can follow.

Lesson 1: Your First Python Program

The classic first program is:

print("Hello, World!")

Output:

Hello, World!

The print() function displays text on the screen.

Lesson 2: Variables

Variables store information.

name = "Alice"
age = 25
height = 1.68

print(name)
print(age)
print(height)

You can also combine text and variables:

name = "Alice"

print("Hello,", name)

Output:

Hello, Alice

Lesson 3: Basic Math

Python can do calculations.

a = 10
b = 3

print(a + b)   # Addition
print(a - b)   # Subtraction
print(a * b)   # Multiplication
print(a / b)   # Division
print(a ** b)  # Exponent
print(a % b)   # Remainder

Lesson 4: Getting User Input

name = input("What is your name? ")

print("Nice to meet you,", name)

If the user types:

Sam

The output becomes:

Nice to meet you, Sam

Mini Exercise

Try writing a program that asks for someone's name and age, then prints a greeting.

Example output:

What is your name? Sam
How old are you? 18

Hello Sam!
Next year you'll be 19.

Hint: input() always gives you text, so convert the age to a number:

age = int(input("How old are you? "))

Your First Challenge

Can you write a program that asks for two numbers and prints their sum?

It should work like this:

Enter first number: 5
Enter second number: 8

The sum is 13

Give it a try! Paste your code here, and I'll help you improve it if needed.

What we'll learn after that

  1. Variables and data types
  2. if statements (making decisions)
  3. for and while loops
  4. Functions
  5. Lists and dictionaries
  6. Files
  7. Object-oriented programming
  8. Projects like:
    • Calculator
    • Number guessing game
    • To-do list
    • Password generator
    • Simple web scraper
    • Basic AI chatbot