How to Build a Simple Calculator in Python - Step by Step 1

  Рет қаралды 347,480

Kindson The Tech Pro

Kindson The Tech Pro

5 жыл бұрын

This is a very interesting tutorial on how to build a simple calculator in Python
****** HOW TO BUILD A SIMPLE CALCULATOR IN PYTHON STEP BY STEP ****************
1. ADD
2. SUBTRACT
3. MULTIPLY
4. DIVIDE
Find me on www.kindsonthegenius.com
print("Select an operation to perform: ")
print("1. ADD")
print("2. SUBTRACT")
print("3. MULTIPLY")
print("4. DIVIDE")
I use PyCharm, get it here
www.jetbrains.com/pycharm/dow...
To Learn Python: www.kindsonthegenius.com/python
Machine Learning 101: www.kindsonthegenius.com/mach...
Subscribe Kindson The Genius KZbin: bit.ly/2PpJd8Q
Join Machine Learning & Data Science in Python and R - / 704770263315075
Join my group ICS on Facebook: / internationalcomputerp...
Follow me on Instagram - / kindsonm
Connect with me on LinkedIn: / kindson
Follow me on Twitter: / kindsonm
Learn about me: www.kindsonthegenius.com
Tutorial 6. Creating Interactive 3D Plots - • Lesson 6 - Creating In...
How to Perform Linear Regression in R - • How to Perform Linear ...
How to Perform Linear Regression in Python - • How to Perform Linear ...

Пікірлер: 273
@sophyabud8602
@sophyabud8602 2 жыл бұрын
i was supposed to do exactly this for my homework and didn't understand it in my 4 hour class but i totally got it in a 15 minute video, thank you!!
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
Glad it helped!
@rajputacademy3960
@rajputacademy3960 2 жыл бұрын
Amazing@@KindsonTheTechPro
@jsims2985
@jsims2985 Жыл бұрын
lol, me as well. Great video!
@pannalalgadecha007
@pannalalgadecha007 Жыл бұрын
@@KindsonTheTechPro sir this code will be worked on pyroid 3 app for Android ?
@vaishnavii4881
@vaishnavii4881 11 ай бұрын
​@@pannalalgadecha007 i tried it's not working
@mohisa2512
@mohisa2512 7 ай бұрын
Just wanna share my comments: You can declare the numbers so you’ll have reusable function: def get_nums(): x = float(input('Enter 1st number: ')) y = float(input('Enter 2nd number: ')) return x, y and simply assign it to your operations function like this: def sum(x, y): return x + y inside your loop you can do this instead: x, y = get_nums() so you don’t have to repeat it… if operation == '1': result = sum(x, y) you can use fstring instead to make it simplified. print(f'The Sum of {x} and {y} is {result}') also put error handling on your division operation: if y is equal to zero, you can print cannot divide by zero. Overall, it' s really nice. Thanks for sharing your knowledge.
@ogochukwuonwujekwe6511
@ogochukwuonwujekwe6511 Жыл бұрын
Thank you for this. I didn't know how to go about this but you just simplified it in 15 mins. Thank you so much
@plancton4058
@plancton4058 2 жыл бұрын
A diffrent Calculator: num1 = input("Insert a number: ") variable = input("Insert a variable(+, -, *, /): ") num2 = input("Insert a number: ") add = float(num1) + float(num2) subtract = float(num1) - float(num2) multiply = float(num1) * float(num2) divide = float(num1) / float(num2) if variable == "+": print (add) elif variable == "-": print(subtract) elif variable == "*": print(multiply) elif variable == "/": print(divide) else: print("Error: Invalid input")
@dragonstev5715
@dragonstev5715 2 жыл бұрын
thanks dude *very cool*
@ianjakoncic2352
@ianjakoncic2352 2 жыл бұрын
a lot esier i agree
@muhammadtayyab253
@muhammadtayyab253 2 жыл бұрын
If you write int() instead of float() then it's good...
@Simon-beast
@Simon-beast 2 жыл бұрын
@@muhammadtayyab253 if you want to use decimal numbers, it wont be good therefore, "float" is the better expression in general, unless you are specifically working with whole numbers
@muhammadtayyab253
@muhammadtayyab253 2 жыл бұрын
@@Simon-beast Yeah ok but what if we use float only for division??
@friendlyperson9841
@friendlyperson9841 10 ай бұрын
This was such an amazing tutorial. Wonderful to follow and easy to understand! Keep up the great work.
@Aquaf1ina
@Aquaf1ina 2 жыл бұрын
im brand new to python and after some videos i made my own calculator and this is like the exact same thing i made myself nice
@adityanaik099
@adityanaik099 2 жыл бұрын
I've made a Calculator program, hope you like it : Edit : Just added another function that can calculate times tabels. # Calculator program # In python #----------------------------- def addition(x,y): output1 = (x + y) return output1 #----------------------------- def subtraction(x,y): output2 = (x - y) return output2 #----------------------------- def multiplication(x,y): output3 = (x * y) return output3 #----------------------------- def division(x,y): output = (x / y) return output #----------------------------- def square(z): output4 = (z * z) return output4 #----------------------------- def cube(z): output5 = (z * z * z) return output5 #----------------------------- def factorial_pos(z): output6 = 1 for i in range(z,1,-1): output6 = (output6 * i) return output6 #----------------------------- def factorial_neg(z): output7 = (-1) for i in range(z,-1): output7 = (output7 * i) return output7 #----------------------------- def exp_pos(b,p): output8 = 1 for i in range(p): output8 = (output8 * b) return output8 #----------------------------- def exp_neg(b,p): output9 = (-1) for i in range(p): output9 = (output9 * b) return output9 #----------------------------- def mtp_tables_ps(x,y): print(" Result: ") for i in range(1,y+1): print(f"{x} x {i} = {x*i}") else: print(f''' These are the multiplication tables of {x} with-in the range of {y}''') #----------------------------- def mtp_tables_ng(x,y): print(" Result: ") for i in range(-1,(y-1),-1): print(f"{x} x {i} = {x*i}") else: print(f''' These are the multiplication tables of {x} with-in the range of {y}''') #----------------------------- def operator(c): if(c == ('+')): try: x = float(input("Enter 1st number : ")) y = float(input("Enter 2nd number : ")) except ValueError: print(" You can only enter integers.Try to run again!") else: print("Result:") print(addition(x,y)) elif(c == ('-')): try: x = float(input("Enter 1st number : ")) y = float(input("Enter 2nd number : ")) except ValueError: print(" You can only enter integers.Try to run again!") else: print("Result:") print(subtraction(x,y)) elif(c == ('*')): try: x = float(input("Enter 1st number : ")) y = float(input("Enter 2nd number : ")) except ValueError: print(" You can only enter integers.Try to run again!") else: print("Result:") print(multiplication(x,y)) elif(c == ('/')): try: x = float(input("Enter 1st number : ")) y = float(input("Enter 2nd number : ")) division(x,y) except ValueError: print(" You can only enter integers.Try to run again!") except ZeroDivisionError: print(" You cant divide by 0.Try to run again!") else: print("Result:") print(division(x,y)) elif(c == ("**")): try: z = float(input("Enter the number to sqaure it : ")) except ValueError: print(" You can only enter integers.Try to run again!") else: print("Result:") print(square(z)) elif(c == ("***")): try: z = float(input("Enter the number to cube it : ")) except ValueError: print(" You can only enter integers.Try to run again!") else: print("Result:") print(cube(z)) elif(c == ('!')): try: z = int(input("Enter the number to calculate its factorial : ")) if(z > 0): print("Result:") print(factorial_pos(z)) elif(z < 0): print("Result:") print(factorial_neg(z)) else: if(z == 0): print("Result:") print(z*0) else: pass except ValueError: print(" You can only enter Integers.Try to run again!") elif(c == ('exp')): try: b = int(input("Enter the base number : ")) p = int(input("Enter the power number : ")) if(p < 0): print(" You cant enter negative integers as Power.Try to run again!") elif(b > 0): print("Result:") print(exp_pos(b,p)) elif(b < 0): print("Result:") print(exp_neg(b,p)) elif(b == 0): print("Result:") print(b*0) else: pass except ValueError: print(" You can only enter Integers.Try to run again!") elif(c == "mtp"): try: x = int(input("Enter the number for its multiplication tables : ")) y = int(input("Enter the range for the tables : ")) if(y > 0): mtp_tables_ps(x,y) elif(y < 0): mtp_tables_ng(x,y) else: print("Result:") print(x*y) except ValueError: print(" You can only enter Integers.Try to run again!") else: print(" Invalid operator!") #----------------------------- def new_program(c): c = input('''Enter an operator sign: ('+' , '-' , '*' , '/' , '**' , '***' , '!' , 'exp' , 'mtp') : ''') operator(c) #----------------------------- c = input('''Enter an operator sign: ('+' , '-' , '*' , '/' , '**' , '***' , '!' , 'exp' , 'mtp') : ''') operator(c) print() ctn = input('''Do you want to continue your calculation? Enter 'y' for Yes / 'n' for No. : ''') ctn_cmd = ['y','Y','n','N'] while(ctn == 'y' or ctn == 'Y'): print() new_program(c) print() ctn = input('''Do you want to continue your calculation? Enter 'y' for Yes / 'n' for No. : ''') if(ctn == 'n' or ctn == 'N'): print() print("Thank you for using the calculator. ") else: if(ctn not in ctn_cmd): print(" Invalid command!Try to run again. ") else: pass #----------------------------- # Code finished successfully.
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
Interesting!!
@adityanaik099
@adityanaik099 2 жыл бұрын
@@KindsonTheTechPro Thank you for Appreciating my effort !
@nandakumarm508
@nandakumarm508 2 жыл бұрын
appreciated
@axeLimex
@axeLimex 5 ай бұрын
Simple and fast! Thank you for the lazy ones: print("Select an operation to perforn: ") print("1. ADD") print("2. SUBTRACT") print("3. MULTIPLY") print("4. DIVIDE") operation = input() if operation == "1": num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The sum is " + str(int(num1) + int(num2))) elif operation == "2": num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The difference is " + str(int(num1) - int(num2))) elif operation == "3": num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The product is " + str(int(num1 * int(num2)))) elif operation == "4": num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The result is " + str(int(num1) / int(num2))) else: print("Invalid Entry")
@inandout-qj2uh
@inandout-qj2uh 8 ай бұрын
your teaching is brilliant please keep going
@legiteh8275
@legiteh8275 Жыл бұрын
I think instead of using operation = input() if operation == “1” You can use operation = int(input() If you want it to run without error instead of int use float() so if the user enters ‘1.5’ it’ll come back as invalid entry instead of error. Also if you used int instead of float on num1 etc it will not read floats (numbers with a decimal)
@byfraqz458
@byfraqz458 Жыл бұрын
float is not necessary here… you can use operation = int(input()) and then by the result: print(„The result is“ + str(num1 (operation) num2)) this should be easier if you use float it‘s always returning a float even if it is 5+5 it is returning 10.0 instead of simply 10 and float is always using 64-bit and integers only use 32-bit so it’s better for performance aspect
@chak_dz6961
@chak_dz6961 2 жыл бұрын
When print() the final value... You can type (,num1 + num2) Instead of + str(int(num2) + int(num2) 👍
@noctowlcactus394
@noctowlcactus394 2 жыл бұрын
You’re right because “,” can be used for int() values as spaces so mind blowing thanks man.
@adityanaik099
@adityanaik099 2 жыл бұрын
@@noctowlcactus394 You can also use "f" strings ( also works int() ) instead of print(,num1 + num2) you can write print(f"{num1 + num2}) "f" strings come very handy in object oriented programming..... :)
@pineapplejuice1156
@pineapplejuice1156 2 жыл бұрын
@@adityanaik099 You don't need the formatted string in that piece of code
@devooko
@devooko 2 жыл бұрын
Thank you !
@AsifKhan-cg3sc
@AsifKhan-cg3sc 8 ай бұрын
Thank you❤
@piyushashinde2189
@piyushashinde2189 2 жыл бұрын
Thanks a lot, you have helped a lot. The video is amazing and easy for me to understand.
@pineapplejuice1156
@pineapplejuice1156 2 жыл бұрын
can you make a calculator with a while loop?
@seegulp
@seegulp 2 жыл бұрын
my homemade calculator said syntax error so now i know school was teaching us wrong all along
@the_master520
@the_master520 2 жыл бұрын
I have 1 question (its not about the video): How can I check if the number after the decimal . is 0 then make the number to int
@suno2219
@suno2219 3 жыл бұрын
Pro tip: change the int with float so it's able to process numbers with commas
@aati7679
@aati7679 2 жыл бұрын
@justin blackwell num1 = float(input("enter a number: "))
@mynameisandrew1903
@mynameisandrew1903 7 ай бұрын
Hey how do i get rid of the errors it doesnt let me start the thing
@gustavofring6176
@gustavofring6176 3 ай бұрын
Thank you so much this is my first ever coding experience
@serpentinefireball
@serpentinefireball 3 жыл бұрын
This was amazing! I have just started learning python literally days so its amazing I can make a functioning calculator through this video. Thank you.
@micahholt4583
@micahholt4583 2 жыл бұрын
I know same I just started a day ago. But it kinda bothers me that I'm following a tutorial and not making it myselft, y'know?
@famo7503
@famo7503 2 жыл бұрын
@@micahholt4583 I too just started a coding class recently. When doing homework I find myself just following along on whatever help on the internet I find. How is it going for you bro? any advice on how to make the learning stick? My professor basically just tells us to read from the book but that isn't helping me much, so during the "help sessions" our professor has, again, I just find myself following how he does and mimicking it instead of actually learning.. 😔
@micahholt4583
@micahholt4583 2 жыл бұрын
What I did is I watched some videos on the essentials, and you kinda just start going on your own. Which I know as u just read that made u confused af. But keep taking the class and watching vids. Trust me you’ll just pick it up.
@famo7503
@famo7503 2 жыл бұрын
@@micahholt4583 Gotchya, I appreciate brother, thank you.
@micahholt4583
@micahholt4583 2 жыл бұрын
Np
@gohilap1392
@gohilap1392 2 жыл бұрын
Suppose we want two or more numbers add ..what I do?
@sheda7777
@sheda7777 2 жыл бұрын
Thank you so much, you are a lifesaver
@EvilSpesh_Gvng
@EvilSpesh_Gvng 5 ай бұрын
To save the num1 and num2 as integers you could use something like num1 = int(input("enter first num")) and then the same for num2
@vespervenom2343
@vespervenom2343 2 жыл бұрын
What if I want to add multiple numbers at once
@calmmap4065
@calmmap4065 2 жыл бұрын
Thank you so much , this is easy to understand
@ambreenkakakhel1534
@ambreenkakakhel1534 2 жыл бұрын
brother what is the difference between elif and else??@kindson the tech pro
@lycheebutterfly
@lycheebutterfly 2 жыл бұрын
Where we have to do this in pycham
@sivanamoah6947
@sivanamoah6947 Ай бұрын
thank you, you kept it very simple
@durveshmahajan8097
@durveshmahajan8097 2 жыл бұрын
Thank you so so much Sir....This Video helped me very much
@serious6037
@serious6037 2 жыл бұрын
yea but when you convert this into bat file or exe it crashes and does not repeate the first steps you do. it would be good if you just could tell us how to LOOP IT..
@veera-os3ck
@veera-os3ck 2 жыл бұрын
how more than 2 variables given in calculator method?
@HiteshDodeja07
@HiteshDodeja07 3 жыл бұрын
It really helped thank you
@Arzoo223
@Arzoo223 Ай бұрын
npx ayezi23-simple-calculator Run this command in CMD please
@oluwagbemigababatunde7735
@oluwagbemigababatunde7735 Жыл бұрын
This is really great. I like the way you intentionally made those mistakes to teach us what could cause any error. You're a good teacher.
@fishyplayzz5047
@fishyplayzz5047 7 ай бұрын
it wasnt intentionally dumbo
@_.mystery._
@_.mystery._ 2 жыл бұрын
Bro just thankx it made my day easy thankx 😀👍
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
My pleasure 😊and pls remember to subscribe 😃
@HikingFeral
@HikingFeral Жыл бұрын
This is a basic calculator for beginners and he did a good job, pretty weird of people to be flexing more complex ones in the comments that involve learning about float, it's for b.e.g.i.n.n.e.r.s float is what stops you sink to beginner.
@timothyadumeta3596
@timothyadumeta3596 3 ай бұрын
how do you go back to main menu instead of rerunning the code
@manipv2131
@manipv2131 2 жыл бұрын
sir please ,how to continuely to see 6 operations ,and please send extra add 2more operator using in this calculator.
@OXANE
@OXANE 2 жыл бұрын
which compiler do you use
@Simon-beast
@Simon-beast 2 жыл бұрын
PyCharmCommunity
@moonchildsnjs
@moonchildsnjs Жыл бұрын
Thank you so much!
@tejharighimire6070
@tejharighimire6070 Жыл бұрын
Very helpful bro keep on going -_-
@golmaalgaming3158
@golmaalgaming3158 Жыл бұрын
Bro only 2 number add and sub this came simple calculator. whatever infinity values add and sub anything.i don't know that special key words reply pls.
@atoz8665
@atoz8665 Жыл бұрын
Thanks brother. (Channel subscribed)
@user-eb9ng7oo5n
@user-eb9ng7oo5n 10 ай бұрын
I git an error at minus i needed to add an coma after the twxt xan someone explain?😅
@muhammadrafayhaider9803
@muhammadrafayhaider9803 5 ай бұрын
Amazing
@ralfkjapsna3486
@ralfkjapsna3486 Жыл бұрын
How to import fraction to this calculator?
@justsomeguywhodoesrandomco7231
@justsomeguywhodoesrandomco7231 Жыл бұрын
Thank you, you made it sooooo simple❤❤😊
@KindsonTheTechPro
@KindsonTheTechPro Жыл бұрын
You're welcome 😊
@Gman.218
@Gman.218 Жыл бұрын
at minute 7:36 you can use an f string to say the sum of num1 and num2 is...
@mustafaahmed-wf2qy
@mustafaahmed-wf2qy Жыл бұрын
Thank you so much ☺️
@Purple-ym4xz
@Purple-ym4xz 2 жыл бұрын
How to solve improper TCL installation?
@Charlie-qr2ov
@Charlie-qr2ov 2 жыл бұрын
What IDE are you using?
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
PyCharm
@REZON_FF
@REZON_FF Жыл бұрын
it is showing me " expected an indented block after 'if' statement on line 9"
@pavangaming627
@pavangaming627 Жыл бұрын
Thanks again
@dusty5178
@dusty5178 Жыл бұрын
how can you fix this?
@-taarakmehtakaooltahchashm8078
@-taarakmehtakaooltahchashm8078 2 жыл бұрын
thank you n1 = input("Enter first number"" ") n2 = input("Enter second number"" ") print("The sum is:" , int(n1) + int(n2)) elif operation == "2": n1 = input("Enter first number"" ") n2 = input("Enter second number"" ") print("The difference is:" , int(n1) - int(n2)) elif operation == "3": n1 = input("Enter first number"" ") n2 = input("Enter second number"" ") print("The product is:", int(n1) * int(n2)) elif operation == "4": n1 = input("Enter first number"" ") n2 = input("Enter second number"" ") print("The quotient is:", int(n1) / int(n2))
@EstebanGodoy-wd2sd
@EstebanGodoy-wd2sd Жыл бұрын
I´ve got the same errors, thanks for the help :)
@rokrok27
@rokrok27 2 жыл бұрын
Wat about a button that toggles the integer value between positive and negative
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
Coming soon! Keep subscribed to get updated!😊
@benque7491
@benque7491 Жыл бұрын
Nice video, I did it Btw how can I make it reusable
@vikco2243
@vikco2243 2 ай бұрын
Hello I have a question, when dividing by zero is it possible to have it print "You cannot divide by zero" instead of it giving me an error or crashing ?
@Ninjawarus64
@Ninjawarus64 Ай бұрын
What if you put that if 0 is second number in division section, don’t do the operation and respond with the message you gave
@andreibarrios189
@andreibarrios189 3 жыл бұрын
Thanks buddy
@NirmalKumar-ux2my
@NirmalKumar-ux2my 2 жыл бұрын
superb👍
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
Thanks 🤗
@albxrb
@albxrb Жыл бұрын
I just start to study Phyton this days but... at first, you dont need FIVE prints, right? I think if you just write with " " " should works; something like this: print("""Select an operation to perfom: 1. Add 2. Subtract 3. Multiply 4. Divide """)
@KindsonTheTechPro
@KindsonTheTechPro Жыл бұрын
You are absolutely right! Thanks! Another way is to use a singl print statement with characters.
@sunilyadav4688
@sunilyadav4688 2 жыл бұрын
How to perform the sum or result = 10+5.5= 15.5 ,, how to add interger + float !! in a single operation????
@ofxharvs
@ofxharvs 2 жыл бұрын
I think this code had already copied but I would agree your app is great! Make sure you should explain how is your calculator app will be gonna work and understanding of for,while loops and some if,elif,else
@rexdanielnavarro1303
@rexdanielnavarro1303 Жыл бұрын
Thanks!
@anjalis4016
@anjalis4016 2 жыл бұрын
Yes it's so helpful thank you
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
So glad! and do remember to subscribe 😊
@viniciusaguiar6605
@viniciusaguiar6605 Жыл бұрын
hi guys, i am trying to get to this programming thing, im looking for exercises for me to practice what i am learning, i just watch this video and i found a different way to code this calculator, and i would like to see if theres is something that could improve on this: n1 = int(input('WHAT IS THE FIRST NUMBER? ')) n2 = int(input('WHAT IS THE SECOND NUMBER? ')) print ('SELECT AN OPERATION') print('1. ADD') print('2. SUBTRACT') print('3. DIVIDE') print('4. MULTIPLY') OPERATION = input() if OPERATION == '1': RESULT = n1 + n2 elif OPERATION == '2': RESULT = n1 - n2 elif OPERATION == '3': RESULT = n1 / n2 elif OPERATION == '4': RESULT = n1 * n2 else: print('INVALID INPUT') print(RESULT)
@ayoubjo3329
@ayoubjo3329 11 ай бұрын
Istead of result=n1+n2 do Print(n1+n2)
@ragavaviraji4094
@ragavaviraji4094 Ай бұрын
Kindson : So I'm going to run it Subtitles: So I'm going to ronnie 😆😆😆
@RUNE-5
@RUNE-5 Жыл бұрын
thank you
@KindsonTheTechPro
@KindsonTheTechPro Жыл бұрын
Welcome!
@industrialelectricalbd6900
@industrialelectricalbd6900 Жыл бұрын
Nice Thanks a lot
@KindsonTheTechPro
@KindsonTheTechPro Жыл бұрын
So nice of you
@Spooky_Specters_
@Spooky_Specters_ 2 жыл бұрын
Hats off to you
@Noobmaster9678
@Noobmaster9678 2 жыл бұрын
What is th app? Is it ms visual studio code? Please tell me
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
I use PyCharm. See link in description to download.
@Noobmaster9678
@Noobmaster9678 2 жыл бұрын
@@KindsonTheTechPro thank you very much 😊
@abusekak1934
@abusekak1934 Жыл бұрын
im trying to build my own calculator in python but the + operator doesnt work properly, like im typing 1 as num1 and 3 as num2 but the program just prints out '13'
@numerousoriabure459
@numerousoriabure459 Жыл бұрын
You're concatenating. ____________ num1 = '1' num2 = '3' print(num1 + num2) will evaluate to 13 because you've got string values for your variables. __________________________________ Instead try: num1 = 1 num2 = 3 print(num1 + num2) will evaluate to 4. Note: '1' is a string. 1 is an integer.
@mohisa2512
@mohisa2512 7 ай бұрын
By default when you enter something on input() it will be a string. That's why the operation becomes concatenate. You have to convert it to int or float.
@aaronfisher5989
@aaronfisher5989 2 жыл бұрын
I accidently put if in every elif statement and it ran
@Pritplayz_09
@Pritplayz_09 2 жыл бұрын
Thank you soo much
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
You're welcome!
@KrepesWT
@KrepesWT 2 жыл бұрын
even simpler is just: x = input() print(eval(x)) example you type 5+5 it will print 10 works even for float you can divide multiply and more the simplest form of a python calculator
@mr.peanutbuttersfavepisode
@mr.peanutbuttersfavepisode Жыл бұрын
bro that doesn't do anything. you just use terminal
@user-em7uc9pw7d
@user-em7uc9pw7d 3 ай бұрын
Bro one video on lock 🔒
@ahmadquraan3624
@ahmadquraan3624 2 жыл бұрын
thank you!!
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
You're welcome!
@anjalichauhan8021
@anjalichauhan8021 2 жыл бұрын
Sir which app you have used
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
Pycharm
@glowria_balla4332
@glowria_balla4332 Жыл бұрын
I keep getting invalid syntax anytime I run my code
@mykhealyt
@mykhealyt 9 ай бұрын
1 line calculator: print(eval(input()))
@sahasict9887
@sahasict9887 2 жыл бұрын
thanks
@kridhay1194
@kridhay1194 2 жыл бұрын
Thanku so so so much sir
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
You re so so welcome!!
@kridhay1194
@kridhay1194 2 жыл бұрын
@@KindsonTheTechPro Respect and love from India sir🇮🇳🇮🇳🇮🇳
@dusty5178
@dusty5178 Жыл бұрын
What if you divided by 0? The program would then just break.
@randallcharlestuckermrcyse1479
@randallcharlestuckermrcyse1479 Жыл бұрын
a bit different. while True: print("addition 1:") print("subtract 2:") print("multiply 3:") print("division 4:") operation = input("Enter Number 1-4: ") num1 = float(input("Enter Number: ")) num2 = float(input("Enter Number: ")) if operation == "1": print(num1, "+", num2, "=", (num1+num2)) elif operation == "2": print(num1, "+", num2, "=", (num1-num2)) elif operation == "3": print(num1, "+", num2, "=", (num1*num2)) elif operation == "4": print(num1, "+", num2, "=", (num1/num2)) else: print("invalid submission")
@balakae6955
@balakae6955 2 жыл бұрын
i need help its reasing num1 and num 2 as str
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
Just ust the int() or the str() function in Python. See about conversions here www.kindsonthegenius.com/python/08-python-basic-math-and-numbers/
@balakae6955
@balakae6955 2 жыл бұрын
@@KindsonTheTechPro thanks
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
U're welcome 😊
@parulyadav4581
@parulyadav4581 2 жыл бұрын
which app did you use!!?
@joytiseli1744
@joytiseli1744 2 жыл бұрын
Thanks a lot
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
Most welcome
@user-es8ss6ul8w
@user-es8ss6ul8w 5 ай бұрын
Hi im new to python programming i really don't understand yhe basics but i tried my best here is mine(on the reply of this comment)
@user-es8ss6ul8w
@user-es8ss6ul8w 5 ай бұрын
print("Select an operation to perform") print("1. ADD") print("2. SUBTRACT") print("3. MULTIPLY") print("4.DIVIDE") operation = input()" if operation == "1": num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The sum is " + str(int(num1 + int(num2))) elif operation == "2"": num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The difference is " + str(int(num1 - int(num2))) elif operation == "3"": num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The productis " + str(int(num1 * int(num2))) elif operation == "2"": num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The result is " + str(int(num1 / int(num2))) else: print("Invalid Entry")
@user-es8ss6ul8w
@user-es8ss6ul8w 5 ай бұрын
I don't know why it wouldn't work pls help me
@ravis8532
@ravis8532 3 жыл бұрын
What if i want to add 3 numbers ? This wont work
@aunvi
@aunvi 3 жыл бұрын
Because you are taking 2 inputs only. To add 3 numbers input 3 numbers and add them in print(num1+num2+num3)
@ravis8532
@ravis8532 3 жыл бұрын
@@aunvi 10 numbers then 10 inputs ?
@javeda430
@javeda430 3 жыл бұрын
@@ravis8532 you can use that in loop instead writing them 10times
@codingisfun413
@codingisfun413 2 жыл бұрын
@@aunvi i wanna let my user take as much number as he want , how will i do that?
@amanalisaiyed5317
@amanalisaiyed5317 2 жыл бұрын
@@codingisfun413 use it in loop
@deepthik9841
@deepthik9841 2 жыл бұрын
i made a easier one but thanks i took a lot of info from this video
@user-om9eg1rj8v
@user-om9eg1rj8v 2 жыл бұрын
can you send the easier one to me? if that's not too much to ask. Thanks, it would really help me out a lot in school
@matozka1083
@matozka1083 Жыл бұрын
@Rafe Esin thats literally what i coded code for code before i found your comment lol
@matozka1083
@matozka1083 Жыл бұрын
@Rafe Esin thats literally what i coded code for code before i found your comment lol
@user-sz7up6ts7z
@user-sz7up6ts7z 7 ай бұрын
Highlh recommended
@r7h4d
@r7h4d 6 ай бұрын
a=float(input("Enter first number:")) b=float(input("Enter second number:")) print("Sum=",a+b) print("Subtraction=",a-b) print("Product=",a*b) print("Division=",a/b) print("Remainder=",a%b) Isnt this better and easy?
@emmanuelalile
@emmanuelalile 5 жыл бұрын
Nice video. Please what's the name of the IDE you used?
@hanialimam
@hanialimam 3 жыл бұрын
he said it in the video "pycharm"
@yvng4697
@yvng4697 3 жыл бұрын
Thats pycharm in presentation mode!
@Naif-so8yk
@Naif-so8yk 3 жыл бұрын
Jupyter notebook support
@smartiepieaku2302
@smartiepieaku2302 3 жыл бұрын
pycharm
@karaboprince8438
@karaboprince8438 3 жыл бұрын
Pycharm He said it in the first line
@lilponozka5077
@lilponozka5077 2 жыл бұрын
thanks so much man, you just saved my ass !
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
I"m so glad! ☺️
@pro_coder
@pro_coder Жыл бұрын
i can code in 1 line while True: print(f"ANS : {eval(input('> '))}")
@iffasyahirah1236
@iffasyahirah1236 2 жыл бұрын
How-to do square and square root
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
@Iffa Syahirah just use the sqrt() function
@bizuplays
@bizuplays Ай бұрын
mine instantly crashes when I run in python
@mohamedtag_eldeen9320
@mohamedtag_eldeen9320 3 жыл бұрын
it was very funny video
@legendaynon3834
@legendaynon3834 3 жыл бұрын
how was it funny tf
@fortnitegamer-ph5jg
@fortnitegamer-ph5jg 3 жыл бұрын
@@legendaynon3834 yeah bruh I'm learning code wdym funny
@nordafricain2520
@nordafricain2520 3 жыл бұрын
You are student in Hungary ?
@KindsonTheTechPro
@KindsonTheTechPro 3 жыл бұрын
Yes. Final semester of my PhD program
@memabe7629
@memabe7629 3 жыл бұрын
Hi sir I need to develop a python program in anaconda to run an application like calculator or clock or any other applications if u have them in ur mind please suggest sir. Also how am I going to do it ?
@VictorMmaduegbochukwuaka
@VictorMmaduegbochukwuaka 6 ай бұрын
Is good😂
@the_master520
@the_master520 2 жыл бұрын
why its showing me that 1+2=12 please help me
@KindsonTheTechPro
@KindsonTheTechPro 2 жыл бұрын
You need to convert string to int using int()
@the_master520
@the_master520 2 жыл бұрын
@@KindsonTheTechPro Thank you so much!
@alexonthespot1276
@alexonthespot1276 2 жыл бұрын
elif wont work
How to Build a Simple Calculator in Python - Step by Step 2
11:39
Kindson The Tech Pro
Рет қаралды 18 М.
Build this JS calculator in 15 minutes! 🖩
15:20
Bro Code
Рет қаралды 308 М.
Barriga de grávida aconchegante? 🤔💡
00:10
Polar em português
Рет қаралды 28 МЛН
skibidi toilet 73 (part 2)
04:15
DaFuq!?Boom!
Рет қаралды 30 МЛН
Simple GUI Calculator in Python
22:51
NeuralNine
Рет қаралды 230 М.
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,4 МЛН
Python Program to Make a Simple Calculator | Complete Tutorial
8:58
How to Make a Game in Python
43:01
Tech With Tim
Рет қаралды 347 М.
ASMR Programming - Calculator App Coding - No Talking
34:06
AsmrProg
Рет қаралды 4,3 МЛН
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 224 М.
I Made 200 Python Projects...Here Are My 5 FAVORITES
11:23
Tech With Tim
Рет қаралды 110 М.
Automate your job with Python
6:07
John Watson Rooney
Рет қаралды 291 М.