My First Python Program: A Simple Calculator
Today, I am going to create a simple calculator using Python.
This might be your first code ever, and honestly, this is also my first Python code. So don’t worry — we are learning together.

Let’s start step by step.
Step 1: Open VS Code
First, open Visual Studio Code (VS Code).
Step 2: Create a Folder and a File
- Create a new folder (you can name it anything).
- Inside the folder, create a new file.
- In my case, I named the file
first.py.
👉 .py is the file extension for Python, just like:
.cppfor C++.javafor Java
Step 3: Write the Python Code
Now, write the following code in first.py:
num1 = float(input("Enter num 1: ")) # Taking first number from the user
num2 = float(input("Enter num 2: ")) # Taking second number from the user
opr = input("Enter operator: ") # User selects the operator (+, -, *)
if opr == "+": # If operator is +
output = num1 + num2
if opr == "-": # If operator is -
output = num1 - num2
if opr == "*": # If operator is *
output = num1 * num2
print("Your calculation is:", output) # Displaying the resultExplanation (Very Simple)
input()takes values from the userfloat()converts input into numbersifconditions check which operator you selected- Python uses indentation (spaces) instead of brackets
{}
Step 4: Save the File
Press Ctrl + S to save the file.
Step 5: Run the Program
- Open a new terminal in VS Code.
- Make sure the terminal is opened in the same folder where
first.pyexists. - Run the command:
python first.pyStep 6: Use Your Calculator
- Enter the first number
- Enter the second number
- Enter the operator (
+,-, or*) - You will see the result on the screen
🎉 Your calculator is ready!
Final Words
This is my first Python program, and I’m really excited to share it with you.
If you are a beginner, trust me — everyone starts from here.
If you like this blog, please share it with others and keep learning 🚀
Happy Coding!
🌐 Online References
- LinkedIn: https://www.linkedin.com/in/raees-yaqoob-qazi-ryqs/
- Medium Blog: https://medium.com/@raeesyaqubqazi
- Blogspot: https://brillertechnologies.blogspot.com/
- Facebook Page: https://web.facebook.com/profile.php?id=61553548371216
- YouTube Channel: https://www.youtube.com/@RaeesQ.
- TikTok: https://www.tiktok.com/@mrryqs?_t=ZS-8y7t0fQfJKu&_r=1
Comments
Post a Comment