我的 python 学校作业有问题,我不知道我做错了什么。我要么得到一个未定义的全局名称,要么如果我改变周围的东西,我会得到不同的 sythax 错误。我希望有人能够帮助我解决我做错的事情。
这是分配详细信息的图像:
def main():
x = int(input("Give me integer #1: "))
y = int(input("Give me integer #2: "))
z = input("Give me a string: ")
print("min:",min(x,y))
print("max:",max(x,y))
print("equal:",equal(x,y))
print("is_even:",is_even(x))
print("is_odd:",is_odd(x))
print("format_dollar:",format_dollar(x))
print("lab_grade:",lab_grade(x))
print("is_unlucky:",is_unlucky(x))
print("is_lucky:",is_lucky(x))
print("pluralize:",pluralize(z))
#1 This function will figure out the min of 2 integer arguments and return the smaller one
def min(num1,num2):
if num1 >= num2: return num1
else: return num2
#2 This function will figure out the max of 2 integer arguments and return the smaller one
def max(num1,num2):
if num1 <= num2: return num1
else: return num2
#3 This function will figure out if the 2 numbers are equal
def equal(x,y):
if x == y: True
else: False
#4 This function will find out if the number is even
def is_even(num1,num2):
is_even = x
if x % 2 == 0: return ("True")
else: return ("False")
#5 This function will find out if the number is odd
def is_odd(num1,num2):
is_odd = x
if x % 2 == 1: return ("True")
else: return even
#6 This function will format the returned string
def format_dollar(num1,num2):
x**('.2f')
#7 This function will fin out a lab grade
def lab_grade(x):
lab_grade = int(raw_input("Enter the student's grade: "))
if grade >= 90:
return 'A'
if grade >= 80:
return 'B'
if grade >= 70:
return 'C'
if grade >= 60:
return 'D'
else:
return 'F'
#8 This will determine if the function is un_lucky
def is_unlucky(x):
if x == 4:
return ('True')
if x == 13:
return ('True')
if x == 7:
return ('True')
else: ('False')
print()
#9 This will determine if the function is lucky
def is_lucky(x):
if x == 3:
return ('True')
if x == 4:
return ('True')
if x == 8:
return ('True')
if x == 7:
return ('True')
else:
return ('False')
print('')
#10 This function will pluralize
def pluralize(z):
if not z:
return plural
print('')
main()