This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]) : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 '] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 == "!!!": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |