
What Will I Learn?
- You will learn to write an alarm program in Python language
- You will learn to use the "while" loops
- You will learn to use 'if, elif and else' functions from conditional states
- You will learn to use the 'time' library and the 'localtime' module
- You will improve your algorithm ability when writing programs
Requirements
- Python 3.6.5
- Pycharm or another text editors (python idle)
Difficulty
- Intermediate
Links
Codes
print("""******************
Alarm Program
******************""")
import time
Ahour = int(input("Please enter the alarm hour:"))
Aminute = int(input("Please enter the alarm minute:"))
while True:
LT = time.localtime(time.time())
if Ahour == LT.tm_hour and Aminute == LT.tm_min :
print( "Time is:", LT.tm_hour, ":", LT.tm_min, "The alarm is ringing")
break
elif (LT.tm_min == 30 and LT.tm_sec ==1 ) or (LT.tm_min == 7 and LT.tm_sec ==1 ):
rhour = Ahour - LT.tm_hour
rminute= Aminute - LT.tm_min
print( "Remaining to Alarm:", rhour, ":", rminute)
else:
pass
print (" The Alarm Has been terminated")
Description
In this lesson I will tell you how to write the Alarm application in Python language. We use the 'time' library when designing the alarm program algorithm. By using the 'locatime' module in this library, we instantly get the clock data of our computer into the program. The alarm starts by asking the user to enter the alarm time and minute. After this phase, we are beginning to test the alarm information that the user has entered in the 'while' loop. We check that the alarm clock entered in the test phase matches the local time of our computer. In this control phase we use 'if, elif and else' functions. You can see the details of these functions in the codes and videos we have done. We also learned not to get the duration of the alarm to be steady at certain intervals within the program. I hope that this content is useful for you.
Step -1
In the first step, we enter the name of our program and import the 'time' library
Step -2
In the second step, we define our variables so that the user can enter the alarm time.
Step -3
In the third step, we start the 'while' cycle according to the condition of 'True'.
Step -4
In the fourth step, we set the conditions according to the alarm time that the user has entered and make sure that they are tested.
Step -5
In the fifth step, we complete the program by typing the expression indicating the end of our program.
Video Tutorial
Curriculum
- This is the first part of the Python Video Tutorial Serie
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for your contribution. It has been reviewed and scored.
@redart, you need to work on the tutorial itself because the tutorial should bring insights into the Open Source Project so that learners can use the technical features after watching your video.
You also need to work on the tutorial by presenting clearly the concepts. Presently, there is no structure in the presentation although you try to lay out the steps for learners to follow.
Try to work on a flow in the video so that your users can stay engaged as they learn from your video. Write out a draft or script for yourself to follow. You need to edit out the parts where your presentation brings no significant value to the tutorial.
If you have questions, please contact us at discord.
Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.
[utopian-moderator]
Thanks for your valuable comments. I will improve myself by taking into what you say and I will make my contributions more useful.