Program Dice Simulator Python

Program Dice Simulator Python


Pada post kali ini, saya akan membagikan program sederhana ya bisa buat nentuin giveaway, main uler tangga, main monopoli, atau sekedar nebak doang, programnya yaitu dice simulator, ya simulator dadu, langsung ke source codenya.

Source Code:

import random
print("This is a dice simulator")
x = "y"
 
while x == "y":
    number = random.randint(1,6)
 
    if number == 1:
        print("----------")
        print("|        |")
        print("|    O   |")
        print("|        |")
        print("----------")
    if number == 2:
        print("----------")
        print("|        |")
        print("| O    O |")
        print("|        |")
        print("----------")
    if number == 3:
        print("----------")
        print("|    O   |")
        print("|    O   |")
        print("|    O   |")
        print("----------")
    if number == 4:
        print("----------")
        print("| O    O |")
        print("|        |")
        print("| O    O |")
        print("----------")
    if number == 5:
        print("----------")
        print("| O    O |")
        print("|    O   |")
        print("| O    O |")
        print("----------")
    if number == 6:
        print("----------")
        print("| O    O |")
        print("| O    O |")
        print("| O    O |")
        print("----------")
    x = input("Press y to roll again ")
 
itu dia source codenya, sangat sederhana sekali, terima kasih.

Post a Comment

0 Comments