Question

Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Bl...

Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Blinky Pinky and Clyde will get to play pinball in that month.

The function provided will increment the day of the week to the next correct day.

Function written in 3a):

def pinball(dayOfWeek, dayOfMonth) :
if dayOfMonth % 4 ==0:
return "Pinky"
if dayOfWeek == "Sunday":
return "Blinky"
elif dayOfWeek == "Monday":
return "Blinky"
elif dayOfWeek == "Tuesday":
return "Inky"
elif dayOfWeek == "Thursday":
return "Inky"
else:
return "Clyde"

function provided:

def incDay(day) :
if (day == "Sunday") :
return "Monday"
elif (day == "Monday") :
return "Tuesday"
elif (day == "Tuesday") :
return "Wednesday"
elif (day == "Wednesday") :
return "Thursday"
elif (day == "Thursday") :
return "Friday"
elif (day == "Friday") :
return "Saturday"
elif (day == "Saturday") :
return "Sunday"

function to create:

def playCount(startingDay, daysInMonth) :
# your code here

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

# Function written in 3a):

def pinball(dayOfWeek, dayOfMonth) :
   if dayOfMonth % 4 ==0:
       return "Pinky"
   if dayOfWeek == "Sunday":
       return "Blinky"
   elif dayOfWeek == "Monday":
       return "Blinky"
   elif dayOfWeek == "Tuesday":
       return "Inky"
   elif dayOfWeek == "Thursday":
       return "Inky"
   else:
       return "Clyde"

# function provided:

def incDay(day) :
   if (day == "Sunday") :
       return "Monday"
   elif (day == "Monday") :
       return "Tuesday"
   elif (day == "Tuesday") :
       return "Wednesday"
   elif (day == "Wednesday") :
       return "Thursday"
   elif (day == "Thursday") :
       return "Friday"
   elif (day == "Friday") :
       return "Saturday"
   elif (day == "Saturday") :
       return "Sunday"

# function to create:

def playCount(startingDay, daysInMonth) :
   # your code here
  
   Num_of_days = {"Pinky":0, "Blinky":0, "Inky":0, "Clyde": 0}
   day = startingDay
   for i in range(daysInMonth):
       Num_of_days[pinball(day,i)] += 1
       day = incDay(day)

   return Num_of_days

print("startingDay is Sunday and daysInMonth = 31")
print(playCount("Sunday",31))

print("startingDay is Tuesday and daysInMonth = 28")
print(playCount("Tuesday",28))

#############OUTPUT##################

startingDay is Sunday and daysInMonth = 31
{'Pinky': 8, 'Blinky': 7, 'Clyde': 9, 'Inky': 7}
startingDay is Tuesday and daysInMonth = 28
{'Pinky': 7, 'Blinky': 6, 'Clyde': 9, 'Inky': 6}

Add a comment
Know the answer?
Add Answer to:
Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Bl...
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
  • Coding in C++ Write a program using structures to store the following weather information: - Month...

    Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...

  • Births are not, as you might think, evenly distributed across the days of the week. The...

    Births are not, as you might think, evenly distributed across the days of the week. The table includes the average numbers of babies born on each day of the week in 2014 Day Sunday Monday Tuesday Wednesday Thursday Friday Saturday Births 7,371 11,805 12,630 12,155 12,112 12,042 8,344 The boxplots are based on more detailed data from Toronto, Canada: the number of births on each of the 365 days in a year, grouped by day of the week. jo Monday...

  • Why isnt my MyCalender.java working? class MyCalender.java : package calenderapp; import java.util.Scanner; public class MyCalender {...

    Why isnt my MyCalender.java working? class MyCalender.java : package calenderapp; import java.util.Scanner; public class MyCalender { MyDate myDate; Day day; enum Day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }    public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.println("Enter date below :"); System.out.println("Enter day :"); int day = sc.nextInt(); System.out.println("Enter Month :"); int month = sc.nextInt(); System.out.println("Enter year :"); int year = sc.nextInt(); MyDate md = new MyDate(day, month, year); if(!md.isDateValid()){ System.out.println("\n Invalid date . Try...

  • Zeller's congruence is an algorithm developed to calculate the day of the week. Write a program...

    Zeller's congruence is an algorithm developed to calculate the day of the week. Write a program that prompts the user to enter a year, month, day of month and it displays the name of the week. Here is my source code. I need it broke down into a flowchart. public static void main(String[] args) {        //all variables are initialized to 0, because local variables require at least an initial value before use        Scanner input = new...

  • Please help me write a program flowchart! I have been struggling for quite some time, and...

    Please help me write a program flowchart! I have been struggling for quite some time, and mainly I need the answer. Thank you ! room Hef main(); #run order: date waitlist budget result numGuests = guests() weekDay = date() waitList = waitlist(weekDay) hotelBudget - budget() print("Day:, displayWeek (weekDay)) print("Budget: ", hotel Budget) result(waitList, numGuests, room(numGuests, hotelBudget)) def guests(): numGuests - while numGuests <=@ or numGuests > 8: try: numGuests = (int(input("Please enter number of guests:"))) if numGuests > 8: print("Maximum...

  • 3. A post office requires different numbers of full-time employees on different days of the week....

    3. A post office requires different numbers of full-time employees on different days of the week. Each full-time employee must work five consecutive days and then receive two days off. The following table gives the number of employees required on each day of the week is specified. The post office would like to minimize the number of full-time employees needed to satisfy these constraints. Day No. of full-time employees required 15 Monday Tuesday Wednesday Thursday Friday Saturday Sunday 16 11...

  • Write a C++ Program. You have a following class as a header file (dayType.h) and main()....

    Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public:     static string weekDays[7];     void print() const;     string nextDay() const;     string prevDay() const;     void addDay(int nDays);     void setDay(string d);     string getDay() const;     dayType();     dayType(string d); private:     string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...

  • Write a function to determine the day of the week a person was born given his...

    Write a function to determine the day of the week a person was born given his or her birthday. The following steps should be used to find the day of the week corresponding to any date from 1901 through the present. In the following explanation, the following terms will be helpful. Assuming I type in my birthday as "6 10 1981": The month is 6. The day of the month is 10. The year is 1981. Find the number of...

  • C++ Only. Don't use other libraries other than #include <iostream> and using namespace std; Write a...

    C++ Only. Don't use other libraries other than #include <iostream> and using namespace std; Write a function maxTemp which takes a filename as string argument and returns the maximum temperature as float type for the week. Input file will contain temperature readings for each day of the week. Your function should read each line from the given filename, parse and process the data, and return the required information. Your function should return the highest temperature for the whole week. Empty...

  • hi can you please use simple c++, and write with using "Arrays" and include "ctype.h, string,iostream" a...

    hi can you please use simple c++, and write with using "Arrays" and include "ctype.h, string,iostream" and use "while" "||&& operators" "for" "if" statements, ,this should be written in c++101, thanks Function Return Type Description Return size size size t max_size size t Return maximum size (always match with size) Test whether array is empty bool empty Fill array with value fill void void Exchanges the content of the array by the content of x, which is another array object...

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