r/PythonProjects2 • • 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\] = hours

print ("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 Upvotes

6 comments sorted by

View all comments

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

1

u/MtnDoobie Nov 17 '21

I think I did it. When I posted this from my PC the format was fine, but I’m on mobile now so I can’t tell if the format changed for you.

2

u/Foreign_Flower1141 Nov 17 '21

It's still not formatted. Just to make sure, by formatting I mean indenting the code that's being done by surrounding all of it in ``` symbols (that is, in markdown editor. You can use code highlighter in fancy pants editor)

# just like this
if True:
    print("I am indented")