Python Forum
Basic Coding Slays College Girl
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Coding Slays College Girl
#1
It is 4:30 in the morning. Been up since 8am yesterday and been running on 2 hours of sleep, coffee, and a Monster energy drink. I've seen that you guys have a certain format for asking questions, but I've been running on fumes all day and been working on homework for 9 hours straight; 3 of these trying to comprehend how to do this single problem. I promise to stick to your format in the future, but for now, please help. I have to get this one and another one done by Friday, along with piles of work from other classes due soon.

The problem:

If a moderately active person cuts their calorie intake by 500 calories a day, they can typically lose about about 4lb per month. Write a program that lets the user enter the starting weight, then creates and displays a table showing what their expected weight will be at the end of each month for the next 6 months if they stay on this diet.

How do I code this? Please. I'll be very, very grateful if someone can help me make sense of this. Also, just to clarify, I'm using Python 2.7.13.
Reply
#2
We are sorry to hear that you are under pressure given the deadline for your homework, however we are not going to do it for you. The program you are asking is several lines of code, so take a good nap, clear your head, do your best attempt at it, post your code along with any specific questions you may have. Don't forget to add full traceback if you get any.
Reply
#3
We will not write it for you.
Here's some Pseudo code to help:
  • Begin function
  • Declare constant: loss_per_month = 4
  • Enter starting weight
  • Create empty list to hold weights hint: weights = []
  • Ask Starting weight and save in cell 0 of list
  • Iterate through loop 6 times, start at 1, continue through 6
  • weights[index] = weights[index-1] - loss_per_month
  • finish loop
  • display contents of loop
Reply
#4
(Sep-14-2017, 09:12 AM)Larz60+ Wrote: We will not write it for you.
Here's some Pseudo code to help:
  • Begin function
  • Declare constant: loss_per_month = 4
  • Enter starting weight
  • Create empty list to hold weights hint: weights = []
  • Ask Starting weight and save in cell 0 of list
  • Iterate through loop 6 times, start at 1, continue through 6
  • weights[index] = weights[index-1] - loss_per_month
  • finish loop
  • display contents of loop

Thank you for at least doing this. Unfortunately, I can't remember how to do lists for the life of me. I've gone through my textbook in the chapters we've covered and couldn't find anything about it and I've been googling for help online and haven't found any clear answer on how to do it. At this rate, my homework for this class will never be done.
Reply
#5
>>> i_am_a_list = []
>>> for n in range(5):
...     i_am_a_list.append(n)
...
>>> print(i_am_a_list)
[0, 1, 2, 3, 4]
>>>
Reply
#6
>>> i_am_a_list[2]
2
>>> i_am_a_list[1:3]
[1, 2]
>>> i_am_a_list[2:]
[2, 3, 4]
>>> i_am_a_list.reverse()
>>> i_am_a_list
[4, 3, 2, 1, 0]
>>> i_am_a_list.sort()
>>> i_am_a_list
[0, 1, 2, 3, 4]
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Checking my basic understanding of coding dilans94 3 2,505 Jan-07-2019, 04:21 PM
Last Post: nilamo
  I need help on a basic coding question Presssure 1 4,188 May-23-2018, 05:12 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

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