Python Fruit Machine

admin

Create a new Python file called Fruit Machine.py STEP 2: Add the following code to your program. Save and run the code to make sure it works. Here we set up a function called fruitmachine and call it at the bottom of our code. We also get some user input. Remember indenting is very important!! STEP 3: Now let’s set up an Array.

Final game play video of this cracking machine as its going to be sold next week! Import the Libraries. We will start by importing the necessary libraries required to implement the. I used Python 3.5 for this.SOURCE CODE: https://docs.google.com/document/d/1miS5oxCqhxd7jR0frts1gWx7BF9Oq9cdJjtakl5nfmQ/edit?usp=sharing.

Monty Python Fruit Machine

Nov-08-2017, 04:45 AM (This post was last modified: Nov-08-2017, 04:45 AM by Prrz.)
Hello Python Forum, as a learning experience I created a very basic 'Slot' machine. It's far from perfect and could definitely use many upgrades, more winning options, pay tables, etc. As for this project I was mostly focusing on functionality, and I may continue working on it from time to time to make it better (more interesting to play).
That's all for now, please tell me what you think! Any suggestions, comments, criticism: All is welcome!
Thank you,
Prrz
Nov-09-2017, 03:14 PM
Now you should learn tkinter for a simple GUI.
Nov-21-2017, 03:03 AM
(Nov-09-2017, 03:14 PM)heiner55 Wrote: Now you should learn tkinter for a simple GUI.

Thanks for your reply, I'm not sure I'll be tinkering with GUI just yet but I hope it will be in my future! I've still much to learn before I take that leap.
Nov-26-2017, 01:46 PM
OK, we are waiting.

Users browsing this thread: 1 Guest(s)

In this challenge we are going to write a Python program that automatically generates six random numbers (from 1 to 50) and display them on the screen, sorted in ascending order.

The program will need to make sure that each number is unique; the same number cannot come twice in the selection of six selected numbers.

Learning Objectives


By completing this code, you will understand the difference between the two types of loops used in Python:Online
  • For Loops (Count-Controlled Loops): A count-controlled loop is one that is executed a certain number of times. In our example, because we know that we need exactly six numbers we are going to use a for loop to repeat (iterate through) some of our code exactly six times.
  • While Loops (Condition-Controlled Loops): A condition-controlled loop such as a While loop keeps going while a certain condition is true. As soon as the condition becomes false, the loop stops iterating. In our case, when generating a random number, we are going the check that the new number has not already been picked up. If it has then we are going to generate a new one and will carry on doing so till we get a number that has not already been picked up.
Fruit machine code python

Check the code

Your Challenge

Fruit Machine Code Python

  1. Complete this code to store your own selection of six numbers. For testing purposes, you can store these numbers directly into the code and display these to the end-user. Alternatively you can ask the end-user to type six numbers.
  2. Then your code will use the program given above to generate the six lottery numbers.
  3. Finally your code will check and inform the end-user of how many numbers the user guessed correctly by comparing the user’s six numbers with the six randomly generated lottery numbers!

Note


The probability of guessing several lottery numbers is very low. You may want to tweak your program to only pick up numbers between 1 and 20 (instead of 50). This will give you a better chance to guess some of these numbers and hence test whether your code is working.

Video Tutorial

Python

Other challenges you may enjoy...

Tagged with: iteration, List, Python Challenge