SlideShare a Scribd company logo
Exercise 2 Write a Python function which first accepts a number from the range of [1,7] where
each number represents one day of the a week where the number 1 is for Monday and 7 for
Sunday. Once the number is accepted from the user, you should print the name of the week on
the screen. If the input number is not in the range of [1.7], your function should print the following:
input number x is not valid where x is the input number. Your function does not have to retum any
value in this exercise Your function should work for each of the numbers properly in the range of [1
,7] For example, if the number is entered as 8 by the user, then your function should print input
number 8 is not valid. * Implement your solution for Exercise 2 in this cell def printday(number): #
you need to implement the code block for this function below If assuming that the value of the
input variable: number is given to you. if number =1 : print("Monday") elif # cosplete the rest of this
function by yoursetf II Now the function is defined, we can call that function below. # But before
calling that function, let's first take on input value I from the user and make sure that that number
is between 1 and 7 mynumber =0 while (mynumber <1 ) or (mynumber >7 ) : mynumber -
int(input("Please enter a nuaber in the range of [1,7]:) ) if (mynumber <1 ) or (iynumber >7 ):
print("Input number", mynumber, "is not vaild") # Now we can call the function that we have
implemented above. printday(mynumber) Please enter a number in the range of [1,7]:2

More Related Content

Similar to Exercise 2 Write a Python function which first accepts a num.pdf

I need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdfI need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
pratyushraj61
 
Literary Genre MatrixPart 1 Matrix FictionNon-fiction.docx
Literary Genre MatrixPart 1 Matrix FictionNon-fiction.docxLiterary Genre MatrixPart 1 Matrix FictionNon-fiction.docx
Literary Genre MatrixPart 1 Matrix FictionNon-fiction.docx
jeremylockett77
 
I need help getting my code to work (code is at the bottom)1.3.pdf
I need help getting my code to work (code is at the bottom)1.3.pdfI need help getting my code to work (code is at the bottom)1.3.pdf
I need help getting my code to work (code is at the bottom)1.3.pdf
pratyushraj61
 
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxCMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
clarebernice
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
vrickens
 

Similar to Exercise 2 Write a Python function which first accepts a num.pdf (16)

Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python_Functions.pdf
Python_Functions.pdfPython_Functions.pdf
Python_Functions.pdf
 
ForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptxForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptx
 
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdfI need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
 
python.pdf
python.pdfpython.pdf
python.pdf
 
ch-3 funtions - 1 class 12.pdf
ch-3 funtions - 1 class 12.pdfch-3 funtions - 1 class 12.pdf
ch-3 funtions - 1 class 12.pdf
 
Introduction-to-Iteration (2).pptx
Introduction-to-Iteration (2).pptxIntroduction-to-Iteration (2).pptx
Introduction-to-Iteration (2).pptx
 
Functions
FunctionsFunctions
Functions
 
Literary Genre MatrixPart 1 Matrix FictionNon-fiction.docx
Literary Genre MatrixPart 1 Matrix FictionNon-fiction.docxLiterary Genre MatrixPart 1 Matrix FictionNon-fiction.docx
Literary Genre MatrixPart 1 Matrix FictionNon-fiction.docx
 
Programada chapter 4
Programada chapter 4Programada chapter 4
Programada chapter 4
 
I need help getting my code to work (code is at the bottom)1.3.pdf
I need help getting my code to work (code is at the bottom)1.3.pdfI need help getting my code to work (code is at the bottom)1.3.pdf
I need help getting my code to work (code is at the bottom)1.3.pdf
 
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxCMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
 
Python Exam (Questions with Solutions Done By Live Exam Helper Experts)
Python Exam (Questions with Solutions Done By Live Exam Helper Experts)Python Exam (Questions with Solutions Done By Live Exam Helper Experts)
Python Exam (Questions with Solutions Done By Live Exam Helper Experts)
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical
 
Chapter 1.ppt
Chapter 1.pptChapter 1.ppt
Chapter 1.ppt
 

More from acupressuresujok

FAST university has hired you to make an operating system fo.pdf
FAST university has hired you to make an operating system fo.pdfFAST university has hired you to make an operating system fo.pdf
FAST university has hired you to make an operating system fo.pdf
acupressuresujok
 
FAOFunded Aquaponics Project Launched In Barbados Barbados .pdf
FAOFunded Aquaponics Project Launched In Barbados Barbados .pdfFAOFunded Aquaponics Project Launched In Barbados Barbados .pdf
FAOFunded Aquaponics Project Launched In Barbados Barbados .pdf
acupressuresujok
 
Famoso por sus impactantes anuncios Benetton comenz en 195.pdf
Famoso por sus impactantes anuncios Benetton comenz en 195.pdfFamoso por sus impactantes anuncios Benetton comenz en 195.pdf
Famoso por sus impactantes anuncios Benetton comenz en 195.pdf
acupressuresujok
 
FACT SUMMARY Waddell and Rustin entered partners When the p.pdf
FACT SUMMARY Waddell and Rustin entered partners When the p.pdfFACT SUMMARY Waddell and Rustin entered partners When the p.pdf
FACT SUMMARY Waddell and Rustin entered partners When the p.pdf
acupressuresujok
 
FA es un 80 aos hombre que se presenta al Hospital de la A.pdf
FA es un 80 aos hombre que se presenta al Hospital de la A.pdfFA es un 80 aos hombre que se presenta al Hospital de la A.pdf
FA es un 80 aos hombre que se presenta al Hospital de la A.pdf
acupressuresujok
 

More from acupressuresujok (20)

Fasttwitch fibres are preferentially affected in Duchennes.pdf
Fasttwitch fibres are preferentially affected in Duchennes.pdfFasttwitch fibres are preferentially affected in Duchennes.pdf
Fasttwitch fibres are preferentially affected in Duchennes.pdf
 
FAST university has hired you to make an operating system fo.pdf
FAST university has hired you to make an operating system fo.pdfFAST university has hired you to make an operating system fo.pdf
FAST university has hired you to make an operating system fo.pdf
 
FARO Technologies whose products incluste portable 30 measu.pdf
FARO Technologies whose products incluste portable 30 measu.pdfFARO Technologies whose products incluste portable 30 measu.pdf
FARO Technologies whose products incluste portable 30 measu.pdf
 
FAOFunded Aquaponics Project Launched In Barbados Barbados .pdf
FAOFunded Aquaponics Project Launched In Barbados Barbados .pdfFAOFunded Aquaponics Project Launched In Barbados Barbados .pdf
FAOFunded Aquaponics Project Launched In Barbados Barbados .pdf
 
Farkl sektrlerdeki 4 farkl hizmet iletmesi iin Web siteler.pdf
Farkl sektrlerdeki 4 farkl hizmet iletmesi iin Web siteler.pdfFarkl sektrlerdeki 4 farkl hizmet iletmesi iin Web siteler.pdf
Farkl sektrlerdeki 4 farkl hizmet iletmesi iin Web siteler.pdf
 
Farelerde siyah krk B beyaza b baskndr farkl bir baskn.pdf
Farelerde siyah krk B beyaza b baskndr farkl bir baskn.pdfFarelerde siyah krk B beyaza b baskndr farkl bir baskn.pdf
Farelerde siyah krk B beyaza b baskndr farkl bir baskn.pdf
 
Famoso por sus impactantes anuncios Benetton comenz en 195.pdf
Famoso por sus impactantes anuncios Benetton comenz en 195.pdfFamoso por sus impactantes anuncios Benetton comenz en 195.pdf
Famoso por sus impactantes anuncios Benetton comenz en 195.pdf
 
FACT SUMMARY Waddell and Rustin entered partners When the p.pdf
FACT SUMMARY Waddell and Rustin entered partners When the p.pdfFACT SUMMARY Waddell and Rustin entered partners When the p.pdf
FACT SUMMARY Waddell and Rustin entered partners When the p.pdf
 
Falcon Corporation compr un activo depreciable por 840 000.pdf
Falcon Corporation compr un activo depreciable por 840 000.pdfFalcon Corporation compr un activo depreciable por 840 000.pdf
Falcon Corporation compr un activo depreciable por 840 000.pdf
 
Fadeley Inc uses activhbased costing to account for its c.pdf
Fadeley Inc uses activhbased costing to account for its c.pdfFadeley Inc uses activhbased costing to account for its c.pdf
Fadeley Inc uses activhbased costing to account for its c.pdf
 
FA es un 80 aos hombre que se presenta al Hospital de la A.pdf
FA es un 80 aos hombre que se presenta al Hospital de la A.pdfFA es un 80 aos hombre que se presenta al Hospital de la A.pdf
FA es un 80 aos hombre que se presenta al Hospital de la A.pdf
 
FA illustrates D is any digit L is a lowercase letter othe.pdf
FA illustrates D is any digit L is a lowercase letter othe.pdfFA illustrates D is any digit L is a lowercase letter othe.pdf
FA illustrates D is any digit L is a lowercase letter othe.pdf
 
Factors Determining Comparative Advantage Five years ago Sc.pdf
Factors Determining Comparative Advantage Five years ago Sc.pdfFactors Determining Comparative Advantage Five years ago Sc.pdf
Factors Determining Comparative Advantage Five years ago Sc.pdf
 
Fact The following information from OBD is availabie Roquir.pdf
Fact The following information from OBD is availabie Roquir.pdfFact The following information from OBD is availabie Roquir.pdf
Fact The following information from OBD is availabie Roquir.pdf
 
f the probability distribution of a random variable X has me.pdf
f the probability distribution of a random variable X has me.pdff the probability distribution of a random variable X has me.pdf
f the probability distribution of a random variable X has me.pdf
 
f One of the secure solutions to store passwords in a data.pdf
f One of the secure solutions to store passwords in a data.pdff One of the secure solutions to store passwords in a data.pdf
f One of the secure solutions to store passwords in a data.pdf
 
F Ditributios n005 in the Riahe Tnill Question 1 3 pt de.pdf
F Ditributios n005 in the Riahe Tnill Question 1 3 pt de.pdfF Ditributios n005 in the Riahe Tnill Question 1 3 pt de.pdf
F Ditributios n005 in the Riahe Tnill Question 1 3 pt de.pdf
 
EXTRA CREDIT Write a function to be included in a sorted li.pdf
EXTRA CREDIT Write a function to be included in a sorted li.pdfEXTRA CREDIT Write a function to be included in a sorted li.pdf
EXTRA CREDIT Write a function to be included in a sorted li.pdf
 
Extrachromosomal pieces of DNA which promote transfer of gen.pdf
Extrachromosomal pieces of DNA which promote transfer of gen.pdfExtrachromosomal pieces of DNA which promote transfer of gen.pdf
Extrachromosomal pieces of DNA which promote transfer of gen.pdf
 
Eyeless D melanogasterda 4 kromozom zerindeki bir gen i.pdf
Eyeless D melanogasterda 4 kromozom zerindeki bir gen i.pdfEyeless D melanogasterda 4 kromozom zerindeki bir gen i.pdf
Eyeless D melanogasterda 4 kromozom zerindeki bir gen i.pdf
 

Recently uploaded

Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security Services
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 

Exercise 2 Write a Python function which first accepts a num.pdf

  • 1. Exercise 2 Write a Python function which first accepts a number from the range of [1,7] where each number represents one day of the a week where the number 1 is for Monday and 7 for Sunday. Once the number is accepted from the user, you should print the name of the week on the screen. If the input number is not in the range of [1.7], your function should print the following: input number x is not valid where x is the input number. Your function does not have to retum any value in this exercise Your function should work for each of the numbers properly in the range of [1 ,7] For example, if the number is entered as 8 by the user, then your function should print input number 8 is not valid. * Implement your solution for Exercise 2 in this cell def printday(number): # you need to implement the code block for this function below If assuming that the value of the input variable: number is given to you. if number =1 : print("Monday") elif # cosplete the rest of this function by yoursetf II Now the function is defined, we can call that function below. # But before calling that function, let's first take on input value I from the user and make sure that that number is between 1 and 7 mynumber =0 while (mynumber <1 ) or (mynumber >7 ) : mynumber - int(input("Please enter a nuaber in the range of [1,7]:) ) if (mynumber <1 ) or (iynumber >7 ): print("Input number", mynumber, "is not vaild") # Now we can call the function that we have implemented above. printday(mynumber) Please enter a number in the range of [1,7]:2