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 time import strftime | |
| now = int(strftime("%Y")) | |
| name = input("What is your name?\n->") | |
| years = list(range(100)) | |
| while True: | |
| try: | |
| age = int(input("How old are you?\n->")) | |
| if age not in years: |
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: | |
| try: | |
| check = input("Input a natural number.\n->") | |
| if check == 'exit': break | |
| num = input("Input a divider.\n->") | |
| if num == 'exit': break | |
| check = int(check) | |
| num = int(num) | |
| if check % 4 == 0: | |
| print("{0} is multiple of 4.".format(check)) |
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, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
| num = input('Input a number: ') | |
| num = int(num) | |
| b = [i for i in a if i < num] | |
| 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
| num = input("Input a number: ") | |
| num = int(num) | |
| rng = range(1,num+1) | |
| new_rng = [i for i in rng if num % i ==0] | |
| print(new_rng) |
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)) |
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
| 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
| 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
| 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
| 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] |
OlderNewer