.. Are You Ready to Learn Real Coding?
If you have already made games and animations using Scratch
or other block-based platforms you are ready for the step: **Python
programming**.
Python is a popular programming language. It is used by
people who make games, websites and even work at NASA.
The good thing about Python is that it is easy to learn and
understand, for students who are learning text-based coding for the first time.
In this tutorial you will make **3 fun Python projects** in
under 30 minutes. You will learn things like:
* Variables
* User Input
* Print Statements
* Loops
* Random Choices
* Conditional Logic
Lets start coding!
---
. Project 1: Magic 8-Ball Predictor
.. What You Will Make
A Magic 8-Ball that answers your questions with random
predictions.
... Python Code
```python
import random
answers = [
"Yes!"
"No!"
""
"Ask again later."
"Definitely!"
"I don't think so."
]
question = input("Ask the Magic 8-Ball a question:
")
print("Thinking...")
print(random.choice(answers))
```
---
.. How It Works
... Variables
```python
answers = [...]
```
A variable is like a box where you can store things. Here we
store possible answers.
... User Input
```python
question = input(...)
```
The program waits for you to type a question.
... Random Selection
```python
random.choice(answers)
```
Python picks one answer from the list randomly.
... Print Function
```python
print(...)
```
It shows text on the screen.
---
.. Challenge
Add 5 funny answers to the list!
---
. Project 2: Libs Story Generator
.. What You Will Make
A funny story where you choose the words.
... Python Code
```python
name = input("Enter a name: ")
animal = input("Enter an animal: ")
place = input("Enter a place: ")
story = f"""
One day {name} met a giant {animal}
at {place}.
Together they built a rocket ship
Flew to the moon!
The End.
"""
print(story)
```
---
.. How It Works
... Variables
```python
name
animal
place
```
These variables store the information you enter.
... User Input
```python
input()
```
You get to choose the words for the story.
... Formatted Strings
```python
f"..."
```
The `f` lets Python put the values into the text.
... Print Function
```python
print(story)
```
It shows the completed story.
---
.. Challenge
Add words like:
* Favorite food
* Superpower
* Movie character
Then create a crazier story!
---
. Project 3: Number Guessing Game
.. What You Will Make
A game where you try to guess a number.
... Python Code
```python
import random
secret_number = random.randint(1, 10)
guess = 0
while guess != secret_number:
guess = int(input("Guess a number between 1 and 10:
"))
if guess < secret_number:
low!")
elif guess > secret_number:
print("Too high!")
else:
print("You got it!")
```
---
.. How It Works
... Random Number Generation
```python
random.randint(1,10)
```
It creates a secret number between 1 and 10.
... While Loop
```python
while guess != secret_number:
```
The game keeps going until you guess the number.
... User Input
```python
input()
```
You enter your guesses.
... Conditional Statements
```python
if
elif
else
```
These help Python decide what message to show.
---
.. Challenge
Make the game better by:
* Counting how many guesses you make
* Giving you 5 attempts
* Adding medium and hard levels
* Keeping track of scores
---
. What You Learned
By making these three projects you have already practiced
some of the most important programming concepts:
✅ Variables
✅ User Input
✅ Print Functions
✅ Lists
✅ Randomization
✅ Loops
✅ If/Else Logic
These are the same things used in bigger applications,
games, websites and AI systems.
Remember: all professional programmers started with projects
like these.
---
. What's Next After These Python Projects?
Once you are good at beginner Python projects you can start
making:
* Games that you can play
* Programs that work on your computer
* Chatbots that can talk to you
* Websites that you can visit
* Tools that can help you with work
* Projects that use data science
The possibilities are endless.
.jpeg)
No comments:
Post a Comment