Professional Documents
Culture Documents
AI Worksheet Exp 2
AI Worksheet Exp 2
HOME TASK
EXPERIMENT – 2
Task-1:
Create a program wages.py that assumes people are paid double time for hours over 60.
They get paid for at most 20 hours overtime at 1.5 times the normal rate.
For example, a person working 65 hours with a regular wage of $10 per hour would work at
$10 per hour for 40 hours, at 1.5 * $10 for 20 hours of overtime, and 2 * $10 for 5 hours of
double time, for a total of
If the number of working hours is less than 40, display message “The salary cannot be
generated” with sound of system bell as a warning.
Requirements:
Python version 3.7.
Code:
import random
import winsound
#randomrange
a= random.randrange(35,75)
print("Numbers of working hrs: ",a)
if a==40:
b= int(40*10)
print(" wages: ",b)
elif 40<a<=60:
c=float(40*10 + (a-40)*10*1.5)
print(" wages: ",c)
elif a>60:
d=float(40*10 + (a-60)*10*2 + (60-40)*10*1.5)
print(" wages: ",d)
else:
print("The salary cannot be generated")
winsound.PlaySound("WindowsBackground", winsound.SND_FILENAME)
Outcome:
Foundations of AI Applications Lab
Task-2:
WAP to take word input from user and display the input in jumbled form eg.
Input – game
Output - agme
Requirements:
Python version 3.7.
Code:
import random
word = input("Enter the word: ")
jumble=""
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[:position] + word[(position + 1):]
print("Jumbled word is: ",jumble)
Outcome: