Python Forum
write a program which prints the day in english
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
write a program which prints the day in english
#9
(Jul-24-2021, 07:34 PM)ben1122 Wrote: I guess with my code its impossible to do it, I have to use a new code for it? i mean, restart it.
No you just need to add the user input to what Yoriz has showed you.
I would add a function like to make cleaner,and the point is that no if,elif is needed for this.
import calendar

def day_of_week(year, month, day):
    weekday = calendar.weekday(year, month, day)
    print(f"Day of the week in english is {calendar.day_name[weekday]}")

if __name__ == '__main__':
    year = int(input("Please choose your year: "))
    month = int(input("Please choose your month: "))
    day = int(input("Please choose your day: "))
    day_of_week(year, month, day)
Test.
Output:
Please choose your year: 2021 Please choose your month: 7 Please choose your day: 24 Day of the week in english is Saturday
Reply


Messages In This Thread
RE: write a program which prints the day in english - by snippsat - Jul-24-2021, 08:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  zfill prints extra et the end of a var tester_V 4 935 Mar-24-2023, 06:59 PM
Last Post: tester_V
  (python) Can i get some help fixing a English to Morse translator? Pls AlexPython 7 1,659 Sep-12-2022, 02:55 AM
Last Post: AlexPython
  variable prints without being declared. ClockPillow 2 1,840 Jul-11-2021, 12:13 AM
Last Post: ClockPillow
  More non english characters johnboy1974 8 4,569 Apr-23-2021, 02:35 PM
Last Post: snippsat
  Output prints Account.id at the end? LastStopDEVS 5 2,861 Dec-19-2020, 05:59 AM
Last Post: buran
  I have an index error inline 76 but I write the program in a way that cant reach tha abbaszandi 2 2,100 Nov-13-2020, 07:43 AM
Last Post: buran
  Try/Exept prints only ones tester_V 11 3,964 Nov-03-2020, 02:38 AM
Last Post: tester_V
  loop only prints last character. mcmxl22 1 1,751 Feb-17-2020, 02:36 AM
Last Post: menator01
  How to write a script to execute a program need passing additional input? larkypython 2 2,598 Nov-23-2019, 04:38 AM
Last Post: larkypython
  English interpretation of the following file handing snippet mortch 5 3,227 May-30-2019, 08:10 AM
Last Post: mortch

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020