我有一个Python计算器,很快就可以做代数 我是Python的新手,所以我可能搞砸了。代码的除法,乘法和指数部分不能正常工作,而其他所有功能都可以!
我尝试检查缩进。 不确定“浮动”仅适用于某些操作吗? 正如我说的我很新。
#MathPython v0.4 (c) 2019 UEG Productions################################################################################################################################
loop = 1
while loop == 1:
input('Welcome to PyMath version 0.4! >> Press [Enter] to continue <<' )
input('Please Choose an option by typing it below >> Press [Enter] to continue <<')
operation = input('test score, +, -, /, *, <, >, **, help Operation: ')
######here is where everything is executed!###############
if operation == 'help':
print('Welcome to the MathPython Help Guide!')
print('Ensure you type the EXACT symbol or text of the funtion you want to be performed')
input('Follow directions carefully! >>')
print('If any other questions are present please contact us at ########@gmail.com')
if operation == 'test score':
print('Two values are needed to find the test score')
print('Please type in the total amount of questions on the test')
totalqs = int(input('Total: '))
print('Now, type the number of questions you got correct')
correctqs = int(input('Correct: '))
pct = float(correctqs / totalqs * 100)
print('you got a(n) ' + format(correctqs) + ' out of ' + format(totalqs))
print('That is equivelent to ' + format(pct) + '%')
if format(pct) <= 70:
print('You Better study! Your grade was below a 70% Which is below average')
else:
print('Good job on the test, keep it up!')
if operation == '+':
print('First value?')
add1 = int(input('VALUE 1: '))
print('Second value? ')
add2 = int(input('VALUE 2: '))
added = float(add1 + add2)
print(format(added))
input('Operation done! >>Press [Enter] to go continue<<')
#SUBTRACTION ---- "add" is just a variable so don't confuse it!
if operation == '-':
print('First value?')
add1 = int(input('VALUE 1: '))
print('Second value? ')
add2 = int(input('VALUE 2: '))
added = float(add1 - add2)
input(format(added))
input('Operation done! >>Press [Enter] to go continue<<')
#Division
if operation == '/':
print('First value?')
add1 = int(input('VALUE 1: '))
print('Second value? ')
add2 = int(input('VALUE 2: '))
added = float(add1 / add2)
input(format(added))
input('Operation done! >>Press [Enter] to go continue<<')
#Multiplication
if operation == '*':
print('First value?')
add1 = int(input('VALUE 1: '))
print('Second value? ')
add2 = int(input('VALUE 2: '))
added = float(add1 * add2)
input(format(added))
input('Operation done! >>Press [Enter] to go continue<<')
#Exponents
if operation == '**':
print('First value?')
add1 = int(input('VALUE 1: '))
print('Second value? ')
add2 = int(input('VALUE 2: '))
added = float(add1 ** add2)
input(format(added))
input('Operation done! >>Press [Enter] to go continue<<')
没有错误消息,只是在执行某些操作时不断循环回到开头