r/PythonProjects2 • u/MtnDoobie • Nov 17 '21
[P] Moderate Python Program w/ Excel. Can anyone help?
Heyo everyone! I'm back again looking for some more tips/guidance in my python programming journey.
I have to edit some code to where it writes the results into a python program.
Column A will be employee names. Column B will be corresponding pay amounts.
I need to write the labels 'Name' into cell A1 and 'Pay Amount' in B1.
Here is the code I have so far---
# create blank dictionary
paychecks = {}
# Read in all the names and hours
empCount = int(input("\nHow many employees worked this week? "))
for nextEmp in range (1, empCount+1):
name = input("\\nWho was employee " + str(nextEmp) + "? ")
hours = int(input("How many hours did " + name + " work this week? "))
paychecks\[name\] = hoursprint ("Employee -- pay") #NEED TO CHANGE THIS BLOCK OF CODE
print ("---------------")
for nextEmp in paychecks.keys() :
name = nextEmp
hours = paychecks\[name\]
if hours <= 40:
pay = hours \* 8.50
else :
pay = (40\*8.50) + ( 12.75 \* (hours-40))print(nextEmp, "---", pay)
I know right now the only thing I need to really edit is the 'Print' blocks of code, but I'm unsure of what to put in it's place to make the program run as intended. Any help would be greatly appreciated!
2
u/Foreign_Flower1141 Nov 17 '21
Please edit the post and format code with ``` surrounding at the beginning and the end. It is pain to read and guess indentations