Question

Python Coding problem

Tracking the Shipment Dates

Radan Logistics is a mid sized Shipping Company known for its Customer oriented delivery services. The Company Management intended to place an information kiosk in their Head Office which would help their Customers to fetch all the desired information with regards to their shipment. One such vital information that Customers would prefer to know is the details of the working days of the Company which would help them track their shipments.


Help the Management write a program for the kiosk, that when given the start day, number of days ‘n’ and the start date, will output the dates of the ‘n’ business days (excluding Saturday and Sunday).


Input Format :

 The first line of input is a String, the start day.

The second line of the input is the number of days.

Third line is a string, that correponds to the start date of the shipment.


Output Format :

Output is list of dates of 'n' working days seperated by new line.



Sample Input 1 :

Monday

7

03-12-2007

Sample Output 1 :

04-12-2007

05-12-2007

06-12-2007

07-12-2007

10-12-2007

11-12-2007


Sample Input 2 :

Thursday

10

25-02-2012

Sample Output 2 :

26-02-2012

29-02-2012

01-03-2012

02-03-2012

03-03-2012

04-03-2012

07-03-2012

08-03-2012

09-03-2012

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

start_day=input()

no_of_days=input()

shipment_date=input()

day=shipment_date.split("-")[0]

month=shipment_date.split("-")[1]

year=shipment_date.split("-")[2]

if(start_day=="Monday"):

    count=0

    j=0

    day=str(int(day)+1)

    for i in range(0,100,1):

        if ((count - 4) % 7 == 0 or (count - 5) % 7 == 0):

            day = str(int(day) + 1)

            count += 1

            continue

        #day = str(int(day) + 1)


        if (int(year) % 4 == 0):

            if (int(month) == 2):

                if (int(day) > 29):

                    day = str(1);

                    month=str(int(month)+1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5

                  or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                        if (int(day) > 31):

                            day = str(1);

                            month=str(int(month)+1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)





        elif(int(year) % 4 != 0):

            if (int(month) == 2):

                if (int(day) > 28):

                    day = str(1)

                    month=str(int(month)+1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5 or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                if (int(day) >31):

                    day = str(1);

                    month=str(int(month)+1)

            elif(int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month=str(int(month)+1)



        print(day+"-"+month+"-"+year)

        j+=1

        if(j==int(no_of_days)-1):

            break


        day = str(int(day) + 1)

        count+=1


elif(start_day=="Tuesday"):

    count = 0

    j = 0

    day = str(int(day) + 1)

    for i in range(0, 100, 1):

        if ((count - 3) % 7 == 0 or (count - 4) % 7 == 0):

            day = str(int(day) + 1)

            count += 1

            continue

        # day = str(int(day) + 1)


        if (int(year) % 4 == 0):

            if (int(month) == 2):

                if (int(day) > 29):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5

                  or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)





        elif (int(year) % 4 != 0):

            if (int(month) == 2):

                if (int(day) > 28):

                    day = str(1)

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5 or int(month) == 7 or int(month) == 8 or int(

                    month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)


        print(day + "-" + month + "-" + year)

        j += 1

        if (j == int(no_of_days) - 1):

            break


        day = str(int(day) + 1)

        count += 1


elif(start_day=="Wednesday"):

    count = 0

    j = 0

    day = str(int(day) + 1)

    for i in range(0, 100, 1):

        if ((count - 2) % 7 == 0 or (count - 3) % 7 == 0):

            day = str(int(day) + 1)

            count += 1

            continue

        # day = str(int(day) + 1)


        if (int(year) % 4 == 0):

            if (int(month) == 2):

                if (int(day) > 29):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5

                  or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)





        elif (int(year) % 4 != 0):

            if (int(month) == 2):

                if (int(day) > 28):

                    day = str(1)

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5 or int(month) == 7 or int(month) == 8 or int(

                    month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)


        print(day + "-" + month + "-" + year)

        j += 1

        if (j == int(no_of_days) - 1):

            break


        day = str(int(day) + 1)

        count += 1



elif(start_day=="Thrusday"):

    count = 0

    j=0;

    day = str(int(day) + 1)

    for i in range(0,100,1):

        if ((count - 1) % 7 == 0 or (count - 2) % 7 == 0):

            day = str(int(day) + 1)

            count += 1

            continue

        if (int(year) % 4 == 0):

            if (int(month) == 2):

                if (int(day) > 29):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5

                  or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)





        elif (int(year) % 4 != 0):

            if (int(month) == 2):

                if (int(day) > 28):

                    day = str(1)

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5

                  or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9

                  or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)

        print(day + "-" + month + "-" + year)

        j+=1

        if(j==int(no_of_days)-1):

            break


        day = str(int(day) + 1)

        count += 1


elif(start_day=="Friday"):

    count = 0

    j = 0

    day = str(int(day) + 1)

    for i in range(0, 100, 1):

        if ((count - 0) % 7 == 0 or (count - 1) % 7 == 0):

            day = str(int(day) + 1)

            count += 1

            continue

        # day = str(int(day) + 1)


        if (int(year) % 4 == 0):

            if (int(month) == 2):

                if (int(day) > 29):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5

                  or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)





        elif (int(year) % 4 != 0):

            if (int(month) == 2):

                if (int(day) > 28):

                    day = str(1)

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5 or int(month) == 7 or int(month) == 8 or int(

                    month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)


        print(day + "-" + month + "-" + year)

        j += 1

        if (j == int(no_of_days) - 1):

            break


        day = str(int(day) + 1)

        count += 1


elif(start_day=="Saturday"):

    count = 0

    j = 0

    day = str(int(day) + 1)

    for i in range(0, 100, 1):

        if ((count) % 7 == 0 or (count - 6) % 7 == 0):

            day = str(int(day) + 1)

            count += 1

            continue

        # day = str(int(day) + 1)


        if (int(year) % 4 == 0):

            if (int(month) == 2):

                if (int(day) > 29):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5

                  or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)





        elif (int(year) % 4 != 0):

            if (int(month) == 2):

                if (int(day) > 28):

                    day = str(1)

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5 or int(month) == 7 or int(month) == 8 or int(

                    month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)


        print(day + "-" + month + "-" + year)

        j += 1

        if (j == int(no_of_days) - 1):

            break


        day = str(int(day) + 1)

        count += 1


elif(start_day=="Sunday"):

    count = 0

    j = 0

    day = str(int(day) + 1)

    for i in range(0, 100, 1):

        if ((count-5) % 7 == 0 or (count - 6) % 7 == 0):

            day = str(int(day) + 1)

            count += 1

            continue

        # day = str(int(day) + 1)


        if (int(year) % 4 == 0):

            if (int(month) == 2):

                if (int(day) > 29):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5

                  or int(month) == 7 or int(month) == 8 or int(month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)





        elif (int(year) % 4 != 0):

            if (int(month) == 2):

                if (int(day) > 28):

                    day = str(1)

                    month = str(int(month) + 1)

            elif (int(month) == 1 or int(month) == 3 or int(month) == 5 or int(month) == 7 or int(month) == 8 or int(

                    month) == 10 or int(month) == 12):

                if (int(day) > 31):

                    day = str(1);

                    month = str(int(month) + 1)

            elif (int(month) == 4 or int(month) == 6 or int(month) == 9 or int(month) == 11):

                if (int(day) > 30):

                    day = str(1);

                    month = str(int(month) + 1)


        print(day + "-" + month + "-" + year)

        j += 1

        if (j == int(no_of_days) - 1):

            break


        day = str(int(day) + 1)

        count += 1



else:

    print("Invalid day")




answered by: Satyam Keshri
Add a comment
Know the answer?
Add Answer to:
Python Coding problem
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
  • Python Coding

    Expiry DateAt Transglobal Logistics, a commodity will be accepted for shipment only if it reaches the destination before the expiry date. Find whether a commodity is accepted for shipping, based on the expiry date, departure date of the commodity from the Source port and number of days required to reach the destination port.Input Format:First line is a string that corresponds to the expiry date.Second line is a string that corresponds to the departure date of the commodity from the source...

  • Code with Java using arrays and Scanner only ( input should end with 0 to terminate...

    Code with Java using arrays and Scanner only ( input should end with 0 to terminate the program) Everyone loves to be celebrated on their birthdays. Birthday celebration can encourage positive social interaction among co-workers, foster friendship among classmates or even strengthen bond between families. Birthday graph can be display in many forms. It can a creative drawing consists of cupcakes, balloons, candles with names, or it can be in the form of simple bar chart to indicate the birthday...

  • Python coding

    Palindromic CargoThe Gocargo carriers are celebrating their digitization process, which has given them a lot of benefits and ease of work for their employees. In account of this initiative they are offering their customers to ship their cargoes free of cost, if and only if the cargo names are palindromic.Given a cargo name, check whether the cargo name is a palindrome or not. Consider only alphabets while checking, remove special characters and spaces.Note : Define a function named check Palindrome()...

  • Java code BIRTHDAY GRAPH5 4B Input Standard input Output Standard output Topic Array & Array Processing...

    Java code BIRTHDAY GRAPH5 4B Input Standard input Output Standard output Topic Array & Array Processing Birthday Graph Problem Description Everyone loves to be celebrated on their birthdays. Birthday celebration can encourage positive social E interaction among co-workers, foster friendship among classmates or even strengthen bond between E BOBO Birthday graph can be display in many forms. It can a creative drawing consists of cupcakes, balloons, UU candles with names, or it can be in the form of simple bar...

  • Python help it is a grade 12 course def find astrological sign(month, date): (int, int)-str Given...

    Python help it is a grade 12 course def find astrological sign(month, date): (int, int)-str Given two int values represent ing a month and a date, return a 3-character string that gives us what star sign a person born in that month and on that date belongs to, Use the SIGNS string (already defined for you at the top of this file) to figure this out. NOTE FROM BOB: A lot of string slicing to do here. It looks like...

  • The code should work exactly the same as given example. The files: ---------------------------------------------------...

    The code should work exactly the same as given example. The files: ---------------------------------------------------------------------------------------------------- -------- FILE NAME ------- album0 ---------- FILE ------- <album> 323 Licensed to Ill Beastie Boys 25.0 </album> <album> 70 Enter the Wu_Tang: 36 Cham... Wu Tang Clan 25.99 </album> turning to Alice, she went on, `What's your name, child?' and there stood the Queen in front of them, with her arms folded, <album> 115 Daydream Nation Sonic Youth 5.0 </album> <album> 414 52nd Street Billy Joel 25.75...

  • CODING IN JAVA Dates are printed in several common formats. Two of the more common formats...

    CODING IN JAVA Dates are printed in several common formats. Two of the more common formats are: 07/21/55 and July 21, 1955 Write a program that reads a date in the first format and prints that date in the second format. Prompt the user and accept user input for the date in MM/DD/YYYY format. Retrieve the month portion of the date entered and convert it to an integer. Do the same thing for day and year Create a string named...

  • Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART...

    Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART A PART B Assignment 1 #include <iostream> #include <string> #include <fstream> #include <iomanip> #include <stdio.h> #include <ctype.h> #include <string.h> #include <algorithm> using namespace std; /** This structure is to store the date and it has three integer fields **/ struct Date{    int day;    int month;    int year; }; /** This structure is to store the size of the box and it...

  • anyString.substr(x, n) - Returns a copy of a substring. The substring is n characters long and...

    anyString.substr(x, n) - Returns a copy of a substring. The substring is n characters long and begins at position x of anyString. Write a program that reads a string from the user containing a date in the format mm/dd/yyyy. You have to use above substring method to extract the various fields from the format. It should print the date in the form Month Date, Year. Validate:  Exit the program with error message as “Invalid date format” if length of...

  • The file containing the JAVA files, pseudocode file and doc file that have written for this...

    The file containing the JAVA files, pseudocode file and doc file that have written for this lab. Preamble The file releasedates.txt contains a list of video games and their release dates. Each line of the file contains the release date, a tab character, and then the name. The list is currently totally unsorted. The object of today's lab is to write a series of methods that allow us to perform the following tasks: read contents from a file and store...

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