ASE Labs
Welcome Guest. Please register or log in now. There are 87 people online (0 Friends).
  • Home
  • Articles
  • News
  • Forum
  • Register/Login

[Python] Need help with error:

There are 3 messages in this topic Watch this topic for replies Subscribe to this topic
Add Reply Back to forum "Software Discussion" Back to Index
WhiteEagle Avatar Living with God daily. Joined: July 14, 2010 Status: Offline Posts: 2040 Rep: PIP Level 2 (11563)PIP Level 2 (11563)PIP Level 2 (11563)PIP Level 2 (11563)PIP Level 1 (11563)
Question mark [Python] Need help with error: Old Mon Oct 25, 2010 2:48:46 PM #138038 Perm Link
Hey all,

I need help with a programming error. I get this when I try to run this temperature conversion program I've coded:

Code

SyntaxError: invalid syntax
whiteeagle@whiteeagle-desktop:/media/Storage/PyBackup$ python temperature.py
  File "temperature.py", line 6
    print f "degrees Fahrenheit";
                                              ^
SyntaxError: invalid syntax


The code is:

Code

#Converts Celsius to Fahrenheit as well as Fahrenheit to Celsius

def c_to_f():
	f = int(raw_input("Temperature in Celsius please:	"))
	f = (c-32)/1.8;
	print f "degrees Fahrenheit";
	break

def f_to_c():
	c = int(raw_input("Temperature in Fahrenheit please: "))	
	c = (f*1.8)+32;
	print c "degrees Celsius";
	break

def menu_2():
	print "What do you want to do?";
	print "1. Convert Celsius to Fahrenheit.";
	print "2. Convert Fahrenheit to Celsius.";
	print "Any other key to return to the main menu.";

def main_menu():
	print "Would you like to do a conversion? Y or y to confirm. ";

while 1:
	main_menu()
	x = raw_input("Menu choice please: ")
		while x == "y" or x == "Y":
			menu_2()
			y = raw_input("Menu choice please: ")
			if y == 1:
				c_to_f()
			if y == 2:
				f_to_c()
			else:
				break
		else:
			break
else:
	print "Goodbye.";
	break


Where am I going wrong here?

I fold for team 52482. Do you fold@home?
WhiteEagle's Aerie Unlimited Fan Fiction
Reply Quote Multi-Quote-Off Send PM Profile
Aron Schatz Avatar 2014: Year of change. Joined: August 3, 2001 Status: Offline Posts: 10753 Rep: PIP Level 3 (332767)PIP Level 3 (332767)PIP Level 3 (332767)PIP Level 3 (332767)PIP Level 1 (332767)
(No Title) Old Mon Oct 25, 2010 10:04:42 PM #138061 Perm Link
I think you're print statement is wrong. I don't know python, but most languages (scripting too) require you to concatenate strings for echoing.

try

print f,"degrees Fahrenheit";

You'll also need to modify the other lines to use commas as well.

2014 is going to be a good year. More content, more streamlining. Be a part of history!
Reply Quote Multi-Quote-Off Send PM Profile
WhiteEagle Avatar Living with God daily. Joined: July 14, 2010 Status: Offline Posts: 2040 Rep: PIP Level 2 (11563)PIP Level 2 (11563)PIP Level 2 (11563)PIP Level 2 (11563)PIP Level 1 (11563)
(No Title) Old Tue Oct 26, 2010 3:15:45 PM #138075 Perm Link
Thanks, I had lots of debugging even after I fixed that error. I must of really forgotten how to code if I had made probably close to 30 errors total. Sad

I fold for team 52482. Do you fold@home?
WhiteEagle's Aerie Unlimited Fan Fiction
Reply Quote Multi-Quote-Off Send PM Profile
Page: [1]
Add Reply Back to forum "Software Discussion" Back to Index

Quick Reply

Login
Welcome Guest. Please register or log in now.
Forgot your password?
Navigation
  • Home
  • Articles
  • News
  • Register/Login
  • Shopping
  • ASE Forums
  • Anime Threads
  • HardwareLogic
  • ASE Adnet
Latest News
  • Kingston HyperX Cloud 2 Pro Gaming Headset Unboxing
  • Synology DS415+ Unboxing
  • D-Link DCS-5020L Wireless IP Pan/Tilt IP Camera
  • Actiontec WiFi Powerline Network Extender Kit Unboxing
  • Durovis Dive Unboxing
  • Bass Egg Verb Unboxing
  • Welcome to the new server
  • Gmail Gets Optional Preview Pane
  • HBO Go on Consoles
  • HP Touchpad Update
Latest Articles
  • D-Link Exo AC2600 Smart Mesh Wi-Fi Router DIR-2660-US
  • HyperX Double Shot PBT Keys
  • Avantree ANC032 Wireless Active Noise Cancelling Headphones
  • ScharkSpark Beginner Drones
  • HyperX Alloy FPS RGB Mechanical Gaming Keyboard
  • D-Link DCS-8300LH Full HD 2-Way Audio Camera
  • Contour Unimouse Wireless Ergonomic Mouse
  • HyperX Cloud Alpha Pro Gaming Headset
  • Linksys Wemo Smart Home Suite
  • Fully Jarvis Adjustable Standing Desk
Latest Topics
  • Hello
  • Welcome to the new server at ASE Labs
  • Evercool Royal NP-901 Notebook Cooler at ASE Labs
  • HyperX Double Shot PBT Keys at ASE Labs
  • Avantree ANC032 Wireless Active Noise Cancelling Headphones at ASE Labs
  • ScharkSpark Beginner Drones at ASE Labs
  • HyperX Alloy FPS RGB Mechanical Gaming Keyboard at ASE Labs
  • D-Link DCS-8300LH Full HD 2-Way Audio Camera at ASE Labs
  • Kingston SDX10V/128GB SDXC Memory at ASE Labs
  • What are you listening to now?
  • Antec Six Hundred v2 Gaming Case at HardwareLogic
  • Sans Digital TR5UTP 5-Bay RAID Tower at HardwareLogic
  • Crucial Ballistix Smart Tracer 6GB PC3-12800 BL3KIT25664ST1608OB at HardwareLogic
  • Cooler Master Storm Enforcer Mid-Tower Gaming Case at HardwareLogic
  • Arctic M571-L Gaming Laser Mouse at ASE Labs
  • Contour Unimouse Wireless Ergonomic Mouse at ASE Labs
Press Release
  • Huntkey Has Launched Its New Power Strips with USB Chargers on Amazon US
  • Inspur Releases TensorFlow-Supported FPGA Compute Acceleration Engine TF2
  • Hot Pepper Introduces Spicy New Smartphones in US Markets
  • Sharp Introduces New Desktop Printers For The Advanced Office
  • DJI Introduces Mavic 2 Pro And Mavic 2 Zoom: A New Era For Camera Drones
  • DJI Introduces Mavic 2 Pro And Mavic 2 Zoom: A New Era For Camera Drones
  • Fujifilm launches "instax SQUARE SQ6 Taylor Swift Edition", designed by instax global partner Taylor Swift
  • Huawei nova 3 With Best-in-class AI Capabilities Goes on Sale Today
  • Rand McNally Introduces Its Most Advanced Dashboard Camera
  • =?UTF-8?Q?My_Size_to_Showcase_Its_MySizeId=E2=84=A2_Mobil?= =?UTF-8?Q?e_Measurement_Technology_at_CurvyCon_NYC?=
Home - ASE Publishing - About Us
© 2010 Aron Schatz (ASE Publishing) [Queries: 19 (9 Cached)] [Rows: 365 Fetched: 60] [Page Generation time: 0.012766122817993]