Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver1
0いいね 18 views回再生

Controlling Program Flow Using If Statement in Python - 60 Seconds to Code

Welcome to 60 seconds to code where I show you how to code in 60 seconds or less.
Today you will learn about controlling the flow of your programs using if statements.
Step 1 – Create a new file called ifstatements.py and type my_var = True
Step 2 – Type
if my_var:
print(‘Value is true’)
else:
print(‘The Value is False’)
as it appears on screen.
Step 3 – Run the program from the terminal
Step 4 – Change the value of the my_var variable to False and run the program again
Step 5 – As you can probably tell, the if statement executes if the given condition is true and the else condition executes if that condition is false.
Step 6 – You can also check the exact same condition by using the double equal sign
Step 7 – Change the second line in the program to if my_var == True: and run the program again.
Congratulations, you’ve learned basic control flow using if statements. Remember to commit and push your code to GitHub and try to code a little every day because CODE IS LIFE
#howto control the flow of logic in your program with if statements #60secondstocode #codeislife

コメント