Skip to main content

Command Palette

Search for a command to run...

Python 30 Days Challenge: Day 1 - Area of a Circle - Code With Drew

Updated
3 min read
Python 30 Days Challenge: Day 1 - Area of a Circle - Code With Drew

Hey there 👋

Welcome to Day 1 of my Python 30 Days Coding Challenge!

In today’s challenge, we’re starting with something simple yet powerful — calculating the area of a circle in Python. It’s a great warm-up to help beginners understand variables, mathematical formulas, and input/output in Python.

🎥 Watch the full video here:

🧩 What You’ll Learn Today

  • How to take user input in Python

  • How to use the math module

  • How to perform basic arithmetic operations

  • How to print formatted results

💡Python Challenge Problem Description

Write a Python program to find the area of a circle given its radius.

📝 Input Format

You’ll receive a single floating-point number — the radius of the circle.

📤 Output Format

Your program should print a message showing the area of the circle.

🧠 Thinking Process

Before jumping into the code, let’s break it down step-by-step:

  1. Recall the formula:

    A=πr2A = πr^2A=πr2

    where AAA is the area and rrr is the radius.

  2. Take input from the user — we’ll convert it to a float to allow decimal values.

  3. Use the built-in math.pi constant for better precision.

  4. Calculate the area and round it to 2 decimal places.

  5. Display the result clearly.

🐍 Python Code

Here’s the full code we used in the video:

import math

radius = float(input("Enter the radius of the circle: "))
area = math.pi * (radius ** 2)
print(f"The area of the circle with radius {radius} is {area:.2f}")

🧮 Code Example Run

Input:

5

Output:

The area of the circle with radius 5.0 is 78.54

Pretty neat, right? 🔥

Python makes calculations like this super straightforward once you understand the syntax.

💬 Python Challenge Extra Tip

You can simplify your output even more by using Python’s built-in round() function:

print("Area:", round(area, 2))

Both methods work — it’s all about your preferred style!

🌱 Reflection

Day 1 might seem easy, but it’s an important foundation. You’ve just learned how to:

✅ Take user input
✅ Perform mathematical operations
✅ Use the math library
✅ Format outputs for readability

These skills will come in handy throughout the rest of this challenge.

🚀 Your Turn

Try modifying the code to find the circumference of the circle, or even ask the user for multiple radii in one run. Play around — that’s how you’ll truly learn!

🙌 Final Thoughts

If you found this tutorial helpful, check out the full video on YouTube above.
Don’t forget to subscribe to my channel for more daily Python challenges — we’re just getting started! 💪

See you in Day 2 of the Python 30 Days Coding Challenge 🎯