Red Security

Full Version: Python Project To Add in Your Resume (Beginners level)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: BFMMlbcQvml9HSqXcvNp]

Roll the dice Project for Beginners:
 
   In this thread I am going to show how you can make a simple program that rolls a dice. And most interestingly you can add this in your resume. I will show you how to code it and explain each and every step of it.

Code:
import random


This code imports a module called random. Modules are actually files with .py extension and contain code related to some function. In this case random function will generate random numbers as we roll our dice

Code:
min = 1
max = 6

Setting the range for our dice as dice has only minimum number 1 and maximum number 6

Code:
roll_dice = 'yes'

roll_dice = ‘yes’ means that this program will run at least once.

while roll_dice == 'yes' or roll_dice == 'y':

In this step we are checking whether the program should run or not. But for at least one time the program must run
   
Code:
print("Rolling the dice...")
    print('You got the number ' + str(random.randint(min, max)))

Generating the random number and concatenating it with string to output the result for user

   
Code:
roll_dice = input('Do you want to roll again. press y to continue.')


Asking the user whether he/she wants to play again or not.

Quote:Exclamation  But keep in mind that all lines of code after the while function are indented !

So that’s it for now, hope you understand each and every step of the code...

"Keep Good care of your Health
Allah Hafiz and Good Bye Till the next post"
"Keep Learning and Keep exploring"