Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
create trace table from algorithm
0
votes
asked
Nov 9, 2019
by
anonymous
1
flag
def someMaths( aNumber ):
newNumber = aNumber // 1000
newNumber = newNumber % 7
return newNumber
def dayOfWeek( dayNumber ):
if dayNumber == 0:
dayString = "Sunday"
elif dayNumber == 1:
dayString = "Monday"
elif dayNumber == 2:
dayString = "Tuesday"
elif dayNumber == 3:
dayString = "Wednesday"
elif dayNumber == 4:
dayString = "Thursday"
elif dayNumber == 5:
dayString = "Friday"
elif dayNumber == 6:
dayString = "Saturday"
return dayString
def daysFrom( oldDayNumber, howManyDays ):
nextDay = ( oldDayNumber + howManyDays ) % 7
dayString = dayOfWeek( nextDay )
return dayString
studentNumber = int( input( "Please enter your student number: " ) )
calculatedNumber = someMaths( studentNumber )
print( calculatedNumber )
dayOne = dayOfWeek( calculatedNumber )
print( "The day of the week with that number is " + dayOne + "." )
dayTwo = daysFrom( calculatedNumber, 3 )
print( "3 days after it will be " + dayTwo + "." )
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
1 Answer
0
votes
answered
Nov 15, 2019
by
Artem
(
330
points)
Replace dayOfWeek function by tuple
dayOfWeek = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
and use the dayOfWeek[n] instead of function call dayOfWeek(n)
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...