In a company work n employee whose salaries range between $ 100 and $ 500, create a program that reads the salaries that each employee receives and report how many employees receive between $ 100 and $ 300 and how many receive more than $ 300. In addition, the program must report the amount the company spends in salaries to staff.
Answer:
#reading employees number and declaring variables
n=int (input())
ar=[]
c=0
sal=0
print(“salary ranges between $100 and $500”)
print (“enter salaries”)
for i in range (n):
sal=int (input())
ar.append (sal)
#Check Conditionality
for i in ar:
if 100<=i<=300:
c+=1
#Display Outputs
print (c,” Persons Receives Salary Between $100 and $300″)
print(len(ar)-c,” Persons Receive More Than $300″)
print(“Company Spends in $”,Sum(ar),” Amount in Salaries to Staff”)
- Make a program that allows you to load two lists of 15 numbers each. Inform with a message which of the two lists has a greater cumulative value (messages “List 1 major”, “List 2 major”, “Equal lists”).
Answer:
def readList (n):
data = []
while len (data) != n:
data. Append (int (input(‘Enter a integer: ‘)))
return data
print (‘Reading First List:’)
a = ReadList(15)
print(‘Reading Second List:’)
b = ReadList(15)
aSum = sum (a)
bSum = sum (b)
if aSum > bSum:
print(‘List 1 Major’)
elif aSum < bSum:
print(‘List 2 Major’)
else:
print(‘Equal Lists’)