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 numpy | |
def rnd_list(): | |
size_of_list = numpy.random.randint(10, 20) | |
return numpy.random.randint(0, 100, size_of_list) | |
def rm_duplicates_1(lst): | |
return list(set(lst)) |
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
def get_user_int(msg): | |
''' | |
Return integer from user. | |
:param msg: | |
:return user_input: | |
''' | |
user_input = input(msg) | |
try: | |
user_input = int(user_input) | |
except: |
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
def get_list_ends(input_list): | |
""" | |
Return the first and last item of list. | |
:param input_list: | |
:return list_ends: | |
""" | |
return [input_list[0], input_list[-1]] | |
a = [5, 10, 15, 20, 25] |
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
def get_user_int(msg): | |
''' | |
Return integer from user. | |
:param msg: | |
:return user_input: | |
''' | |
user_input = input(msg) | |
try: | |
user_input = int(user_input) | |
except: |
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 numpy | |
def rnd(): | |
return numpy.random.randint(0, 100, numpy.random.randint(10, 30)) | |
a, b = rnd(), rnd() | |
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
# b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] |
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 | |
def new(): | |
global num, count | |
num = random.randint(1, 9) | |
count = 0 | |
too = [8, 7, 6, 5] | |
close = [4, 3, 2, 1] |
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
from pandas import DataFrame | |
rules = "\n'r' for 'rock;\n'p' for 'paper';\n's' for 'scissors'." | |
pick = ['r', 'p', 's'] | |
m = DataFrame([[None, True, False], [False, None, True], [True, False, None]], | |
columns=pick, | |
index=pick) | |
print("Rock-Paper-Scissors Game!\n"+rules) | |
while True: | |
one = input("Player one: ") |
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 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] | |
b = [i for i in a if i % 2 == 0] | |
print(b) |
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
while True: | |
something = input('Input text("exit" to break): ') | |
if something == 'exit': | |
break | |
# exceptions | |
restricted_symbols = [' ', '!', '.', | |
'?', ',', '_', | |
'$', '#', '@', |
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 numpy | |
def rnd(): | |
return numpy.random.randint(0, 100, numpy.random.randint(10, 20)) | |
a, b = rnd(), rnd() | |
c = [i for i in a if i in b] | |
print("First array: {0}\nSecond array: {1}\nArray of common items: {2}".format(a, b, c)) |