def splitfile(filename, filename1, filename2, weight):
    newfile = open(filename, 'r', encoding='utf-8')
    file1 = open(filename1, 'a')
    file2 = open(filename2, 'a')
    for line in newfile:
        if dice(1, weight) == 1:
            file2.write(line)
        else:
            file1.write(line)
    newfile.close()
    file1.close()
    file2.close()
    return True
def main():
    print("Welcome to this game")
    pp1=input("Enter your name : ")
    po=0
    while(1):
        print("Rolling a dice.....")
        time_delay()
        secret_number=int(dice(1,6))
        choise=int(input("What's your guess : "))
        if(secret_number==choise):
            print("Hurray you nailed it!")
            po += 1
        elif(secret_number>choise):
            print("You're too low!\nKeep Trying")
        elif(secret_number<choise):
            print("You're too high!\nKeep Trying")
            
        descision=input("Can we continue : Y/N : ")
        descision.lower()
        if(descision=='n'):
            break
    thank(pp1,po)
# Updated: 2019-10-30

			### MODULES ###

# modules - import extra functionality
	import random # whole module
	print(random.randint(1, 10))
	
	from random import randint # specific functions
	print(randint(1, 10))
	
	from random import randint as dice # specific functions with a custom name
	print(dice(1, 6))
	
		# importing modules to Python
		pip install module_name
		
			### ELEMENTARY COMMANDS ###
			
# print - output text to console
	print('text')
	
# r'' - treat text as raw
	print(r'\text') # \text


# Arithmetic operators
	# +		addition
	# -		subtraction
	# *		multiplication
	# /		division)
Example #4
0
from random import randint as dice

secret_number = dice(1, 9)
count = 0
name = input(
    "Let's play a dice game, shall we? You will have 5 attempts. Input your name to confirm: "
)
guest_number = 0

while (guest_number != secret_number and count < 5):
    guest_number = input(name +
                         " Please pick a interge number between 1 to 9 : ")
    guest_number = int(guest_number)
    count = count + 1
    if (guest_number > 9 and count < 5):
        print("It must be a number between 1 to 9")
    elif (guest_number > secret_number and count < 5):
        print("Try a smaller number, you have used " + str(count) + " try")
    elif (guest_number < secret_number and count < 5):
        print("Try a bigger number, you have used " + str(count) + " try")
    elif (guest_number != secret_number and count >= 5):
        print("Sorry, the game is ended")
    else:
        print("Congradulation!You have found the correct number " +
              str(secret_number))
def dice_roll():
    return dice(1, 6) + dice(1, 6)
Example #6
0
def gen_seq(length):
    seq = list()
    for _ in range(length):
        seq.append(dice(-100, 100))
    return tuple(seq)
Example #7
0
 def __init__(self):
     sg.change_look_and_feel('Reds')
     layout = [[
         sg.Text('Nome:', size=(12, 0)),
         sg.Input(size=(15, 0), key='no')
     ],
               [
                   sg.Text('Habilidade:', size=(12, 0)),
                   sg.Input(dice(1, 6) + 6, key='ha', size=(15, 0))
               ],
               [
                   sg.Text('Energia:', size=(12, 0)),
                   sg.Input(dice(1, 6) + dice(1, 6) + 12,
                            key='en',
                            size=(15, 0))
               ],
               [
                   sg.Text('Sorte:', size=(12, 0)),
                   sg.Input(dice(1, 6) + 6, key='so', size=(15, 0))
               ],
               [
                   sg.Text('Fé:', size=(12, 0)),
                   sg.Input(dice(1, 6) + 3, key='fe', size=(15, 0))
               ],
               [
                   sg.Text('Provisões:', size=(12, 0)),
                   sg.Slider(range=(0, 15),
                             default_value=0,
                             orientation='h',
                             size=(15, 15),
                             key='pro')
               ],
               [
                   sg.Text('Ouro:', size=(12, 0)),
                   sg.Slider(range=(0, 50),
                             default_value=0,
                             orientation='h',
                             size=(15, 15),
                             key='ouro')
               ], [sg.Button('Atualizar')], [sg.Text('Equipamento.')],
               [
                   sg.Checkbox('1:', key='I1'),
                   sg.Input(size=(24, 10), default_text='Arma', key='i1')
               ],
               [
                   sg.Checkbox('2:', key='I2'),
                   sg.Input(size=(24, 10), default_text='Escudo', key='i2')
               ],
               [
                   sg.Checkbox('3:', key='I3'),
                   sg.Input(size=(24, 10),
                            default_text='Armadura',
                            key='i3')
               ],
               [
                   sg.Checkbox('4:', key='I4'),
                   sg.Input(size=(24, 10), default_text='Jóia', key='i4')
               ],
               [
                   sg.Checkbox('5:', key='I5'),
                   sg.Input(size=(24, 10),
                            default_text='Encantamento',
                            key='i5')
               ], [sg.Text('Log de mudanças.', size=(24, 0))],
               [sg.Output(size=(30, 12))]]
     self.janela = sg.Window('Ficha').layout(layout)