示例#1
0
    def __init__(self):
        self.live = 1
        self.points = 0
        self.id = canv.create_oval(50, 50, 100, 100)
        self.id_points = canv.create_text(30, 30, text=self.points, font='28')

        self.x = rnd(600, 780)
        self.y = rnd(300, 550)
        self.r = rnd(20, 50)
        color = self.color = 'red'

        self.vx = rndint(0, 10)
        self.vy = rndint(0, 10)
        #self.new_target()
        canv.coords(self.id, self.x - self.r, self.y - self.r, self.x + self.r,
                    self.y + self.r)
        canv.itemconfig(self.id, fill=color)
示例#2
0
 def cons ():
      r=rndint(0,2)
      if r==0:
           return np.array((nv(mx,mx/4), rnd()*15, nv(peak,10),\
                            nv(-mx,mx/4)*-10,rnd()*15, nv(peak,10),\
                            c*nv(1, 0.1)))
      elif r==1:
           return np.array((nv(mx,mx/4)*10, rnd()*15, nv(peak,10),\
                            nv(mn,mn/4)*-10,rnd()*15, nv(trough,10),\
                            c*nv(1, 0.1)))
      else :
           return np.array((nv(mn,mn/4)*10, rnd()*15, nv(trough,10),\
                            nv(mn,mn/4)*-10,rnd()*15, nv(trough,10),\
                            c*nv(1, 0.1)))
示例#3
0
def shake():
    board = [rndint(1, 6) for i in range(5 - len(saveDice))]
    return board
from random import randint as rndint, random
import sys

MIN_BONUS=2
MAX_BONUS=6
MIN_NR_REGIONS=2
MAX_NR_REGIONS=5
MIN_NR_SUPER_REGIONS=10
MAX_NR_SUPER_REGIONS=20
MIN_NR_NEIGHBOURS=1
MAX_NR_NEIGHBOURS=2

super_regions = range(rndint(MIN_NR_SUPER_REGIONS, MAX_NR_SUPER_REGIONS))
bonus = { sr : b 
          for sr in super_regions 
          for b in [rndint(MIN_BONUS, MAX_BONUS)] }

total_nr_regions = 0
regions = []
for sr in super_regions:
    nr_regions = rndint(MIN_NR_REGIONS, MAX_NR_REGIONS)
    total_nr_regions += nr_regions
    new_regions = [{"id" : i+len(regions), 
                    "superRegion" : sr,
                    "neighbors" : [r 
                                   for r in range(len(regions),i+len(regions)) + range(i+len(regions)+1,nr_regions+len(regions))
                                   if random()<0.85] } 
                   for i in range(nr_regions)]
    regions.extend(new_regions)

for r in regions:
示例#5
0
from notifypy import Notify  #if not available, install with "pip3 install notify-py"
from time import sleep
from random import randint as rndint
import os
d = 20  #notification duration. (in minutes)

notify = Notify()
facts = [
    "Only 1.1% of the water on earth is suitable for drinking as is.",
    "Our bodies consist of 55 – 75% water",
    "Depression and fatigue can often be symptoms of dehydration.",
    "Adult humans are 60 percent water, and our blood is 90 percent water.",
    "Water is essential for the kidneys and other bodily functions.",
    "When dehydrated, the skin can become more vulnerable to skin disorders and wrinkling.",
    "Drinking water instead of soda can help with weight loss.",
    "Children in the first 6 months of life consume seven times as much water per pound as the average American adult.",
    "Water is Part of a Deeply Interconnected System.",
    "A Person Can Only Live About a Week Without Water.",
    "Water Regulates the Earth's Temperature.",
    "Approximately 80% of your brain tissue is made of water"
]
sleep(60 * 1)
while (True):
    notify.title = "Water Reminder | Please drink a glass of water"
    randfacts = facts[rndint(0, len(facts) - 1)]
    notify.message = randfacts
    notify.icon = str(os.path.dirname(__file__)) + "/icon/icon.png"
    notify.send()
    sleep(60 * d)
#################################################


#import required libraries
from random import randint as rndint
import sys


#set a list of valid objects
objects = ['Rock', 'Paper', 'Scissors']

print('\n\nRock, Paper, Scissors')
while True:
    #let computer randomly pick one of the valid objects
    computer_throw = objects[rndint(0,2)]
    
    #collect player pick
    player_throw = input('\nChoose either "Rock", "Paper" \
or "Scissors"\n------> ').title()
    
    #ask player again for a pick after an invalid selection
    while player_throw not in objects:
        player_throw = input('Your pick is invalid,\nChoose either \
"Rock", "Paper" or "Scissors"\n------> ').title()
        
    #set conditions for a tied game
    if computer_throw == player_throw:
        print('Tie!')
        
    #set conditions for player wins