This is python lesson 8
In this lesson we are moving on to if. If is slightly more tricky than other things in Python as you really need to type carefully now. We will be combining our work on inputs with if.
choice = input
choice (“Do you want to hear a joke? Y/N”)
if choice == “Y”:
print (“Why did the toilet roll roll down the down the hill”)
print (“To get to the bottom!”)
In the above piece of code we have many new things again. First of all we have import time. Python has many extra commands which can be imported with no additional downloads. Import time lets Python have a sleep or break between commands for as long as you like. You simply use : time.sleep(amount of seconds). Next we have an if which is very useful. It lets you do many amazing things. Python will only do something if something = something. In this case it will only display the code if the letter Y is typed. Any code under the if statement must be indented. Also it must be followed by a colon.