Comparator, if else, for loop

 

If else syntax


# if statement for area

if area > 15:

    print("big place!")


# if-else construct for room

if room == "kit" :

    print("looking around in the kitchen.")

else :

    print("looking around elsewhere.")


# if-elif-else construct for area

if area > 15 :

    print("big place!")

elif area >10:

    print("medium size, nice!")

else :

    print("pretty small.")



# Definition of dictionary

europe = {'spain':'madrid', 'france':'paris', 'germany':'berlin',

          'norway':'oslo', 'italy':'rome', 'poland':'warsaw', 'austria':'vienna' }

          

# Iterate over europe

for key, value in europe.items():

    print("the capital of "+key+" is "+value)





Comments

Popular posts from this blog

Useful links (updated: 2024-04-26)

Genome editing technology short note

SUSA Thailand - Sustainable University? (update 2023-06-23)