Python Forum
PLEASE HELP! Basic Python Program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PLEASE HELP! Basic Python Program
#3
Thank you for your time, this would be perect if it had the choice of metres or inches and could calculate the answer to be in metres of inches, if you could implement this that would be amazing.

thank you




(Apr-10-2021, 01:11 PM)BashBedlam Wrote: Here is one way to go about it:

def get_numeric_input (prompt: str) -> float :
	while True :
		answer = input (prompt)
		try :
			return float (answer)
		except : pass

while True :
	print ("Strain Calculator")
	print ("Menu")
	print ("1) Strain")
	print ("2) Quit Now")
	answer = input ("Enter your choice : ")
	print ()
	if answer == "1" :
		change = get_numeric_input ("Enter change in length : ")
		original = get_numeric_input ("Enter original length : ")
		print (f"The answer is {change / original}\n")
	elif answer == "2" :
		exit ()
Reply


Messages In This Thread
PLEASE HELP! Basic Python Program - by joeroffey - Apr-10-2021, 11:59 AM
RE: PLEASE HELP! Basic Python Program - by joeroffey - Apr-10-2021, 01:49 PM
RE: PLEASE HELP! Basic Python Program - by ndc85430 - Apr-10-2021, 01:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Basic Coding Question: Exit Program Command? RockBlok 3 726 Nov-19-2023, 06:31 PM
Last Post: deanhystad
  trying to understand a string literal in a basic server program CompleteNewb 4 2,271 Nov-14-2021, 05:33 AM
Last Post: deanhystad
  Python basic program webshakeup 4 2,920 Sep-19-2019, 07:14 AM
Last Post: Maheshsharma
  Heating program to translate from Basic to Python tommy2k19 12 6,300 May-21-2019, 08:16 AM
Last Post: tommy2k19
  Very basic programming help needed: pig latin program bstocks 2 8,109 Dec-02-2017, 08:12 AM
Last Post: RickyWilson

Forum Jump:

User Panel Messages

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