Question

How to make this into a table in Python? def displayPay(lst): for inner_lst in lst: name=inner_lst[0]...

How to make this into a table in Python?

def displayPay(lst):
    for inner_lst in lst:
        name=inner_lst[0]
        hr=float(inner_lst[1])
        rate=float(inner_lst[2])
        if hr<=40:
            pay=hr*rate
        else:
            pay=40*rate+(hr-40)*rate*1.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
def displayPay(lst):
    print("name\t\thr\t\trate\t\t\tpay")
    print("----------------------------------------")
    for inner_lst in lst:
        name=inner_lst[0]
        hr=float(inner_lst[1])
        rate=float(inner_lst[2])
        if hr<=40:
            pay=hr*rate
        else:
            pay=40*rate+(hr-40)*rate*1.
        print(name,"\t",hr,"\t",rate,"\t",pay)

displayPay([["name","11.123","1231.23112"],["name","11.123","1231.23112"],["name","11.123","1231.23112"]])
Add a comment
Know the answer?
Add Answer to:
How to make this into a table in Python? def displayPay(lst): for inner_lst in lst: name=inner_lst[0]...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • def _merge(lst: list, start: int, mid: int, end: int) -> None: """Sort the items in lst[start:end]...

    def _merge(lst: list, start: int, mid: int, end: int) -> None: """Sort the items in lst[start:end] in non-decreasing order. Precondition: lst[start:mid] and lst[mid:end] are sorted. """ result = [] left = start right = mid while left < mid and right < end: if lst[left] < lst[right]: result.append(lst[left]) left += 1 else: result.append(lst[right]) right += 1 # This replaces lst[start:end] with the correct sorted version. lst[start:end] = result + lst[left:mid] + lst[right:end] def find_runs(lst: list) -> List[Tuple[int, int]]: """Return a...

  • def slice_list(lst: List[Any], n: int) -> List[List[Any]]: """ Return a list containing slices of <lst> in...

    def slice_list(lst: List[Any], n: int) -> List[List[Any]]: """ Return a list containing slices of <lst> in order. Each slice is a list of size <n> containing the next <n> elements in <lst>. The last slice may contain fewer than <n> elements in order to make sure that the returned list contains all elements in <lst>. === Precondition === n <= len(lst) >>> slice_list([3, 4, 6, 2, 3], 2) == [[3, 4], [6, 2], [3]] True >>> slice_list(['a', 1, 6.0, False],...

  • THIS CODE IS IN PYTHON #This program calls a function from the main function def getInput():...

    THIS CODE IS IN PYTHON #This program calls a function from the main function def getInput(): ''' This function gets the rate and the hours to calculate the pay ''' userIn = float(input("Enter the rate: ")) print(userIn) inputHours = float(input("Enter the hours: ")) print(inputHours) def main(): getInput() main() YOU NEED TWO FUNCTIONS : main() function get_inputs function

  • Python. Write a function that takes in a list and returns the first nonzero entry. def...

    Python. Write a function that takes in a list and returns the first nonzero entry. def nonzero(lst): """ Returns the first nonzero element of a list >>> nonzero([1, 2, 3]) 1 >>> nonzero([0, 1, 2]) 1 >>> nonzero([0, 0, 0, 0, 0, 0, 5, 0, 6]) 5 """ "*** YOUR CODE HERE ***"

  • Help with Python code. Right now I'm creating a code in Python to create a GUI....

    Help with Python code. Right now I'm creating a code in Python to create a GUI. Here's my code: #All modules are built into Python so there is no need for any installation import tkinter from tkinter import Label from tkinter import Entry def calculatewages(): hours=float(nhours.get()) nsal=float(nwage.get()) wage=nsal*hours labelresult=Label(myGUI,text="Weekly Pay: $ %.2f" % wage).grid(row=7,column=2) return Tk = tkinter.Tk()    myGUI=Tk myGUI.geometry('400x200+100+200') myGUI.title('Pay Calculator') nwage=float() nhours=float() label1=Label(myGUI,text='Enter the number of hours worked for the week').grid(row=1, column=0) label2=Label(myGUI,text='Enter the pay rate').grid(row=2, column=0)...

  • How to convert this python to c++? class SOMENode: def __init__(self, name, parent, verbose=False): self.name =...

    How to convert this python to c++? class SOMENode: def __init__(self, name, parent, verbose=False): self.name = name self.parent = parent self.children = [] if self.parent: self.parent.add_child(self) self.verbose = verbose

  • If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly...

    If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly pay) If the employee is not a supervisor and she worked 40 hours or less calculate her paycheck as her hourly wage * hours worked (regular pay) If the employee is not a supervisor and worked more than 40 hours calculate her paycheck as her (hourly wage * 40 ) + (1 ½ times here hourly wage * her hours worked over 40) (overtime...

  • fix this python program (error:NameError: name 'turtle' is not defined) def Drawtriangularmotion():     import turtle    ...

    fix this python program (error:NameError: name 'turtle' is not defined) def Drawtriangularmotion():     import turtle     import random index=0 size=[80,75,60] color=['red','green','blue'] myTurtle=turtle.Turtle() screen = turtle.Screen() def draw_square():     global index     myTurtle.fillcolor(color[index])     myTurtle.begin_fill()     for _ in range(4):         myTurtle.left(90)         myTurtle.forward(size[index])     myTurtle.end_fill()     index+=1 def draw_triangle():     for _ in range(3):         draw_square()         myTurtle.penup()         myTurtle.forward(450)         myTurtle.left(120)         myTurtle.pendown() def main():     draw_triangle()     screen.exitonclick() main()

  • In Python, please change this function so if someone inputs an invalid age (string, float, number...

    In Python, please change this function so if someone inputs an invalid age (string, float, number below 0), print "wrong". Use the "isdigit()" function -------------------------- def age_name(): name = input("Enter name:") age = int(input("Enter age:")) print("Hello", name) if(age <= 18): print("Child") elif(age <= 64): print("Adult") else: print("Senior")

  • ###############recursion (Python) ##def facto( num ): ## if num == 0: ## return 1 ## else:...

    ###############recursion (Python) ##def facto( num ): ## if num == 0: ## return 1 ## else: ## return num * facto( num - 1 ) ## ##Task 2. N! = 1*2*3*...*(N-1)*N as we know. There is another "double factorial": ##N!! : ##1)if N is odd then N!! = 1*3*5*7*9*...*N ##2)if N is even then N!! = 2*4*6*8*...*N ## ####Task 2. Create a function facto2 which calculates facto2(N) = N!! ##Show that your function works. ######use input(...)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT