Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,601 members, 7,812,969 topics. Date: Tuesday, 30 April 2024 at 12:18 AM

Someone Help Me Solve This Python Question - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Someone Help Me Solve This Python Question (264 Views)

Basic Python Question / Can Someone Help With This Python Problems / Help With This Python Programming Assignment Please (2) (3) (4)

(1) (Reply) (Go Down)

Someone Help Me Solve This Python Question by Kingju: 4:36pm On Apr 13
please help if you know it:

"Let's write a small program that calculates how many years, weeks and days can be formed from the given integer variable days, printing the result on screen as in the following example:

700 days equals 1 years, 47 weeks and 6 days.
Hints!

The remainder operator % is a good way to get the "overflow" when calculating how many days remain after the complete years are removed."
Re: Someone Help Me Solve This Python Question by Karleb(m): 5:23pm On Apr 13
Do it with math first first then convert it to python.

Play around with the modulus sign to actually understand how it works.

This question is simple, don't cheat.

1 Like

Re: Someone Help Me Solve This Python Question by KushLyon(m): 10:28pm On Apr 13
1. Find a way to get the number of years from that 700. How do you get that "1 year" from 700 days?

2. When you have figured it out, make sure the result is actually 1 and not something like 1.91 (only the 1 is needed, round it down).

3. Figure out a way to get the total number of days in the year result. If it's 1 year, how many days are in a year? If it's 2 years, how many days are in 2 years? Do the calculation.

4. After you have gotten the result, you now have to calculate the number of days remaining from that initial 700 days. One way to do it is to use the modulus operator (%) but you can also use subtraction.

5. When you have gotten the remaining days, you can now calculate the weeks. Calculating this is similar to how you did it for the year, but remember that there are 7 days in a week.

6. After you have gotten the weeks, follow step 3 but you should now figure out the number of days in that weeks that you calculated (47 weeks). How many days are in 47 weeks? The hint for calculating this is in step 5

7. Calculate the remaining days using a similar method to the one in step 4 but remember that you're not calculating this from the initial 700 but it should be calculated from the remaining days value you got in step 4.

8. The answer you get in step 7 is the number of days (6 days)

As someone else said, first do the math with a pen and paper. If the modulus operator is confusing to use while doing the math, use subtraction. The problem is very easy, just try to solve it on your own rather than looking for a direct answer. I have given you more than enough hints, follow it step by step and understand it. Good luck
Re: Someone Help Me Solve This Python Question by Kingju: 11:55am On Apr 14
Karleb:
Do it with math first first then convert it to python.

Play around with the modulus sign to actually understand how it works.

This question is simple, don't cheat.

Please can I get your contact, I would like to call you please
Re: Someone Help Me Solve This Python Question by Kingju: 11:59am On Apr 14
KushLyon:
1. Find a way to get the number of years from that 700. How do you get that "1 year" from 700 days?

2. When you have figured it out, make sure the result is actually 1 and not something like 1.91 (only the 1 is needed, round it down).

3. Figure out a way to get the total number of days in the year result. If it's 1 year, how many days are in a year? If it's 2 years, how many days are in 2 years? Do the calculation.

4. After you have gotten the result, you now have to calculate the number of days remaining from that initial 700 days. One way to do it is to use the modulus operator (%) but you can also use subtraction.

5. When you have gotten the remaining days, you can now calculate the weeks. Calculating this is similar to how you did it for the year, but remember that there are 7 days in a week.

6. After you have gotten the weeks, follow step 3 but you should now figure out the number of days in that weeks that you calculated (47 weeks). How many days are in 47 weeks? The hint for calculating this is in step 5

7. Calculate the remaining days using a similar method to the one in step 4 but remember that you're not calculating this from the initial 700 but it should be calculated from the remaining days value you got in step 4.

8. The answer you get in step 7 is the number of days (6 days)

As someone else said, first do the math with a pen and paper. If the modulus operator is confusing to use while doing the math, use subtraction. The problem is very easy, just try to solve it on your own rather than looking for a direct answer. I have given you more than enough hints, follow it step by step and understand it. Good luck

Thank you, please can I get your contact
Re: Someone Help Me Solve This Python Question by Alphabyte3: 12:07pm On Apr 14
Kingju:


Thank you, please can I get your contact

U could look at this Google helps

.https://codescracker.com/python/program/python-convert-days-in-years-weeks-days.htm
Re: Someone Help Me Solve This Python Question by Kingju: 1:09pm On Apr 14
Alphabyte3:


U could look at this Google helps

.https://codescracker.com/python/program/python-convert-days-in-years-weeks-days.htm

I too love my nairaland people, thank you boss
Re: Someone Help Me Solve This Python Question by Kingju: 1:21pm On Apr 14
Alphabyte3:


U could look at this Google helps

.https://codescracker.com/python/program/python-convert-days-in-years-weeks-days.htm
.
Can I reach you on phone please, I need someone who has knowledge of python please
Re: Someone Help Me Solve This Python Question by KushLyon(m): 1:23pm On Apr 14
Kingju:


Thank you, please can I get your contact

Send me a mail and I will reply with my number
Re: Someone Help Me Solve This Python Question by Kingju: 1:48pm On Apr 14
KushLyon:


Send me a mail and I will reply with my number
done
Re: Someone Help Me Solve This Python Question by Nazgul: 2:17pm On Apr 14
Kingju:
please help if you know it:

"Let's write a small program that calculates how many years, weeks and days can be formed from the given integer variable days, printing the result on screen as in the following example:

700 days equals 1 years, 47 weeks and 6 days.
Hints!

The remainder operator % is a good way to get the "overflow" when calculating how many days remain after the complete years are removed."
Do it this way...

#calculate_years_weeks_days(700)

DAYS_IN_WEEK = 7

# Function to find
# year, week, days

def find( number_of_days ):

# Assume that years is

# of 365 days

year = int(number_of_days / 365)

week = int((number_of_days % 365) /

DAYS_IN_WEEK)

days = (number_of_days % 365) % DAYS_IN_WEEK

print("years = ",year,

"\nweeks = ",week,

"\ndays = ",days)
Re: Someone Help Me Solve This Python Question by ekehopp2: 5:23pm On Apr 14
Kingju:
please help if you know it:

"Let's write a small program that calculates how many years, weeks and days can be formed from the given integer variable days, printing the result on screen as in the following example:

700 days equals 1 years, 47 weeks and 6 days.
Hints!

The remainder operator % is a good way to get the "overflow" when calculating how many days remain after the complete years are removed."
You can easily use ChatGPT or Google Gemini for stuff like this.
Also start doing Leetcode regularly to build your own competency in tackling these sort of DSAs.
Re: Someone Help Me Solve This Python Question by stevenson007: 8:13pm On Apr 14
My solution will be

(1) (Reply)

Care To Run A Thrift Organization?, Thrift And Loan Management App,cus / How To Earn $100 Daily From Home / Microservices Online Certification | Microservice Certification- Dotnettricks

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.