имя «да» не определено - PullRequest
0 голосов
/ 12 мая 2019

Когда я углубляюсь в код, он говорит, что «Да» не определено. Код спрашивает пользователя, как долго он работал, и вычисляет код.

Я попробовал несколько незначительных изменений в этом утверждении. Это дало мне те же результаты.

Когда пользователь отвечает «Да»; Я хочу, чтобы код для расчета брутто зарплаты

Overtimeflag = 50

if Overtimeflag == 50: 

 Overtimeflag = True

Else:

Overtimeflag = False


Name = input('Whats your first and last name')

Address = input('Whats your address')

HoursWorked=float(input('How many years have you been working here'))

Overtime=float(input('how long did you work today'))

if HoursWorked > 40:

   print('You are qualified for overtime pay')

elif Overtime >= 2:

    Overtime = HoursWorked - 40

else:

    print('In order to earn overtime, the user must have worked for at least 2 years')

grossPay =float(input('Whats your hourly rate'))

Overtimeflag =input('Did you work 50 hours this week')

##Calculate the gross pay with the following formula

if grossPay == Yes:

    Overtime2 * grossPay * 2 + HoursWorked - Overtimeflag * grossPay

else:

    print('You do not earn overtime due to lack of years of service')

1 Ответ

0 голосов
/ 13 мая 2019

Да, это должна быть строка, поскольку она не определена ранее.

Overtimeflag = 50

if Overtimeflag == 50: 
 Overtimeflag = True
else:
    Overtimeflag = False


Name = input('Whats your first and last name')

Address = input('Whats your address')

HoursWorked=float(input('How many years have you been working here'))

Overtime=float(input('how long did you work today'))

if HoursWorked > 40:
   print('You are qualified for overtime pay')
elif Overtime >= 2:
    Overtime = HoursWorked - 40
else:
    print('In order to earn overtime, the user must have worked for at least 2 years')
grossPay =float(input('Whats your hourly rate'))
Overtimeflag3 =input('Did you work 50 hours this week')
##Calculate the gross pay with the following formula

if Overtimeflag3 == "Yes":
    Overtime2 = grossPay * 2 + HoursWorked - Overtimeflag * grossPay
    print("Overtime pay: ",Overtime2 )
else:
    print('You do not earn overtime due to lack of years of service')

ВЫХОД:


Whats your first and last namecd scsd
Whats your addresscsd
How many years have you been working here9
how long did you work today99
Whats your hourly rate9
Did you work 50 hours this weekYes
Overtime pay:  18.0
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...