#๐Ÿ”’ Proofreading a project

16 messages ยท Page 1 of 1 (latest)

stone geyser
#

Hi, if willing, i need a person to proofread a project i have due tmrw and make sure it runs well (its a python calculator). also if willing i can send over the rubric and make sure it matches it. thanks so much!

def add1(num1, num2):
return num1 + num2

def sub1(num1, num2):
return num1 - num2

def multiply1(num1, num2):
return num1 * num2

def divide1(num1, num2):
return num1 / num2

print("Please select operation -\n"
"1. Add\n"
"2. Subtract\n"
"3. Multiply\n"
"4. Divide\n")

choice=int(input("Select operations form 1, 2, 3, 4 :"))

num1=int(input("Enter first number: "))
num2=int(input("Enter second number: "))

if choice==1:
print(num1, "+", num2, "=",
add1(num1, num2))

elif choice==2:
print(num1, "-", num2, "=",
sub1(num1, num2))

elif choice==3:
print(num1, "*", num2, "=",
multiply1(num1, num2))

elif choice==4:
print(num1, "/", num2, "=",
divide1(num1, num2))
else:
print("Invalid input")

next impBOT
#

@stone geyser

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

chrome sinew
#

Why is every function's name followed by 1?

In the line with choice = you have typo in the word 'from'.

In the division you should check if num2 is not 0 as it will cause a error.

#

And directly converting input (string) to int without checking the value or catching a error may raise error

stone geyser
stone geyser
chilly belfry
chrome sinew
chilly belfry
#

!e

int("bad int")
next impBOT
# chilly belfry !e ```python int("bad int") ```

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     int("bad int")
004 | ValueError: invalid literal for int() with base 10: 'bad int'
astral oar
#

Also I highly recommend running all code though ruff check and ruff format

next impBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.