Invalid synthx error on line 9 - python-2.7

I'm not sure what I did wrong but it's returning invalid syntax on line 9, if anyone can help thank you.
hrs = raw_input("Enter Hours:")
rate = raw_input ("Enter Rates:")
hrs = float(hrs)
rate = float(rate)
def computepay(hrs,rate):
if hrs > 40:
pay = (hrs * rate) + (rate * 1.5) + (hrs- 40)
else:
pay = hrs * rate
return pay
p = computepay(10,20)
print "Pay", p

Related

combining 3 indicators into a strategy

I want to combine 3 indicators (MACD, EMA, and VOLUME) to build a strategy where to get notified (overlay=true, with character) if the candle is over 7 days EMA and the VOLUME is higher than the previous 4 days and the MACD is in a positive direction.
strategy('MACD')
[macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
ema7 = ema(close, 7)
buy = close > ema7
vol = volume
vol1 = volume[1]
vol2 = volume[2]
vol3 = volume[3]
buycon = buy and macdLine >= signalLine and vol > vol1 and vol > vol2 and vol > vol3
stopcon = close < ema7
start = timestamp(2019,1,1,0,0)
if time >= start
strategy.entry("buy", strategy.long, 1000, when = buycon)
strategy.close("buy", when = stopcon)
Please help

I keep getting this error: type error: int object not iterable error when i try to run this. i dont seem to understand why

def calculate_tax(income_input):
income_inpu = {}
for item in income_input:
tax = '0'
income = income_input[item]
if income in range(0, 1001):
tax = (0*income)
if income in range(1001, 10001):
tax = (0.1 * (income-1000))
if income in range(10001, 20201):
tax = ((0.1*(10000-1000)) + (0.15*(income-10000)))
if income in range(20201, 30751):
tax = ((0.1*(10000-1000)) + (0.15*(20200-10000)) + (0.2*(income-20200)))
if income in range(30751, 50001):
tax = ((0.1*(10000-1000)) + (0.15*(20200-10000)) + (0.2*(30750-20200)) + (0.25*(income-30750)))
if (income > 50000):
tax = ((0.1*(10000-1000)) + (0.15*(20200-10000)) + (0.2*(30750-20200)) + (0.25*(50000-30750)) + (0.3*(income-50000)))
income_inpu[item] = tax
return income_inpu

Python - overtime pay compute using def & return function

I am new to the python and have a question on python practice I am working on!
Rate is given to 10.5 and hour is 45 hours. Pay should be $498.75 but my code below keeps showing $551.25...
Am I missing anything?
def computepay(hrs, rate):
if hrs <=40:
pay = hrs * rate
elif hrs > 40:
pay = ((hrs-40)*1.5*rate) + (hrs*rate)
return pay
hrs = float(raw_input('Enter hours '))
print computepay(hrs, 10.5)
Oh never mind!
Found an error on elif pay calculation LOL
def computerpay(hrs, rate):
if hrs <=40:
pay = hrs * rate
elif hrs > 40:
pay = ((hrs-40)*1.5*rate) + (40*rate)
return pay
hrs = float(raw_input('Enter hours '))
print computerpay(hrs, 10.5)

I would like to add an hours and minute format to my list and list each item with the hour next to it starting at 0:00 and going to 23:00

This is for PYthon 3.5. I am looking to add hours and minutes format to the list and get it to print out currently it will not do either.
I am looking to get a list of what is input as:
0:00 The temperature is ##
1:00 The temperature is ##
up to 23:00.
Thanks for the help.
HourlyTemperatures = []
def main():
def GetTemperatures(HourlyTemperatures):
for hours in range(0,24):
HourlyTemperatures.append(int(input("Please input a temperature for the hour: " % hours)))
while HourlyTemperatures[hours] <= -50 or HourlyTemperatures[hours] >= 130:
print("Please enter a valid Temperature between -50 or 130")
HourlyTemperatures[hours] = (int(input("Please input a temperature for the hour: ")))
return HourlyTemperatures
def ComputeAverageTemp(HourlyThemperatures):
AverageTemperature = sum(HourlyTemperatures) / len(HourlyTemperatures)
return AverageTemperature
def ComputeMaxTemp(HourlyTemperatures):
MaxTemp = max(HourlyTemperatures)
return MaxTemp
def ComputeMinTemp(HourlyTemperatures):
MinTemp = min(HourlyTemperatures)
return MinTemp
CalcTemperature = GetTemperatures(HourlyTemperatures)
AverageTemperature = ComputeAverageTemp(CalcTemperature)
MaxTemp = ComputeMaxTemp(CalcTemperature)
MinTemp = ComputeMinTemp(CalcTemperature)
CalcDisplayTemperature = DisplayTemperatures(HourlyTemperatures, AverageTemperature)
print(CalcTemperature)
print(HourlyTemperatures)
print(AverageTemperature)
print(MaxTemp)
print(MinTemp)
The following code will repeatedly ask for temperatures and then show the minimum, maximum and average values.
The new thing in this code is the use of the datetime module and the datetime.time(hours + 1, 0).strftime('%H:%M') to format a value as 01:00, 02:00 and so on. This is using the strftime method on a time (which is what datetime.time() creates) and it formats the value as HH:MM (two digits for the hour, two digits for the minutes).
It also uses enumerate which is a built-in function that Python provides for going over a list of values while also providing a counter variable. So you'll get both the position in the list as well as the value at that position. This is useful in our case because we want to display both the hour and the temperate value of that hour.
import datetime
HourlyTemperatures = []
def GetTemperatures(HourlyTemperatures):
for hours in range(0,24):
message = "Please input a temperature for the hour: %s " % datetime.time(hours + 1, 0).strftime('%H:%M')
HourlyTemperatures.append(int(input(message)))
while HourlyTemperatures[hours] <= -50 or HourlyTemperatures[hours] >= 130:
print("Please enter a valid Temperature between -50 or 130")
HourlyTemperatures[hours] = int(input(message))
return HourlyTemperatures
def ComputeAverageTemp(HourlyThemperatures):
AverageTemperature = sum(HourlyTemperatures) / len(HourlyTemperatures)
return AverageTemperature
def ComputeMaxTemp(HourlyTemperatures):
MaxTemp = max(HourlyTemperatures)
return MaxTemp
def ComputeMinTemp(HourlyTemperatures):
MinTemp = min(HourlyTemperatures)
return MinTemp
CalcTemperature = GetTemperatures(HourlyTemperatures)
AverageTemperature = ComputeAverageTemp(CalcTemperature)
MaxTemp = ComputeMaxTemp(CalcTemperature)
MinTemp = ComputeMinTemp(CalcTemperature)
print(CalcTemperature)
print(HourlyTemperatures)
print(AverageTemperature)
print(MaxTemp)
print(MinTemp)
for hour, temperature in enumerate(HourlyTemperatures):
print("The temperature for " + datetime.time(hour + 1, 0).strftime('%H:%M') + " is " + str(temperature))

Python Salary Program Using Conditionals

I get an error # line 19, the Bonus function and I can't figure out why. I'll probably get an error for the other functions too. I've checked my spaces, my numbers vs. my strings, and my DOM. My first problem were about my globals and I fixed it from global comrate to `comrate = 0; . I've got debugging blindness. Thank you guys in advance!
def main():
#Welcome user and get sales number
print("Welcome to the Bonus Qualification Calculator! Please honestly answer the following questions:")
name = str(input("What is your name? "))
sales = float(input("What is your sales total? "))
jobtime = float(input("How many months have you been with the company? "))
vacationtime = float(input("How many vacation days have you taken? "))
#Define Global Vars
comrate = 0;
compedsalary = 0;
bonussalary = 0;
finalsalary = 0;
#Begin calculations
Bonus(sales, jobtime)
vacation(vacationtime)
print(str(name) + ", your salary based on the information you provided is " + str(format(finalsalary,'.2f'))
def Bonus(sales,jobtime):
#Calcultate commission
if sales < 10000:
comrate = 0
elif sales > 10000 and sales <= 1000000:
comrate = .02
elif sales >= 100001 and sales <= 500000:
comrate = .15
compedsalary = float(comrate * 2000)
if jobtime > 3:
bonussalary = float(compedsalary + 1000)
else:
print("You don't qualify for a bonus due to your limited time at the company.")
elif sales >= 500001 and sales <= 1000000:
comrate = .28
compedsalary = float(comrate * 2000)
if jobtime > 3:
bonussalary = float(compedsalary + 5000)
else:
print("You don't qualify for a bonus due to your limited time at the company.")
elif sales > 1000000:
comrate = .35
compedsalary = float(comrate * 2000)
if jobtime > 3:
bonussalary = float(compedsalary + 100000)
elif jobtime > 60:
bonussalary = float(compedsalary + 101000)
else:
print("You don't qualify for a bonus due to your limited time at the company.")
def vacation(finalsalary):
if vacation > 3:
finalsalary = float(bonussalary - 200)
else:
finalsalary = bonussalary
main()
You're using full quotes where you should be using apostrophes. You're using contractions in your print statements, which confuses Python. Just put "do not" instead of "don't" in your print statements.