It's another week, and I am glad to be part of this course for the second time; missing out wasn't intentional but for some personal and challenging reasons I opt out for a while. I have read previous courses and I wish I could really understand week2 course, it seems a little bit complex, I am glad that I was able to find an application that can help me testrun my codes too.
Conditional structures are programming constructions used to explain situations and the consequences that follow each situation. They involve a conditional term "if," which is a clause that indicates a condition. The consequence or result depends on whether or not each condition is fulfilled. As we program, we don't leave the commands without an end; if a particular condition is not fulfilled, another code must be written to end it; that is the consequence, but somehow it is another fulfillment. Let's take, for instance, a door of height 6 feet that can let only people that are 6 feet tall and below pass it. It is certain that if someoneor something greater than 6 feet wants to pass it, it will not allow, so in this case I can make a program of waiting there since it doesn't meet the criteria.
This conditional structure is applied in all facets, from the look of things; even natural conditions go with this too.
- In refrigerators I think they go by this condition, if you turn on the refrigator, it is believe that if it goes below a certain temperature freezing occurs, if it doesn't it is mere cooling.
- In decision-making, we make use of conditional structures. Most times, when my parents send me to redraw money from the bank, they give me a condition, which also the bank programs into their system too.
- Check balance If the amount is 100, then redraw 80; if it is 50, then withdraw 40; paraventure: the balance is 50, and I forgot to check the balance; I insert 80 to redraw; even the system will reject my command, which will move me to check the balance. So I would say it is used in financial decision-making and also in automated household appliances.
Using the example given I was able to come up with something and the programing language I utilised here is python, the code looks more straight forward.
print("Welcome to the room! What do you want to do?")
print("1. Turn on the light")
print("2. Leave the room")
choice = int(input())
if choice == 1:
print("You have turned on the light.")
elif choice == 2:
print("You have left the room.")
else:
print("Invalid choice. Please enter 1 or 2.")
After this I had to test the protocols here to see my output and it gave me something admirable
The code and terminal is on left and the display of the code and terminal when I choosed option 1 is on the right
Using the same programming language this is what I was able to come up with.
print("Section Evaluation Program")
rating1 = float(input("Rating 1 (out of 100): "))
rating2 = float(input("Rating 2 (out of 100): "))
rating3 = float(input("Rating 3 (out of 100): "))
rating4 = float(input("Rating 4 (out of 100): "))
average = (rating1 + rating2 + rating3 + rating4) / 4
print("Average Rating: {average:.2f}")
if average >= 70:
print("Status: Passed")
else:
print("Status: Can Improve")
This particular image has the program and the outcome when I inserted digits that in calculating will not give me an average greater than 70, it shows can Improve as the consequence of the conditions
For the image above, the terminal show how I insert value that can give me an average greater than equal to or greater than 70 and this is what displayed as the final result, passed👍
I would love my friends @o1eh @drhira and @miftahulrizky to contest via this link
Upvoted! Thank you for supporting witness @jswit.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Upvoted. Thank You for sending some of your rewards to @null. It will make Steem stronger.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
X promotion link
https://x.com/nsijoro/status/1842382891575099841?t=WqTvNH0gph_kCkUkdSgHrw&s=19
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Your post has been rewarded by the Seven Team.
Support partner witnesses
We are the hope!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit