Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Measurement
#1
A US gill is measure of volume that is equal to 32 fluid drams .One drams is equal to 1/8 of a US ounce. If you know the number of fluid ounces, you can calculate the number of drams = ounces *8 and the number of gills as gills= ounces /4. Write a program to enter the number of apple cider they want to purchase. Calculate and display the correct number of gills and drams. If the result is more than 1024 drams, a message should display indicating that the amount they want is large and they need to purchase  their cider in gallons. If the result is less than 100 drams, a message should display indicating that the amount they want is too small and perhaps they should just order a pint
Reply
#2
<moved to homework>

What have you tried?
Reply
#3
int(Input(" Enter the number of ounces of apple cider they want to purchase')
print( "drams =(1/8 *32) *8")
print("gills =("1/8 *32)*8")
total of drams is needed
total of gills is needed
Reply
#4
You can't just provide your verbatim homework and your code, outside of code tags. You need to ask a question that helps you get unblocked, and you should use code tags when you post code (and generally you should be posting code).
Reply
#5
How that can ever be tested?

int(Input(" Enter the number of ounces of apple cider they want to purchase")
print( "drams =(1/8 *32 *8")
print("gills =("1/8 *32 *8")
if result > 1024 :
print("The amount they want is too large and they will need to purchase their cider in gallons.")
elif result <100 :
print("The amount they want is too small and perhaps they should just order a pint.")
else:
print("the number of gills and drams.")
Reply
#6
You do not get any input. You have to assign it to a variable
In Python there is no Input() builtin function but input(). Small 'i'
There is no 'result' definition. This variable don't exist
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#7
Using the 'code tags' is not a request, you must use them. Either consult the Help document or click the "BBCode Help" button at the bottom of the edit window for instructions on how to properly post code.  As it stands, your script will not run at all. As was pointed out, the value of your incorrectly spelled "input" statement is not assigned to any variable.  Next you have two print statements that won't work because the number of closing parenthesis does not match the number of opening parenthesis and in one case you have to many quotation marks. In order to use parenthesis correctly you need to understand how Python uses Order of Precedence.  Within your 'print' statements, you show a variable and a value assigned to that variable, but they have no use to your script since they are not actually assigned, just printed.  Then you have the variable "result" which has no value assigned to it (what do you think would be a most excellent value to assign to the variable "result"?).  Finally the code you posted has no indentation, which again will prevent your script from running.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#8
This is a string:
"drams =(1/8 *32 *8"
This evaluates an expression and assigns the result to a variable
drams = 1/8*32*8
I don't like the assignment because it does not specify what unit is used for user input. The teacher must have provided additional information because you have chosen to have the user enter their order using ounces. The instructions provide the conversions from ounces to drams and ounces to gils. Read the instructions carefully and you will see that your equation is wrong. Nowhere should you be using 32.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020