Discord Server Red Security Twitter Donation to Red Security Red Security Youtube Channel Red Security Tumblr Profile
Login or Register to Hide ads and Accessing all features on the forum

Tutorial 

Python Project To Add in Your Resume (Beginners level)

0 Replies, 678 Views

[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"
Love me like you do Heart
(This post was last modified: 05-04-2022, 08:25 AM by Covid-19.)

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tutorial Doubly Linked List in Python Covid-19 0 2,249 07-30-2022, 09:15 PM
Last Post: Covid-19
  Tutorial Linked List in Python Covid-19 2 2,639 07-30-2022, 08:25 PM
Last Post: Covid-19
  Tutorial File Handling in Python Covid-19 2 2,674 06-16-2022, 06:17 PM
Last Post: Covid-19
  Tutorial Exceptions in Python Covid-19 0 1,844 06-08-2022, 09:19 PM
Last Post: Covid-19
  Free Automate the boring stuff with Python Covid-19 0 1,608 06-07-2022, 06:58 PM
Last Post: Covid-19
  Tutorial Turtle in Python Covid-19 0 1,841 06-02-2022, 10:14 PM
Last Post: Covid-19
  Tutorial Python 3.5: Class Methods Covid-19 0 1,793 05-29-2022, 01:07 PM
Last Post: Covid-19
  Tutorial Python 3.2: Inheritance in Python Covid-19 2 2,833 05-27-2022, 06:47 PM
Last Post: Covid-19
  Tutorial Python 3.4: Encapsulation and Abstraction Covid-19 0 1,825 05-27-2022, 06:45 PM
Last Post: Covid-19
  Tutorial Python 3.3: Operator Overloading Covid-19 2 2,828 05-26-2022, 08:50 PM
Last Post: Covid-19



Users browsing this thread: 1 Guest(s)