Skip to main content

Your choice?

Let us look at some image. Now a days image uploading has become very difficult. Why?


You feel this happens to you very often in real life. You have to make blind choices. And no matter what you do it will prove to be harmful to you. Happens to me.

No, no, this funny (dark) game is completely text based and written in python with just 42 lines of code.

Not my invention. I copied it from http://inventwithpython.com

If you are interested, here is the program.


import random
import time
 
def displayIntro():
   print('''You are in a land full of dragons. In front of you,
   you see two caves. In one cave, the dragon is friendly
   and will share his treasure with you. The other dragon
   is greedy and hungry, and will eat you on sight.''')
   print()
 
def chooseCave():
      cave = ''
      while cave != '1' and cave != '2':
          print('Which cave will you go into? (1 or 2)')
          cave = input()
 
      return cave
 
def checkCave(chosenCave):
     print('You approach the cave...')
     time.sleep(2)
     print('It is dark and spooky...')
     time.sleep(2)
     print('A large dragon jumps out in front of you! He opens his jaws and...')
     print()
     time.sleep(2)
 
     friendlyCave = random.randint(1, 2)
 
     if chosenCave == str(friendlyCave):
         print('Gives you his treasure!')
     else:
          print('Gobbles you down in one bite!')
 
playAgain = 'yes'
while playAgain == 'yes' or playAgain == 'y':
      displayIntro()
      caveNumber = chooseCave()
      checkCave(caveNumber)
 
      print('Do you want to play again? (yes or no)')
      playAgain = input()
Python is quite a popular language nowadays. But first of all it is a scripting language and is interpreted.

And the syntax is really bugging to people who go from programming background. You should not write conditional expressions in brackets.

And most irritating is indent for blocks!! Most of the time you will try correct error which says "unexpected indent"

Anyways people say it is powerful. It must be. Because pinterest is written in it.

I had installed sololearn's python course in my phone. And I completed coursera's introductory course in this language. Still not feeling inclined towards it.

Comments

Popular posts from this blog

ಧರ್ಮದ ಉದಯ

 ಇಷ್ಟು ವರ್ಷಗಳ ನಂತರ ನನಗೆ ಒಂದು ವಿಷಯ ಸ್ಪಷ್ಟವಾಗುತ್ತಾ ಇದೆ. ಧರ್ಮ-ದೇವರುಗಳ ಮೂಲ ಸಂಸ್ಥಾಪಕಿ ನಮ್ಮ-ನಿಮ್ಮ ಹಾಗೆ ವಯಸ್ಸಾದ ಮಹಿಳೆ. ಜೀಸಸ್ ಅಲ್ಲ, ಬುದ್ಧ ಅಲ್ಲ, ಮಹಮದ್ ಅಲ್ಲ, ಬಸವಣ್ಣನಲ್ಲ.  ನೀವು ಖಂಡಿತ ಒಪ್ಪಿಕೊಳ್ಳವದಿಲ್ಲ ತಾನೇ? ಸ್ವಲ್ಪ ವಿಶ್ಲೇಷಿಸಿ ನೋಡೋಣ. ಶಾಂತಮ್ಮ - ಹಾಗೆಂದು ಹೆಸರಿಡೋಣ ನಮ್ಮ ಸಂಸ್ಥಾಪಕಿಗೆ. ಅವಳಿಗೆ ಚಾಲೀಸು, ಪಚಾಸು ಎಲ್ಲ ಯಾವಾಗಲೋ ದಾಟಿದೆ. ಮಕ್ಕಳು-ಮೊಮ್ಮಕ್ಕಳೆಲ್ಲ ದೊಡ್ಡವರಾಗಿ ಅವರವರ ಗೂಡು ಸೇರಿದ್ದಾರೆ. ಮನೆಯಲ್ಲಿರವವರು ಅವಳು, ಗಂಡ. ಎಲ್ಲೋ ಒಂದಿಷ್ಟು ಜಿರಲೆ, ಹಲ್ಲಿ, ಇರುವೆಗಳು ಕಂಪನಿ ಕೊಡುತ್ತಿವೆ. ದಿನದಲ್ಲಿ ೩-೪ ಗಂಟೆ ಅಡಿಗೆ-ಕಸ-ಮುಸುರೆ ಮಾಡಿದ ನಂತರ ಅವಳ ಕೈ, ಮನಸ್ಸು ಎಲ್ಲಾ ಖಾಲಿ. ಟಿ.ವೀ., ಮೊಬೈಲ್ ನೋಡುತ್ತ, ಬೇಜಾರಾದರೆ ಗೋಡೆ ನೋಡುತ್ತ ಕುಳಿತು ಅಲ್ಲೇ ನಿದ್ದೆ ಬಂದಿದೆ. ಅರೆ ನಿದ್ರೆ, ಅರೆ ಕನಸಿನಲ್ಲಿ ಏನೋ ನೋಡುತ್ತಾಳೆ - ಅದು ನಿಜವಾದ ಕನಸಾ, ಅಥವಾ ನೋಡಿರುವ ಸಾವಿರಾರು ಸೀರಿಯಲ್ಲುಗಳ ಕಲಸುಮೇಲೋಗರವಾ ಗೊತ್ತಿಲ್ಲ. ಒಂದು ವ್ಯಕ್ತಿ ಕಾಣುತ್ತಾನೆ - ಅವನ ತಲೆಯ ಸುತ್ತ ಬೆಳಕು (ಅಷ್ಟು ಹೊತ್ತಿಗೆ ಒಂದರೆಕ್ಷಣ ದೊಡ್ಡ ಬಿಸಿಲು ಬಂತಾ ?). ಅವನು ಏನೋ ಹೇಳುತ್ತಿದ್ದಾನೆ. ಅವಳಿಗೆ ಸರಿಯಾಗಿ ಕೇಳಿಸುತ್ತಿಲ್ಲ. ಕೊನೆಯಲ್ಲಿ ಅಭಯ ಹಸ್ತ ತೋರಿಸಿ ಮಾಯವಾಗುತ್ತಾನೆ. ಪೊಲಿಟಿಶಿಯನ್ನಾ? ಎದ್ದ ಶಾಂತಮ್ಮ ಕನಸು ನೆನಪಿಸಿಕೊಳ್ಳಲು ನೋಡುತ್ತಾಳೆ - ಎಲ್ಲಾ ಅರೆಸ್ಪಷ್ಟ. ಏನಿರಬಹುದು - ಯಾ...

Dharmabheeru

 I wanted to call this post 'fear'. Then something told me I might have at least one more post with that title. And of course there it was.  So the title had to be changed to Dharmabheeru (dharma - religion, bheeru - fearful, timid) - god fearing - pious. You are afraid. But that is not a bad thing because you are afraid of God - that he may punish you if you commit a sin.   But I have a feeling that fear makes us religious, makes us believe in God, because we want to be protected by someone - and mom can't protect the adult us.   Drowning myself in Sanskrit works - particularly Ashtavakragita ,  I had to find some meaning of these words like atma, mukti, jnana. And I asked AI to find me some texts to understand history of religions. It gave me many options - most of which are not available. But the one I stuck to was "The natural history of religions".  Reading that text was not very easy - but 3 part series of podcasts by 'Philosophize this' ab...

A festival day

 If you read works of 19th century writers like Saki or Wodehouse, you will find the rich old aristocratic ladies who are bored with their lives and waiting for some event, any event in their life.  I am certainly living in 19th century. This century, particularly this decade has been really eventful, most of them not so good. But still as an older lady, who spends most of her life within walls of her home, I can say my life is almost non-eventful.  Yesterday was different. I decided that I will celebrate the festival in good, traditional manner. Which is hypocritical to say the least. I am not so much traditional, not very much religious either.  But bored, yes of course. So I practiced one particular rangoli for the festival. I tried to learn one or two songs for Ganesha - today's deity, not so successful. And I decided I will make the same 5 sweets for Ganesha puja.  This morning did not start well. The kitchen sink malfunctioned and decided it needed more at...