Journal #7

At this point I learned about if and else statements.
15_32.jpgFor this I have made a code for a logic puzzle that uses if and else

 

#Logic puzzle from

#https://www.brainbashers.com/showpuzzles.asp?puzzle=ZFSC

print (“During a recent police investigation, Chief Inspector Stone was interviewing five local villains to try and identify who stole Mrs Archer’s cake from the mid-summers fayre. \nBelow is a summary of their statements \nArnold: it wasn’t Edward

\n it was Brian.\nBrian: it wasn’t Charles \n it wasn’t Edward.\nCharles: it was Edward \n it wasn’t Arnold \nDerek: it was Charles\n it was Brian. \nEdward: it was Derek\n it wasn’t Brian.

It was well known that each suspect told exactly one lie. Can you determine who stole the cake?”)

user_name = input(“Who stole the Cake? “)

if user_name.lower() == “Charles”:

print (“You are correct! Great work!”)

else:

print (“You are wrong.”)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s