+ 11

I made my first ever program in python 3 could you guys see if its good?

This is my FIRST EVER program so please don't go too harsh thanks def add(x, y): return x + y def times(x, y): return x * y def divide(x, y): return x / y def subtract(x, y): return x - y print("Hi Sololearn, This is my first ever program (calculator) in python after 3 days of learning!") print("choose an option") print("1. add") print("2. divide") print("3. times") print("4. subtract") option = input("enter an option either 1, 2, 3, 4, = ") num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) if option == '1': print(num1, "+" ,num2, "=" ,add(num1, num2)) if option == '2': print(num1, "/" ,num2, "=" ,divide(num1, num2)) if option == '3': print(num1, "x" ,num2, "=" ,times(num1, num2)) if option == '4': print(num1, "-" ,num2, "=" ,subtract(num1, num2))

23rd Feb 2020, 6:34 PM
umar saad
umar saad - avatar
17 Antworten
- 8
There is no sense to create function for every option. Just write print(num1, '-', num2, '=', num1 - num2)
23rd Feb 2020, 6:40 PM
Non
Non - avatar
+ 13
hey later you will find out, that is much to improve. But congrats for first prog. I smell talent👍
23rd Feb 2020, 6:42 PM
Oma Falk
Oma Falk - avatar
+ 8
You look like superhuman. Every programmer write his/her first program for showing some message on console but you are the genius one. Using function for simple operations are useless also don't use print Statement 5-6 times or more, instead you can use escape sequence '\n'.Rest all is quite good as a beginner. All the best!!
23rd Feb 2020, 6:51 PM
Nitin Tiwari
Nitin Tiwari - avatar
+ 6
thanks for the postive comments <3 <3 Nitin Tiwari, Oma Falk
23rd Feb 2020, 7:02 PM
umar saad
umar saad - avatar
+ 3
It's better than my first "Hello World" program.
24th Feb 2020, 1:07 AM
Sonic
Sonic - avatar
+ 2
@Mirielle👽 just run in python in visual studio 2019
23rd Feb 2020, 7:35 PM
umar saad
umar saad - avatar
+ 1
I'm a beginner too and one of my first programs was a calculator as well. Much simpler than this tho. Keep up the good work!
24th Feb 2020, 5:04 AM
sTiNgRaY
sTiNgRaY - avatar
+ 1
Congrats... This is great program for beginners..... Keep it up, hopes to see you from time to time..... 👍🏻
24th Feb 2020, 7:19 AM
DeWill
DeWill - avatar
+ 1
good to have function. you can write test to load lots of inputs and define expected out put. passed or failed
24th Feb 2020, 2:17 PM
\•/
\•/ - avatar
+ 1
Bro use elif instead of if
25th Feb 2020, 10:19 AM
Ujjwal Pratap Singh
Ujjwal Pratap Singh - avatar
+ 1
great start, keep it up! if you write it in the coding section, you can also post it here in a way people can see it working - without then having to copy it to their IDE :)
25th Feb 2020, 12:28 PM
phil
+ 1
Nice buyo
25th Feb 2020, 4:33 PM
Mugisha Ryan
Mugisha Ryan - avatar
+ 1
U r learn fast
25th Feb 2020, 4:33 PM
Mugisha Ryan
Mugisha Ryan - avatar
+ 1
Isaac Simon Opoku (ISO) Please post a new question, if you have problems with a specific program. and find no answer by using searchbar.
25th Feb 2020, 6:48 PM
Oma Falk
Oma Falk - avatar
0
Hope you'll enjoy the benefits of using sololearn, 🎆🎉👍
24th Feb 2020, 1:56 AM
dario harbas
dario harbas - avatar
0
This the best to learn the basic concept of Python programming, Thanks
24th Feb 2020, 9:48 AM
sonu singh
sonu singh - avatar