วิธีที่จะทำให้เป็นลภาษาไพธอน

รหัสตัวอย่าง

1
0

จกลิ้ง simulator กับเขาเป็นภาษาไพธอน

from random import randint

def roll_dice():
    print(f"Number is: {randint(1,6)}")

# Do this to simulate once
roll_dice()   

# Do this to simulate multiple times
whatever = 12 # Put the number of times you want to simulate here
for number in range(whatever):
    roll_dice()
0
0

วิธีที่จะทำให้เป็นลองโปรแกรมที่เป็นภาษาไพธอน

import random
run = 1
level = 0
while(run == 1):
        print("**ROUND " + str(level) + "**") 
        print("player 1: ",random.randint(0, 6))
        print("player 2: ",random.randint(0, 6))
        run = int(input("enter 1 to go again or 0 to end: "))
        print("")
        level += 1
0
0

วิธีที่จะทำให้เป็นลภาษาไพธอน

#For one time roll
from random import randint

dice_roll = randint(1,6) 
#You can change numbers to anything you want, it can go up to 1 million if you really want it to
print("You Threw a", dice_roll)
#That's for one time throw but if you want it for multiple people then do this

#For multiple roles 
import time
from random import randint
for j in range(10):
    dice_roll = randint(1,6)
    time.sleep(3)
    print("You threw a", dice_roll)

หน้าคล้ายกัน

คล้ายกันหน้ากับตัวอย่าง

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังหน้ากับตัวอย่างอยู่ในหมวดหมู่