Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:04:38+00:00 2026-06-12T19:04:38+00:00

I am attempting to learn how to program. I really do want to learn

  • 0

I am attempting to learn how to program. I really do want to learn how to program; I love the building and design aspect of it. However, in Java and Python, I have tried and failed with programs as they pertain to objects, classes, methods.. I am trying to develop some code for a program, but im stumped. I know this is a simple error. However I am lost! I am hoping someone can guide me to a working program, but also help me learn (criticism is not only expected, but APPRECIATED).

class Converter:

    def cTOf(self, numFrom):
        numFrom = self.numFrom
        numTo = (self.numFrom * (9/5)) + 32
        print (str(numTo) + ' degrees Farenheit')
        return numTo

    def fTOc(self, numFrom):
        numFrom = self.numFrom
        numTo = ((numFrom - 32) * (5/9))
        return numTo

convert = Converter()

numFrom = (float(input('Enter a number to convert..                '))) 
unitFrom = input('What unit would you like to convert from.. ')
unitTo = input('What unit would you like to convert to..    ')

if unitFrom == ('celcius'):
    convert.cTOf(numFrom)
    print(numTo)
    input('Please hit enter..')


if unitFrom == ('farenheit'):
    convert.fTOc(numFrom)
    print(numTo)
    input('Please hit enter..')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:04:40+00:00Added an answer on June 12, 2026 at 7:04 pm

    Classes and objects are tools to accomplish a task — they allow you to encapsulate data or state with a set of methods. However, your data is just a number. There is no need to encapsulate the integer, so there is no need to create a class.

    In other words, don’t create a class because you think you should, create a class because it makes your code simpler.

    import sys
    
    def f_to_c(x):
        return (x - 32) * (5/9)
    
    def c_to_f(x):
        return x * (9/5) + 32
    
    num_from = float(input('Enter a number to convert: '))
    unit_from = input('What units would you like to convert from? ')
    unit_to = input('What units would you like to convert to? ')
    
    if (unit_from, unit_to) == ('fahrenheit', 'celsius'):
        num_to = f_to_c(num_from)
    elif (unit_from, unit_to) == ('celsius', 'fahrenheit'):
        num_to = c_to_f(num_from)
    else:
        print('unsupported units')
        sys.exit(1)
    
    print('{} degrees {} is {} degrees {}'
          .format(num_from, unit_from, num_to, unit_to))
    
    Enter a number to convert: 40
    What units would you like to convert from? celsius
    What units would you like to convert to? fahrenheit
    40.0 degrees celsius is 104.0 degrees fahrenheit
    

    The convert object and Converter class don’t serve any purpose, so the code is simpler and easier to read without them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been attempting to learn Grails, however I am running into the following
I am attempting to learn Ruby by converting a Java program to Ruby, but
I am attempting to learn C and I have written a small program which
I'm attempting to learn Scala coming from a Java background. Should the below program
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be
I'm attempting to learn Scala so I have decided to implement datastructures with it.
I'm trying to learn python and I'm attempting a hangman game. But when I
I am attempting to learn about creating windows in c++, I have looked at
I am attempting to implement Heap sort in my program to learn more about
I am attempting to learn php and I am at a really early stage!

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.