Question

use python to write You want to figure out how many days you spent in your...

use python to write

You want to figure out how many days you spent in your highschool education. Assign the start and the end year for your highschool studies (or you can make up two years that are at least 2-4 years apart). For simplicity, we will not worry about the months or the actual dates. Write a program that will display how many days you had in that range (inclusive of both the years). For example, if you started your undergrad in 2015 and finished in 2016, you will have 731 days.

[ Hint: you will need to write a loop that runs with that range. Within that loop, you will need to check for leap year. Remember -- our program needs to be general, and so while we have a specific application in mind, the loop we write should be able to work on any two years, no matter how far apart.]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Code Screenshot :

- total days.py - D:/Coding/Python/total days.py (3.7.4) File Edit Format Run Options Window Help #Initialize start and finis

Sample Output :

RESTART: D: /Coding/Python/total days.py 731 Total days >>> |

Program Code to Copy

#Initialize start and finish years
start = 2015
finish = 2016

total = 0
for i in range(start,finish+1):
#Add days
total += 365
#Add 1 more day, if leap year
if i%400==0 or (i%4==0 and i%100!=0):
total+=1
print('Total days ',total)

Add a comment
Know the answer?
Add Answer to:
use python to write You want to figure out how many days you spent in your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3. Using no date-specific Java libraries, write a program that computes the number of days between...

    3. Using no date-specific Java libraries, write a program that computes the number of days between any two dates (inclusive). You must take into account leap years. The rule for computing a leap year is as follows: If the year is divisible by 4 it is a Leap Year ... Unless the year is divisible by 100, then it is _not_ a Leap Year ... Unless the year is divisible by 400, then it _is_ a Leap Year. During a...

  • PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program tha...

    PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program that reads a values for hour and minute from the input test file timeData.txt . The data read for valid hour and valid minute entries. Assume you are working with a 24 hour time format. Your program should use functions called validateHour and validateMinutes. Below is a sample of the format to use for your output file  timeValidation.txt :   ...

  • # 3. PUT IN PYTHON CODE # Write a program that prints a count of how...

    # 3. PUT IN PYTHON CODE # Write a program that prints a count of how many occurrences of the letter "a" # there are in q. Do to this you will have to use a loop within a loop. q = ["apple", "beans", "orange", "tangerine", "butter", "watermelon", "vinegar"] # Type your answer here:

  • PYTHON I need some basic python homework help! Write a program that prompts the user to...

    PYTHON I need some basic python homework help! Write a program that prompts the user to enter a date (day, month, and year). Your program will print out the day of the week for that date. You do not need to validate the input. That means you can assume: the year will be entered as a four-digit number in the range 1900 through 2100 inclusive. the month will be one of the strings "January", "February", . . ., "December". the...

  • Please use Python for this program Random Number File Writer Write a program that writes a...

    Please use Python for this program Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range 1 through 500. The program should let the user specify how many random numbers to put into the file. The name of the file to write to should be 'random.txt'. Submit the random.txt file generated by your program with the assignment. Sample program execution: Python 3.4.3 Shell Eile Edit...

  • Write a python program to print a poem of your own choice. Then count how many...

    Write a python program to print a poem of your own choice. Then count how many words in each line, use a print statement to add the number of words in each line and display it. Hint: use print(3+5+4+6), for example. My poem: 'Tis better to have loved and lost Than never to have loved at all.'

  • Write a program in Python that computes the interest accrued on an account. You can modify...

    Write a program in Python that computes the interest accrued on an account. You can modify the “futval.py” program given in Chapter 2 to accomplish it. Your program should use a counted loop rather than a formula. It should prompt the user to enter the principal amount, the yearly interest rate as a decimal number, the number of compounding periods in a year, and the duration. It should display the principal value at the end of the duration. To compute...

  • Write a Python program that prints a name as shown in the image below. The program...

    Write a Python program that prints a name as shown in the image below. The program asks the user to enter a name and how many time the user wants to display the name.. You need two to input two integer values. First, for repeating name in a row. Second, for number of rows. In total, your program will have three inputs. Add three comment lines at start of the program, which shows program purpose, your name and date. Hint:...

  • Please write a Java program that ask the user how many beers he or she expects...

    Please write a Java program that ask the user how many beers he or she expects to consume each day, on average, as well as the average amount of money he or she spends on a single 12-ounce can of beer. Studies have shown that, on average, someone who consumes a single 12-ounce can of beer every day without compensating for the calorie intake through diet modifications or extra exercise, will gain approximately 15 pounds in one year. You can...

  • Write a C# program that prints a calendar for a given year. Call this program calendar....

    Write a C# program that prints a calendar for a given year. Call this program calendar. The program prompts the user for two inputs:       1) The year for which you are generating the calendar.       2) The day of the week that January first is on, you will use the following notation to set the day of the week:             0 Sunday                     1 Monday                   2 Tuesday                   3 Wednesday       4 Thursday                 5 Friday                      6 Saturday Your program should...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT