text
stringlengths
5
121k
import tkinter v=tk.Tk() v.title('counting second') Button1=Button(guitext='stop',width='25',command=v.destroy) Button2=Button(guitext='cancle',width='25',command=v.destroy) Button3=Button(guitext='submit',width='25',command=v.destroy) Button1.pack() Button2.pack() Button3.pack() v.mainloop()
class BinarySearch(list): def __init__(self, a, b): super(BinarySearch, self).__init__(range(b, a * b + b, b)) self.length = a def search(self,value): index = 0 dict_obj = {"count":0,"index": 0} first = 0 last = self.length - 1 while last >= first : dict_obj["count"] = dict...
import random def play_twice(): play=str(input("Do you want to play again??Y/N: ")).lower() if play=='y': game() elif play=='n': print("Thankyou!! you for playing") else: print("Your output didn't match Y or N please try again!!!") play_twice() def compute...
def read_lines(filename="", nb_lines=0): c = 0 c_ = 0 with open(filename, encoding="utf-8") as file: for line in file: line = file.readline() if line[-1:] == '\n': c += 1 c += 1 if nb_lines <= 0 or nb_lines >= c: with open(filename, en...
""" This divide a matrix into a given number and return a new matrix """ def matrix_divided(matrix, div): """ checks data accuracy to perfom division """ msg_1 = "matrix must be a matrix (list of lists) of integers/floats" msg_2 = "Each row of the matrix must have the same size" msg_3 = "divi...
""" This function will add two values casted values if necessary (int/float) and return the addition """ def add_integer(a, b=98): """ check if args are ints to add'em' """ if not isinstance(a, (int, float)): raise TypeError("a must be an integer") if not isinstance(b, (int, float)): ...
import sys def create_combination(l1,l2,b1,b2): tot_count=0 for l in range(l1,l2+1): for b in range(b1,b2+1): ret=count_bars(l,b) print("Chocolate Bar size ({0} x {1}), can be distributed to \"{2}\" children...".format(l,b,ret)) tot_count=tot_count+ret print("\...
print("Hello, world!") var = False if var: print("Var é verdadeiro") else: print("Var é falso") print("Pode apostar nisso!") """Bloco de Comentarios """ print(type(1)) print(type("Igor")) print(type(var)) print(type(1.5)) print(type([])) print(type({})) print(type(())) print(type("Igor"));print(ty...
import pandas as pd from sklearn import linear_model def coefficient_of_determination(): df = pd.read_csv('src/mystery_data.tsv', sep='\t') x = df.loc[:, 'X1':'X5'] y = df.loc[:, 'Y'] model = linear_model.LinearRegression(fit_intercept=True) model.fit(x, y) score = mod...
class Rational(object): def __init__(self, numerator, denominator): self.numerator = numerator self.denominator = denominator def __str__(self): return f'{self.numerator}/{self.denominator}' def __add__(self, numb): new_denom = int(self.denominator) * int(numb.denominator...
import math def main(): while True: shape = input('Choose a shape (triangle, rectangle, circle): ') if shape == '': break else: if shape == 'rectangle': r_width = int(input("Give width of the rectangle: ")) r_height = int(input("Giv...
from generate_tic_tac_toe_tree import generate_tic_tac_toe_tree from main import history_to_state, determine_result, Result def create_tic_tac_toe_solving_tree(): tree = generate_tic_tac_toe_tree() calculate_percentages_of_loose_outcomes_recursion(tree.root) return tree def calculate_percentages_of_loos...
__author__ = 'Khali' from placeholders import * def generator_zip(seq1, seq2, *more_seqs): items=[] if len(more_seqs) !=0 : items.append(iter(seq1)) items.append(iter(seq2)) for x in more_seqs: items.append(iter(x)) wh...
class InstructionList(object): ''' An instruction list is the result of parsing an idiotscript script. It may have nested instruction lists, which is the result of branching in the idiotscript. This implementation uses a linked list. ''' def __init__(self): self._head = None ...
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) -...
st = "Python Programming is fun" sub = "n" pos = st.find(sub) while pos >= 0: print("Found at ", pos) pos = st.find(sub, pos + 1)
import requests code = input("Enter country code :") resp = requests.get("https://restcountries.eu/rest/v2/alpha/" + code) info = resp.json() if 'name' in info: print(info["name"]) print(info["capital"]) else: print("Country Not Found!")
class EvenIterator: def __init__(self,start, end): self.start = start if start % 2 == 0 else start + 1 self.end = end def __iter__(self): self.value = self.start return self def __next__(self): if self.value <= self.end: v = self.value self....
import sqlite3 try: con = sqlite3.connect(r"e:\classroom\python\hr.db") cur = con.cursor() ename = input("Enter name :") salary = input("Enter salary : ") dept = input("Enter dept id :") cur.execute("select max(empid) + 1 from emp") empid = cur.fetchone()[0] cur.execute("inse...
from Account import * class Product: def __init__(self, name, price=None): self.__name = name self.__price = price @property def netprice(self): return self.__price * 1.12 def print(self): print('Name ', self.__name) print("Price ", self.__price) ...
from datetime import datetime from patient import Patient patients = [] with open('data.txt', 'r', encoding='utf-8') as dataFile: for line in dataFile: words = line.split(';') p = Patient( words[0], words[1], words[2], datetime(year=int(words[3]), mo...
""" Exercise 5 of the Part IV of the book "Learning Python" Function "addDict" - Returns a union of dictionaries Created on Mon Nov 9 11:06:47 2020 @author: lfbia """ def addList(list1, list2): return list1 + list2 def addDict(aurelio, michaellis): D = {} for i in aurelio.keys(): D[i] = aurelio[...
import math import os import random import re import sys """ def checkMagazine(magazine, note): #using dictcomp hashWords = {x: magazine.count(x) for x in set(note)} if list(hashWords.values()).count(0): print('No') else: hashNoteWords = {x: (hashWords[x] - note.count(x)) for x in ...
L = [2 ** i for i in range(7)] X = 5 pot = 2 ** X if pot in L: print('at index', L.index(pot)) else: print(X, 'not found')
""" Node is defined as self.left (the left child of the node) self.right (the right child of the node) self.info (the value of the node) """ def levelOrder(root): nodeQueue = [root] levelList = [] while nodeQueue: if nodeQueue[0].left: nodeQueue.append(nodeQueue[0].left) if...
def secondWorst(arr): grades = {} for i in arr: grades[i[0]] = i[1] arr = sorted(list(set(grades.values()))) ans = [i for i in grades if grades[i] == arr[1]] return sorted(ans) if __name__ == '__main__': arr = [] for _ in range(int(input())): name = input() scor...
""" Exercise 10 of the Part IV of the book "Learning Python" Timing three ways to get the square root of a number Created on Mon Nov 9 16:12:52 2020 @author: lfbia """ import sys, math, timer1 as timer reps = 10000 repslist = list(range(reps)) def usingmath(): return [math.sqrt(x) for x in repslist] def ...
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input()) permutationCollection = [] for i in range(x+1): for j in range(y+1): for k in range(z+1): sum = i+j+k if sum != n: oneCombo ...
def swap_case(s): characters = list(s) convertedCharacters = [] convertedStr = "" for i in range(len(characters)): if characters[i].isupper(): convertedCharacters.append(characters[i].lower()) elif characters[i].islower(): convertedCharacters.append(characters[i]...
def serie(n): if n==0: return 3 return 3*serie(n-1)+4 n=int(input("Ingrese numero: ")) print (serie(n))
weight = 60 height = 1.65 result = weight / (height * height) print('BMI的值为: ',result) if result < 18.5: print('过轻') elif result < 25: print('正常') elif result < 28: print('过重') elif result < 32: print('肥胖') else: print('严重肥胖')
import networkx as nx import random def Random_Path(G, length, path = []): """ Given a graph, G, this function returns a random path of a given number of edges (length =n). This path is represented by a list of nodes of G [v0,v1,..., vn] such that (vi,vi+1) is an edge. This is done...
import json filename = "tweet_data.txt" file_handle = open(filename) outer_dictionary = json.load(file_handle) tweet_list = outer_dictionary.get("tweet_list") for tweet in tweet_list: print("Tweet:", tweet.get("text")) print("Tweeted at:", tweet.get("created_at")) print("Tweet ID:", tweet.get("id")) ...
def longestSubseqWithK(str, k): n = len(str) freq = {} for i in range(n): if str[i] not in freq: freq[str[i]] = 1 else: freq[str[i]] += 1 for i in range(n): if (freq[str[i]] >= k): print(str[i], end="") print("") str = "geekswaforgeekswas...
def reverse(num): result = 0 while num > 0: rem = num % 10 result = result * 10 + rem num = num // 10 return result print(reverse(123))
from keras.models import Sequential from keras.layers import Convolution2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers import Dense classifier = Sequential() classifier.add(Convolution2D(32, (3, 3), input_shape=(64, 64, 1), activation='relu')) classifier.add(MaxPoolin...
import socket s = socket.socket() p = 4444 s.bind(('', p)) s.listen(5) while True: c, addr = s.accept() c.send('Connected to server !!!') c.close()
''' Problem Statement: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Output: 4 ''' class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: if matrix ...
from tkinter import * class Application(Frame): def say_hi(self): self.label["text"] = "hi there, everyone!" def createWidgets(self): self.f1 = Frame(self) self.f1.pack() self.QUIT = Button(self.f1) self.QUIT["text"] = "QUIT" self.QUIT["fg"] = "re...
""" Created on Tue Sep 1 13:16:18 2020 @author: dabol99 This files contains functions that are useful to preprocess strings for nltk and to build document embeddings. """ import nltk import re import sklearn import sklearn.cluster import pandas """ this function uses nltk features to returns the word frequenci...
def scanner(name, function): file = open(name, 'r') while True: line = file.readline() if not line: break function(line) file.close() def scanner2(name, function): for line in open(name, 'r'): function(line) def scanner3(name, function): l...
lis = [100, 48, 96, 63, 23, 73, 23, 37, 22, 98, 22, 37, 51, 40, 74, 14, 65, 15, 77, 5] print('The raw list is:\n', lis) l = len(lis) for i in range(0, l - 1): for j in range(i + 1, l): if lis[j] < lis[i]: temp = lis[j] lis[j] = lis[i] lis[i] = temp ...
from pptx import Presentation import itertools file1 = "name_of_file" file2 = "name_of_file" file3 = "name_of_file" powerpoint_name = "name_of_powerpoint" _file1 = file1 + ".txt" _file2 = file2 + ".txt" _file3 = file3 + ".txt" _powerpoint_name = powerpoint_name + ".pptx" slide_master_template = "slide_master.pptx"...
string=str(input("Str->")) string=string.upper() if string=="YES": print ("Yes") elif string=="NO": print ("No")
while True: n=int(input("n=")) if n>0: break else: n=int(input("n=")) sum=0 for i in range(1,n+1): sum+=(i/(i+1)) print("Sum=",round(sum,2))
class Shape: def __init__(self): pass def area(self): return 0 class Square(Shape): def __init__(self,length=0): Shape.__init__(self) self.length=length def area(self): return round((self.length*self.length),2) length=float(input("Length->")) square=Square(len...
def pow(a): return a**2 lst=[i for i in range(1,21)] res=list(map(pow,lst)) print(res)
import unittest from probElevenTwenty import * class SecondClassTest(unittest.TestCase): def test_four_digit_binary(self): expected = str(1010) input_data = four_digit_binary('0100,0011,1010,1001') self.assertEqual(input_data, expected) def test_even_1000_3000(self): self....
def tu(n): tup=tuple(i*i for i in range(1,n+1)) print(tup) n=int(input("n=")) tu(n)
def task_91(): lst=[12,24,35,70,88,120,155] lst.remove(lst[0]) lst.remove(lst[4]) lst.remove(lst[5]) return lst def task_92(): lst=[12,24,35,70,88,120,155] lst.remove(24) return lst def task_93(): lst1=[1,3,6,78,35,55] lst2=[12,24,35,24,88,120,155] res=[] for i in ls...
numero = 1 while (numero < 100): print ("El valor de numero es:",numero) numero = numero+1
tupla=(25,1.81,"Diego") print (tupla[2]) indice = 0 while indice< len(tupla): print (tupla[indice]) indice = indice + 1
def isPrime(number): for divisor in range(2, number): if number % divisor == 0: return False return True def primeInRange(number): list = [] isPrime = True for number in range(1,number): for n in range(2,number): if number % n == 0: isPr...
weight = float(input('Your weight in kilos: ')) height = float(input('Your height in meters: ')) BMI = weight / height ** 2 BMI = round(BMI, 1) if BMI < 16: result = 'Severely underweight.' elif 16 < BMI <= 18.5: result = 'Underweight.' elif 18.5 < BMI <= 25: result = 'Normal.' elif 25 < BMI <= 30: result = 'Overwei...
def test_phrase(): phrase = input("Set a phrase: ") actual_result = (int(len(phrase))) print(int(len(phrase))) assert actual_result < 15, "The phrase is greater than 15 characters"
list_1 = ['History', 'Math', 'Physics', 'CompSci'] list_2 = list_1 print(list_1) print(list_2) list_1[0] = 'Art' print(list_1) print(list_2) tuple_1 = ('History', 'Math', 'Physics', 'CompSci') tuple_2 = tuple_1 print(tuple_1) print(tuple_2) empty_tuple = () empty_tuple = tuple()
def scramble2Encrypt(plainText): evenChars = "" oddChars = "" charCount = 0 for ch in plainText: if charCount % 2 == 0: evenChars = evenChars + ch else: oddChars = oddChars + ch charCount = charCount + 1 cipherText = oddChars + evenChars retur...
def median(): Num_one = input ("Enter your first integer: ") Num_two = input ("Enter your second integer: ") Num_three = input("Enter the third integer: ") if (int (Num_one) < int (Num_two) and int (Num_one) > int (Num_three)): print ("The Median of the numbers is: " +Num_one) elif (int (Nu...
''' 学习 matplotlib 图形库 https://morvanzhou.github.io/tutorials/data-manipulation/plt/3-2-Bar/ ''' import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.gridspec as gridspec ''' 基本使用 '''
""" There are three allowable string edits: - remove a character - add a character - replace a character Given two strings, write a function to determine whether they are one edit (or zero edits) away """ def is_one_away(str1, str2): if str1 == str2: return True if abs(len(str1) - len(str2)) > 1: return Fa...
STARTYEAR = 1753 STARTDAY = 1 STARTMONTH = 1 MONTHS = { 1: 'January', 2: 'February', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'July', 8: 'August', 9: 'September', 10: 'October', 11: 'November', 12: 'December' } DAYS = { 0: 'Monday', 1: 'Tuesday', 2: 'We...
class My_searching: def linear_search(self,pi,source): for i in source: if pi in i: return int(source.index(i)) return False class My_sorting: def insertion_sort(self,list_a,index): for i in range(1,len(list_a)): save = list_a[i] j...
class Node(object): def __init__(self, data=None, next=None): self._node_data = data self.next = next def __str__(self): return repr(self._node_data) class BinaryNode(object): def __init__(self, data=None, right_child=None, left_child=None): self._node_data = data self._rig...
fin = open('words.txt') def is_anagram(text): sorted_dict = dict() for line in text: original_word = line.strip() sorting_word = ''.join(sorted(list(original_word.lower()))) sorted_word = sorting_word sorted_dict.setdefault(sorted_word, []).append(original_word) ...
""" Created on Mon Apr 27 09:19:25 2020 @author: gualteros """ def contar(w): cont = 0 for i in range (0,len(w)): if w[i] == "," : cont += 1 if w[i+1] == ",": cont -= 1 return cont word = (input("Ingrese un texto : ")) cant = contar(word) print ("\n",cant) ...
name = input("What your name?: ") if name == "Vlad": print("Ooo, Hello Vlad!") else: print("Who are you?")
class AbstractGame: """Abstract class for running a card game""" def __init__(self, players=[], deck=None): self.players = list(players) self.deck = deck def play_game(self): """Override this function for custom game logic""" pass
def break_statement(): print('Break if "l" -> Hello world!') for val in 'Hello world!': if val == 'l': break print(val) print('The end.') def continue_statement(): print(' ------------------ ') print('Continue if "l" -> Hello world!') for val in 'Hello world!': ...
def sum_all_numbers_stored_in_a_list(): list_of_numbers = [5, 1, 7, 4, 10, 2, 3, 9, 8] sum = 0 for val in list_of_numbers: sum = sum + val print(5, 1, 7, 4, 10, 2, 3, 9, 8,sep='+') print('=', sum) def range_function(): print(range(10)) print(list(range(10))) print(list(range(1...
import time def countingSort(insertedArray,countArray,sortedArray): for i in range(len(insertedArray)): countArray[insertedArray[i]] += 1 print("Counting Array Is : ",countArray) for i in range(1,len(countArray)): countArray[i]+=countArray[i-1] print("Modified Counting Array : ",countA...
""" Problem 101: https://leetcode.com/problems/symmetric-tree """ class Solution: def preOrderTraversal(self, root, result): if root: result.append(root.val) if root.left or root.right: if root.left: self.preOrderTraversal(root.left, resu...
""" 501. Find Mode in Binary Search Tree https://leetcode.com/problems/find-mode-in-binary-search-tree/ """ class Solution: def dfs(self, root, mode): if root: if root.val in mode: mode[root.val] += 1 else: mode[root.val] = 1 if root....
bod = {"Benny", "Hans", "Tine", "Mille", "Torben", "Troels", "Søren"} management = {"Tine", "Trunte", "Rane"} employees = {"Niels", "Anna", "Tine", "Ole", "Trunte", "Bent", "Rane", "Allan", "Stine", "Claus", "James", "Lars"} a = bod.difference(employees) print(a) b = bod.intersection(employees) print(b) ...
cur_x = 6 gamma = 0.01 precision = 0.00001 previous_step_size = cur_x def df(x): return 4 * x**3 - 9 * x**2 while previous_step_size > precision: prev_x = cur_x cur_x += -gamma * df(prev_x) previous_step_size = abs(cur_x - prev_x) print("The local minimum occurs at %f" % cur_x)
""" @author: strA ProjectEuler-problem-41 """ def gen_prime(n): prime = [True]*(n+1) prime[0] = False prime[1] = False for i in range(1,n+1): if prime[i]: m = i*2 while m<n: prime[m] = False m = m+i return prime def check(n): n_...
""" @author: strA ProjectEuler-problem-44 """ """ 先写个简单的 """ import math def check(n): if int((1+math.sqrt(1+24*n))/6)==(1+math.sqrt(1+24*n))/6: return True else: return False def Pentagon(n): return (n*(3*n-1))//2 i = 1 flag = True while flag: j = 1 while j<i: diff ...
""" Created on Sun Mar 4 00:46:34 2018 @author: strA ProjectEuler-problem-12 """ import math def factor_count(n): t = 0 for i in range(1,int(math.sqrt(n))+1): if n%i == 0: t += 1 t = 2*t if math.sqrt(n) - int(math.sqrt(n))<0.001: t = t-1 return t sum = 1 term = 1 w...
convidados = [] def adicionar(): '''funcao para adicionar convidados na lista''' global convidados qtd = int(input("Digite a quantidade de convidados: ")) print(qtd) for n in range(qtd): nome = input('Insira o nome do convidado '+str(n+1)+": ") convidados.append(nome) ...
dataList = [5, 6, 1, 4, 7, 9, 8] def heapSort(dataList, start, length): maxIndex = 0 while start * 2 + 1 < length: if start * 2 + 2 < length: maxIndex = start * 2 + 1 if dataList[start * 2 + 1] > dataList[start * 2 + 2] else start * 2 + 2 if dataList[maxIndex] > dataLi...
if __name__ == '__main__': t = int(input()) for t_itr in range(t): nk = input().split() n = int(nk[0]) k = int(nk[1]) if (k-1|k)<=n: print(k-1) else: print(k-2)
''' We will work with the IMDB movie reviews data. We will: 1. Prepare the data 2. restrict the movie reviews to the top 10000 most common words 3. Cut off the reviews after only 20 words. 4. The network will learn 8-dimensional embeddings for each of the 10000 words, turn the input integer sequences (2D integer tensor...
import math class Solution: """超时""" def countPrimes(self, n: int) -> int: count = 0 for i in range(2, n): if self.isPrime(i): count += 1 return count def isPrime(self, n: int) -> int: for i in range(2, int(math.sqrt(n) + 1)): if n ...
import math """ 歌德巴赫猜想j 2000以内大于2的偶数能分解为两个素数之和。 """ def isPrime(n): for j in range(2, int(math.sqrt(float(n))) + 1): if n % j == 0: return False return True def getPrime(n): primes = list() for j in range(2, n + 1): if isPrime(j): primes.append(j) retu...
""" Created on Mon Sep 2 04:55:04 2019 @author: ashima """ import numpy as np class Heap: def __init__(self, Capacity): self.heap = [] self.length = 0 self.capacity = Capacity def get_parent(self, index): return int(index/2) def isEmpty(self): if self.l...
""" Created on Mon Sep 2 05:05:16 2019 @author: ashima """ class Node: def __init__(self, state, parent, g, h): self.state = state self.parent = parent self.g = g self.h = h self.f = self....
def eval(exp): exp = exp.replace("+-","-") if "(" in exp: start = exp.find("(") numparen = 1 i = start while(numparen > 0): i += 1 if(exp[i] == "("): numparen += 1 elif(exp[i] == ")"): ...
purse = dict() purse['money'] = 12 purse['candy'] = 3 purse['tissues'] = 75 print(purse) print(purse['candy']) purse['money'] = purse['money'] + 8 print(purse) lst = list() lst.append(21) lst.append(3) print(lst) print(lst[1]) abc = dict() abc['age'] = 21 abc['course'] = 146 print(abc) abc['age'...
import sys import csv import numpy as np import nltk.data from nltk.sentiment.vader import SentimentIntensityAnalyzer from nltk import sentiment from nltk import word_tokenize if(len(sys.argv) != 3): print("Usage: python3 spamPolarityScores.py <pathtodatafile> <pathtowritefile>") sys.exit() filename = sys....
INPUT =1 while INPUT !=0 : INPUT = int(input("숫자 입력 :: ")) i=2 while True: if(INPUT%i == 0): break i +=1 if(i == INPUT): print("소수 입니다.") else: print("소수가 아닙니다.") print("종료 합니다.")
ints = [1,2,3,4,5] def listadd(ints): total = 0 for item in ints: total += item return (total) value = listadd(ints) print (value)
class Cat(): def __init__(self, name, age, gender): self.name = name self.age = age self.gender = gender Cat_info = Cat("來福", 7 ,"male") print("姓名:",Cat_info.name,"\n" "年齡:",Cat_info.age,"\n" "性別:",Cat_info.gender)
""" port.py This file holds the representation of the Port object, which just holds the conversion type of the port. resourceType denotes what resource you need to trade in, and number denotes how many of that resource you need to trade in to get a resource of your choice. """ class Port: ''' This ...
import media import fresh_tomatoes def make_list_of_movies(): ''' this function statically builds Movies() objects, and returns an array of the Movie() objects ''' avatar = media.Movie( "Avatar", "Like Minecraft and Alien combined", "https://images-na.ssl-images-amazon.com/i...
""" This is program is designed to provide real-time generated data printed into a csv file. Further features will include operations on a json file. """ from time import * from random import randint import csv class File: _csv_reader = None _csv_writer = None _count = 0 _file = None def __...
class Solution: def pos(self,a,lst,dit,string,index,N): if(len(string)==N): lst.append(string) return cur = dit[a[index]] for i in range(len(cur)): self.pos(a,lst,dit,string+cur[i],index+1,N) def possibleWords(self,a,N): lst = [] dit...
class Solution: def check(self,A,B,N): d={} for i in A: if i in d: d[i]=d[i]+1 else: d[i]=1 for i in B: if i not in d or d[i]<=0: return False else: d[i]=d[i]-1 retu...
import unittest from board import Board import numpy as np class TestBoard(unittest.TestCase): def test_create(self): b = Board() equal_elements = np.sum(b.data == np.ones((3,3))*-1) self.assertEqual(equal_elements,9) def test_set_piece(self): b = Board() b.se...
grades = [20,10,90,85,40,75,65,64,12,74,71,98,50] grades = list(filter(lambda x : x >= 70, grades)) print(grades) dog_ages = [12,8,4,1,2,6,4,4,5] dog_ages = list(map(lambda x : x * 7, dog_ages)) print(dog_ages) transactions = [51.0,49.99,80.99,67.99,120.52,23.49] transactions = [round(x) for x in transac...
list=[1,2,5,-1,6,0,15] smallest=min(list) mini=list[0] for i in list: if (i<mini) and (i>smallest): mini=i print(mini)
for r in range(5): for c in range(r+2): if c<1 : print((5-r)*' ',r,end = '') elif c>1: print('',r,end = '') while c==2: c=0 print()