SlideShare uma empresa Scribd logo
1 de 1
Baixar para ler offline
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

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

Último (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

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