In: Computer Science
*Create a python function that uses a while list to allow a user to enter values for sales and to add each value into a list in order to track all values entered. Set the gathering of values to stop when the value of zero is entered. Then take the created list and calculate the values within the list to return the total for all the values. Next, take the previously created list and display all the values from smallest to largest and then from largest to smallest. Then create a function that will check to see if the value 100 is in the list. If it is in the list have the function return "Yes, 100 is in the list" if no have the function return, "No, 100 is not in the list".
*Next make another script and create a list that contains the values for each day of the week. For example; ‘Sunday’, ‘Monday’, ‘Tuesday’, etc….. Modify the script to have a for loop that prints out each day of the week contained within your list. Next, modify your script to ask for input from a user to Enter a number for the day of the week they would like to choose (1-7). Then print the output for the day of the week they have chosen from your list.
#Python code
def funccheck100(lst):
if 100 in lst:
return "Yes, 100 is in the list"
else:
return "No, 100 is not in the list"
def funcsales():
saleslist=[]
while True:
input1=int(input("Enter value to add to list: "))
saleslist.append(input1)
if 0 in saleslist:
break
sumtotal=0
for elem in saleslist:
sumtotal= sumtotal+ elem
print("Total sum of sales list is "+str(sumtotal))
saleslist.sort()
print("The sorted list from smallest to largest is: ")
print(saleslist)
print("The sorted list from largest to smallest is: ")
saleslist.sort(reverse=True)
print(saleslist)
print(funccheck100(saleslist))
funcsales()
def funcdays():
dayslist=['Sunday', 'Monday',
'Tuesday','Wednesday','Thursday','Friday','Saturday']
for day in dayslist:
print(day)
dayno= int(input("Enter day no: "))
print('Day is :')
print(dayslist[dayno-1])
funcdays()