This file contains 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
myList = [[2,4,5],[6,7,8]] | |
for i in myList : | |
print(i) |
This file contains 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
myList = [[2,4,5],[5,6,7]] | |
for x,eachList in enumerate(myList) : | |
for i in enumerate(myList) : | |
print(i) |
This file contains 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
>>> sum = lambda x,y : x + y | |
>>> add = lambda x,y : x+ y | |
>>> add(24,16) | |
40 | |
>>> add | |
<function <lambda> at 0x038FD780> | |
>>> 0x038FD780 | |
59758464 |
This file contains 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
##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)] |
This file contains 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
#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 = [] |
This file contains 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
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]) |
This file contains 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 | |
print('you') | |
time.sleep(2) | |
print('have') | |
time.sleep(2) | |
print('been') | |
time.sleep(2) | |
print('HACKED') |
This file contains 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 | |
namePeople = ['birthday' , 'airplane' , 'tiger' , 'butterfly' , 'giraffe'] | |
wordGenerated = (random.choice(namePeople)) | |
times_failed = 0 | |
while True : | |
userGuess = input("Guess the word: ") | |
if userGuess == wordGenerated : |
This file contains 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
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) |
OlderNewer