Dice
Write a program that, like a dice, prints a random number between 1 and 6 in the output with each time running
Write a program that, like a dice, prints a random number between 1 and 6 in the output with each time running
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
import random def roll_dice(): # Select a random number between 1 and 6 dice_number = random.randint(1, 6) return dice_number # The implementation of the function and printing the result result = roll_dice() print("تاس رول شده:", result)
import random
while True:
a=input("Would you like to roll the dice: 1.Yes 2.No\n")
if a=="2":
print("End")
break
elif a=="1":
print(random.randint(1,7))
continue
from random import randint
def dice():
yield randint(1, 6)
dice_gen=dice()
print(next(dice_gen))
from random import choice
nums = list(range(1,7))
print(f"Tas number is: {choice(nums)} ")
public static void main(String[] args) { int RolDice = (int) (Math.random() * 6) + 1; if (RolDice == 1) { System.out.println("[ ]"); System.out.println("[ 0 ]"); System.out.println("[ ]"); }else if (RolDice == 2) { System.out.println("[0 ]"); System.out.println("[ ]"); System.out.println("[ 0]"); }else if (RolDice == 3) { System.out.println("[0 ]"); System.out.println("[ 0 ]"); System.out.println("[ 0]"); }else if (RolDice == 4) { System.out.println("[0 0]"); System.out.println("[ ]"); System.out.println("[0 0]"); }else if (RolDice == 5) { System.out.println("[0 0]"); System.out.println("[ 0 ]"); System.out.println("[0 0]"); }else if (RolDice == 6) { System.out.println("[0 0]"); System.out.println("[0 0]"); System.out.println("[0 0]"); } }
import random x = random.randint(1,6) while True: y = input("for end & start program press (s/d):") if y == 'd' : print("....end....") break elif y == 's' : while True: if x == 1: print(" | |",'\n',"| o |",'\n',"| |") elif x == 2: print(" |o |",'\n',"| |",'\n',"| o|") elif x == 3: print(" |o |",'\n',"| o |",'\n',"| o|") elif x == 4: print(" |o o|",'\n',"| |",'\n',"|o o|") elif x == 5: print(" |o o|",'\n',"| o |",'\n',"|o o|") elif x == 6 : print(" |o o|",'\n',"|o o|",'\n',"|o o|") break else : print("Invalid input. Please choose 's' or 'd'.")
from random import * a=randrange(1,7) print('your number is',a)
Submitting answers is currently unavailable.
You must be logged in to access this section.
Login/Sign up If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.