CodeSolved

A comprehensive source of programming questions and exercises

Name of the weeks of the week

Practice Easy 1608/ Download 833 Views

Write a program that shows its name by receiving the day number of the week

Input: 1
Shaanbe

Input: 3
Doshanbe

21 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
def week():
    """
    تابع روز های هفته را بر اساس ترتیب اعداد چاپ میکند 
    """
    while True:
        try:
            user_input = int(input("please enter a number between 1 and 7(exit=0) :"))
            if user_input == 0: # If it is zero out of the program
                print("good bye...")
                break           
            
            if not user_input in range(1,8): # If it wasn't between one and 7
                print("The number must be between 1 and 7⛔")
                
            match user_input:                       
                case 1:print("saturday")
                case 2:print("sunday")
                case 3:print("monday")
                case 4:print("tuesday")
                case 5:print("wednesday")
                case 6:print("thursday")
                case 7:print("friday")
                
        except ValueError: # Receive Error text if the application is logged but the program does not stop
            print("please enter a integer amount⛔")
week() # Farakhani
# Receive Input
i=input("input: ")
# Define the weeks of the week with dictionary
hafte={"1":"shanbe","2":"yek shanbe","3":"do shanbe","4":"se shanbe"
,"5":"chahar shanbe","6":"panj shanbe","7":"jome"}
# Displaying the output
print(hafte[i])
days={"1":"shanbe","2":"yek_shanbe","3":"do_shanbe","4":"se_shanbe"
,"5":"chhar_shanbe","6":"panj_shanbe","7":"jome"}
a= input()
print(days.get(a)
User 2201 Download Python
# Getting the number of the day of the week from the user
x=int(input('Shomareh rooz mored nazar ra vared konid:'))
if x == 1:
    print('Shanbeh')
elif x == 2:
    print('Yekshanbeh')
elif x == 3:
    print('Doshanbeh')
elif x == 4:
    print('Seshanbeh')
elif x == 5:
    print('Chaharshanbeh')
elif x == 6:
    print('Panjshanbeh')
elif x == 7:
    print('Jomee')
Ati.hamedi Download Python
while True:
    try:
        day = int(input("Enter the number:"))
        if day == 1:
            print("Shanbe")
        elif day == 2:
            print("yek Shanbe")
        elif day == 3:
            print("do Shanbe")
        elif day == 4:
            print("se Shanbe")
        elif day == 5:
            print("chahar Shanbe")
        elif day == 6:
            print("panj Shanbe")
        elif day == 7:
            print("jome")
        else:
            print("Shoma faghat mitavanid adade yek ta haft ra vared namayid.")
    except:
        print("Please enter a number.")
Yasin.hn Download Python
function daysOfWeek(daynumber) {
    const days =['Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday'];
    if (daynumber >=8) {
        return 'your number is undefined';
    }else{
        daynumber--;
        let result=days[daynumber];
        return result;
    }
}
Parsa Download JavaScript
number = int(input("enter your number: "))
if number == 1:
    print("shanbe")
elif number == 2:
    print("yekshanbe")
elif number == 3:
    print("doshanbe")
elif number == 4:
    print("seshanbe")
elif number == 5:
    print("chaharshanbe")
elif number == 6:
    print("pangshanbe")
elif number == 7:
    print("jomme")
else:        
    print("the number must be between 1 and 7")
User 291 Download Python
<< Previous page 1 2 3 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close