Skip to content

Instantly share code, notes, and snippets.

View iamshadmirza's full-sized avatar
👨‍💻
Tap Tap Tap

Shad Mirza iamshadmirza

👨‍💻
Tap Tap Tap
View GitHub Profile
@iamshadmirza
iamshadmirza / listcomprehension.py
Created February 19, 2018 15:29
Intersection on two lists
import random
a= random.sample(range(1,30), 7)
b= random.sample(range(1,30), 10)
result1= []
result2 = []
result3 = []
for element in a:
if element in b:
result1.append(element)
print(result1)
@iamshadmirza
iamshadmirza / guessthenumber.py
Created February 19, 2018 14:24
beginning with python
import random
cpunum = random.randrange(1,9)
usernum = 0
count = 0
print('guess a number between 1 and 9')
while True:
usernum = input()
count += 1
if usernum== 'exit':
break
@iamshadmirza
iamshadmirza / stonepaperscissor.py
Created February 19, 2018 12:03
Interacting with python
import random
def mainfunction():
while True:
rnum = random.randrange(1,4)
cpuschoice = numtochoice(rnum)
userscoice = input("Choose between stone, paper and scissor\n")
print('Cpu has choosen : ', cpuschoice)
print(decision(userscoice.lower(), cpuschoice))
def numtochoice(num):