text
stringlengths
5
121k
r"""quaternion use example""" from quaternions.quaternion import Quaternion q = Quaternion() print(q) print(q.normalize()) print(q.conjugate()) q = Quaternion(a=2, b=3) print(q)
''' Open a file, count the number of words in that file using a space as a delimeter between character groups. ''' file_name = 'input-files/one.txt' num_lines = 0 num_words = 0 words = [] with open(file_name, 'r') as f: for line in f: print(f'A line looks like this: \n{line}') split_line = lin...
import sqlite3 DROP_BOOKS = "DROP TABLE IF EXISTS books" CREATE_BOOKS = '''CREATE TABLE books( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, author TEXT, cover TEXT DEFAULT 'book.png' )''' conn = sqlite3.connect('bookdb.sqlite3') c = conn.cursor() c.execute(DROP_BOOKS) c.execute(CREATE_BOOKS) conn...
from random import randint def replay(): try_again = raw_input("Try again? (y/n) ") if try_again == "y": play_game() elif try_again == "n": print("Thanks for playing!") else: print("Sorry, I did not understand your response.") replay() ...
n = int(input()) edges = [] degrees = [0] for i in range(n): degrees.append(0) output = [] for i in range(n-1): output.append(-1) def d3(): d3_vertex = 0 for i in range(n+1): if ( degrees[i] > 2 ): d3_vertex = i return d3_vertex for i in range (n-1): ...
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression A = 2 B = 3 xArr = np.random.randint(100, size=(100, 1)) eArr = np.random.randint(200, size=(100, 1)) yArr = A + B * xArr + eArr data = np.c_[xArr, yArr] save = pd.DataFrame(data, columns=["x_dat...
""" Puzzle 21 id 76 """ def ping(i): if i > 0: return pong(i - 1) return "0" def pong(i): if i > 0: return ping(i - 1) return "1" print(ping(29)) print(ping(10)) print(pong(29)) print(pong(10)) print("Me (*´∀`*)oo0(So the answer will be different by given numbers are odd or not a...
from des64v1 import cipher, reverse_cipher, tobits, frombits text = 'BONJOUR!' key = 'aa00df8' print('encryption key: ', key) print('text before encryption: ', text) bin_text = tobits(text) bin_key = tobits(key) print('#### CIPHERING ####') bin_result = cipher(bin_text, bin_key) result = frombits(bin_r...
import random for x in range(5): print(random.random()) for x in range(5): print(random.randint(10,30)) pets = ['turtle','frog','mantis','cat','bees'] first_feed = random.choice(pets) print(first_feed) import random class Dice: def dice(self): face1 = random.randint(1,7) face2 =...
"""Binary Search Tree and Binary Search Tree""" class node: def __init__(self, data=None): self.data = data self.left = None self.right = None class binary_search_tree: def __init__(self): self.root = None def insert(self, data): if self.root == None: ...
import csv import os import requests import bs4 from bs4 import BeautifulSoup """Get Prominent Cajun Fiddlers""" def result_page_spider(): url = 'https://en.wikipedia.org/wiki/Cajun_fiddle' source_code = requests.get(url) source_text = source_code.text soup = BeautifulSoup(source_text,"lxml") ...
for letter in "coffee": print(letter) for num in range (10,20,2): print(num) for num in range(0,100,5): print(num) x = 0 for n in range(10,21): if n % 2 !=0: x += n times = input ("How many time do I have to tell You ?") times = int(times) for time in range(times): print(...
""" name = 'onja' if name == 'ola': print('Hey, ola') elif name == 'onja': print('Hey, onja') else: print('Hey, anything') def hi(name): print('hi ' + name + '!') girls = ['ra', 'liliy', 'You'] for name in girls: hi(name) print('next') """ for i in range(1,7): print(i)
class Organismo: def __init__(self, position, size): self.position = position self.size = size class Parede_celular: def __init__(self, gram): self.gram = gram class Despesa: def __init__(self, upkeep): self.upkeep = upkeep class Cachorro(Organismo, Despesa): def __in...
a=str(input("Enter the Client MAC Address: ")) x='Y' while x.upper()=='Y': b=int(input(''' Select operation 1) Display SSID 2) Dispaly User Session Duration 3) Display Smart Device Type 4) Dispaly Local Time Zone 5) Privacy ALert! Users Domain Accesse...
stuff = {'rope' : 1, 'torch' : 6,'gold coin':42, 'dagger' : 1, 'arrow' : 12} inv = {'gold coin': 42, 'rope': 1} dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby'] def displayInventory(inventory): print('Inventory:') total = 0 for a,b in inventory.items(): p...
import random print('Hello. what is your name') name = input() secretnumber = random.randint(1,20) print('Well, '+ name + ' ,I am thinking of a number between 1 to 20') for guesses in range(1,7): print('Take a guess') number = int(input()) if secretnumber < number: print('Too high') ...
spam = 0 while spam < 5: print('Hello world!') spam = spam + 1 print('Example 1') print('-'*13) name = '' while name != 'your name': print('Please type your name.') name = input() print('Thank you!') print('Example 2') print('-'*13) name = '' while True: print('Please type your...
file = open('MadLibs.txt') content = file.read() print(content) file.close() wordssplit = content.split() wordsDictionary = {k: v for k, v in enumerate(wordssplit)} check_words = ['ADJECTIVE', 'NOUN', 'ADVERB', 'VERB'] for keys, values in wordsDictionary.items(): for cw in check_words: ...
content = "The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffected by these events." wordssplit = content.split() wordsDictionary = {k:v for k,v in enumerate(content)} check = ["ADJECTIVE", 'NOUN', 'ADVERB', 'VERB'] for keys,values in wordsDictionary: for checkspeech in check: ...
a=int(input('请输入a:')) b=int(input('请输入b:')) c=int(input('请输入c:')) if a<1: a=1 if a>10: a=10 if b<1: b=1 if b>10: b=10 if c<2: c=2 if c>5: c=5 for x in range(a): print('我爱爸爸') for x in range(b): print('我爱妈妈') for x in range(c): print('我是胡嘉亮')
x = int(input()) y = int(input()) def addnumber(x,y): print(x+y) def minus(x,y): print(x-y) def multiplier(x,y): print(x*y) def division(x,y): print(x/y) addnumber(x,y) minus(x,y) multiplier(x,y) division(x,y)
import random as r num = r.randrange(100) guess_attempts = 5 while guess_attempts >= 0: player_guess = int(input('Enter your guess : ')) def check(x): if player_guess == x: print('You Won!!') elif player_guess > x: print('You are a bit on the...
""" File: nimm.py ------------------------- Add your comments here. """ def main(): stones = 20 player = 1 while stones > 0: if player == 1: print("There are " + str(stones) + " stones left") choice = int(input("Player " + str(player) + " Would you like to remove 1 or 2 ston...
def count_evens(nums): q=0 for i in range(len(nums)): if nums[i]%2==0: q=q+1 return q
def caught_speeding(speed, is_birthday): if is_birthday==True: if speed <66: return 0 elif speed<86: return 1 else : return 2 else : if speed <61: return 0 elif speed<81: return 1 else : return 2
''' Daily Coding Problem #108: Given two strings A and B, return whether or not A can be shifted some number of times to get B. For example, if A is abcde and B is cdeab, return true. If A is abc and B is acb, return false. ''' def can_shift(arg1, arg2): for i in range(len(arg1)): shifted = arg1[...
def cube(num): return num * num * num num = int(input("Enter an any number: ")) cub = cube(num) print("Cube of {0} is {1}".format(num, cub))
def isWordGuessed(secretWord, lettersGuessed): for x in secretWord: if x not in lettersGuessed: return False def getGuessedWord(secretWord, lettersGuessed): word = '' for x in secretWord: if x in lettersGuessed: word += x else: ...
nota1 = float(input('Digite a primeira nota: ')) nota2 = float(input('Digite a segunda nota: ')) media = (nota1+nota2)/2 print('A media do aluno foi {:.1f}.'.format(media))
class Player: """ Creates a Player object for use in the TriviaGame. Player includes a name, score, and buzzer, and button. """ def __init__(self, name, button, buzzer,led): self.name = name self.score = 0 self.buzzer = buzzer self.button = button s...
import numpy as np def encrypt_hill(plainText, key): """ encrypts plaintext with hill cipher method and writes the output in hill_cipher.txt Args: plainText(list): list of plaintext in hill_plain.txt file [each line in the file is a list element] key(list): h...
import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score import itertools from sklearn.metrics import confusion_matrix from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.linear_model import PassiveAggressiveClass...
from abc import ABC, abstractmethod class DataProvider(ABC): ''' An abstract class that all data providers must inherit from Data Providers are intended to be wrappers around vendors that provide daily stock market data ''' @property @abstractmethod def name(self): pass @p...
import os def numfold(path): files = folders = 0 for _, dirnames, filenames in os.walk(path): folders += len(dirnames) return folders def numfile(path): files = folders = 0 for _, dirnames, filenames in os.walk(path): files += len(filenames) return files if __name__ == '__main__': ...
print("Hello") first_name = input("Enter your first name: ") last_name = input("Enter your last name: ") city = input("Enter city: ") state = input("Enter State: ") zip_code = input("Enter Zip Code: ") message = "My name is {0},{1} and I live in {2}, {3}, {4}".format(first_name,l...
from grid_point import GridPoint __author__ = 'mokkeee' class GridPoints(object): def __init__(self, *args): if not self.__is_valid_grids(args): raise ValueError self.__grids = args def __contains__(self, item): if not isinstance(item, GridPoint): return Fal...
import turtle import random directions = [0, 90, 180, 270, 360] tmnt = turtle.Turtle() tmnt.shape("turtle") tmnt.pensize(13) tmnt.speed("fastest") turtle.colormode(255) def random_colour(): r = random.randint(0, 255) g = random.randint(0, 255) b = random.randint(0, 255) return (r, g, b) for _ in ra...
"""Typecasting and input from console""" def oddeven(num): if num%2==0: print("Even") else: print("Odd") return def main(): print("running") n = int(input("Enter a number to check even or odd : ")) print("THIS IS MAIN FUCNTION") oddeven(num) if __name__ == '...
def fib(n): return 0 if not n else 1 if n==1 else fib(n-1) + fib(n-2) print(fib(0)) print(fib(5)) print(fib(8))
def sum_odd_and_even(lst): return [sum(x for x in lst if x%2==0) ,sum(x for x in lst if x%2)] print(sum_odd_and_even([1, 2, 3, 4, 5, 6]))
def recaman_index(n): lst = [0] while n not in lst: num1 = lst[-1]-len(lst) num2 = lst[-1]+len(lst) lst.append(num1 if num1>=0 and num1 not in lst else num2) return len(lst)-1 print(recaman_index(7))
def collatz(num): count = 0 while num!=1: if num%2:num= num*3 +1 else:num/=2 count+=1 return count print(collatz(10))
def words_to_sentence(words): if not words: return '' words = [x for x in words if x] l = len(words) return ''.join(words[x] +(' and ' if x==l-2 else '' if x==l-1 else ', ') for x in range(l)) print(words_to_sentence(None))
def unique(lst): return [x for x in lst if lst.count(x)==1][0] print(unique([3, 3, 3, 7, 3, 3]))
from itertools import combinations as cb def sum_of_two(lst,k): return any(sum(x)==k for x in cb(lst,2)) print(sum_of_two([10, 15, 3, 7],17)) print(sum_of_two([10, 15, 3, 2],17)) print(sum_of_two([9, 10, 3, 7],18)) print(sum_of_two([9, 9, 3, 7],18))
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] def is_prime(primes, num, left=0, right=None): for x in range(left,len(primes)): if primes[x]==num: return 'yes' return 'no' print(is_prime(primes, 3))
def mystery_func(n): n=str(n) res = [n[0]] for x in range(1,len(n)): if n[x]==n[x-1]: res[-1]+=n[x] else: res.append(n[x]) return ''.join([''.join([str(len(x)),x[0]]) for x in res]) print(mystery_func(5211255))
def character_mapping(txt): lst = '' for x in txt: if x not in lst: lst+=x return [lst.index(x) for x in txt] print(character_mapping("babbcb"))
def scale_tip(lst): left = sum(lst[:lst.index('I')]) right = sum(lst[lst.index('I')+1:]) return 'balanced' if left==right else 'left' if left>right else 'right' print(scale_tip([0, 0, "I", 1, 1]))
def sort_merge(lst): return sorted(sum(lst,[])) lst = [[1,5,8],[0,2,6]] print(sort_merge(lst))
def climb(stamina, obstacles): count = 0 x = 1 while True: try: prev = obstacles[x-1] now = obstacles[x] except IndexError: return count if prev==now: count+=1 x+=1 elif prev>now and stamina>=int((prev-now)+0.999): stamina-=int((prev-now)+0.999) count+=1 x+=1 elif prev<now a...
n = int(input().strip()) unsorted = [] unsorted_i = 0 for unsorted_i in range(n): unsorted_t = str(input().strip()) unsorted.append(unsorted_t) unsorted.sort(key= lambda x:(len(x),x)) for i in unsorted: print(i)
def convet24(txt): if txt[-2:]=='AM' and txt[:2]=='12': return 0 elif txt[-2:]=='PM' and txt[:2]!='12': return int(txt.split(':')[0])+12 else: return int(txt.split(':')[0]) def hours_passed(time1, time2): return 'no time passed' if time1==time2 else '%s hours' %(convet24(time2)- convet24(time1)) ...
def vending_machine(products, money, product_number): if product_number not in range(1,10): return 'Enter a valid product number' if money < products[product_number-1]['price']: return 'Not enough money for this product' lst = [500,200,100,50,20,10] count = 0 money-= products[product_numb...
def bin_consecutive(n): lst = [] count = 0 for x in bin(n): if x=='1': count+=1 else: lst.append(count) count=0 return max(lst) print(bin_consecutive(156))
rep_list = [1, 3, 2, 4, 3, 2, 5, 5, 7] list_temp = [] for i in rep_list: if i not in list_temp: list_temp.append(i) print(list_temp)
def count_term_match(test_term,match_term): count = 0 for tt in test_term: if tt!='': count = count + match_term.count(tt) return count
def fizzbuzz(number): if number == 3: return "fizz" elif number == 5: return "buzz" elif number == 15: return "fizzbuzz" elif number == 4: return "4" elif number % 15 == 0: return "fizzbuzz"
def fib(n): if n == 0: return 0 elif n in (1,2): return 1 else: return fib(n - 1) + fib(n - 2) def perimeter(n): sum = 0 for i in range(n + 2): sum += fib(i) return 4 * sum perimeter(30)
def sol_equa(n): lst = [] for x in range(n,0,-1): y = 0 while x**2 - 4 * (y**2) > 0 : answer = (x - 2*y) * (x + 2*y) if answer == n: lst.append([x,y]) y += 1 return lst
import string def is_pangram(s): s = s.lower() alphabet = ['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m'] for i in alphabet: if i in s: continue else: return False return True pangram = "The quick, Brown fox jump...
def order(sentence): dict = {} lst = [] for i in sentence.split(): for j in range(len(sentence.split()) + 1): if str(j) in i: dict[j] = i for i in range(1,len(sentence.split()) + 1): lst.append(dict[i]) return ' '.join(lst) order("is2 Thi1s T4est 3a")
well_height = 125 daily_distance = 30 nightly_distance = 20 snail_position = 0 days = 1 distance_difference = daily_distance - nightly_distance snail_position += distance_difference while snail_position < well_height: snail_position += distance_difference da...
def factorial(n) : product = 1 while n > 0: product = product * n n = n - 1 return product n = input("Please input x:") product = factorial(int(n)) print(product) str = list(str(product)) i = -1 counter = 0 while int(str[i]) == 0: counter = counter + 1 i = i - 1 ...
from exercise2.listwrapper import Mylist class MylistSub (Mylist): number_of_calls = 0 def __init__ (self, data = []): MylistSub.number_of_calls += 1 Mylist.__init__(self, data) def __add__ (self, other): MylistSub.number_of_calls += 1 if type (ot...
class Mylist(): def __init__ (self, data = []): self.data = [] for item in data: self.data.append(item) def __add__ (self, other): if type (other) == Mylist : return Mylist(self.data + other.data) return Mylis...
def read_integers(filename): """ Returns list of numbers from file containing list of numbers separated by new lines """ infile = open(filename, "r") number_list = [] while True: num = infile.readline() if len(num) == 0: break if "\n" in num: num = num...
""" Created on Sat Mar 13 17:43:39 2021 @author: hungd """ class BinaryTree: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def insert(self, values, i=0): if i >= len(values): return queue ...
""" Created on Tue Feb 2 20:32:31 2021 @author: hungd """ def reverseWordsInString(string): newString = "" prevI = len(string) hasSpaces = False for i in reversed(range(len(string))): if string[i] == " ": newString += string[i:prevI] prevI = i hasSpac...
def threeNumberSum(array, targetSum): threeNumberList = list() array.sort() for i in range(len(array) - 2): low = i + 1 high = len(array) - 1 while low < high: if array[i] + array[low] + array[high] == targetSum: threeNumberList.append([array[i], array[lo...
""" Created on Wed Dec 16 10:58:33 2020 @author: hungd """ def diskStacking(disks): disks.sort(key=lambda disk:disk[2]) heights = [[0, []] for _ in range(len(disks))] for i in range(len(disks)): maxHeight = disks[i][2] maxHeightJ = None for j in reversed(range(i)): ...
""" Created on Sat Dec 26 16:50:44 2020 @author: hungd """ def removeIslands(matrix): visited = [[0 for j in range(len(matrix[0]))] for i in range(len(matrix))] i = 0 for j in range(len(matrix[0])): matrixTraverse(matrix, visited, i, j) i = len(matrix) - 1 for j in rang...
""" Created on Tue Nov 24 13:23:31 2020 @author: hungd """ class SuffixTrie: def __init__(self, string): self.root = {} self.endSymbol = "*" self.populateSuffixTrieFrom(string) def populateSuffixTrieFrom(self, string): for i in range(len(string)): sel...
""" Created on Sun Mar 7 20:43:15 2021 @author: hungd """ def calendarMatching(calendar1, dailyBounds1, calendar2, dailyBounds2, meetingDuration): calendar1 = putDailyBoundsinCalendar(dailyBounds1, calendar1) calendar2 = putDailyBoundsinCalendar(dailyBounds2, calendar2) calendar = mergeCalendars(ca...
""" Created on Thu Jan 21 20:41:01 2021 @author: hungd """ def cycleInGraph(edges): visited = {} for i in range(len(edges)): containsCycle = cycleInGraphHelper(i, edges, visited, {}) if containsCycle: return True return False def cycleInGraphHelper(node, edges, visi...
import numpy as np from scipy.stats import bernoulli import matplotlib.pyplot as plt Num_of_Arms = 4 winning_parameters = np.array([0.2, 0.3, 0.85, 0.9], dtype=float) max_prob = 0.9 optimal_arm = 3 T = 1000 total_iteration = 200 reward_round_iteration = np.z...
import sys import os def is_int(s): try: int(s) return True except ValueError: return False def main(): """ Put enough prepending 0 padding according to the README """ if len(sys.argv) != 2: print("Usage: target_dir") exit() root_dir = os.getcwd() targe...
from Tkinter import * from PIL import ImageTk,Image root=Tk() root.title("Hello World") root.iconbitmap("@/home/suraj/Desktop/INTERNSHIP/index.xbm") def open(): global image top=Toplevel() image=ImageTk.PhotoImage(Image.open("/home/suraj/Desktop/INTERNSHIP/index.jpeg")) l=Label(top,image=image) l....
class Parent(): def __init__(self,last_name,eye_color): print("parent construcot called") self.last_name = last_name self.eye_color = eye_color def show_info(self): print("Last Name - "+self.last_name) print("Eye Color - "+self.eye_color) class Child(Parent): def ...
basket = {'Apple', 'Banana', 'Avocado', 'pineapple', 'Apple', 'Orange'} print(sorted(basket)) a = set('abracadabra') b = set('alacazam') print(a.intersection(b)) print(a | b) print(a & b) print(a ^ b) print(a.isdisjoint(b)) print(b.issubset(a)) s = {x for x in 'abracadabra' if x not in 'ab...
''' This class calculates the total price of the drinks Author: Fasermaler March 2019 ''' class price_calculator: def __init__(self, price_list): self.set_price_list(price_list) self.drinks_list = [] self.total_price = 0.0 self.old_ids = None def set_price_list(self, price_list): self.price_list ...
import sys as s x = int(s.argv[1]) y = int(s.argv[2]) z = int(s.argv[3]) if x>y: if x>z: print("x is largest") elif y>z: print("y is largest") else: print("z is largest")
""" Gauss: 50 pairs of numbers that added up to 100: 1 + 99, 2 + 98, 3 + 97, and so on, until 49 + 51. Since 50 × 100 is 5,000, when you add that middle 50, the sum of all the numbers from 0 to 100 is 5,050. """ while True: total = 0 try: num = int(input('Type in the number you want to add up to: ')) ...
from Classes import Queue class PrioQueue(Queue.Queue): def __init__( self, prio_queue=[], heuristic=None ): Queue.Queue.__init__(self, prio_queue) if heuristic is None: self.sorter = None else: self.sorter = heuristic def enqueue(self, elem): ...
""" Created on Mon Dec 10 21:23:10 2018 @author: Isaac Parentheses 문자열 앞뒤로 괄호 붙이기 """ ss = input("입력 : ") print("출력 : ", end='') if (ss.startswith('(') == False) : print("(", end="") print(ss, end="") if (ss.endswith(')') == False) : print(")", end="")
import random numbers = [] for num in range(0,10) : numbers.append(random.randrange(0,10)) print("생성된 리스트 : ", numbers) for i in range(0,10) : if i not in numbers : print(i,"는 리스트에 없어요.")
""" Created on Wed Nov 21 20:01:05 2018 @author: Isaac Lotto """ import random def getNumber() : return random.randrange(1,46) lotto = [] num = 0 if __name__ == "__main__" : print("로또 추첨 시작~\n") while(True) : num = getNumber() if (lotto.count(num) == 0) : lotto.appe...
""" Created on Sun Oct 21 01:35:07 2018 @author: Isaac """ myList = [30,10,20] print("현재 리스트 : %s" % myList) myList.append(40) print("append(40) 후의 리스트 : %s" % myList) print("pop()으로 추출한 값 : %s " % myList.pop()) print("pop() 후의 리스트 : %s" % myList) myList.sort() print("sort() 후의 리스트 : %s" % myList) myList.reverse...
a=int(input("첫 번째 값? ")) b=int(input("두 번째 값? ")) c = int(a) + int(b) print(c)
""" 142694 윤이삭 Substring 함수 만들기 <실행예> Enter the first string: asdf Enter the second string: vfrtgasdfnhy asdf is a substring of vfrtgasdfnhy Enter the first string: 깊은바다 Enter the second string: 파란하늘은 깊은바다와 같다 깊은바다 is a substring of 파란하늘은 깊은바다와 같다 """ def Substring(subst,st) : if(st.find(subst) == -1) : ...
""" Created on Tue Dec 11 01:06:21 2018 @author: Isaac Count to 1 - Recursive 1까지 세는 재귀함수 """ def count(num) : if (num >= 1) : print(num, end=' ') count(num - 1) else : print() return count(10) count(20)
class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x >= 2**31-1 or x<0: return False if x%10 ==0 and x != 0: return False new=0 while new <= x: if new ...
class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not root: return True return self.findSymetry(root.left, root.right) def findSymetry(self, left,right): if l...
""" Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock before you buy one. """ def ma...
def decorator(lower, upper): def outer_wrapper(func): def inner_wrapper(func_arg): print('before') val = func(func_arg) assert lower <= val assert val <= upper print('after') return inner_wrapper return outer_wrapper @decorator(1, 100) def func(arg): return arg * 7 func(8)
""" Created on Wed Apr 8 19:31:58 2020 @author: Sansrit """ import numpy as np import matplotlib.pyplot as plt a = [[11, 12, 13], [21, 22, 23], [31, 32, 33]] A = np.array(a) print(A) print(A.ndim) print(A.shape) print(A.size) print(A[1,1]) print(A[0][0:2]) print(A[0:2, 2...
for _ in range(0, int(input())): num_list = list(map(int, input().split())) even_list = [] for i in range(0, len(num_list)): if num_list[i] % 2 ==0: even_list.append(num_list[i]) print(sum(even_list), min(even_list))
n = int(input()) num=[] for i in range(0, n): lis = int(input()) num.append(lis) for j in sorted(num): print(j)
for _ in range(0, int(input())): text = list(str(input())) first = text.pop(0) if first.isupper() == False: first=first.upper() print(first ,end='') for i in range(0, len(text)): print(text[i],end='') print()