Skip to content

Instantly share code, notes, and snippets.

View codeboy101's full-sized avatar

Tushar codeboy101

View GitHub Profile
myList = [[2,4,5],[6,7,8]]
for i in myList :
print(i)
myList = [[2,4,5],[5,6,7]]
for x,eachList in enumerate(myList) :
for i in enumerate(myList) :
print(i)
>>> sum = lambda x,y : x + y
>>> add = lambda x,y : x+ y
>>> add(24,16)
40
>>> add
<function <lambda> at 0x038FD780>
>>> 0x038FD780
59758464
item = ['burger','fries','pizza'] ## price for burger : 40 , fries : 20 , pizza : 50
price_customer_order = []
customer_order = []
place_order = input("place order")
## now assuming the customer ordered say : 12 say burger and fries
for i in place_order :
if i == "1" :
customer_order.append(item[0])
price_customer_order.append(40)
elif i == "2" :
##okay so we want to make a list of square of numbers 1 to 5 :
## so we can do it like this :
square_list = []
for i in range(1,6) :
square_list.append(i**2)
print(square_list)
## or by using list comprehension :
square_list = [i**2 for i in range(1,6)]
#F1 see this :
# wordWars my version :
loadAmmo = input("enter your word seperated by a space : ") #taking in words
new = loadAmmo.split(' ') # splitting em
redTeam = new[0] ## assigning straightaway because we know there are only going to be 2 words
blueTeam = new[1]
blueAmmo = [] # arrays for unique letters or characters for each team
redAmmo = []
numbers_in_file = []
with open('numbersTest.txt') as file : ## the contents of the text file are exactly as follows , without the quotations and the arrow --> " 3 5 8"
x = file.read()
for i in x :
numbers_in_file.append(i)
del numbers_in_file[1]
del numbers_in_file[2]
int_3 = int(numbers_in_file[0])
int_5 = int(numbers_in_file[1])
import time
print('you')
time.sleep(2)
print('have')
time.sleep(2)
print('been')
time.sleep(2)
print('HACKED')
import random
namePeople = ['birthday' , 'airplane' , 'tiger' , 'butterfly' , 'giraffe']
wordGenerated = (random.choice(namePeople))
times_failed = 0
while True :
userGuess = input("Guess the word: ")
if userGuess == wordGenerated :
my_num = '153'
new_num = [int(x) for x in my_num]
check_num = (new_num[0] * 100) + (new_num[1] * 10) + (new_num[2] * 1)