Level 1: Beginner
import random
message="You rolled a"
print("Rolling the dice")
print(message,random.randint(1,6))
can we upgrade this code to make a software randomgenarator from 1-100 with UI?
dice_roll_user = random.randint(1, 6)
dice_roll_computer = random.randint(1, 6)
if dice_roll_user > dice_roll_computer:
print(f'You won the computer! You rolled a {dice_roll_user} and the computer rolled a {dice_roll_computer}.')
elif dice_roll_user == dice_roll_computer:
print(f'You tied with the computer! You rolled a {dice_roll_user} and the computer rolled a {dice_roll_computer}.')
else:
print(f'You lost for computer! You rolled a {dice_roll_user} and the computer rolled a {dice_roll_computer}.')
print("Dice Roll " + str(random.randint(1, 6)))
My solution:
"""
Autor: Juan Sebastian Valencia
Simple Dice Rolling Simulator
Proyecto diario de Dialy Python Projects
Modulo para retornar un numero aleatorio entre 1 y 6
from random import randint
def rolling_simulator():
return f'You rolled a {randint(1, 6)}!'
print(rolling_simulator())
print(f"You rolled a {random.randint(1,6)}! ")
import random
message="You rolled a"
print("Rolling the dice")
print(message,random.randint(1,6))
can we upgrade this code to make a software randomgenarator from 1-100 with UI?
import random
dice_roll_user = random.randint(1, 6)
dice_roll_computer = random.randint(1, 6)
if dice_roll_user > dice_roll_computer:
print(f'You won the computer! You rolled a {dice_roll_user} and the computer rolled a {dice_roll_computer}.')
elif dice_roll_user == dice_roll_computer:
print(f'You tied with the computer! You rolled a {dice_roll_user} and the computer rolled a {dice_roll_computer}.')
else:
print(f'You lost for computer! You rolled a {dice_roll_user} and the computer rolled a {dice_roll_computer}.')
import random
print("Dice Roll " + str(random.randint(1, 6)))
My solution:
"""
Autor: Juan Sebastian Valencia
Simple Dice Rolling Simulator
Proyecto diario de Dialy Python Projects
Modulo para retornar un numero aleatorio entre 1 y 6
"""
from random import randint
def rolling_simulator():
return f'You rolled a {randint(1, 6)}!'
print(rolling_simulator())
import random
print(f"You rolled a {random.randint(1,6)}! ")