Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    7
  • comments
    2
  • views
    1425

a fortune cookie program

Sign in to follow this  
WinterDragon

581 views

So it took one day to write and bug fix.

Then another day to go through guesswork and figuring it out - to get the program to work.

I haven't got up to while loops in the book, so it took a while - a few errors before I got it working.

And I certainly haven't got as far as def methods, so using them was difficult and problematic. But I wanted my program to be complete with an exit option.

 

import random
    
def end_game():
    end_message = ("game over")
    print (end_message)
    
def game():
    againPlay = "y"
    while againPlay == "y":
        nmCookie = random.randrange(5)   
        begin = input ("cookie time, open your fortune cookie")
        if nmCookie < 1:
            print ("you are going to die someday")
            againPlay = input ("Still hungry")
        elif nmCookie == 1:
            print ("you just ate a cookie")
            againPlay = input ("Still hungry")
        elif nmCookie == 2:
            print ("you are going to eat another cookie")
            againPlay = input ("Still hungry")
        elif nmCookie == 3:
            print ("you like cookies")
            againPlay = input ("Still hungry")
        elif nmCookie == 4:
            print ("you will have a gargantuan legacy")
            againPlay = input ("Still hungry")
        else: end_game()


game ()
end_game ()
 

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By TheAICodeGuy
      Hello everyone!
      If you couldn't figure it out I'm new here. I've been reviewing jobs regarding AI game programming because I love working on AI systems. A few searches have been well straight forward and I'm grateful for that, but for anybody whose has or who still is currently working as an AI programmer, what skills would you say are necessary? I've learned (and still am learning because well learning and getting BETTER never ends) C and C++. Of course I'll continue to sharpen my skills there as much as possible. I've seen some jobs list python and/or lua in their descriptions. Would you say these extra skills are, I guess, major in the game industry? I know python a bit, but lua I don't really know much at all. 
      However I'm most definitely willing to learn.
      Thank you to anyone willing to give feedback!
    • By kalydos
      Currently I have two creative talents with me on board to work with me for my visual novel dating sim and we are currently looking for a programmer to work with in Ren'py (or another program if that works), minimal pixel art and it would require being able to contribute creatively as well as programming a stat/leveling system, affection system, calendar/scheduling activities system, a minimal sidescrolling exploration system and it would also be nice to have a GUI designer. If any clarification or anyone is on board contact me on discord kalydos#0726
    • By renedudfield
      The pygame book project has begun. It's called "pygame 4000" and is a book project by one of the main contributors of the pygame project.

      Not only does the book aim to cover Python programming, but also aims to cover C, and the GLSL shading language.
      [ Pixel Perfect Collision Detection ] [ SDL2 Fundamentals Tutorial in C ] [ Sound Generation and Visualization ] [ Python intro for game programming ] [ Let's make a shit JavaScript Interpreter! ] [ How to port and market games ] [ Let's write a unit test! ] [ Arduino; Serial & pixels for breakfast ] [ Awesome pygame. Great stuff you can use with pygame. ] pygame 4000 available as an early preview pre-release on the pygame book itch page. Updates will be posted on the pygame book developer web log.
      pygame is the most popular game/art/and music library available for the most popular programming language in the world -- Python. pygame is used in school classes, university courses, and workshops around the world. It's used in embedded devices like handheld game consoles, in video synthesizers, museum displays, and interactive art installations. It's available in over 130 different OS distributions, including on the Raspberry Pi, Ubuntu, and MacOS. All funds from the pygame 4000 book go towards pygame development and improvements to the pygame 4000 book.

      View full story
    • By renedudfield
      The pygame book project has begun. It's called "pygame 4000" and is a book project by one of the main contributors of the pygame project.

      Not only does the book aim to cover Python programming, but also aims to cover C, and the GLSL shading language.
      [ Pixel Perfect Collision Detection ] [ SDL2 Fundamentals Tutorial in C ] [ Sound Generation and Visualization ] [ Python intro for game programming ] [ Let's make a shit JavaScript Interpreter! ] [ How to port and market games ] [ Let's write a unit test! ] [ Arduino; Serial & pixels for breakfast ] [ Awesome pygame. Great stuff you can use with pygame. ] pygame 4000 available as an early preview pre-release on the pygame book itch page. Updates will be posted on the pygame book developer web log.
      pygame is the most popular game/art/and music library available for the most popular programming language in the world -- Python. pygame is used in school classes, university courses, and workshops around the world. It's used in embedded devices like handheld game consoles, in video synthesizers, museum displays, and interactive art installations. It's available in over 130 different OS distributions, including on the Raspberry Pi, Ubuntu, and MacOS. All funds from the pygame 4000 book go towards pygame development and improvements to the pygame 4000 book.
    • By Gomta777
      Hello, I am a Japanese, a novice of the python programming.
      I am currently trying to program games using pygame.
      The progress of the game production can be seen on the following blog and youtube channel.
      https://ko-gaku-jiji.hatenablog.jp/
      (sorry all of my page is written by Japanese)

      I'm trying to make a Tetris-like game right now, but sometimes I'm worried.
      In the process for the Tetris game, such as the process of line erasing, I feel that I can write a program more simply by using multithreading.
      However, I couldn't find a suitable sample for multithreading with pygame.
      If you know, please introduce me a web page with a simple and easy-to-understand sample.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!