SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Problem 1: Write a short program in Python that turns on all
LEDs, one at a time, in a looping fashion. When an LED is on,
it should stay on for 1 second. You will use a while loop to
identify the number of loops. You will have a total of 10 loops.
Note: n is initialized to 0 (zero). Inside the ‘while’ loop, make
sure to change the value of n by incrementing by 1. Also, print
the iteration count using the following line of code:
print(“Iteration: “,n). Finish the code block:
#testing a while loop
#import GPIO library
#import time library
import RPi.GPIO as GPIO
import time
#Global variables
N = 0
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT) #red LED
GPIO.setup(11,GPIO.OUT)#green LED
GPIO.setup(13,GPIO.OUT)#yellow LED
Problem 2: Problem 2 is going to take you some time to think
through and write. Although not an extensively long program, it
will require anywhere between 20 and 30 lines of code. For this
reason, I am only giving you 2 problems for homework. Write a
short program in Python that turns on an LED based on the
answer to a math calculation. Your program should do the
following:
1. Print: Say hello to the end user and tell the end user that the
program is designed to add 2 integers.
2. Print: Tell the end user that – if the answer is less than 10,
the red LED will turn on.
3. Print: Tell the end user that = if the answer is between (and
inclusive) 10 and 30, the yellow LED will turn on.
4. Print: Tell the end user that – if the answer is greater than 30,
the green LED will turn on.
5. Prompt the end user for 2 variables inputs, one at a time.
6. Calculate the addition problem.
7. Use an ‘if, else-if’ structure as described below.
Note, to ask the end user for an int input value, write the
following code:
x = int(input(“Enter a number to be added: “))
y = int(input(“Enter another number to be added: ))
Note, to use the if-else statement in Python, do the following:
If(answer <= 10):
Elif(answer > 10 or answer < 30):
Elif(answer >= 30):
PS Do not forget the ‘:’ (colon) at the end of these lines of
code!
Finish the code block:
#import GPIO library
#import time library
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT) #red LED
GPIO.setup(11,GPIO.OUT)#green LED
GPIO.setup(13,GPIO.OUT)#yellow LED
Problem 1 Write a short program in Python that turns on all LEDs,.docx

Weitere Àhnliche Inhalte

Ähnlich wie Problem 1 Write a short program in Python that turns on all LEDs,.docx

Temperature sensor with raspberry pi
Temperature sensor with raspberry piTemperature sensor with raspberry pi
Temperature sensor with raspberry piSantosh Kumar Kar
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxgerardkortney
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsMuhammadTalha436
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchartRohit Shrivastava
 
Python Course Basic
Python Course BasicPython Course Basic
Python Course BasicNaiyan Noor
 
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
Week 2PRG 218   Variables and Input and Output OperationsWrite.docxWeek 2PRG 218   Variables and Input and Output OperationsWrite.docx
Week 2PRG 218 Variables and Input and Output OperationsWrite.docxmelbruce90096
 
Raspberry pi led blink
Raspberry pi led blinkRaspberry pi led blink
Raspberry pi led blinkvishal choudhary
 
C101-PracticeProblems.pdf
C101-PracticeProblems.pdfC101-PracticeProblems.pdf
C101-PracticeProblems.pdfT17Rockstar
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxCMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxmonicafrancis71118
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdfRohitSindhu10
 
02 Control Structures - Loops & Conditions
02 Control Structures - Loops & Conditions02 Control Structures - Loops & Conditions
02 Control Structures - Loops & ConditionsEbad ullah Qureshi
 
P3
P3P3
P3lksoo
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Salahaddin University-Erbil
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdfCBJWorld
 

Ähnlich wie Problem 1 Write a short program in Python that turns on all LEDs,.docx (20)

lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Temperature sensor with raspberry pi
Temperature sensor with raspberry piTemperature sensor with raspberry pi
Temperature sensor with raspberry pi
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docx
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ Exams
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Python Course Basic
Python Course BasicPython Course Basic
Python Course Basic
 
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
Week 2PRG 218   Variables and Input and Output OperationsWrite.docxWeek 2PRG 218   Variables and Input and Output OperationsWrite.docx
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
 
Raspberry pi led blink
Raspberry pi led blinkRaspberry pi led blink
Raspberry pi led blink
 
C101-PracticeProblems.pdf
C101-PracticeProblems.pdfC101-PracticeProblems.pdf
C101-PracticeProblems.pdf
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxCMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
 
02 Control Structures - Loops & Conditions
02 Control Structures - Loops & Conditions02 Control Structures - Loops & Conditions
02 Control Structures - Loops & Conditions
 
Cpp Homework Help
Cpp Homework Help Cpp Homework Help
Cpp Homework Help
 
C# Loops
C# LoopsC# Loops
C# Loops
 
P3
P3P3
P3
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
 

Mehr von sleeperharwell

For this assignment, review the articleAbomhara, M., & Koie.docx
For this assignment, review the articleAbomhara, M., & Koie.docxFor this assignment, review the articleAbomhara, M., & Koie.docx
For this assignment, review the articleAbomhara, M., & Koie.docxsleeperharwell
 
For this assignment, provide your perspective about Privacy versus N.docx
For this assignment, provide your perspective about Privacy versus N.docxFor this assignment, provide your perspective about Privacy versus N.docx
For this assignment, provide your perspective about Privacy versus N.docxsleeperharwell
 
For this assignment, provide your perspective about Privacy vers.docx
For this assignment, provide your perspective about Privacy vers.docxFor this assignment, provide your perspective about Privacy vers.docx
For this assignment, provide your perspective about Privacy vers.docxsleeperharwell
 
For this Assignment, read the case study for Claudia and find two to.docx
For this Assignment, read the case study for Claudia and find two to.docxFor this Assignment, read the case study for Claudia and find two to.docx
For this Assignment, read the case study for Claudia and find two to.docxsleeperharwell
 
For this assignment, please start by doing research regarding the se.docx
For this assignment, please start by doing research regarding the se.docxFor this assignment, please start by doing research regarding the se.docx
For this assignment, please start by doing research regarding the se.docxsleeperharwell
 
For this assignment, please discuss the following questionsWh.docx
For this assignment, please discuss the following questionsWh.docxFor this assignment, please discuss the following questionsWh.docx
For this assignment, please discuss the following questionsWh.docxsleeperharwell
 
For this assignment, locate a news article about an organization.docx
For this assignment, locate a news article about an organization.docxFor this assignment, locate a news article about an organization.docx
For this assignment, locate a news article about an organization.docxsleeperharwell
 
For this assignment, it requires you Identifies the historic conte.docx
For this assignment, it requires you Identifies the historic conte.docxFor this assignment, it requires you Identifies the historic conte.docx
For this assignment, it requires you Identifies the historic conte.docxsleeperharwell
 
For this assignment, create a framework from which an international .docx
For this assignment, create a framework from which an international .docxFor this assignment, create a framework from which an international .docx
For this assignment, create a framework from which an international .docxsleeperharwell
 
For this assignment, create a 15-20 slide digital presentation in tw.docx
For this assignment, create a 15-20 slide digital presentation in tw.docxFor this assignment, create a 15-20 slide digital presentation in tw.docx
For this assignment, create a 15-20 slide digital presentation in tw.docxsleeperharwell
 
For this assignment, you are to complete aclinical case - narrat.docx
For this assignment, you are to complete aclinical case - narrat.docxFor this assignment, you are to complete aclinical case - narrat.docx
For this assignment, you are to complete aclinical case - narrat.docxsleeperharwell
 
For this assignment, you are to complete aclinical case - narr.docx
For this assignment, you are to complete aclinical case - narr.docxFor this assignment, you are to complete aclinical case - narr.docx
For this assignment, you are to complete aclinical case - narr.docxsleeperharwell
 
For this assignment, you are provided with four video case studies (.docx
For this assignment, you are provided with four video case studies (.docxFor this assignment, you are provided with four video case studies (.docx
For this assignment, you are provided with four video case studies (.docxsleeperharwell
 
For this assignment, you are going to tell a story, but not just.docx
For this assignment, you are going to tell a story, but not just.docxFor this assignment, you are going to tell a story, but not just.docx
For this assignment, you are going to tell a story, but not just.docxsleeperharwell
 
For this assignment, you are asked to prepare a Reflection Paper. Af.docx
For this assignment, you are asked to prepare a Reflection Paper. Af.docxFor this assignment, you are asked to prepare a Reflection Paper. Af.docx
For this assignment, you are asked to prepare a Reflection Paper. Af.docxsleeperharwell
 
For this assignment, you are asked to prepare a Reflection Paper. .docx
For this assignment, you are asked to prepare a Reflection Paper. .docxFor this assignment, you are asked to prepare a Reflection Paper. .docx
For this assignment, you are asked to prepare a Reflection Paper. .docxsleeperharwell
 
For this assignment, you are asked to conduct some Internet research.docx
For this assignment, you are asked to conduct some Internet research.docxFor this assignment, you are asked to conduct some Internet research.docx
For this assignment, you are asked to conduct some Internet research.docxsleeperharwell
 
For this assignment, you are a professor teaching a graduate-level p.docx
For this assignment, you are a professor teaching a graduate-level p.docxFor this assignment, you are a professor teaching a graduate-level p.docx
For this assignment, you are a professor teaching a graduate-level p.docxsleeperharwell
 
For this assignment, we will be visiting the PBS website,Race  .docx
For this assignment, we will be visiting the PBS website,Race  .docxFor this assignment, we will be visiting the PBS website,Race  .docx
For this assignment, we will be visiting the PBS website,Race  .docxsleeperharwell
 
For this assignment, the student starts the project by identifying a.docx
For this assignment, the student starts the project by identifying a.docxFor this assignment, the student starts the project by identifying a.docx
For this assignment, the student starts the project by identifying a.docxsleeperharwell
 

Mehr von sleeperharwell (20)

For this assignment, review the articleAbomhara, M., & Koie.docx
For this assignment, review the articleAbomhara, M., & Koie.docxFor this assignment, review the articleAbomhara, M., & Koie.docx
For this assignment, review the articleAbomhara, M., & Koie.docx
 
For this assignment, provide your perspective about Privacy versus N.docx
For this assignment, provide your perspective about Privacy versus N.docxFor this assignment, provide your perspective about Privacy versus N.docx
For this assignment, provide your perspective about Privacy versus N.docx
 
For this assignment, provide your perspective about Privacy vers.docx
For this assignment, provide your perspective about Privacy vers.docxFor this assignment, provide your perspective about Privacy vers.docx
For this assignment, provide your perspective about Privacy vers.docx
 
For this Assignment, read the case study for Claudia and find two to.docx
For this Assignment, read the case study for Claudia and find two to.docxFor this Assignment, read the case study for Claudia and find two to.docx
For this Assignment, read the case study for Claudia and find two to.docx
 
For this assignment, please start by doing research regarding the se.docx
For this assignment, please start by doing research regarding the se.docxFor this assignment, please start by doing research regarding the se.docx
For this assignment, please start by doing research regarding the se.docx
 
For this assignment, please discuss the following questionsWh.docx
For this assignment, please discuss the following questionsWh.docxFor this assignment, please discuss the following questionsWh.docx
For this assignment, please discuss the following questionsWh.docx
 
For this assignment, locate a news article about an organization.docx
For this assignment, locate a news article about an organization.docxFor this assignment, locate a news article about an organization.docx
For this assignment, locate a news article about an organization.docx
 
For this assignment, it requires you Identifies the historic conte.docx
For this assignment, it requires you Identifies the historic conte.docxFor this assignment, it requires you Identifies the historic conte.docx
For this assignment, it requires you Identifies the historic conte.docx
 
For this assignment, create a framework from which an international .docx
For this assignment, create a framework from which an international .docxFor this assignment, create a framework from which an international .docx
For this assignment, create a framework from which an international .docx
 
For this assignment, create a 15-20 slide digital presentation in tw.docx
For this assignment, create a 15-20 slide digital presentation in tw.docxFor this assignment, create a 15-20 slide digital presentation in tw.docx
For this assignment, create a 15-20 slide digital presentation in tw.docx
 
For this assignment, you are to complete aclinical case - narrat.docx
For this assignment, you are to complete aclinical case - narrat.docxFor this assignment, you are to complete aclinical case - narrat.docx
For this assignment, you are to complete aclinical case - narrat.docx
 
For this assignment, you are to complete aclinical case - narr.docx
For this assignment, you are to complete aclinical case - narr.docxFor this assignment, you are to complete aclinical case - narr.docx
For this assignment, you are to complete aclinical case - narr.docx
 
For this assignment, you are provided with four video case studies (.docx
For this assignment, you are provided with four video case studies (.docxFor this assignment, you are provided with four video case studies (.docx
For this assignment, you are provided with four video case studies (.docx
 
For this assignment, you are going to tell a story, but not just.docx
For this assignment, you are going to tell a story, but not just.docxFor this assignment, you are going to tell a story, but not just.docx
For this assignment, you are going to tell a story, but not just.docx
 
For this assignment, you are asked to prepare a Reflection Paper. Af.docx
For this assignment, you are asked to prepare a Reflection Paper. Af.docxFor this assignment, you are asked to prepare a Reflection Paper. Af.docx
For this assignment, you are asked to prepare a Reflection Paper. Af.docx
 
For this assignment, you are asked to prepare a Reflection Paper. .docx
For this assignment, you are asked to prepare a Reflection Paper. .docxFor this assignment, you are asked to prepare a Reflection Paper. .docx
For this assignment, you are asked to prepare a Reflection Paper. .docx
 
For this assignment, you are asked to conduct some Internet research.docx
For this assignment, you are asked to conduct some Internet research.docxFor this assignment, you are asked to conduct some Internet research.docx
For this assignment, you are asked to conduct some Internet research.docx
 
For this assignment, you are a professor teaching a graduate-level p.docx
For this assignment, you are a professor teaching a graduate-level p.docxFor this assignment, you are a professor teaching a graduate-level p.docx
For this assignment, you are a professor teaching a graduate-level p.docx
 
For this assignment, we will be visiting the PBS website,Race  .docx
For this assignment, we will be visiting the PBS website,Race  .docxFor this assignment, we will be visiting the PBS website,Race  .docx
For this assignment, we will be visiting the PBS website,Race  .docx
 
For this assignment, the student starts the project by identifying a.docx
For this assignment, the student starts the project by identifying a.docxFor this assignment, the student starts the project by identifying a.docx
For this assignment, the student starts the project by identifying a.docx
 

KĂŒrzlich hochgeladen

Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...Nguyen Thanh Tu Collection
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 

KĂŒrzlich hochgeladen (20)

Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 

Problem 1 Write a short program in Python that turns on all LEDs,.docx

  • 1. Problem 1: Write a short program in Python that turns on all LEDs, one at a time, in a looping fashion. When an LED is on, it should stay on for 1 second. You will use a while loop to identify the number of loops. You will have a total of 10 loops. Note: n is initialized to 0 (zero). Inside the ‘while’ loop, make sure to change the value of n by incrementing by 1. Also, print the iteration count using the following line of code: print(“Iteration: “,n). Finish the code block: #testing a while loop #import GPIO library #import time library import RPi.GPIO as GPIO import time #Global variables N = 0 GPIO.setmode(GPIO.BOARD) GPIO.setup(7,GPIO.OUT) #red LED GPIO.setup(11,GPIO.OUT)#green LED GPIO.setup(13,GPIO.OUT)#yellow LED Problem 2: Problem 2 is going to take you some time to think through and write. Although not an extensively long program, it will require anywhere between 20 and 30 lines of code. For this reason, I am only giving you 2 problems for homework. Write a short program in Python that turns on an LED based on the answer to a math calculation. Your program should do the following: 1. Print: Say hello to the end user and tell the end user that the program is designed to add 2 integers.
  • 2. 2. Print: Tell the end user that – if the answer is less than 10, the red LED will turn on. 3. Print: Tell the end user that = if the answer is between (and inclusive) 10 and 30, the yellow LED will turn on. 4. Print: Tell the end user that – if the answer is greater than 30, the green LED will turn on. 5. Prompt the end user for 2 variables inputs, one at a time. 6. Calculate the addition problem. 7. Use an ‘if, else-if’ structure as described below. Note, to ask the end user for an int input value, write the following code: x = int(input(“Enter a number to be added: “)) y = int(input(“Enter another number to be added: )) Note, to use the if-else statement in Python, do the following: If(answer <= 10): Elif(answer > 10 or answer < 30): Elif(answer >= 30): PS Do not forget the ‘:’ (colon) at the end of these lines of code! Finish the code block: #import GPIO library #import time library import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(7,GPIO.OUT) #red LED GPIO.setup(11,GPIO.OUT)#green LED GPIO.setup(13,GPIO.OUT)#yellow LED