Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Python Expert

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):

Python, Programming

  • Category:- Python
  • Reference No.:- M91794672
  • Price:- $45

Priced at Now at $45, Verified Solution

Have any Question?


Related Questions in Python

Question a software company sells a package that retails

Question : A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity Discount 10 - 19 20% 20 - 49 30% 50 - 99 40% 100 or more 50% Write a program usi ...

Architecture and system integrationcase study queensland

Architecture and System Integration Case Study: Queensland Health - eHealth Investment Strategy After evaluating various platforms, Queensland Health finally decided to adopt a Service Oriented Architecture (SOA) for its ...

Show times in tmus and seconds1 an associate grasps an oven

Show times in TMUs and seconds. 1. An associate grasps an oven door within reach and pulls it open 18 inches with the left hand (he does not relinquish control of the door). With a pan in the right hand, he carefully pos ...

The second task in this assignment is to create a python

The second task in this assignment is to create a Python program called pancakes.py that will determine the final order of a stack of pancakes after a series of flips.(PYTHON 3) Problem Task In this problem, your input w ...

Question why is software configuration management

Question : Why is software configuration management considered an umbrella activity in software engineering? Please include examples and supporting discussion. The response must be typed, single spaced, must be in times ...

Simple python traffic lightswrite a program that simulates

Simple Python (Traffic lights) Write a program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or green. When a radio button is selected, the light is turned on, and onl ...

Project reconnaissance and attack on ics

Project: Reconnaissance and Attack on ICS NetworksEnvironment Setup The second mini project will be based on Industrial Network Protocols, specifically the Modbus protocol. Please follow the instructions carefully to set ...

Assignment1 utilising python 3 build the following

Assignment 1. Utilising Python 3 Build the following regression models: - Decision Tree - Gradient Boosted Tree - Linear regression 2. Select a dataset (other than the example dataset given in section 3) and apply the De ...

Question write a python program with a graphical user

Question: Write a python program with a graphical user interface that will allow a user to create a custom pizza which they wish to order. At minimum, the user should be able to choose the size of the pizza, the type of ...

Question research pythons dictionary data type dictdiscuss

Question : Research Python's dictionary data type (dict). Discuss its interface and usage. Include examples. Discuss practical applications of dictionaries.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As