Computer Science, asked by ahujavarun106, 7 months ago

please write a python code for:-

A company pays the salary to its customers on hourly work basis as per the following criteria.

First 8 hours Rs. 20 per hour

Next 4 hours Rs. 30 per hour
First 6 hours Rs. 50 per hour

For more than 18 hours Rs. 100 per hour

Write the code to input number of hours worked in a day by a worker. Calculate and print his monthly

salary considering that he works for same no. of hours daily

complete it fast please​

Answers

Answered by uday3prakash
0

Answer:

#!/usr/bin/python3

hours_worked_per_day = float(input('Enter the number of hours worked:'))

salary_per_day = 0

if hours_worked_per_day > 18:

   salary_per_day += (hours_worked_per_day - 18) * 100

   hours_worked_per_day = 18

if 12 < hours_worked_per_day <= 18:

   salary_per_day += (hours_worked_per_day - 12) * 50

   hours_worked_per_day = 12

if 8 < hours_worked_per_day <= 12:

   salary_per_day += (hours_worked_per_day - 8) * 30

   hours_worked_per_day = 8

if hours_worked_per_day <= 8:

   salary_per_day += hours_worked_per_day * 20

print('salary_per_day:', salary_per_day)

Explanation:

calculating with multiple independent if conditions will help

Answered by Equestriadash
3

choice = "Yes"

while choice == "Yes":

   h = int(input("Enter the number of hours: "))

   print()

   if h < 8:

       sal = 20*h

       print(sal, "is your salary.")

   elif h < 12:

       sal = 30*h

       print(sal, "is your salary.")

   elif h < 18:

       sal = 50*h

       print(sal, "is your salary.")

   elif h > 18:

       sal = 100*h

       print(sal, "is your salary.")

   print()

   choice = input("Next worker? [Yes/No]: ")

   print()

Attachments:
Similar questions