gpt4 book ai didi

if else 语句上的 python 3.5.1 语法错误

转载 作者:太空宇宙 更新时间:2023-11-04 10:15:21 24 4
gpt4 key购买 nike

<分区>

我正在做家庭作业,看起来像这样:

def main():
keep_going = 'y'
number_of_salespeople = 0

while keep_going == 'y' or keep_going == 'Y':
process_sales()
number_of_salespeople += 1
keep_going = input('Are there more salespeople? (enter y or Y for yes) ')

print(' ')
print('There were', number_of_salespeople, 'salespeople today.')

def process_sales():
print(' ')
name = input('What is the salesperson\'s name? ')

first_sale_amount = float(input('What is', name, '\'s first sale amount? '))
while 0 <= first_sale_amount <= 25000:
print('Error: that is not a valid sales amount. The amount must be greater than 0')
first_sale_amount = float(input('Please enter a correct sale amount: '))

highest_sale = first_sale_amount
lowest_sale = first_sale_amount
average_sale = first_sale_amount

number_of_sales = float(input('How many sales did', name, 'make this month? '))

for number in range(2, number_of_sales + 1):
sale_amount = float(input('Enter', name, '\'s time for sale #' + str(number) + ': '))
while 0 <= sale_amount <= 25000:
print('Error: that is not a valid sales amount. The amount must be greater than 0')
sale_amount = float(input('Please enter a correct sale amount: '))

if sale_amount > highest_sale:
highest_sale = sale_amount

else sale_amount < lowest_sale:
lowest_sale = sale_amount

total_sales += sale_amount
average_sale = (first_sale_amount + total_sales) / number_of_sales

print('The highest sale for', name, 'was', \
format(highest_sale, ',.2f'), \
sep='')

print('The lowest sale for', name, 'was', \
format(lowest_sale, ',.2f'), \
sep='')

print('The average sale for', name, 'was', \
format(average_sale, ',.2f'), \
sep='')

main()

我遇到的错误是在底部的 if else 语句中,

if sale_amount > highest_sale:
highest_sale = sale_amount

else sale_amount < lowest_sale:
lowest_sale = sale_amount

错误看起来像这样:

Syntax Error: else sale_amount < lowest_sale:: , line 58, pos 24

我看不出问题出在哪里,谁能帮我找出错误的来源。感谢您的帮助。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com