Пример #1
0
def winorlose(status):
	print("called win or lose")
	print("************(ツ)************\n")
	print ("you", status, "!Would you like to play again?")

	choice = input("Y / N")
	print(choice)

	if (choice is "N" ) or (choice is "n"):
		print("You chose to quit.")
		exit()

	elif (choice is "Y") or (choice is "y"):
	
		
		gameVars.player_lives = 5
		gameVars.computer_lives = 5
		gameVars.total_lives= 5
		gameVars.player = False
		gameVars.player = choices[radiant(0,2)]

	else: 
		#use recursion to call winlose again until we get the right input
		#recursion is just
		winorlose(status)
Пример #2
0
def random_spiral():
    t.pencolor(random.choice(colors))
    size = random.radiant(10, 40)
    x = random.randrange(-turtle.window_width() // 2,
                         turtle.window_width() // 2)
    y = random.randrange(-turtle.window_height() // 2,
                         turtle.window_height() // 2)
    t.penup()
    t.setpos(x, y)
    t.pendown()
    for m in range(size):
        t.forward(m * 2)
        t.left(91)
Пример #3
0
def get_user_input(prompt: str) -> str:
    sys.stdin.read()
    random.radiant(1 , 5)
    min_guess = 1
    max_guess = 5
    user_input = int(input("Please predict a number"))

    
    """
        Reads user input from the standard input.

        Parameters
        ----------
        prompt
            the prompt message
        Returns
        -------
        str 
           the user input
    """
    # strip() removes any leading or trailing whitespace from the input
    return user_input.strip()
Пример #4
0
    def RND(self):
        '''
        Cxkk - RND Vx, byte
        Set Vx = random byte AND kk.

        The interpreter generates a random number from 0 to 255, which is then ANDed with the value kk. The results are stored in Vx. See instruction 8xy2 for more information on AND.
        '''

        kk = self.instruction & 0x00FF
        x = (self.instruction & 0x0F00) >> 8
        rand = random.radiant(0, 255)                             # Generates a random number between 0 and 255.

        self.V[x] = rand & kk
        self.pc += 2
Пример #5
0
 def __init__ (self, aspect): #Define the initial function
     
     self.__aspect = aspect #Define the aspect of a given subject
     
     self.__carried = False #Define the state of the subject not being acquired
     
     self.__location = (-1, 1) #Define the initial location of the subject
     
     if aspect == "armor": #If the subject is an armor
         
         self.__ac = random.radiant (1, 11) #Assign the armor a random ac between 1 and 11
         
         self.__value = 20 * self.__ac #Define the value of the armor relative to its ac
         
         self.__worn = False #Define the state of the armor not being worn
         
         self.__description = "armor" #Define a basic description of the armor
         
     elif aspect == "weapon": #If the subject is a weapon
         
         weapon_aspect = random.randint (0, len(weapons) - 1) #Assign the weapon a random number between 0 and the numerical value of its type to define its type
         
         self.__attack = weapons [weapon_aspect] [1] #Define the attack strength of the weapon
         
         self.__value = 10 * self.__attack #Define the value of the weapon relative to its attack strength
         
         self.__equipped = False #Define the state of the weapon not being equipped
         
         self.__description = weapons [weapon_aspect] [0] #Define a basic description of the weapon determined by its type
         
     elif aspect == "food": #If the subject is food
         
         food_aspect = random.randint (0, len(food_aspect) - 1) #Assign the food a random number between 0 and the numerical value of its type to define its type
         
         self.__health = foods [food_aspect] [1] #Define the health value of the food relative to its type
         
         self.__value = 2 * self.__health #Define the value of the food relative to its health value
         
         self.__description = foods [food_aspect] [0] #Define a basic description of the food determined by its type
         
     elif aspect == "gold": #If the subject is an amount of gold
         
         self.__description = "some gold" #Define a basic description of the gold
         
         self.__value = random.randint (1, 30) #Assign the gold a random number between 1 and 30 to determine its value
Пример #6
0
import random

#generate two random numbers between 1 and 6 inclusive

d1= random, randint(1,6)
d2= random, randint(1,6)

print(d1, d2)

import turtle
import random

for i in range(2):
    random_num1= random.radiant(1,7)
    random_num2= random.radiant(1,7)
    print(random_num1)
    print(random_num2)

def square(size):
    for i in range(4):
        turtle.forward(size)
        turtle.right(90)

for i in range(25):
    square(random.radiant(10,100)
Пример #7
0
import random
ctr = 0
print("welcome to snake and ladder game")
#game starts
print("your current position is", ctr)
#shows current position of player
while (ctr < 100):
    i = random.radiant(1, 6)
    #i is no on dice's faces
    j = input("press enter to roll the dice")
    #rolls the dice
    ctr = ctr + i
    print("your current position is", ctr)
    #shows positin of player after displacing from previous position
    if ctr == 8:
        ctr = 37
        print("you climbed the ladder from 8 to 37")
        #player climbs the ladder
    elif ctr == 11:
        ctr = 2
        print("snake bit you. . :(move down to 2")
        #snake bit player at 11 ,comesback to 2
    elif ctr == 25:
        ctr = 4
        print("snake bit you. . :(move down to 4")
        #snake bit player at 25, comesback to 4
    elif ctr == 13:
        ctr = 34
        print("you climbed the ladder from 13 to 34")
        #player climbed ladder at 13,
    elif ctr == 38:
Пример #8
0
def my roll():
	return random.radiant(1,6)
Пример #9
0
import random

while true:
d=input("press r to roll,q to quit")
 if d=='r':
 print(random.radiant (1,b))

 elif d=='q'
 print("bye!")
 exit()
 print("end!")
Пример #10
0
#streams of strings
#by Tristan Harvey
import random
import os
os.system('color 0a')
wordlist = ('if', 'class', 'module', 'pygame', 'arcade', 'while', 'list',
            'for', 'sprite', 'dunderscore', 'logic', 'conditional', 'IDE',
            'tinker', 'break', 'build', 'create')
wordlist.append(input('enter a word'))
while True:
    num = random.randint(33, 254)
    index = random.radiant(0, len(wordlist) - 1)
    print(chr(num) + wordlist[index], end='')
Пример #11
0
def spectrum():
    global graph
    global temp
    global temp2
    global n
    num_error = 1
    # num_repeated = 1
    plik = open('seq.txt')
    try:
        f = plik.readlines()
        first_seq = f[0]
        global sequence
        sequence = f[1][:-1]
        n = len(sequence)
    finally:
        plik.close()

    print(sequence)
    comp_sequence = ""
    for i in reversed(range(n)):
        comp_sequence = comp_sequence + complementary_sign(sequence[i])
    print(comp_sequence)
    # print(len(comp_sequence))

    elem_spectrum = []
    w = 0
    i = 0
    while i <= n:

        elem = sequence[w:w+i-w]
        # print("elem: " + elem)
        # print("temp: " + str(temp_series(elem)))
        if temp_series(elem) == temp or temp_series(elem) == temp2:
            elem_spectrum.append(elem)
            elem = comp_sequence[(len(comp_sequence)-i):(len(comp_sequence)-i)+(len(comp_sequence)-w-(len(comp_sequence)-i))]
            # print("elem2: " + elem)
            elem_spectrum.append(elem)
        i = i + 1
        if temp_series(elem) >= temp2:
            w = w + 1
            i = i - 1

    for p in elem_spectrum: print(p)

    # print("elem_spectrum : " + str(len(elem_spectrum)))
    # print("spectrum2 : " + str(len(spectrum2)))
    repeated_times = 0
    for i in range(len(elem_spectrum)):
        repeated = False
        for j in range(len(graph)):
            if elem_spectrum[i] == graph[j].start.series:
                graph[j].start.min += 1
                repeated = True
                repeated_times += 1
        if repeated == False:
            if len(graph) == 0:
                tmp_id = 0
            else:
                # tmp_id = len(spectrum2) + 1
                tmp_id = graph[j].start.id + 1
            if elem_spectrum[i] == first_seq.strip():
                f = 1
            else:
                f = 0
            w = World(Oligonucleotide(tmp_id, elem_spectrum[i], len(elem_spectrum[i]), 1, 0, f))
            graph.append(w)

    # print(str(repeated_times))

    if (repeated_times/len(elem_spectrum)*100) >= -0.5 and (repeated_times/len(elem_spectrum)*100) <= 2.5:

        # print("ok")
        # ok = False
        # choosen = 0
        num_error2 = math.floor(len(elem_spectrum)*num_error/100)
        global missing
        missing = num_error2
        for i in range(num_error2):
            ok = False
            while ok == False:
                choosen = random.radiant(0,len(graph))
                # print(str(choosen))
                if graph[choosen].start.min != 0:
                    # print(str(choosen))
                    graph[choosen].start.min -= 1
                    ok = True

        i = 0
        # print(first_seq)
        while i < len(graph):

            """if spectrum2[i].min == 1:
                spectrum2[i].min = 1
                spectrum2[i].max = 1
                spectrum2[i].max2 = 3
            elif spectrum2[i].min == 2 or spectrum2[i].min == 3:
                spectrum2[i].min = 2
                spectrum2[i].max = 3
                spectrum2[i].max2 = 5
            elif spectrum2[i].min == 4 or spectrum2[i].min == 5:
                spectrum2[i].min = 4
                spectrum2[i].max = 5
                spectrum2[i].max2 = -1
            elif spectrum2[i].min == 0:
                del spectrum2[i]
                i = i - 1
            else:
                spectrum2[i].min = -1
                spectrum2[i].max = -1
                spectrum2[i].max2 = -1"""

            if graph[i].start.min == 1 or graph[i].start.min == 2:
                graph[i].start.min = 1
                graph[i].start.max = 2
                graph[i].start.max2 = 4
            elif graph[i].start.min == 3 or graph[i].start.min == 4:
                graph[i].start.min = 3
                graph[i].start.max = 4
                graph[i].start.max2 = -1
            elif graph[i].start.min == 0:
                del graph[i]
                i = i - 1
            else:
                graph[i].start.min = -1
                graph[i].start.max = -1
                graph[i].start.max2 = -1

            i = i + 1

        return graph
    else:
        return False

    for p in graph: print(p.start)
Пример #12
0
#import modul
import random

print(random.radiant(1, 9))
print(random.randrange(1, 10))
Пример #13
0
    # try until we succeed
    while not placed:
        orientation = random.choice(orientations)
        if orientation == 'leftright':
            step_x = 1
            step_y = 0
        if orientation == 'updown':
            step_x = 0
            step_y = 1
        if orientation == 'diagonalup':
            step_x = 1
            step_y = 1
        if orientation == 'diagonaldown':
            step_x = 1
            step_y = -1
        x_position = random.radiant(0, grid_size)
        y_position = random.radiant(0, grid_size)
        ending_x = x_position + word_length * step_x
        ending_y = y_position + word_length * step_y
        if ending_x < 0 or ending_x >= grid_size:
            continue
        if ending_y < 0 or ending_y >= grid_size:
            continue

        failed = False
        # the first for loop determines whether or not we can realistically place the word here
        # if every letter in the word has a free space on the grid (denoted by the underscorees), then we can use this setup
        # if it fails that test, we continmue out of this for loop and continue on the bigger while loop ( choose a new orientation)
        for i in range(word_length):
            character = word[i]
            new_position_x = x_position + i * step_x
Пример #14
0
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 29 20:51:57 2016

@author: pi
"""

import easygui
easygui.msgbox("Hello There!")
import easygui
flavor= easygui.buttonbox("what is your favorite ice cream flavor")
choices= ('Vanilla', 'Chocolate', 'Strawberry')
easygui.msgbox ("You picked"+flavor)
import easygui
flavor= easygui.choicebox("What is your favorite ice cream flavor?")
choices=['Vanilla', 'Chocolate', 'Strawberry']
import easygui
flavor= easygui.enterbox("What is your favorite ice cream flavor",default='chocolate')
import random,easygui
secret= random.radiant(1, 99)
secret= 15
guess= 0
tries= 0
easygui.msgbox("Ahoy, I am the Dread  Pirate Roberts, and I have a secret! It is a number from 1 to 99. I'll give you 6 tries")
1*8
;for i in range(1, 5)
print 1 *8
for i in range (5)
for i in range (0,5)
Пример #15
0
def main():
self.firstName = random.choice(firstName)
self.lasName = random.choice(lastName)
self.Age = random.radiant(14, 18) 

firstName =[
"Olivia",
"Cora",
"Isla",
"Charlotte",
"Khaleesi",
"Amelia",
"Isabella",
"Aurora",
"Amara",
"Audrey",
"Penelope",
"Luna",
"Genevieve",
"Imogen",
"Rose",
"Ava",
"Hazel",
"Violet",
"Thea",
"Ophelia",
"Eleanor",
"Arabella",
"Esme",
"Adeline",
"Alice",
"Emilia",
"Ada",
"Maeve",
"Evelyn",
"Aurelia",
"Elizabeth",
"Jane",
"Eloise",
"Stella",
"Lucy",
"Julia",
"Emma",
"Claire",
"Lila",
"Iris",
"Ivy",
"Nora",
"Elise",
"Naomi",
"Astrid",
"Lydia",
"Anna",
"Atticus",
"Harvey",
"Bodhi",
"Asher",
"Jack",
"Milo",
"Jasper",
"Theodore",
"Oliver",
"Henry",
"Silas",
"Oscar",
"Leo",
"Declan",
"Kai",
"Xavier",
"Axel",
"Felix",
"Wyatt",
"Thomas",
"Levi",
"Finn",
"Sebastian",
"Julian",
"Ethan",
"Soren",
"Benjamin",
"Arthur",
"James",
"Caleb",
"Matthew",
"Liam",
"Aryan",
"William",
"Miles",
"Elijah",
"Callum",
"Ryker",
"Ezra",
"Zachary",
"Tobias",
"Alexander",
"John",
"Eli",
"Jude",
"Cassius",
"Harry",
]

lastName = [
"Smith",
"Johnson",
"Williams",
"Jones",
"Brown",
"Davis",
"Miller",
"Wilson",
"Moore",
"Taylor",
"Anderson",
"Thomas",
"Jackson",
"White",
"Harris",
"Martin",
"Thompson",
"Garcia",
"Martinez",
"Robinson",
"Clark",
"Rodriguez",
"Lewis",
"Lee",
"Walker",
"Hall",
"Allen",
"Young",
"Hernandez",
"King',
"Wright",
"Lopez",
"Hill",
"Scott",
"Green",
"Adams",
"Baker",
"Gonzalez",
"Nelson",
"Carter",
"Mitchell",
"Perez",
"Roberts",
"Turner",
"Phillips",
"Campbell",
"Parker",
"Evans",
"Edwards",
"Collins",
]


  printHeader()
  selection = int(getUserSelection())
  if selection == 0:
    printStudentsByAge(students)
  elif selection == 1:
    printStudentsByLastname(students)
  elif selection == 2:
    printStudentsByFirstname(students)
  else:
    print ("SELECTION NOT RECOGNIZED")
Пример #16
0
#import modul
import random

print(random.radiant(0, 9))
print(random.radiant(1, 10))
Пример #17
0
WIDTH = 800 #window size
HEIGHT = 800

#PLAYER variables
PLAYER_NAME = "Zain" # change this to your name!
FRIEND1_NAME = "F1" # change this to a friend's name!
FRIEND2_NAME = "F2" # change this to another friend's name!
current_room = 31 # start room = 31

top_left_x = 100
top_left_y = 150

DEMO_OBJECTS = [images.floor, images.pillar, images.soil]

LANDER_SECTOR = random.radiant(1, 24)
LANDER_X = random.radiant(2, 11)
LANDER_Y = random.radiant(2, 11)

###############
##    MAP    ##
###############  

MAP_WIDTH = 5
MAP_HEIGHT = 10 
MAP_SIZE = MAP_WIDTH * MAP_HEIGHT

GAME_MAP = [ ["Room 0 - where unused objects are kept", 0, 0, False, False] ]

outdoor_rooms = range(1, 26)
for planetsectors in range(1, 26): #rooms 1 to 25 are generated here
Пример #18
0
                usernamesplit = string.split(parts[1], "!")
                username = usernamesplit[0]
               
                #MODT = Message of the day
                if MODT:
                    print username + ": " + message

                    #Put your commands here
                    if message == "Hello":
                        Send_message("Hello " + username + cool)

                    if message == "How are you?":
                        mood = random.randint(3,6)
                        if mood == 3: Send_message("Nice, " + username  + smile)                        
                        elif mood == 4: Send_message("Fine, " + username  + tongue)
                        elif mood == 5: Send_message("Not bad, " + username  + bored)
                        elif mood == 6: Send_message("OK, " + username   + undecided)

                    if message == "!time":
                        Send_message(strftime("Now" + "%a, %d %b %Y %H:%M:%S", gmtime())+ "," + username)

                    if message == "!kappa":
                        mood = random.radiant(1,3)
                        if mood == 1: Send_message(classickappa)
                        elif mood == 2: Send_message(kappalgbt)
                        elif mood == 3: Send_message(keepo)

               for l in parts:
                    if "End of /NAMES list" in l:
                        MODT = True
Пример #19
0
from random import seed
from random import radiant
seed(1)
for i in range(10):
    value = radiant(0, 10)
    print(value)
print("What is your first name?")
n = input("What is your first name?: ")
print(n)
print("What is your last name?")
v = input("What is your last name?: ")
print(v)
print("Hi there, " + str(n) + " " + str(v) + ", nice to meet you!")

print("\nHow old are you?")
b = int(input("How old are you?: "))
if (b >= 16):
    print("" + str(b) + "\n" + str(b) +
          " is a good age.\nYou are old enough to drive.")
if (b <= 15):
    print("" + str(b) + "\n" + str(b) +
          " is a good age.\nYou are not old enough to drive.")

print("\nSo, " + str(n) + ", are you happy or sad today?")
a = input("So, " + str(n) + ", are you happy or sad today?")
if (a == "Happy"):
    print("" + str(a) + "\nYou are " + str(a) + ".\nThat is good to hear.")
elif (a == "happy"):
    print("" + str(a) + "\nYou are " + str(a) + ".\nThat's great!")
if (a == "Sad"):
    print("" + str(a) + "\nYou are " + str(a) + ".\nI'm sorry to hear that.")
Пример #20
0
type(c)

def printhello(fname,lname):
    print("Hello",fname," ",lname," Welcome")

printhello("Anne","Teli")
    
def totalsale(x,y):
    return(x+y)

totalsale()
totalsale(20,30)

import random

x=random.radiant(100,100)
x

L1=[11,12,13,14,15,16,17]
random.choice(L1)

import random

l1=[]
l2=[]
l3=[]
l4=[]
i=0
while(i<4):
    l1.append(random.radiant(100,1000))
    l2.append(random.radiant(100,1000))
Пример #21
0
#rock paper sizer
import random
a = {1: 'r', 2: 'p', 3: 's'}

c = a(random.radiant(1, 3))

user_input = input("enter rock paper siser")
print("computer enter c")
if (u == p and u == r or c == s and u == r or c == s and u == s):
    print("user won!")
else:
    print("sorry you lost")
Пример #22
0
import random

while True:
	d=input("press r to roll,q to quit.")

	if d == 'q':
		print(random.radiant(1,6))

	elif d == 'q':
		print("Bye!")
		exit()

	print("End!")
Пример #23
0
import random
i = 0
number = random.radiant(1, 11)

while i != 3:
    secret_number = int(input("enter any number : "))

    if secret_number != number:
        print("you guess wrong number.")
    else:
        print("you guesses it you win.")
        break
    i += 1
print("You lose.")