Skip to content

Instantly share code, notes, and snippets.

View codeboy101's full-sized avatar

Tushar codeboy101

View GitHub Profile
import time
import random
game_map = [""*i for i in range(9)]
spots_for_comp = [int(x) for x in range(9)]
def checkWinner() :
if all(x==comp_sign for x in game_map[0:3]) :
print("comp wins")
if all(x==user_sign for x in game_map[0:3]) :
import praw
def activeRedditor(name_put_in1 , name_put_in2) :
r = praw.Reddit("activeness checker")
user_name1 = name_put_in1
user_name2 = name_put_in2
user1 = r.get_redditor(user_name1)
print(user1)
user2 = r.get_redditor(user_name2)
with open("questions.txt") as file:
for x in file :
no_new_line = x.replace("\n","")
questions_list = [no_new_line.split(':')]
for i, x in questions_list:
print("{}".format(i))
askUser = input("enter answer:")
if askUser is x:
print("right")
a = ["word\n" , " " , "someword"]
for x in a:
if x == " ":
a.remove(x)
for x in a :
if "\n" in x:
new = x.replace("\n","")
a.append(new)
when_asked = datetime.datetime.now()
when_told = datetime.datetime.now()
intel_time = when_told - when_asked
if intel_time > 0:00:05: ##why does this show as invalid syntax ?
import random
import time
my_team_name = input('name your team: ')
opp_team_names = ['ice slayers' , 'crazy cats' , 'red devils' , 'blue walls']
opp_team_name = random.choice(opp_team_names)
print('your match is against {}'.format(opp_team_name))
pass_text = [' gives the ball to ' , ' passes it to ' , ' sharply gives it to ' , ' puts it in the path of ']
defend_text = [' performs a great tackle ' , ' comes up with a meaty tackle ']
shoot_text = [ 'hits the ball ' , ' curls it towards the goal ' , ' shoots ']
# two different files pasted under one gist.
# server.py
import socket
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # using address family ipv4 and protocol tcp/ip
sock.bind(('0.0.0.0',8888)) # host , port number
sock.listen(5)
s,data=sock.accept() # accept socket connections
while True: #keep on sending and receiving data
new = input()
if new == "!!!":
@codeboy101
codeboy101 / idk.py
Last active January 21, 2016 07:31
data = {'lastname':'','firstname':'','score':'','grade':''}
def df(lastname,firstname,score,grade):
data['lastname'] = lastname
data['firstname'] = firstname
data['score'] = score
data['grade'] = grade
print(data)
df('yourname','yourlastname',80,2)
# the two files server.py and client.py are two different files but they have been pasted into 1 single gist .
#server.py:
import socket
import sys
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.bind(('0.0.0.0',7777))
sock.listen(5)
s,data=sock.accept()
while True:
import time
import datetime
with open("questions.txt") as file:
test_list = [x.split(':') for x in file.read().splitlines()] # the last element of the list created is [""] , the general format is : ["question","answer of the question"] . these values are unpacked as i and x with the for loop. but when the for loop comes to the last element which is [""] , there is an error, not enough values to unpack
correct_count = 0
priority_list = []
time_taken = datetime.timedelta(seconds = 5)