Reference no: EM131070302
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):
Induced current in the inner loop
: A small, 1.80-mm-diameter circular loop with R = 1.40×10-2 Ω is at the center of a large 120-mm-diameter circular loop. Both loops lie in the same plane. The current in the outer loop changes from +1.0A to -1.0A in 0.100 s. What is the induced cur..
|
Index of refraction of the material
: Nicholas and Louis have an unknown clear solid that has a 36 degree critical angle for total internal reflection. What is the index of refraction of the material?
|
How much would she make for hours of work
: Kelko made $198 for 11 hours of work. At the same rate, how much would she make for 8 hours of work
|
Spring pulls in the horizontal direction
: Find the coefficient of kinetic friction between a 4.55-kg block and the horizontal surface on which it rests if a 93.0-N/m spring must be stretched by 6.30 cm to pull it with constant speed. Assume that the spring pulls in the horizontal directio..
|
Write a short program in python that turns on all leds
: 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.
|
Scientific research in the field of psychology
: Discuss the need for scientific research in the field of psychology. How does psychological research obtain and use empirical evidence - Issues related to sexual orientation have been at the forefront of the current political landscape.
|
How the gravitational constant was first measured
: Who first measured G? Where and when? How was this constant related to Sir Isaac Newton (Newton did not measure G)?
|
How does using strings like integers alter the o-notation
: How does using strings instead of simple types like integers alter the O-notation of operations? Is the ADT given in program 4.7 a first-class ADT? Explain your answer.
|
Present data in attractive reports and forms
: With a recent growth in business, Great Outdoors Tours has developed a database in Access 2013 to organize its records. The company would like your help with presenting data in attractive reports and forms that highlight certain information.
|