Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2013

    Question First time homework help using 2.75

    using 2.75
    Homework question here: http://imgur.com/aHLYwyQ
    I've just started learning python so i'm really lost...
    Do I start like

    x= year y= months x= 5 y= 9 print x*12 print y/12 + 11
    this code is terribly, horribly, wrong, but this is my first time trying to learn python >< any help would be SO appreciated. thank you.

  2. #2
    New to the CF scene
    Join Date
    Jul 2013
    Hello lunapt,

    First, there are some redundancies in your code that I suggest to delete. For instance, do not not assign unnecessary dummy variables. You assign year to x, and then 5 to x. Simply, assign 5 to year; the same goes for months.

    Second, you get a wrong result because your formula is wrong. Your assignment asks you to find number of months in year(s) plus some additional months. Thus, your formula should be
    answer= 12*years + months
    Here is the code for the first part of the assignment, the second part is the reverse of the first. You should be able to figure that out. If not, ask.

    years = 18
    months = 27
    answer = years*12 + months
    print years,' years and ',months,' months are equivalent to:', answer,' months'


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts