3 Replies - 847 Views - Last Post: 09 November 2014 - 08:56 AM Rate Topic: -----

#1 Fiddledoo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-November 14

Basic Program Help

Posted 08 November 2014 - 07:04 PM

Hey everyone this is my first year taking computer studies at my school and I need some help. This is probably easy for all of you but I am just a beginner and I really need help! My teacher wants us to make a program like this:

Posted Image

BTW we are using Python 2.7.8. Here is my code so far:

print "Press 0 for celsius to farenheit OR press 1 for farenheit to celcius"
temp = int(raw_input))


choice = int(raw_input))
if choice <=0:
        print "Your coverted temperature is",temp

elif



I honestly don't have clue what I am doing but I really want to learn. After the elif part, it is just supposed to be the part to code the Fahrenheit to Celsius part. If someone could please finish this and explain to me how each part works it would mean a lot to me. This is not getting marked so please don't think I am trying to get someone to do this for me. I just really want explanation of how it works.

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Basic Program Help

#2 Martyr2   User is online

  • Programming Theoretician
  • member icon

Reputation: 5538
  • View blog
  • Posts: 14,541
  • Joined: 18-April 07

Re: Basic Program Help

Posted 08 November 2014 - 07:27 PM

Well I don't have or want to run Python 2.7 to give you that specific syntax, I will leave that up to you. I am using Python 3.2 here. But it shouldn't be hard (covert the prints and input collecting as appropriate)

print("Press 0 for Celsius to Fahrenheit OR press 1 for Fahrenheit to Celsius")

# First of all we are going to collect the input from the user
choice = int(input())

# Based on that choice, we launch separate equations
if choice <=0:
	# Ask for the Celsius temp to convert
	print("Please enter the Celsius temperature you wish to convert:")

	# Convert to float so we can use it with other numbers
	temp = float(input())

        # Here we store the value of our equation into a variable we call "f" for printing later
	f = ((9/5) * temp) + 32

	# Print the result
	print("Temperature converted is:",f)
else:
	# Just like Celsius above, but with Fahrenheit to Celsius equation
	print("Please enter the Fahrenheit temperature you wish to convert:")
	temp = float(input())

	c = (5/9) * (temp - 32)
	print("Temperature converted is:",c)



I hope you get the idea from reading the above code. Pay particular attention to the use of collecting input, the number of parenthesis (you had too many in spots) and how we store values in and use the variables after proper conversions.

:)
Was This Post Helpful? 1
  • +
  • -

#3 Fiddledoo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-November 14

Re: Basic Program Help

Posted 09 November 2014 - 08:52 AM

Thank you so much! :) This helps a lot and I really appreciate it!

This post has been edited by andrewsw: 09 November 2014 - 08:55 AM
Reason for edit:: Removed large previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6834
  • View blog
  • Posts: 28,372
  • Joined: 12-December 12

Re: Basic Program Help

Posted 09 November 2014 - 08:56 AM

@OP You don't have to quote a large previous reply, there is a REPLY button further down the page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1