DEV Community

Ari Wira Saputra
Ari Wira Saputra

Posted on

Days5_if this else that?!

If Statements is These statements are a bit like asking a question. You are telling the computer: if something is true, then do this specific block of code. Double equals (==) is asking the computer to compare if these two things are exactly the same.


def exercise_1():
  name = input("what's your name?: ")
  if name == "Davit" :
    print("Welcome Dude!")
    print("You're just the baldest dude I've ever seen")
  else:
    print("Who on earth are you?!...")

def exercise_2():
  catsOrDogs = input("Are you a cat person? Or a dog person?: ")
  if catsOrDogs == "cat":
    print("Meowwww")
  else:
    print("Woof")

def exercise_3():
  drink = input("Do you prefer coffe or tea?")
  if drink == "coffe":
    print("Tea is Better")
  else:
    print("Excellent choice")

def challenge():
  Text = ("--Marvel Movie Character Creator--")
  print(Text)
  like = input("Do you like 'hanging around'?:")
  if like == "no":
    print("Then you're not Spider-Man")
  else:
    print("Nice")
  have = input("Do you have a 'gravelly' voice?: ")
  if have == "no":
    print("Aww, then you're not korg")
  else:
    print("Nice")
  feel = input("Do you often feel'Marvelouse?: ")
  if feel == "yes":
    print("Aha! You're Caption Marvel! Hi!")

def call():
  exercise_1()
  exercise_2()
  exercise_3()
  challenge()

call()`

Enter fullscreen mode Exit fullscreen mode

If the condition is not met with the if statement, then we want the computer to do the else part instead. Likewise, if the condition is met in the if statement, then the else bit is ignored by the computer. The else statement must be the first thing unindented after the if statement and in line with it

Top comments (0)