Answer:
f=float(input("Enter an integer: "))
c=(f-1)
a=(c-1)
b=(a-1)
print(str(c))
print(str(a))
print(str(b))
Explanation:
This will print everything correctly, just copy and paste!
Questions about Python or more ProjectStem help? Just Send me a message!
The code is working fine but I keep getting an EOF error on my 2nd last line.
program:
# option list for user choice
option = ['y', 'yes', 'YES', 'n', 'no', 'NO']
# invalid characters for hawaiian language
invalid_letters = {"b", "c", "d", "f", "g", "j", "q", "r", "s", "t", "v", "x", "y", "z"}
# dictionary for pronunciation of the letters of word
dictionary = {
'a' : 'ah',
'e' : 'eh',
'i' : 'ee',
'o' : 'oh',
'u' : 'oo',
'ai' : 'eye',
'ae' : 'eye',
'ao' : 'ow',
'au' : 'ow',
'ei' : 'ay',
'eu' : 'eh-oo',
'iu' : 'ew',
'oi' : 'oy',
'ou' : 'ow',
'ui' : 'ooey',
'p' : 'p',
'k' : 'k',
'h' : 'h',
'l' : 'l',
'm' : 'm',
'n' : 'n',
'w' : ['v', 'w']
}
# loop for user input
while option not in ['n', 'no']:
Alolan_word = input("Enter a hawaiian word: ").lower()
word = ' ' + Alolan_word + ' '
pronunciation = ''
skip = False
# loop for traversing the word by character wise
# match each character of word with elements of invalid_letters
for letter in Alolan_word:
if letter in invalid_letters:
print("Invalid word, " + letter + " is not a valid hawaiian character.")
break
# loop for scanning the accepted word letter wise
# match each letter of th word with corresponding pronunciation in the dictionary
for index in range(1,len(word)-1):
letter = word[index]
if skip:
skip = False
continue
if letter in {'p','k','h','l','m','n'}:
pronunciation += dictionary[letter]
if letter == 'w':
if word[index-1] in {'i','e'}:
pronunciation += dictionary[letter][0]
else:
pronunciation += dictionary[letter][1]
if letter == 'a':
if word[index+1] in {'i','e'}:
pronunciation += dictionary['ai'] + '-'
skip = True
elif word[index+1] in {'o', 'u'}:
pronunciation += dictionary['ao'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'
if letter == 'e':
if word[index+1] == 'i':
pronunciation += dictionary['ei'] + '-'
skip = True
elif word [index+1] == 'u':
pronunciation += dictionary['eu'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'
if letter == 'i':
if word[index+1] == 'u':
pronunciation += dictionary['iu'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'
if letter == 'o':
if word[index+1] == 'i':
pronunciation += dictionary['oi'] + '-'
skip = True
elif word [index+1] == 'u':
pronunciation += dictionary['ou'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'
if letter == 'u':
if word[index+1] == 'i':
pronunciation += dictionary['ui'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'
if letter in {"'", ' '}:
if pronunciation[-1] == '-':
pronunciation = pronunciation[:-1]
pronunciation += letter
if pronunciation[-1] == '-':
pronunciation = pronunciation[:-1]
# display the pronounciation of accepted word in hawaiian language
print(Alolan_word.upper() + " is pronounced " + pronunciation.capitalize())
option = input("Would you like to enter another word? [y/yes, n/no] ").lower()
print("All done.")
Answer:
Code is in the attached .txt file
Explanation:
It must have been an indentation error since I get good results using your code properly formatted. I am not sure what the original problem was so unable to comment further
Hello, I desprately need help in python with this question. I have tried everything:This is the question:
4.19 LAB: Driving costs - functions
Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print('{:.2f}'.format(your_value))
Ex: If the input is:
20.0
3.1599
the output is:
1.58
7.90
63.20
Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles.
Ex: If the function is called with:
50 20.0 3.1599
This is my code:
miles_per_gallon = float(input('miles_per_gallon: '))
dollars_per_gallon = float(input('dollars_per_gallon: '))
dollars_per_mile = dollars_per_gallon/miles_per_gallon
your_value1 = 10 * dollars_per_mile
your_value2 = 50 * dollars_per_mile
your_value3 = 400 * dollars_per_mile
print('{:.2f} {:.2f} {:.2f}'.format(your_value1, your_value2, your_value3))
Can someone tell me what I'm doing incorrectly or show me? Thanks truly.
Lily
Answer:
Code is below and also attached in text file
Explanation:
Because Python indentation is extremely important and pasting code in the brainly window sometimes messes it up, I have provided code below as well as in the attached text file. If the one below works, well and good. Otherwise use the one in the text file
Let me know if you have questions
def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon):
'''
Equations Used:
gallons_consumed = driven_miles/miles_per_gallon
dollar_cost = gallons_consumed x dollars_per_gallon
'''
gallons_consumed = driven_miles/miles_per_gallon
dollar_cost = gallons_consumed * dollars_per_gallon
return dollar_cost
# Get inputs from the user
miles_per_gallon = float(input('miles_per_gallon: '))
dollars_per_gallon = float(input('dollars_per_gallon: '))
print()
#Compute dollar cost by calling the driving_cost function
for miles_driven in [10, 50, 400]: #iterate through the list of miles
cost = driving_cost(miles_driven, miles_per_gallon, dollars_per_gallon) #call function
print("{:.2f}".format(cost))
The reduction of the amount of medication in the body can be modeled by
the equation , where A is the amount at time t, A0 is the amount at
t = 0, and k is the decay constant ( ). The half-life time of a certain
medication is 3.5 h. A person takes 400 mg of the medication at t=0, and
then additional 400 mg every 4 h. Determine the amount of the medication
in a patient’s body 23 h after taking the first dose.
After determining the value of k, define a vector
(the time since taking each dose) and calculate the corresponding values of
A. Then use MATLAB’s built-in function sum to determine the total
amount.
Answer:
hahahahahhahah
Explanation:
beacause nathonih