text
stringlengths
37
1.41M
class Product(object): def __init__(self, price, name, weight, brand): self.price = price self.name = name self.weight = weight self.brand = brand self.status = "for sale" def sell(self): self.status = "sold" return self def add_tax(self, tax_rate): if tax_rate >= 1: return self.price + self.price * (tax_rate / 100) if tax_rate < 1: return self.price + self.price * tax_rate def make_return(self, note): if note == "defective": self.status = "defective" self.price = 0 elif note == "in box": self.status = "for sale" elif note == "open box": self.status = "used" self.price = self.price - (self.price * 0.2) return self def display_info(self): print "Product name: {}".format(self.name) print "Product brand:", self.brand print "Price: ${}".format(self.price) print "Item weight {}oz.".format(self.weight) print "Item status:", self.status class Store(object): def __init__(self, name, owner): self.name = name self.owner = owner self.products = [] def add_product(self, price, name, weight, brand): new_product = Product(price, name, weight, brand) self.products.append(new_product) print "Successfully added {}.".format(new_product.name) print "Shelves now contain the following:" for product in self.products: print "\t" + product.name def remove_product(self, query_name): for product in range(len(self.products)): if self.products[product].name == query_name: del self.products[product] break print "Removed {}".format(query_name) print "Shelves now contain the following:" for product in self.products: print "\t" + product.name store1 = Store("GarbageMart", "Oscar T Grouch") store1.add_product(3.50, "Garbage", 100, "Grouch-o") store1.add_product(4.50, "More Garbage", 200, "Grouch-o") store1.add_product(5.50, "Family-size Garbage Pail", 400, "Grouch-o") store1.remove_product("More Garbage")
name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shane", "Oscar"] favorite_animal = ["horse", "cat", "spider", "giraffe", "ticks", "dolphins", "llamas"] def makeDict(list1, list2): if len(list1) > len(list2) or len(list1) == len(list2): key_list = list1 val_list = list2 else: key_list = list2 val_list = list1 print key_list print val_list zipped = zip(key_list, val_list) print zipped new_dict = dict(zipped) print new_dict return new_dict makeDict(name, favorite_animal)
# input word_list = ['hello','world','my','name','is','Anna'] char = 'o' # output new_list = [] for val in range(len(word_list)): if word_list[val].find(char) > -1: new_list.append(word_list[val]) print new_list
import argparse parser = argparse.ArgumentParser(description='XOR string with key') parser.add_argument("-s", "--string", help="String to encrypt", required=True, action="store") parser.add_argument("-k", "--key", help="Encryption key", required=True, action="store") args=parser.parse_args() plaintext=bytearray(args.string, "ASCII") key=bytearray(args.key, "ASCII") encrypted='' i=0 for byte in plaintext: encrypted+=format(byte^key[i], "x") i+=1 if i>=len(key): i=0 print(encrypted)
import argparse from string import ascii_lowercase, ascii_letters, printable, punctuation parser = argparse.ArgumentParser(description='Decrypt string XORed with single letter') parser.add_argument("-s", "--string", help="String to decrypt", required=True, action="store") args=parser.parse_args() bytesarray=bytearray.fromhex(args.string) frequencies = { 'a':0.08167, 'b':0.01492, 'c':0.02782, 'd':0.04253, 'e':0.12702, 'f':0.02228, 'g':0.02015, 'h':0.06094, 'i':0.06966, 'j':0.00153, 'k':0.00772, 'l':0.04025, 'm':0.02406, 'n':0.06749, 'o':0.07507, 'p':0.01929, 'q':0.00095, 'r':0.05987, 's':0.06327, 't':0.09056, 'u':0.02758, 'v':0.00978, 'w':0.02360, 'x':0.00150, 'y':0.01974, 'z':0.00074 } def rate(stringtorate): result=0 for c in ascii_lowercase: count=0 stringtorate=stringtorate.lower() for d in stringtorate: if d in ascii_letters or d in punctuation or d == ' ': if d==c: count+=1 else: return 1001 result+=pow(frequencies[c]-(count/len(stringtorate)), 2) return result best_decrypted='' best_score=1000 for c in ascii_letters: xor='' for byte in bytesarray: xor+=chr(byte^ord(c)) current_rate=rate(xor) if(current_rate<best_score): best_score=current_rate best_decrypted=xor print(best_decrypted)
#!/usr/bin/env python # -*- coding: utf-8 -*- import cv2 import numpy as np def create_blank(width, height, rgb_color=(0, 0, 0)): """Create new image(numpy array) filled with certain color in RGB""" # Create black blank image image = np.zeros((height, width, 3), np.uint8) # Since OpenCV uses BGR, convert the color first color = tuple(reversed(rgb_color)) # Fill image with color print(image) image[:] = color print(image) return image # Create new blank 300x300 red image width, height = 2, 2 red = (255, 0, 0) image = create_blank(width, height, rgb_color=red) # grey = np.zeros((4, 4, 3), np.uint8) # print(grey) cv2.imshow('ImageWindow', image) cv2.waitKey()
''' setattr:设置属性(动态获取某个属性的函数) setattr(对象或者类,属性名称,赋值的新值) setattr 不管属性存在不存在,都会赋给新值 ''' class Phone: property = True def __init__(self,brand): self.brand = brand def call(self): self.xianren = "男" print("使用老年机正在打电话") def send_short_messages(self): print('使用老年机正在发送短信') iphone = Phone('xiaomi') iphone.brand = 'apple' # print(iphone.brand) # 获取属性,获取属性如果不存在,则报错 # 修改,字典 # iphone.color = 'red' # print(iphone.color) # 有时候,提前不知道属性名称是什么,从其他地方拿过来 setattr(iphone, 'food', '麻辣烫') print(iphone.food) setattr(iphone,'brand','华为mate40pro') print(iphone.brand)
def word_ending_by_number(number :int) -> str: number = abs(number) if number in range(11, 20): return 'ов' x = number % 10 if x == 1: return '' elif x in range(2, 5): return 'а' else: return 'ов'
import tkinter as tk from tkinter import * import os root = tk.Tk() root.title("PROJECT ON RECOMMENDED SYSTEM") root.configure(bg='sky blue') #canvas = canvas(root, bg = "blue", height=100, width=100) #canvas.grid(row=0,column=2) #C = tkinter.Canvas(root, bg="blue", height=250, width=300) canvas = tk.Canvas(root) #canvasColor = "yellow" #canvas = Canvas(width=600, height=600, bg='white') canvas.pack() canvas_text = canvas.create_text(10, 10, text='', anchor=tk.CENTER,fill='blue') #canvas_text = C.create_text(10, 10, text='', anchor=tk.NW) test_string = "WELCOME TO HIGHER STUDIES RECOMMENDATION SYSTEM" #Time delay between chars, in milliseconds delta = 100 delay = 10 for i in range(len(test_string) + 1): s = test_string[:i] update_text = lambda s=s: canvas.itemconfigure(canvas_text, text=s) canvas.after(delay, update_text) delay += delta root.mainloop()
def print_sum(a): if a == 1: return 1 else: return a*print_sum(a-1) n = print_sum(5) print(n)
def print_q(y): if y%400 == 0 or y%4 == 0 and y%100 != 0: print("%d是润年"%y) else: print("不是润年") y = int(input("输入年号")) print_q(y)
import trade graph={ "numAttrs":["initialPrice","price","highestPrice","lowestPrice","average","relativePrice","margin"], "coin":"", "initialPrice":0, "price":0, "highestPrice":0, "lowestPrice":0, "average":0, "relativePrice":0, "margin":0 } global clearCanvas clearCanvas=True def clear(): for attr in graph["numAttrs"]: graph[attr]=0 global clearCanvas clearCanvas=True def setBase(): graph["initialPrice"]=graph["price"] global clearCanvas clearCanvas=False def draw(Coin): trade.setBigO() graph["coin"]=Coin graph["price"]=trade.sellOut(Coin) if(clearCanvas): setBase() if(graph["highestPrice"] < graph["price"]): graph["highestPrice"]=graph["price"] if(graph["lowestPrice"] > graph["price"] or graph["lowestPrice"]==0): graph["lowestPrice"]=graph["price"] graph["average"]=((graph["highestPrice"] + graph["lowestPrice"]) / 2) graph["relativePrice"]=graph["price"] / graph["highestPrice"] graph["margin"]=graph["lowestPrice"] / graph["highestPrice"] return graph
import requests import json # This is an example of creating a request with mashivisor Real Estate API # HTTP requests just work like opening a webpage, think about what data a webpage displays when it loads, you're just taking that data when you do requests # Define data you want to send in a request as variables address = '70 Pine St' city = 'New York' state = 'NY' zipcode = '10005' # These variables will likely be linked to your account or specific endpoint and are used to authenticate requests api_key = 'Enter Your API Key Here' mash_id = 'Enter your Mashivisor ID here' # Construct your request, so build out the URL you need for the request, remember to use variables here so its easier to run scripts etc. url_mash_prop = f'https://api.mashvisor.com/v1.1/client/property?id{mash_id}&state={state}&address={address}&city={city}&zip_code={zipcode}' # Your headers should reference any authentication information headers_mash = {'x-api-key' : api_key} # Functions to send the request to your provider, this returns a JSON as a string. This is probably a good idea to use a JSON most of the time def get_cl(url, headers): response = requests.get(url, headers=headers) json_data = json.loads(response.text) return json_data mashivor_data = get_cl(url_mash_prop, headers_mash) #Simple query in the JSON to get specific information long_term = mashivor_data['content']['ROI']['traditional_rental'] short_term = mashivor_data['content']['ROI']['airbnb_rental'] cap_rate = mashivor_data['content']['ROI']['traditional_cap_rate']
# all variables are reference types, x point to object "5" which is primitive type x = 5 # in this case 5 will be garbage collected x = 10 # both x and y will be pointing tot he same integer objects x = 5 y = 5 # this returns true as both x and y point to the same value print(x==y) s1 = "hello" s2 = "hello" # this returns true print(s1 == s2) # value euqality print( 5 ==5 ) # string comparison is case sensitive print("hello" != "Hello") # value equality also applies to collection myFirstList = ["small", "medium", "large", "x-large"] mySecondList = ["small", "medium", "large", "x-large"] # True print(myFirstList == mySecondList) #reference equality aslo use is print( x is y) #reference equality is does not apply to collection # False print(myFirstList is mySecondList) x = 5 # this is reference assignment, y and x point to 5 y = x # this is will change value for both x, 3 is a new object, this is called object immutability # = only assign a new value to an object if right side is value object # y will still be 5 x = 3 print(x) print(y) #same here s1 = 'hello' s2 = s1 s1 = 'bye' #bye print(s1) #hello print(s2) # same here, we will get two separate lists myFirstList = ["small", "medium", "large", "x-large"] mySecondList = myFirstList myFirstList = ["smallish", "medium", "large", "x-large", "xx-large"] print(myFirstList) print(mySecondList) # modification through direct access myFirstDictionary = {"S": "Small", "M": "Medium", "L": "Large", "XL": "X-Large"} mySecondDictionary = myFirstDictionary myFirstDictionary["S"] = "Smallish" myFirstDictionary["XXL"] = "XX-Large" # same value but modified print(myFirstDictionary) print(mySecondDictionary) #passing object by reference def modify_dictionary(dictionary): #this will change original dictionary as well dictionary["XL"] = "Extra Large" return dictionary # keep the original value by making a deep copy def deep_copy_dictionary(dictionary): deep_copy={} for item in dictionary: deep_copy[item] = dictionary[item] return deep_copy
# in operator #it can be applied in list, dictionary, Tuples, and strings my_list = [1, 3, 4, 5, 6] my_dict = {"S": "Small", "M": "Medium", "L": "Large", "XL": "X-Large"} my_tuple = (10, 13, 15, 17, 11) name = "Elvis Presley" list_included = 1 in my_list dict_included = "S" in my_dict tup_included = 11 in my_tuple string_included = 'vi' in name print(list_included) print(dict_included) print(tup_included) print(string_included) list_not_included = 1 not in my_list print(list_not_included)
person = {'name': 'Peter', 'age': 29} person['city'] = 'Cape Town' print person print person['name'] del person['city'] print person states = { 'Oregon': 'OR', 'Florida': 'FL', 'California': 'CA', 'New York': 'NY', 'Michigan': 'MI', } cities = { 'OR':'Portland', 'FL':'Jacksonville', 'CA':'San Francisco', 'NY':'New York City', 'MI':'Detroit', 'NY':'New Jersey' } print cities['NY'] print cities for abreviation, city in cities.items(): print '%s %s' % (abreviation, city)
def isPalindrome(s): r = ''.join(reversed(list(s))) print(s,r) return s == r s = input() print(isPalindrome(s))
# CB 2020-10-02 Palindrome String Checker # CB 2020-10-02 Take in a string as input def stringInput(): originalString = input("Please input a string: ") return originalString # CB 2020-10-02 Reverse the string, store it def reverse(originalString): newString = "" index = len(originalString) - 1 for i in range(len(originalString)): newString += originalString[index] index -= 1 return newString # CB 2020-10-03 Take the original and reversed string and compare def compare(originalString, newString): # CB 2020-10-02 If the input string is the same as output, it's a palindrome if originalString == newString: print (originalString + " is a palindrome") return True # CB 2020-10-02 Else, it's not a palindrome else: print (originalString + " is not a palindrome") return False # CB 2020-10-03 Call the above functions originalString = stringInput() newString = reverse(originalString) isPalindrome = compare(originalString, newString)
print("hello user welcome to my addtion program") num1 = int(input("Please enter first number : ")) num2 = int(input("Please enter second number : ")) sum_of_nums = num1 + num2 print(sum_of_nums) input()
""" The following code is for the trivia bot found on the JakeMac discord server. This is the piece of code that interacts with the actual discord server. Pretty much the front end of it. Author: Kenny Blake 2/14/18 """ import discord from discord.ext import commands import trivia answered = 0 client = commands.Bot(command_prefix=';') @client.event async def on_ready(): print("Bot is ready!") @client.command() async def ping(ctx): await ctx.send(f"{round(client.latency*1000)}ms") @client.command() async def answer(ctx, ans : str): global answered if ctx.channel.name == "jedi-gang": role = "Jedi" elif ctx.channel.name == "sith-gang": role = "Sith" else: ctx.send("Sorry, you must play in either the jedi-gang chatroom , or the sith-gang chatroom.") correct = trivia.t.checkAnswer(ans, role) if correct: q = trivia.t.getQuestion(answered) await ctx.send(f"Correct!") if q == "j": await ctx.send("Game Over! Jedi's Win!") await client.close() elif q == "s": await ctx.send("Game Over! Sith's Win!") await client.close() else: await ctx.send(q) else: await ctx.send("Incorrect. Try again!") answered += 1 @client.command() @commands.has_permissions(manage_messages = True) async def startgame(ctx, ch1 : discord.TextChannel, ch2 : discord.TextChannel): global answered await ctx.send(f"""Welcome to the JakeMac server Official Trivia Game! -Created by: Kenny Blake -The objective of the game is to be the first team to get 5 questions right! -The games are between the Sith, and the Jedi. -Remember! You are all on a team! """) q = trivia.t.getQuestion(answered) if q == False: await ctx.send("Thanks for playing!") await client.close() else: await ctx.send(f"""Welcome to the JakeMac server Official Trivia Game! -Created by: Kenny Blake -The objective of the game is to be the first team to get 5 questions right! -The games are between the Sith, and the Jedi. -Remember! You are all on a team! """) await ch1.send(f"""Welcome to the JakeMac server Official Trivia Game! -Created by: Kenny Blake -The objective of the game is to be the first team to get 5 questions right! -The games are between the Sith, and the Jedi. -Remember! You are all on a team! """) await ch2.send(f"""Welcome to the JakeMac server Official Trivia Game! -Created by: Kenny Blake -The objective of the game is to get the most questions correct! -The games are between the Sith, and the Jedi. -Remember! You are all on a team! -To answer questions, type ;answer [your answer here] -for help, type ;help """) await ch1.send(q) await ch2.send(q) @client.event async def on_command_error(ctx, error: discord.errors): if isinstance(error, commands.CheckFailure): await ctx.send("You don't have permission to do that!") if isinstance(error, commands.CommandNotFound): await ctx.send("That command doesn't exist!") client.run('Left this part out on github.')
#Queue Class that takes a max size as a parameter and will only enqueue items up to that max size indicated class Queue: def __init__(self, MAX_SIZE): self.queue = [] self.MAX_SIZE = MAX_SIZE # create an empty queue def create_queue(self): return [] # return the size of the list added as a parameter def size(self): return len(self.queue) def maxsize(self): return self.MAX_SIZE # add an input to the end of the list # returns list def enqueue(self,input): if self.size() < self.maxsize(): self.queue.append(input) return self.queue # pops off the first item of the list def dequeue(self): return self.queue.pop(0) def printQueue(self): print("this is the whole queue: ") print(self.queue) def getQueue(self): return self.queue def testQueue(): q1 = Queue(4)#make a queue of size 4 q1.printQueue() q1.enqueue(1) q1.printQueue() q1.dequeue() q1.printQueue() q1.enqueue(3) q1.enqueue(4) q1.enqueue(2) q1.enqueue(2) q1.printQueue() q1.enqueue(1) q1.printQueue() print("Item dequeued: " + str(q1.dequeue())) #testQueue()
import random import string def randomString(stringLength=60): """Generate a random string of fixed length """ letters = string.ascii_lowercase return ''.join(random.choice(letters) for _ in range(stringLength)) def randomAlphanumeric(stringLength=60): return ''.join( random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(stringLength)) print(randomString(60).upper()) print(randomAlphanumeric(60).upper())
# written by Matt Borthwick for "Data Exploration in Python" presentation, Jan 17, 2018 from _csv import reader import matplotlib.pyplot as plt import numpy as np # exapmle usage: # # from explorer import FakeDataExplorer # ex = FakeDataExplorer("fake-data.csv") # print(ex.keys()) # ex.histograms("revenue") # ex.scatter_plots("growth", "score2") class FakeDataExplorer(dict): def __init__(self, data_filename): """ load csv data into a dict of lists """ with open(data_filename) as f: rows = reader(f) # headers will be the dict keys headers = next(rows)[1:] # omit the first column, which is names # the dict values will be lists of the column values super().__init__(zip(headers, zip(*(self.process_row(row, headers) for row in rows)))) def process_row(self, row, headers): # missing values will be replaced by zero, omitting the first column # # if the columns hold different types of data, this could instead # call different functions to process the cells in each column return (self.process_cell(cell) for cell in row[1:]) @staticmethod def process_cell(cell): # fill missing cells with zeroes return float(cell) if cell else 0 combinations = ((False, False), (True, False), (False, True), (True, True)) def histograms(self, key, n_bins=200): """ plot four separate histograms of self[key], showing each combination of linear and logarithmic axes and compare each histogram to a normal distribution """ normal_curve = self.calc_normal_curve(self[key], n_bins) plt.figure(0) plt.clf() # clear figure for index, use_log_scale in enumerate(self.combinations, 1): plt.subplot(2, 2, index).tick_params(labelsize="x-small") self.single_histogram(key, use_log_scale=use_log_scale, normal_curve=(None if use_log_scale[0] else normal_curve), n_bins=n_bins) plt.suptitle(key) plt.show(block=False) label_combinations = ((False, True), (False, False), (True, True), (False, False)) def scatter_plots(self, key_x, key_y): """ plot four separate scatterplots of key_y vs. key_x, showing each combination of linear and logarithmic axes """ plt.figure(1) plt.clf() for index, use_log_scale in enumerate(self.combinations, 1): plt.subplot(2, 2, index).tick_params(labelsize="x-small") self.single_scatter_plot(key_x, key_y, use_log_scale=use_log_scale, show_labels=(index > 2, index % 2)) plt.show(block=False) def single_histogram(self, key, use_log_scale=(False, False), normal_curve=None, n_bins=200): """ plot a single histogram of self[key], with log or linear axes as specified, along with a curve showing a normal distribution with the same mean and stdev as self[key] """ vals = self[key] if use_log_scale[0]: # logarithmic x-axis plt.xscale("log") # show only positive values vals = tuple(val for val in vals if val > 0) # make bins equally sized on a logarithmic axis bins = np.geomspace(min(vals), max(vals), n_bins) else: # linear x-axis, just use equally spaced bins bins = n_bins plt.hist(vals, bins=bins, log=use_log_scale[1]) if normal_curve: plt.plot(*normal_curve, color=(1,0,0,0.3), linewidth=2) def calc_normal_curve(self, vals, n_bins): """ calculate a normal distribution with the same mean and stdev as vals """ stdev = np.std(vals) z = np.linspace(-4, 4, 200) x = z * stdev + np.mean(vals) y = len(vals) / n_bins * np.pi * np.exp(-0.5 * z * z) return x, y def single_scatter_plot(self, key_x, key_y, use_log_scale=(False, False), size=0.1, show_labels=(True, True), **keywords): """ plot self[key_y] vs. self[key_x] and calculate the Pearson correlation coefficient between them """ x_vals = self[key_x] y_vals = self[key_y] # show only positive values when using logarithmic axes if use_log_scale[0]: plt.xscale("log") x_vals, y_vals = zip(*((x, y) for x, y in zip(x_vals, y_vals) if x > 0)) if use_log_scale[1]: plt.yscale("log") x_vals, y_vals = zip(*((x, y) for x, y in zip(x_vals, y_vals) if y > 0)) corr_y_vals = np.log(y_vals) vals_for_corr = (np.log(vals) if use_log else vals for vals, use_log in zip((x_vals, y_vals), use_log_scale)) r_squared = "$r^2$ = {:.5}".format(np.corrcoef(*vals_for_corr)[0,1] ** 2) plt.scatter(x_vals, y_vals, s=size, c=(0,0,0.6,0.3), label=r_squared, **keywords) plt.legend(markerscale=0, markerfirst=False, frameon=False) for show_label, labeller, key in zip(show_labels, (plt.xlabel, plt.ylabel), (key_x, key_y)): if show_label: labeller(key)
"""Functions for creating a co-citation graph. A co-citation graph is a semantic similarity measure which ranks documents commonly cited together by other documents [1]_. It provides a forward looking assesment on how similar two documents are, as opposed to the retrospective approach of the citation network. References ---------- .. [1] Henry Small, 1973 "Co-citation in the scientific literature: a new measure of the relationship between two documents" """ import networkx as nx from networkx.utils import not_implemented_for __all__ = ['cocite'] @not_implemented_for('undirected') @not_implemented_for('multigraph') def cocite(G,min_citations = 2): """Compute a the co-citation graph using a citation network Parameters ---------- G : graph A directed graph of citations between nodes. min_citation : integer (optional, default=2) The minimum number of co-citations required to keep an edge in the cocitation graph. Returns ------- G : graph An undirected cocitation graph Notes ----- The implementation is written by Daniel Ellis (2019) [1]_. References ---------- .. [1] . """ if not G.is_directed(): msg = "The cocitation algorithm requires a directed citation graph as an input." raise nx.NetworkXError(msg) #assert type(G) == nx.classes.digraph.DiGraph edges = {} #for each node for n in G.nodes(): # for each outward edge (citing) out = G.out_edges(n) for i in out: for j in out: if i==j: break pair = tuple(set([i[1],j[1]])) try: edges[pair] = edges[pair] + 1 except: edges[pair] = 1 CC = G.to_undirected() # this returns a deepcopy CC = nx.create_empty_copy(CC, with_data=True) edgelist = [(i[0][0],i[0][1],i[1]) for i in edges.viewitems() if i[1]>min_citations] CC.add_weighted_edges_from(edgelist) return CC
from math import hypot oposto = float(input('Qual o comprimento do cateto \033[35moposto\033[m? ')) adjacente = float(input('Qual o comprimento do cateto \033[35madjacente\033[m? ')) hipotenusa = hypot(oposto,adjacente) print('a hipotenusa vai medir \033[36m{:.2f}'.format(hipotenusa))
reais=float(input('Quantos reais você tem? R$')) dol=4.33 print('Com {:.2f} você possui US${:.2f}'.format(reais,reais/dol)) real=float(input('Quantos dólares você tem? US$')) print('Neste caso você possui R${:.2f} reais'.format(real*dol))
from random import randint from time import sleep from operator import itemgetter jogos = {'jogador1' : randint(1,6), 'jogador2' : randint(1,6), 'jogador3' : randint(1,6), 'jogador4' : randint(1,6)} ranking = [] print('Valores sorteados:') for k, v in jogos.items(): print(f' O {k} tirou {v}') sleep(0.5) print('Ranking dos jogadores:') ranking = sorted(jogos.items(), key=itemgetter(1), reverse=True) for i, v in enumerate(ranking): print(f' {i+1}º lugar: {v[0]} com {v[1]}.') sleep(0.5)
times = ('Athletico', 'Fortaleza', 'Bragantino', 'Palmeiras', 'Atlético-MG', 'Fluminense', 'Bahia', 'Santos', 'Flamengo', 'Corinthians', 'Ceará', 'Internacional', 'Juventude', 'Chapecoense') print('-='*30) print('Classificação Brasileirão') print('-='*30) print(f'Os 5 primeiros colocados são {times[0:5]}') print('-='*30) print(f'Os últimos 4 colocados são {times[-4:]}') print('-='*30) print(f'Os times em ordem alfabética {sorted(times)}') print('-='*30) print(f'O chapecoense está na posição {times.index("Chapecoense")+1}')
data = {} gols = [] data['nome'] = str(input('Nome do Jogador: ')) partidas = int(input(f'Quantas partidas {data["nome"]} jogou? ')) for g in range(0, partidas): gols.append(int(input(f'Quantos gols na partida {g+1}? '))) data['gols'] = gols[:] data['total'] = sum(gols) print(data) print('-='*20) print(f'O campo nome tem o valor {data["nome"]}.') print(f'O campo gols tem o valor {gols}.') print(f'O campo total tem o valor {data["total"]}.') print('-='*20) print(f'O jogador {data["nome"]} jogou {partidas}.') for c in range(0, partidas): print(f' => Na partida {c+1}, fez {gols[c]} gols.') print(f'Foi um total de {data["total"]} gols!')
resp = "Y" sum = quant = average = bigger = smaller = 0 while resp in 'Yy': num = int(input('Say a number: ')) sum += num quant += 1 if quant == 1: bigger = smaller = num else: if num > bigger: bigger = num if num < smaller: smaller = num resp = str(input('Do you want to continue? [Y/N] ')).upper().strip()[0] average = sum / quant print('Você digitou {} números, a média entre os números digitados foi {}'.format(quant, average)) print('O maior é {} e o menor {}'.format(bigger, smaller))
from math import radians, cos, sin, tan angulo = float(input('Digite o ângulo que você deseja ' )) seno = sin(radians(angulo)) print('O ângulo {} tem o seno de {:.2f}'.format(angulo,seno)) cosseno = cos(radians(angulo)) print('O ângulo {} tem o cosseno de {:.2f}'.format(angulo,cosseno)) tangente = tan(radians(angulo)) print('O ângulo {} tem a tangente de {:.2f}'.format(angulo,tangente))
cidade = str(input('Digite o nome da sua cidade: ')).strip().split() print(cidade[0].lower() =='santo')
n1=int(input('Diga um número:')) dob=n1*2 trip=n1*3 raiz=n1**(1/2) print('O dobro de {} é: {}. \nO triplo é: {}. \nE a raíz quadrada é: {}.'.format(n1,dob,trip,raiz))
valores = [] impares = [] pares = [] while True: valores.append(int(input('Digite um número: '))) quest = str(input('Deseja continuar?[S/N] ')) if quest in 'nN': break elif quest not in 'nNsS': quest = str(input('Digite S ou N: ')) for i, v in enumerate(valores): if v % 2 == 0: pares.append(v) else: impares.append(v) print(f'Os números pares digitados foram {pares}') print(f'Os números ímpares digitados foram {impares}') print(f'Os números digitados foram {valores}')
num = int(input('\033[36mDigite um número inteiro:\033[m ')) decidir = int(input( '\033[36mEscolha qual será a base de conversão:\033[m \n\033[31mdigite [1] para binário\033[m\n\033[32mdigite [2] para octal\033[m\n\033[34mdigite [3] para hexadecimal:\033[m ')) if decidir == 1: print('\033[31mconvertendo {} para binário fica:\033[m {}'.format(num, bin(num))) elif decidir == 2: print('\033[32mconvertendo {} para octal fica:\033[m {}'.format(num, oct(num))) elif decidir == 3: print('\033[34mconvertendo {} para hexadecimal fica:\033[m {}'.format(num, hex(num))) else: print('\033[36mOpção inválida tente novamente')
import os.path import tempfile class File: def __init__(self, path_to_file): self.path_to_file = path_to_file if not os.path.exists(path_to_file): with open(self.path_to_file, "a") as f: f.write('') file_in_next = open(self.path_to_file, "r") self.file_in_next = file_in_next def read(self): with open(self.path_to_file, "r") as f: content = f.read() return content def write(self, new_content): with open(self.path_to_file, "w") as f: f.write(new_content) def __str__(self): # return f"{self.path_to_file}" abs_path_to_file = os.path.abspath(self.path_to_file) return "{}".format(abs_path_to_file) def __iter__(self): return self def __next__(self): line = self.file_in_next.readline() if not line: #self.file_in_next.close() raise StopIteration return line @classmethod def create_new_file_from_two(cls, path): """создает экземпляр класса из словаря с параметрами""" return cls(path) def __add__(self, obj): content_1 = self.read() content_2 = obj.read() new_content_from_add = content_1 + content_2 print("len(new_content_from_add) ", len(new_content_from_add)) print("new_content_from_add\n", new_content_from_add) new_temp_path = os.path.join(tempfile.gettempdir(),"new_file" ) print("new_temp_path ", new_temp_path) new_class = self.create_new_file_from_two(new_temp_path) print("new_class ", new_class) new_class.write(new_content_from_add) return new_class if __name__ == "__main__": # execute only if run as a script path_to_file = 'some_filename' print("os.path.exists(path_to_file)", os.path.exists(path_to_file)) file_obj = File(path_to_file) print("os.path.exists(path_to_file)", os.path.exists(path_to_file)) print("file_obj.read() ", file_obj.read()) print("file_obj.write('some text') ", file_obj.write('some text')) print("file_obj.read() ", file_obj.read()) print("file_obj.write('other text')" , file_obj.write('other text')) print("file_obj.read() ", file_obj.read()) print("file_obj ", file_obj) file_obj_1 = File(path_to_file + '_1') print("type(file_obj_1) ", type(file_obj_1)) file_obj_2 = File(path_to_file + '_2') file_obj_1.write('line 1\n') file_obj_2.write('line 2\n') new_file_obj = file_obj_1 + file_obj_2 print("isinstance(new_file_obj, File) ", isinstance(new_file_obj, File)) print(new_file_obj) for line in new_file_obj: print(ascii(line)) r = type(new_file_obj)(path_to_file + '_3') print("type(File)(path_to_file + '_3') ", r)
def jHex(word): jap = list(word) List = [] for i in jap: if i == " ": List.append("9940") elif i == ",": List.append("9941") elif i == ".": List.append("9942") elif i == "・": List.append("9943") elif i == ":": List.append("9944") elif i == "?": List.append("9945") elif i == "!": List.append("9946") elif i == "ー": List.append("9947") elif i == "/": List.append("9948") elif i == "”": List.append("9949") elif i == "(": List.append("994A") elif i == ")": List.append("994B") elif i == "%": List.append("994C") elif i == "0": List.append("994D") elif i == "1": List.append("994E") elif i == "2": List.append("994F") elif i == "3": List.append("9950") elif i == "4": List.append("9951") elif i == "5": List.append("9952") elif i == "6": List.append("9953") elif i == "7": List.append("9954") elif i == "8": List.append("9955") elif i == "9": List.append("9956") elif i == "A": List.append("9957") elif i == "B": List.append("9958") elif i == "C": List.append("9959") elif i == "D": List.append("995A") elif i == "E": List.append("995B") elif i == "F": List.append("995C") elif i == "G": List.append("995E") elif i == "H": List.append("995F") elif i == "I": List.append("9960") elif i == "J": List.append("9961") elif i == "K": List.append("9962") elif i == "L": List.append("9963") elif i == "M": List.append("9964") elif i == "N": List.append("9965") elif i == "O": List.append("9966") elif i == "P": List.append("9967") elif i == "Q": List.append("9968") elif i == "R": List.append("9969") elif i == "S": List.append("996A") elif i == "T": List.append("996B") elif i == "U": List.append("996C") elif i == "V": List.append("996D") elif i == "W": List.append("996E") elif i == "X": List.append("996F") elif i == "Y": List.append("9970") elif i == "Z": List.append("9971") elif i == "ぁ": List.append("9972") elif i == "あ": List.append("9973") elif i == "ぃ": List.append("9974") elif i == "い": List.append("9975") elif i == "ぅ": List.append("9976") elif i == "う": List.append("9977") elif i == "ぇ": List.append("9978") elif i == "え": List.append("9979") elif i == "ぉ": List.append("997A") elif i == "お": List.append("997B") elif i == "か": List.append("997C") elif i == "が": List.append("997D") elif i == "き": List.append("997E") elif i == "ぎ": List.append("9980") elif i == "く": List.append("9981") elif i == "ぐ": List.append("9982") elif i == "け": List.append("9983") elif i == "げ": List.append("9984") elif i == "こ": List.append("9985") elif i == "ご": List.append("9986") elif i == "さ": List.append("9987") elif i == "ざ": List.append("9988") elif i == "し": List.append("9989") elif i == "じ": List.append("998A") elif i == "す": List.append("998B") elif i == "ず": List.append("998C") elif i == "せ": List.append("998D") elif i == "ぜ": List.append("998E") elif i == "そ": List.append("998F") elif i == "ぞ": List.append("9990") elif i == "た": List.append("9991") elif i == "だ": List.append("9992") elif i == "ち": List.append("9993") elif i == "ぢ": List.append("9994") elif i == "っ": List.append("9995") elif i == "つ": List.append("9996") elif i == "づ": List.append("9997") elif i == "て": List.append("9998") elif i == "で": List.append("9999") elif i == "と": List.append("999A") elif i == "ど": List.append("999B") elif i == "な": List.append("999C") elif i == "に": List.append("999D") elif i == "ぬ": List.append("999E") elif i == "ね": List.append("999F") elif i == "の": List.append("99A0") elif i == "は": List.append("99A1") elif i == "ば": List.append("99A2") elif i == "ぱ": List.append("99A3") elif i == "ひ": List.append("99A4") elif i == "び": List.append("99A5") elif i == "ぴ": List.append("99A6") elif i == "ふ": List.append("99A7") elif i == "ぶ": List.append("99A8") elif i == "ぷ": List.append("99A9") elif i == "へ": List.append("99AA") elif i == "べ": List.append("99AB") elif i == "ぺ": List.append("99AC") elif i == "ほ": List.append("99AD") elif i == "ぼ": List.append("99AE") elif i == "ぽ": List.append("99AF") elif i == "ま": List.append("99B0") elif i == "み": List.append("99B1") elif i == "む": List.append("99B2") elif i == "め": List.append("99B3") elif i == "も": List.append("99B4") elif i == "ゃ": List.append("99B5") elif i == "や": List.append("99B6") elif i == "ゅ": List.append("99B7") elif i == "ゆ": List.append("99B8") elif i == "ょ": List.append("99B9") elif i == "よ": List.append("99BA") elif i == "ら": List.append("99BB") elif i == "り": List.append("99BC") elif i == "る": List.append("99BD") elif i == "れ": List.append("99BE") elif i == "ろ": List.append("99BF") elif i == "ゎ": List.append("99C0") elif i == "わ": List.append("99C1") elif i == "ゐ": List.append("99C2") elif i == "ゑ": List.append("99C3") elif i == "を": List.append("99C4") elif i == "ん": List.append("99C5") elif i == "ァ": List.append("99C6") elif i == "ア": List.append("99C7") elif i == "ィ": List.append("99C8") elif i == "イ": List.append("99C9") elif i == "ゥ": List.append("99CA") elif i == "ウ": List.append("99CB") elif i == "ェ": List.append("99CC") elif i == "エ": List.append("99CD") elif i == "ォ": List.append("99CE") elif i == "オ": List.append("99CF") elif i == "カ": List.append("99D0") elif i == "ガ": List.append("99D1") elif i == "キ": List.append("99D2") elif i == "ギ": List.append("99D3") elif i == "ク": List.append("99D4") elif i == "グ": List.append("99D5") elif i == "ケ": List.append("99D6") elif i == "ゲ": List.append("99D7") elif i == "コ": List.append("99D8") elif i == "ゴ": List.append("99D9") elif i == "サ": List.append("99DA") elif i == "ザ": List.append("99DB") elif i == "シ": List.append("99DC") elif i == "ジ": List.append("99DD") elif i == "ス": List.append("99DE") elif i == "ズ": List.append("99DF") elif i == "セ": List.append("99E0") elif i == "ゼ": List.append("99E1") elif i == "ソ": List.append("99E2") elif i == "ゾ": List.append("99E3") elif i == "タ": List.append("99E4") elif i == "ダ": List.append("99E5") elif i == "チ": List.append("99E6") elif i == "ヂ": List.append("99E7") elif i == "ッ": List.append("99E8") elif i == "ツ": List.append("99E9") elif i == "ヅ": List.append("99EA") elif i == "テ": List.append("99EB") elif i == "デ": List.append("99EC") elif i == "ト": List.append("99ED") elif i == "ド": List.append("99EE") elif i == "ナ": List.append("99EF") elif i == "ニ": List.append("99F0") elif i == "ヌ": List.append("99F1") elif i == "ネ": List.append("99F2") elif i == "ノ": List.append("99F3") elif i == "ハ": List.append("99F4") elif i == "バ": List.append("99F5") elif i == "パ": List.append("99F6") elif i == "ヒ": List.append("99F7") elif i == "ビ": List.append("99F8") elif i == "ピ": List.append("99F9") elif i == "フ": List.append("99FA") elif i == "ブ": List.append("99FB") elif i == "プ": List.append("99FC") elif i == "ヘ": List.append("9A40") elif i == "ベ": List.append("9A41") elif i == "ペ": List.append("9A42") elif i == "ホ": List.append("9A43") elif i == "ボ": List.append("9A44") elif i == "ポ": List.append("9A45") elif i == "マ": List.append("9A46") elif i == "ミ": List.append("9A47") elif i == "&": List.append("9A48") elif i == "ム": List.append("9A49") elif i == "メ": List.append("9A4A") elif i == "モ": List.append("9A4B") elif i == "ャ": List.append("9A4C") elif i == "ヤ": List.append("9A4D") elif i == "ュ": List.append("9A4E") elif i == "ユ": List.append("9A4F") elif i == "ョ": List.append("9A50") elif i == "ヨ": List.append("9A51") elif i == "ラ": List.append("9A52") elif i == "リ": List.append("9A53") elif i == "ル": List.append("9A54") elif i == "レ": List.append("9A55") elif i == "ロ": List.append("9A56") elif i == "?": List.append("9A57") elif i == "ワ": List.append("9A58") elif i == "=": List.append("9A59") elif i == "☆": List.append("9A5A") elif i == "ヲ": List.append("9A5B") elif i == "ン": List.append("9A5D") elif i == "ヴ": List.append("9A5E") elif i == "△": List.append("9A7A") elif i == "○": List.append("9A7B") elif i == "×": List.append("9A7C") elif i == "<": List.append("9A7D") elif i == ">": List.append("9A7E") elif i == "♪": List.append("9A80") elif i == "?": List.append("9A81") elif i == "▽": List.append("9A82") elif i == "『": List.append("9A83") elif i == "』": List.append("9A84") elif i == "、": List.append("9A85") elif i == "。": List.append("9A86") elif i == "一": List.append("9A87") elif i == "二": List.append("9A88") elif i == "十": List.append("9A89") elif i == "千": List.append("9A8A") elif i == "万": List.append("9A8B") elif i == "地": List.append("9A8C") elif i == "水": List.append("9A8D") elif i == "火": List.append("9A8E") elif i == "風": List.append("9A8F") elif i == "光": List.append("9A90") elif i == "闇": List.append("9A91") elif i == "南": List.append("9A92") elif i == "西": List.append("9A93") elif i == "北": List.append("9A94") elif i == "赤": List.append("9A95") elif i == "白": List.append("9A96") elif i == "黒": List.append("9A97") elif i == "年": List.append("9A98") elif i == "月": List.append("9A99") elif i == "日": List.append("9A9A") elif i == "時": List.append("9A9B") elif i == "戦": List.append("9A9C") elif i == "闘": List.append("9A9D") elif i == "攻": List.append("9A9E") elif i == "撃": List.append("9A9F") elif i == "防": List.append("9AA0") elif i == "御": List.append("9AA1") elif i == "回": List.append("9AA2") elif i == "避": List.append("9AA3") elif i == "術": List.append("9AA4") elif i == "技": List.append("9AA5") elif i == "道": List.append("9AA6") elif i == "具": List.append("9AA7") elif i == "合": List.append("9AA8") elif i == "成": List.append("9AA9") elif i == "神": List.append("9AAA") elif i == "座": List.append("9AAB") elif i == "都": List.append("9AAC") elif i == "市": List.append("9AAD") elif i == "格": List.append("9AAE") elif i == "先": List.append("9AAF") elif i == "行": List.append("9AB0") elif i == "世": List.append("9AB1") elif i == "楽": List.append("9AB2") elif i == "園": List.append("9AB3") elif i == "案": List.append("9AB4") elif i == "外": List.append("9AB5") elif i == "所": List.append("9AB6") elif i == "知": List.append("9AB7") elif i == "大": List.append("9AB8") elif i == "昔": List.append("9AB9") elif i == "人": List.append("9ABA") elif i == "間": List.append("9ABB") elif i == "自": List.append("9ABC") elif i == "分": List.append("9ABD") elif i == "生": List.append("9ABE") elif i == "毎": List.append("9ABF") elif i == "祈": List.append("9AC0") elif i == "決": List.append("9AC1") elif i == "上": List.append("9AC2") elif i == "降": List.append("9AC3") elif i == "今": List.append("9AC4") elif i == "度": List.append("9AC5") elif i == "来": List.append("9AC6") elif i == "待": List.append("9AC7") elif i == "乗": List.append("9AC8") elif i == "空": List.append("9AC9") elif i == "何": List.append("9ACA") elif i == "手": List.append("9ACB") elif i == "入": List.append("9ACC") elif i == "以": List.append("9ACD") elif i == "持": List.append("9ACE") elif i == "武": List.append("9ACF") elif i == "器": List.append("9AD0") elif i == "屋": List.append("9AD1") elif i == "教": List.append("9AD2") elif i == "会": List.append("9AD3") elif i == "食": List.append("9AD4") elif i == "材": List.append("9AD5") elif i == "宿": List.append("9AD6") elif i == "客": List.append("9AD7") elif i == "室": List.append("9AD8") elif i == "階": List.append("9AD9") elif i == "廊": List.append("9ADA") elif i == "下": List.append("9ADB") elif i == "変": List.append("9ADC") elif i == "第": List.append("9ADD") elif i == "章": List.append("9ADE") elif i == "代": List.append("9ADF") elif i == "更": List.append("9AE0") elif i == "広": List.append("9AE1") elif i == "場": List.append("9AE2") elif i == "旧": List.append("9AE3") elif i == "街": List.append("9AE4") elif i == "前": List.append("9AE5") elif i == "悪": List.append("9AE6") elif i == "夢": List.append("9AE7") elif i == "帰": List.append("9AE8") elif i == "王": List.append("9AE9") elif i == "開": List.append("9AEA") elif i == "放": List.append("9AEB") elif i == "土": List.append("9AEC") elif i == "新": List.append("9AED") elif i == "活": List.append("9AEE") elif i == "気": List.append("9AEF") elif i == "住": List.append("9AF0") elif i == "恩": List.append("9AF1") elif i == "最": List.append("9AF2") elif i == "近": List.append("9AF3") elif i == "国": List.append("9AF4") elif i == "団": List.append("9AF5") elif i == "進": List.append("9AF6") elif i == "出": List.append("9AF7") elif i == "信": List.append("9AF8") elif i == "助": List.append("9AF9") elif i == "話": List.append("9AFA") elif i == "顔": List.append("9AFB") elif i == "心": List.append("9AFC") elif i == "底": List.append("9AFD") elif i == "城": List.append("9AFE") elif i == "音": List.append("9AFF") elif i == "底": List.append("9B40") elif i == "城": List.append("9B41") elif i == "音": List.append("9B42") elif i == "聞": List.append("9B43") elif i == "急": List.append("9B44") elif i == "身": List.append("9B45") elif i == "賊": List.append("9B46") elif i == "込": List.append("9B47") elif i == "狙": List.append("9B48") elif i == "率": List.append("9B49") elif i == "精": List.append("9B4A") elif i == "鋭": List.append("9B4B") elif i == "保": List.append("9B4C") elif i == "証": List.append("9B4D") elif i == "襲": List.append("9B4E") elif i == "負": List.append("9B4F") elif i == "傷": List.append("9B50") elif i == "奪": List.append("9B51") elif i == "言": List.append("9B52") elif i == "英": List.append("9B53") elif i == "雄": List.append("9B54") elif i == "男": List.append("9B55") elif i == "見": List.append("9B56") elif i == "目": List.append("9B57") elif i == "朝": List.append("9B58") elif i == "早": List.append("9B59") elif i == "女": List.append("9B5A") elif i == "子": List.append("9B5B") elif i == "止": List.append("9B5C") elif i == "止": List.append("9B5D") elif i == "殿": List.append("9B5E") elif i == "向": List.append("9B5F") elif i == "雪": List.append("9B60") elif i == "書": List.append("9B61") elif i == "界": List.append("9B62") elif i == "中": List.append("9B63") elif i == "思": List.append("9B64") elif i == "泣": List.append("9B65") elif i == "馬": List.append("9B66") elif i == "足": List.append("9B67") elif i == "恋": List.append("9B68") elif i == "盗": List.append("9B69") elif i == "現": List.append("9B6A") elif i == "歌": List.append("9B6B") elif i == "隠": List.append("9B6C") elif i == "事": List.append("9B6D") elif i == "情": List.append("9B6E") elif i == "色": List.append("9B6F") elif i == "感": List.append("9B70") elif i == "動": List.append("9B71") elif i == "運": List.append("9B72") elif i == "命": List.append("9B73") elif i == "明": List.append("9B74") elif i == "寒": List.append("9B75") elif i == "暖": List.append("9B76") elif i == "房": List.append("9B77") elif i == "図": List.append("9B78") elif i == "館": List.append("9B79") elif i == "本": List.append("9B7A") elif i == "読": List.append("9B7B") elif i == "番": List.append("9B7C") elif i == "単": List.append("9B7D") elif i == "文": List.append("9B7E") elif i == "化": List.append("9B7F") elif i == "化": List.append("9B80") elif i == "民": List.append("9B81") elif i == "与": List.append("9B82") elif i == "建": List.append("9B83") elif i == "歴": List.append("9B84") elif i == "史": List.append("9B85") elif i == "的": List.append("9B86") elif i == "美": List.append("9B87") elif i == "私": List.append("9B88") elif i == "語": List.append("9B89") elif i == "禁": List.append("9B8A") elif i == "公": List.append("9B8B") elif i == "静": List.append("9B8C") elif i == "落": List.append("9B8D") elif i == "方": List.append("9B8E") elif i == "爆": List.append("9B8F") elif i == "発": List.append("9B90") elif i == "起": List.append("9B91") elif i == "直": List.append("9B92") elif i == "後": List.append("9B93") elif i == "戻": List.append("9B94") elif i == "好": List.append("9B95") elif i == "乱": List.append("9B96") elif i == "終": List.append("9B97") elif i == "平": List.append("9B98") elif i == "和": List.append("9B99") elif i == "若": List.append("9B9A") elif i == "旅": List.append("9B9B") elif i == "諸": List.append("9B9C") elif i == "温": List.append("9B9D") elif i == "育": List.append("9B9E") elif i == "机": List.append("9B9F") elif i == "学": List.append("9BA0") elif i == "葉": List.append("9BA1") elif i == "庶": List.append("9BA2") elif i == "政": List.append("9BA3") elif i == "治": List.append("9BA4") elif i == "必": List.append("9BA5") elif i == "要": List.append("9BA6") elif i == "我": List.append("9BA7") elif i == "視": List.append("9BA8") elif i == "察": List.append("9BA9") elif i == "笑": List.append("9BAA") elif i == "遠": List.append("9BAB") elif i == "存": List.append("9BAC") elif i == "在": List.append("9BAD") elif i == "危": List.append("9BAE") elif i == "険": List.append("9BAF") elif i == "彼": List.append("9BB0") elif i == "野": List.append("9BB1") elif i == "望": List.append("9BB2") elif i == "積": List.append("9BB3") elif i == "到": List.append("9BB4") elif i == "着": List.append("9BB5") elif i == "遅": List.append("9BB6") elif i == "誘": List.append("9BB7") elif i == "導": List.append("9BB8") elif i == "家": List.append("9BB9") elif i == "小": List.append("9BBA") elif i == "社": List.append("9BBB") elif i == "廃": List.append("9BBC") elif i == "坑": List.append("9BBD") elif i == "宝": List.append("9BBE") elif i == "部": List.append("9BBF") elif i == "悔": List.append("9BC0") elif i == "特": List.append("9BC1") elif i == "別": List.append("9BC2") elif i == "暗": List.append("9BC3") elif i == "号": List.append("9BC4") elif i == "者": List.append("9BC5") elif i == "繁": List.append("9BC6") elif i == "栄": List.append("9BC7") elif i == "願": List.append("9BC8") elif i == "記": List.append("9BC9") elif i == "貧": List.append("9BCA") elif i == "富": List.append("9BCB") elif i == "差": List.append("9BCC") elif i == "税": List.append("9BCD") elif i == "制": List.append("9BCE") elif i == "弱": List.append("9BCF") elif i == "救": List.append("9BD0") elif i == "済": List.append("9BD1") elif i == "予": List.append("9BD2") elif i == "算": List.append("9BD3") elif i == "確": List.append("9BD4") elif i == "安": List.append("9BD5") elif i == "守": List.append("9BD6") elif i == "警": List.append("9BD7") elif i == "組": List.append("9BD8") elif i == "織": List.append("9BD9") elif i == "支": List.append("9BDA") elif i == "援": List.append("9BDB") elif i == "意": List.append("9BDC") elif i == "識": List.append("9BDD") elif i == "改": List.append("9BDE") elif i == "革": List.append("9BDF") elif i == "愛": List.append("9BE0") elif i == "条": List.append("9BE1") elif i == "想": List.append("9BE2") elif i == "素": List.append("9BE3") elif i == "敵": List.append("9BE4") elif i == "当": List.append("9BE5") elif i == "考": List.append("9BE6") elif i == "誤": List.append("9BE7") elif i == "理": List.append("9BE8") elif i == "実": List.append("9BE9") elif i == "即": List.append("9BEA") elif i == "効": List.append("9BEB") elif i == "性": List.append("9BEC") elif i == "求": List.append("9BED") elif i == "劇": List.append("9BEE") elif i == "薬": List.append("9BEF") elif i == "選": List.append("9BF0") elif i == "約": List.append("9BF1") elif i == "束": List.append("9BF2") elif i == "届": List.append("9BF3") elif i == "型": List.append("9BF4") elif i == "引": List.append("9BF5") elif i == "力": List.append("9BF6") elif i == "作": List.append("9BF7") elif i == "内": List.append("9BF8") elif i == "設": List.append("9BF9") elif i == "備": List.append("9BFA") elif i == "数": List.append("9BFB") elif i == "枚": List.append("9BFC") elif i == "句": List.append("9C40") elif i == "仕": List.append("9C41") elif i == "幸": List.append("9C42") elif i == "奥": List.append("9C43") elif i == "採": List.append("9C44") elif i == "掘": List.append("9C45") elif i == "探": List.append("9C46") elif i == "掛": List.append("9C47") elif i == "未": List.append("9C48") elif i == "稼": List.append("9C49") elif i == "略": List.append("9C4A") elif i == "切": List.append("9C4B") elif i == "替": List.append("9C4C") elif i == "電": List.append("9C4D") elif i == "源": List.append("9C4E") elif i == "右": List.append("9C4F") elif i == "段": List.append("9C50") elif i == "突": List.append("9C51") elif i == "壁": List.append("9C52") elif i == "調": List.append("9C53") elif i == "港": List.append("9C54") elif i == "船": List.append("9C55") elif i == "定": List.append("9C56") elif i == "期": List.append("9C57") elif i == "長": List.append("9C58") elif i == "修": List.append("9C59") elif i == "菜": List.append("9C5A") elif i == "商": List.append("9C5B") elif i == "品": List.append("9C5C") elif i == "台": List.append("9C5D") elif i == "不": List.append("9C5F") elif i == "故": List.append("9C60") elif i == "側": List.append("9C61") elif i == "責": List.append("9C62") elif i == "任": List.append("9C63") elif i == "処": List.append("9C64") elif i == "欲": List.append("9C65") elif i == "海": List.append("9C66") elif i == "路": List.append("9C67") elif i == "他": List.append("9C68") elif i == "法": List.append("9C69") elif i == "退": List.append("9C6A") elif i == "屈": List.append("9C6B") elif i == "失": List.append("9C6C") elif i == "礼": List.append("9C6D") elif i == "腕": List.append("9C6E") elif i == "立": List.append("9C6F") elif i == "芸": List.append("9C70") elif i == "受": List.append("9C71") elif i == "参": List.append("9C72") elif i == "然": List.append("9C73") elif i == "勇": List.append("9C74") elif i == "折": List.append("9C75") elif i == "越": List.append("9C76") elif i == "印": List.append("9C77") elif i == "陸": List.append("9C78") elif i == "暮": List.append("9C79") elif i == "準": List.append("9C7A") elif i == "飛": List.append("9C7B") elif i == "振": List.append("9C7C") elif i == "応": List.append("9C7D") elif i == "使": List.append("9C7E") elif i == "僕": List.append("9C7F") elif i == "頼": List.append("9C80") elif i == "企": List.append("9C81") elif i == "業": List.append("9C82") elif i == "滅": List.append("9C83") elif i == "金": List.append("9C84") elif i == "庫": List.append("9C85") elif i == "収": List.append("9C86") elif i == "霧": List.append("9C87") elif i == "眠": List.append("9C88") elif i == "依": List.append("9C89") elif i == "申": List.append("9C8B") elif i == "遺": List.append("9C8C") elif i == "産": List.append("9C8D") elif i == "状": List.append("9C8E") elif i == "貴": List.append("9C8F") elif i == "様": List.append("9C90") elif i == "偶": List.append("9C91") elif i == "主": List.append("9C92") elif i == "取": List.append("9C93") elif i == "跡": List.append("9C94") elif i == "敷": List.append("9C95") elif i == "買": List.append("9C96") elif i == "途": List.append("9C97") elif i == "死": List.append("9C98") elif i == "被": List.append("9C99") elif i == "害": List.append("9C9A") elif i == "売": List.append("9C9B") elif i == "配": List.append("9C9C") elif i == "晴": List.append("9C9D") elif i == "装": List.append("9C9E") elif i == "飾": List.append("9C9F") elif i == "名": List.append("9CA0") elif i == "工": List.append("9CA1") elif i == "嬢": List.append("9CA2") elif i == "石": List.append("9CA3") elif i == "箱": List.append("9CA4") elif i == "渡": List.append("9CA5") elif i == "結": List.append("9CA6") elif i == "局": List.append("9CA7") elif i == "比": List.append("9CA8") elif i == "山": List.append("9CA9") elif i == "疲": List.append("9CAA") elif i == "端": List.append("9CAB") elif i == "位": List.append("9CAC") elif i == "置": List.append("9CAD") elif i == "町": List.append("9CAE") elif i == "俺": List.append("9CAF") elif i == "仮": List.append("9CB0") elif i == "面": List.append("9CB1") elif i == "臣": List.append("9CB2") elif i == "逃": List.append("9CB3") elif i == "秘": List.append("9CB4") elif i == "密": List.append("9CB5") elif i == "多": List.append("9CB6") elif i == "仲": List.append("9CB7") elif i == "経": List.append("9CB8") elif i == "追": List.append("9CB9") elif i == "相": List.append("9CBA") elif i == "返": List.append("9CBB") elif i == "父": List.append("9CBC") elif i == "少": List.append("9CBD") elif i == "関": List.append("9CBE") elif i == "係": List.append("9CBF") elif i == "形": List.append("9CC0") elif i == "歩": List.append("9CC1") elif i == "論": List.append("9CC2") elif i == "夜": List.append("9CC3") elif i == "休": List.append("9CC4") elif i == "指": List.append("9CC5") elif i == "覚": List.append("9CC6") elif i == "君": List.append("9CC7") elif i == "体": List.append("9CC8") elif i == "全": List.append("9CC9") elif i == "包": List.append("9CCA") elif i == "浮": List.append("9CCB") elif i == "無": List.append("9CCC") elif i == "郷": List.append("9CCD") elif i == "同": List.append("9CCE") elif i == "普": List.append("9CCF") elif i == "通": List.append("9CD0") elif i == "元": List.append("9CD1") elif i == "寝": List.append("9CD2") elif i == "付": List.append("9CD3") elif i == "絶": List.append("9CD4") elif i == "対": List.append("9CD5") elif i == "勝": List.append("9CD6") elif i == "利": List.append("9CD7") elif i == "詳": List.append("9CD8") elif i == "忘": List.append("9CD9") elif i == "兄": List.append("9CDA") elif i == "婚": List.append("9CDB") elif i == "田": List.append("9CDC") elif i == "舎": List.append("9CDD") elif i == "村": List.append("9CDE") elif i == "親": List.append("9CDF") elif i == "声": List.append("9CE0") elif i == "叫": List.append("9CE1") elif i == "打": List.append("9CE2") elif i == "兵": List.append("9CE3") elif i == "士": List.append("9CE4") elif i == "機": List.append("9CE5") elif i == "派": List.append("9CE6") elif i == "晩": List.append("9CE7") elif i == "泊": List.append("9CE8") elif i == "似": List.append("9CE9") elif i == "母": List.append("9CEA") elif i == "連": List.append("9CEB") elif i == "用": List.append("9CEC") elif i == "達": List.append("9CED") elif i == "息": List.append("9CEE") elif i == "尊": List.append("9CEF") elif i == "敬": List.append("9CF0") elif i == "遊": List.append("9CF1") elif i == "観": List.append("9CF2") elif i == "強": List.append("9CF3") elif i == "倉": List.append("9CF4") elif i == "怪": List.append("9CF5") elif i == "物": List.append("9CF6") elif i == "倒": List.append("9CF7") elif i == "沈": List.append("9CF8") elif i == "問": List.append("9CF9") elif i == "題": List.append("9CFA") elif i == "脱": List.append("9CFB") elif i == "員": List.append("9CFC") elif i == "程": List.append("9CFD") elif i == "犠": List.append("9CFE") elif i == "牲": List.append("9CFF") elif i == "割": List.append("9D43") elif i == "操": List.append("9D44") elif i == "舵": List.append("9D45") elif i == "激": List.append("9D46") elif i == "初": List.append("9D47") elif i == "航": List.append("9D48") elif i == "続": List.append("9D49") elif i == "補": List.append("9D4A") elif i == "寸": List.append("9D4B") elif i == "際": List.append("9D4C") elif i == "照": List.append("9D4D") elif i == "完": List.append("9D4E") elif i == "舞": List.append("9D4F") elif i == "等": List.append("9D50") elif i == "由": List.append("9D51") elif i == "難": List.append("9D52") elif i == "認": List.append("9D53") elif i == "得": List.append("9D54") elif i == "件": List.append("9D55") elif i == "審": List.append("9D56") elif i == "次": List.append("9D57") elif i == "幹": List.append("9D58") elif i == "崩": List.append("9D59") elif i == "壊": List.append("9D5A") elif i == "共": List.append("9D5B") elif i == "歳": List.append("9D5C") elif i == "原": List.append("9D5D") elif i == "因": List.append("9D5E") elif i == "真": List.append("9D60") elif i == "協": List.append("9D61") elif i == "説": List.append("9D62") elif i == "唯": List.append("9D63") elif i == "預": List.append("9D64") elif i == "没": List.append("9D65") elif i == "態": List.append("9D66") elif i == "談": List.append("9D67") elif i == "羽": List.append("9D68") elif i == "潮": List.append("9D69") elif i == "香": List.append("9D6A") elif i == "議": List.append("9D6B") elif i == "軽": List.append("9D6C") elif i == "伝": List.append("9D6D") elif i == "絡": List.append("9D6E") elif i == "張": List.append("9D6F") elif i == "増": List.append("9D70") elif i == "損": List.append("9D71") elif i == "呼": List.append("9D72") elif i == "油": List.append("9D73") elif i == "断": List.append("9D74") elif i == "穴": List.append("9D75") elif i == "鼻": List.append("9D76") elif i == "興": List.append("9D77") elif i == "味": List.append("9D78") elif i == "便": List.append("9D79") elif i == "拝": List.append("9D7A") elif i == "堂": List.append("9D7B") elif i == "線": List.append("9D7C") elif i == "簡": List.append("9D7D") elif i == "供": List.append("9D7E") elif i == "騎": List.append("9D80") elif i == "属": List.append("9D81") elif i == "敗": List.append("9D82") elif i == "走": List.append("9D83") elif i == "集": List.append("9D84") elif i == "背": List.append("9D85") elif i == "景": List.append("9D86") elif i == "果": List.append("9D87") elif i == "停": List.append("9D88") elif i == "煮": List.append("9D89") elif i == "炒": List.append("9D8A") elif i == "米": List.append("9D8B") elif i == "緒": List.append("9D8C") elif i == "役": List.append("9D8D") elif i == "熱": List.append("9D8E") elif i == "鮮": List.append("9D8F") elif i == "料": List.append("9D90") elif i == "揚": List.append("9D91") elif i == "口": List.append("9D92") elif i == "卵": List.append("9D93") elif i == "焼": List.append("9D94") elif i == "抜": List.append("9D95") elif i == "肉": List.append("9D96") elif i == "統": List.append("9D97") elif i == "加": List.append("9D98") elif i == "減": List.append("9D99") elif i == "賞": List.append("9D9A") elif i == "太": List.append("9D9B") elif i == "刺": List.append("9D9C") elif i == "烈": List.append("9D9D") elif i == "夏": List.append("9D9E") elif i == "浴": List.append("9D9F") elif i == "波": List.append("9DA0") elif i == "漂": List.append("9DA1") elif i == "幻": List.append("9DA2") elif i == "酔": List.append("9DA3") elif i == "瞬": List.append("9DA4") elif i == "魚": List.append("9DA5") elif i == "重": List.append("9DA6") elif i == "深": List.append("9DA7") elif i == "冷": List.append("9DA8") elif i == "宇": List.append("9DA9") elif i == "宙": List.append("9DAA") elif i == "星": List.append("9DAB") elif i == "輝": List.append("9DAC") elif i == "豪": List.append("9DAD") elif i == "快": List.append("9DAE") elif i == "麻": List.append("9DAF") elif i == "婆": List.append("9DB0") elif i == "豆": List.append("9DB1") elif i == "腐": List.append("9DB2") elif i == "辛": List.append("9DB3") elif i == "妙": List.append("9DB4") elif i == "極": List.append("9DB5") elif i == "違": List.append("9DB6") elif i == "異": List.append("9DB7") elif i == "魔": List.append("9DB8") elif i == "養": List.append("9DB9") elif i == "豊": List.append("9DBA") elif i == "盛": List.append("9DBB") elif i == "絵": List.append("9DBC") elif i == "画": List.append("9DBD") elif i == "描": List.append("9DBE") elif i == "構": List.append("9DBF") elif i == "甘": List.append("9DC0") elif i == "巻": List.append("9DC1") elif i == "染": List.append("9DC2") elif i == "高": List.append("9DC3") elif i == "互": List.append("9DC4") elif i == "称": List.append("9DC5") elif i == "誰": List.append("9DC6") elif i == "幼": List.append("9DC7") elif i == "頃": List.append("9DC8") elif i == "演": List.append("9DC9") elif i == "汁": List.append("9DCA") elif i == "介": List.append("9DCB") elif i == "類": List.append("9DCC") elif i == "腹": List.append("9DCD") elif i == "式": List.append("9DCE") elif i == "吸": List.append("9DCF") elif i == "酸": List.append("9DD0") elif i == "清": List.append("9DD1") elif i == "奇": List.append("9DD2") elif i == "贈": List.append("9DD3") elif i == "飲": List.append("9DD4") elif i == "熟": List.append("9DD5") elif i == "須": List.append("9DD6") elif i == "交": List.append("9DD7") elif i == "響": List.append("9DD8") elif i == "曲": List.append("9DD9") elif i == "奏": List.append("9DDA") elif i == "速": List.append("9DDB") elif i == "半": List.append("9DDC") elif i == "拡": List.append("9DDD") elif i == "縮": List.append("9DDE") elif i == "了": List.append("9DDF") elif i == "径": List.append("9DE0") elif i == "冒": List.append("9DE1") elif i == "賛": List.append("9DE2") elif i == "離": List.append("9DE3") elif i == "迷": List.append("9DE4") elif i == "惑": List.append("9DE5") elif i == "孤": List.append("9DE6") elif i == "児": List.append("9DE7") elif i == "院": List.append("9DE8") elif i == "孝": List.append("9DE9") elif i == "逆": List.append("9DEA") elif i == "転": List.append("9DEB") elif i == "塔": List.append("9DEC") elif i == "報": List.append("9DED") elif i == "査": List.append("9DEE") elif i == "隊": List.append("9DEF") elif i == "護": List.append("9DF0") elif i == "衛": List.append("9DF1") elif i == "価": List.append("9DF2") elif i == "値": List.append("9DF3") elif i == "紙": List.append("9DF4") elif i == "苦": List.append("9DF5") elif i == "慣": List.append("9DF6") elif i == "血": List.append("9DF7") elif i == "流": List.append("9DF8") elif i == "労": List.append("9DF9") elif i == "惜": List.append("9DFA") elif i == "捨": List.append("9DFB") elif i == "質": List.append("9DFC") elif i == "胸": List.append("9DFD") elif i == "整": List.append("9E41") elif i == "店": List.append("9E42") elif i == "踏": List.append("9E43") elif i == "巨": List.append("9E44") elif i == "破": List.append("9E45") elif i == "衣": List.append("9E46") elif i == "犯": List.append("9E47") elif i == "捕": List.append("9E48") elif i == "牢": List.append("9E49") elif i == "始": List.append("9E4A") elif i == "嫌": List.append("9E4B") elif i == "過": List.append("9E4C") elif i == "去": List.append("9E4D") elif i == "功": List.append("9E4E") elif i == "績": List.append("9E4F") elif i == "両": List.append("9E50") elif i == "貸": List.append("9E51") elif i == "耳": List.append("9E52") elif i == "趣": List.append("9E53") elif i == "剣": List.append("9E54") elif i == "幕": List.append("9E55") elif i == "誓": List.append("9E56") elif i == "歯": List.append("9E57") elif i == "眼": List.append("9E58") elif i == "悟": List.append("9E59") elif i == "吹": List.append("9E5A") elif i == "昨": List.append("9E5B") elif i == "玉": List.append("9E5C") elif i == "送": List.append("9E5E") elif i == "字": List.append("9E5F") elif i == "暴": List.append("9E60") elif i == "里": List.append("9E61") elif i == "恐": List.append("9E62") elif i == "謝": List.append("9E63") elif i == "聖": List.append("9E64") elif i == "総": List.append("9E65") elif i == "適": List.append("9E66") elif i == "順": List.append("9E67") elif i == "納": List.append("9E68") elif i == "捧": List.append("9E69") elif i == "偉": List.append("9E6A") elif i == "祝": List.append("9E6B") elif i == "福": List.append("9E6C") elif i == "痛": List.append("9E6D") elif i == "友": List.append("9E6E") elif i == "髪": List.append("9E6F") elif i == "短": List.append("9E70") elif i == "残": List.append("9E71") elif i == "念": List.append("9E72") elif i == "抱": List.append("9E73") elif i == "悩": List.append("9E74") elif i == "砕": List.append("9E75") elif i == "威": List.append("9E76") elif i == "勢": List.append("9E77") elif i == "僧": List.append("9E78") elif i == "正": List.append("9E79") elif i == "解": List.append("9E7A") elif i == "虫": List.append("9E7B") elif i == "仇": List.append("9E7C") elif i == "討": List.append("9E7D") elif i == "払": List.append("9E7E") elif i == "黙": List.append("9E80") elif i == "示": List.append("9E81") elif i == "従": List.append("9E82") elif i == "忙": List.append("9E83") elif i == "謁": List.append("9E84") elif i == "週": List.append("9E85") elif i == "毒": List.append("9E86") elif i == "頭": List.append("9E87") elif i == "驚": List.append("9E88") elif i == "有": List.append("9E89") elif i == "荒": List.append("9E8A") elif i == "復": List.append("9E8B") elif i == "境": List.append("9E8C") elif i == "遇": List.append("9E8D") elif i == "健": List.append("9E8E") elif i == "康": List.append("9E8F") elif i == "病": List.append("9E90") elif i == "影": List.append("9E91") elif i == "硬": List.append("9E92") elif i == "慮": List.append("9E93") elif i == "雲": List.append("9E94") elif i == "訳": List.append("9E95") elif i == "許": List.append("9E96") elif i == "換": List.append("9E97") elif i == "拒": List.append("9E98") elif i == "災": List.append("9E99") elif i == "拠": List.append("9E9A") elif i == "肩": List.append("9E9B") elif i == "可": List.append("9E9C") elif i == "能": List.append("9E9D") elif i == "偽": List.append("9E9E") elif i == "善": List.append("9E9F") elif i == "鳥": List.append("9EA0") elif i == "巣": List.append("9EA1") elif i == "憧": List.append("9EA2") elif i == "資": List.append("9EA3") elif i == "誇": List.append("9EA4") elif i == "管": List.append("9EA5") elif i == "量": List.append("9EA6") elif i == "縁": List.append("9EA7") elif i == "愚": List.append("9EA8") elif i == "邪": List.append("9EA9") elif i == "容": List.append("9EAA") elif i == "赦": List.append("9EAB") elif i == "像": List.append("9EAC") elif i == "仰": List.append("9EAD") elif i == "困": List.append("9EAE") elif i == "択": List.append("9EAF") elif i == "夕": List.append("9EB0") elif i == "扱": List.append("9EB1") elif i == "啓": List.append("9EB2") elif i == "汚": List.append("9EB3") elif i == "罰": List.append("9EB4") elif i == "胆": List.append("9EB5") elif i == "猫": List.append("9EB6") elif i == "棒": List.append("9EB7") elif i == "細": List.append("9EB8") elif i == "点": List.append("9EB9") elif i == "製": List.append("9EBA") elif i == "矢": List.append("9EBB") elif i == "居": List.append("9EBC") elif i == "肝": List.append("9EBD") elif i == "答": List.append("9EBE") elif i == "義": List.append("9EBF") elif i == "務": List.append("9EC0") elif i == "留": List.append("9EC1") elif i == "障": List.append("9EC2") elif i == "訓": List.append("9EC3") elif i == "弟": List.append("9EC4") elif i == "妹": List.append("9EC5") elif i == "首": List.append("9EC6") elif i == "迎": List.append("9EC7") elif i == "姉": List.append("9EC8") elif i == "姿": List.append("9EC9") elif i == "将": List.append("9ECA") elif i == "散": List.append("9ECB") elif i == "練": List.append("9ECC") elif i == "猟": List.append("9ECD") elif i == "働": List.append("9ECE") elif i == "例": List.append("9ECF") elif i == "志": List.append("9ED0") elif i == "判": List.append("9ED1") elif i == "冗": List.append("9ED2") elif i == "官": List.append("9ED3") elif i == "臨": List.append("9ED4") elif i == "刻": List.append("9ED5") elif i == "潜": List.append("9ED6") elif i == "服": List.append("9ED7") elif i == "余": List.append("9ED8") elif i == "計": List.append("9ED9") elif i == "争": List.append("9EDA") elif i == "悲": List.append("9EDB") elif i == "閉": List.append("9EDC") elif i == "永": List.append("9EDD") elif i == "耐": List.append("9EDE") elif i == "移": List.append("9EDF") elif i == "候": List.append("9EE0") elif i == "習": List.append("9EE1") elif i == "罪": List.append("9EE2") elif i == "独": List.append("9EE3") elif i == "昼": List.append("9EE4") elif i == "反": List.append("9EE5") elif i == "氷": List.append("9EE6") elif i == "妻": List.append("9EE7") elif i == "注": List.append("9EE8") elif i == "表": List.append("9EE9") elif i == "究": List.append("9EEA") elif i == "徳": List.append("9EEB") elif i == "刃": List.append("9EEC") elif i == "倍": List.append("9EED") elif i == "洗": List.append("9EEE") elif i == "缶": List.append("9EEF") elif i == "押": List.append("9EF0") elif i == "登": List.append("9EF1") elif i == "提": List.append("9EF2") elif i == "常": List.append("9EF3") elif i == "刀": List.append("9EF4") elif i == "怒": List.append("9EF5") elif i == "才": List.append("9EF6") elif i == "木": List.append("9EF7") elif i == "彫": List.append("9EF8") elif i == "夫": List.append("9EF9") elif i == "婦": List.append("9EFA") elif i == "花": List.append("9EFB") elif i == "鳴": List.append("9EFC") elif i == "祭": List.append("9EFD") elif i == "騒": List.append("9EFE") elif i == "況": List.append("9F42") elif i == "嫉": List.append("9F43") elif i == "妬": List.append("9F44") elif i == "借": List.append("9F45") elif i == "寄": List.append("9F46") elif i == "茶": List.append("9F47") elif i == "酒": List.append("9F48") elif i == "燃": List.append("9F49") elif i == "投": List.append("9F4A") elif i == "希": List.append("9F4B") elif i == "費": List.append("9F4C") elif i == "並": List.append("9F4D") elif i == "喜": List.append("9F4E") elif i == "辺": List.append("9F4F") elif i == "仔": List.append("9F50") elif i == "徴": List.append("9F51") elif i == "坊": List.append("9F52") elif i == "飼": List.append("9F53") elif i == "肖": List.append("9F54") elif i == "博": List.append("9F55") elif i == "天": List.append("9F56") elif i == "軍": List.append("9F57") elif i == "祖": List.append("9F58") elif i == "棚": List.append("9F59") elif i == "講": List.append("9F5B") elif i == "呪": List.append("9F5C") elif i == "医": List.append("9F5D") elif i == "勉": List.append("9F5E") elif i == "布": List.append("9F5F") elif i == "訪": List.append("9F60") elif i == "混": List.append("9F61") elif i == "侵": List.append("9F62") elif i == "疑": List.append("9F63") elif i == "儀": List.append("9F64") elif i == "努": List.append("9F65") elif i == "益": List.append("9F66") elif i == "門": List.append("9F67") elif i == "試": List.append("9F68") elif i == "厳": List.append("9F69") elif i == "裏": List.append("9F6A") elif i == "腰": List.append("9F6B") elif i == "帥": List.append("9F6C") elif i == "封": List.append("9F6D") elif i == "柱": List.append("9F6E") elif i == "繋": List.append("9F6F") elif i == "丘": List.append("9F70") elif i == "畑": List.append("9F71") elif i == "忍": List.append("9F72") elif i == "厄": List.append("9F73") elif i == "嫁": List.append("9F74") elif i == "展": List.append("9F75") elif i == "汗": List.append("9F76") elif i == "車": List.append("9F77") elif i == "接": List.append("9F78") elif i == "絹": List.append("9F79") elif i == "肌": List.append("9F7A") elif i == "魂": List.append("9F7B") elif i == "票": List.append("9F7C") elif i == "橋": List.append("9F7D") elif i == "娘": List.append("9F7E") elif i == "根": List.append("9F80") elif i == "怖": List.append("9F81") elif i == "幅": List.append("9F82") elif i == "衝": List.append("9F83") elif i == "射": List.append("9F84") elif i == "罠": List.append("9F85") elif i == "床": List.append("9F86") elif i == "丈": List.append("9F87") elif i == "区": List.append("9F88") elif i == "随": List.append("9F89") elif i == "枝": List.append("9F8A") elif i == "古": List.append("9F8B") elif i == "頂": List.append("9F8C") elif i == "横": List.append("9F8D") elif i == "拾": List.append("9F8E") elif i == "良": List.append("9F8F") elif i == "穫": List.append("9F90") elif i == "承": List.append("9F91") elif i == "森": List.append("9F92") elif i == "雑": List.append("9F93") elif i == "貨": List.append("9F94") elif i == "族": List.append("9F95") elif i == "省": List.append("9F96") elif i == "掃": List.append("9F97") elif i == "除": List.append("9F98") elif i == "粧": List.append("9F99") elif i == "恥": List.append("9F9A") elif i == "濯": List.append("9F9B") elif i == "帯": List.append("9F9C") elif i == "策": List.append("9F9D") elif i == "裕": List.append("9F9E") elif i == "施": List.append("9F9F") elif i == "営": List.append("9FA0") elif i == "優": List.append("9FA1") elif i == "骨": List.append("9FA2") elif i == "埋": List.append("9FA3") elif i == "躍": List.append("9FA4") elif i == "冬": List.append("9FA5") elif i == "遙": List.append("9FA6") elif i == "圧": List.append("9FA7") elif i == "迫": List.append("9FA8") elif i == "獄": List.append("9FA9") elif i == "再": List.append("9FAA") elif i == "亡": List.append("9FAB") elif i == "雨": List.append("9FAC") elif i == "枯": List.append("9FAD") elif i == "噴": List.append("9FAE") elif i == "久": List.append("9FAF") elif i == "衰": List.append("9FB0") elif i == "鈍": List.append("9FB1") elif i == "凍": List.append("9FB2") elif i == "昇": List.append("9FB3") elif i == "低": List.append("9FB4") elif i == "砂": List.append("9FB5") elif i == "含": List.append("9FB6") elif i == "晶": List.append("9FB7") elif i == "溜": List.append("9FB8") elif i == "珠": List.append("9FB9") elif i == "黄": List.append("9FBA") elif i == "霊": List.append("9FBB") elif i == "召": List.append("9FBC") elif i == "喚": List.append("9FBD") elif i == "蒼": List.append("9FBE") elif i == "紅": List.append("9FBF") elif i == "翠": List.append("9FC0") elif i == "草": List.append("9FC1") elif i == "種": List.append("9FC2") elif i == "瓶": List.append("9FC3") elif i == "鱗": List.append("9FC4") elif i == "珍": List.append("9FC5") elif i == "獣": List.append("9FC6") elif i == "蓋": List.append("9FC7") elif i == "鑑": List.append("9FC8") elif i == "欠": List.append("9FC9") elif i == "各": List.append("9FCA") elif i == "煙": List.append("9FCB") elif i == "筒": List.append("9FCC") elif i == "造": List.append("9FCD") elif i == "炭": List.append("9FCE") elif i == "炉": List.append("9FCF") elif i == "槽": List.append("9FD0") elif i == "苗": List.append("9FD1") elif i == "植": List.append("9FD2") elif i == "周": List.append("9FD3") elif i == "囲": List.append("9FD4") elif i == "鍵": List.append("9FD5") elif i == "級": List.append("9FD6") elif i == "干": List.append("9FD7") elif i == "匂": List.append("9FD8") elif i == "涙": List.append("9FD9") elif i == "球": List.append("9FDA") elif i == "漬": List.append("9FDB") elif i == "瓜": List.append("9FDC") elif i == "臭": List.append("9FDD") elif i == "毛": List.append("9FDE") elif i == "芳": List.append("9FDF") elif i == "皮": List.append("9FE0") elif i == "丸": List.append("9FE1") elif i == "牛": List.append("9FE2") elif i == "乳": List.append("9FE3") elif i == "酵": List.append("9FE4") elif i == "胃": List.append("9FE5") elif i == "腸": List.append("9FE6") elif i == "炊": List.append("9FE7") elif i == "穀": List.append("9FE8") elif i == "農": List.append("9FE9") elif i == "八": List.append("9FEA") elif i == "孫": List.append("9FEB") elif i == "柔": List.append("9FEC") elif i == "麦": List.append("9FED") elif i == "粉": List.append("9FEE") elif i == "般": List.append("9FEF") elif i == "脂": List.append("9FF0") elif i == "肪": List.append("9FF1") elif i == "塊": List.append("9FF2") elif i == "塗": List.append("9FF3") elif i == "雅": List.append("9FF4") elif i == "斬": List.append("9FF5") elif i == "基": List.append("9FF6") elif i == "偃": List.append("9FF7") elif i == "厚": List.append("9FF8") elif i == "雰": List.append("9FF9") elif i == "典": List.append("9FFA") elif i == "湾": List.append("9FFB") elif i == "鎌": List.append("9FFC") elif i == "殺": List.append("E040") elif i == "尾": List.append("E041") elif i == "冠": List.append("E042") elif i == "匠": List.append("E043") elif i == "鍛": List.append("E044") elif i == "旋": List.append("E045") elif i == "誉": List.append("E046") elif i == "炎": List.append("E047") elif i == "竜": List.append("E048") elif i == "爪": List.append("E049") elif i == "隼": List.append("E04A") elif i == "紋": List.append("E04B") elif i == "創": List.append("E04C") elif i == "牙": List.append("E04D") elif i == "岩": List.append("E04E") elif i == "剛": List.append("E04F") elif i == "柩": List.append("E050") elif i == "副": List.append("E051") elif i == "葬": List.append("E052") elif i == "鋼": List.append("E053") elif i == "易": List.append("E054") elif i == "裂": List.append("E055") elif i == "妖": List.append("E056") elif i == "稲": List.append("E057") elif i == "慈": List.append("E058") elif i == "忠": List.append("E059") elif i == "円": List.append("E05A") elif i == "卓": List.append("E05B") elif i == "帝": List.append("E05C") elif i == "嵐": List.append("E05E") elif i == "乙": List.append("E05F") elif i == "杖": List.append("E060") elif i == "職": List.append("E061") elif i == "殴": List.append("E062") elif i == "権": List.append("E063") elif i == "標": List.append("E064") elif i == "笏": List.append("E065") elif i == "狂": List.append("E066") elif i == "節": List.append("E067") elif i == "孔": List.append("E068") elif i == "雀": List.append("E069") elif i == "如": List.append("E06A") elif i == "角": List.append("E06B") elif i == "青": List.append("E06C") elif i == "紡": List.append("E06D") elif i == "慟": List.append("E06E") elif i == "哭": List.append("E06F") elif i == "銀": List.append("E070") elif i == "左": List.append("E071") elif i == "東": List.append("E072") elif i == "蛮": List.append("E073") elif i == "錫": List.append("E074") elif i == "匹": List.append("E075") elif i == "蛇": List.append("E076") elif i == "祓": List.append("E077") elif i == "詠": List.append("E078") elif i == "唱": List.append("E079") elif i == "柄": List.append("E07A") elif i == "斧": List.append("E07B") elif i == "槍": List.append("E07C") elif i == "槌": List.append("E07D") elif i == "叉": List.append("E07E") elif i == "矛": List.append("E080") elif i == "鉄": List.append("E081") elif i == "陣": List.append("E082") elif i == "賜": List.append("E083") elif i == "堅": List.append("E084") elif i == "固": List.append("E085") elif i == "杭": List.append("E086") elif i == "灰": List.append("E087") elif i == "冶": List.append("E088") elif i == "科": List.append("E089") elif i == "駆": List.append("E08A") elif i == "逐": List.append("E08B") elif i == "逸": List.append("E08C") elif i == "骸": List.append("E08D") elif i == "緑": List.append("E08E") elif i == "薙": List.append("E08F") elif i == "傑": List.append("E090") elif i == "狩": List.append("E091") elif i == "弓": List.append("E092") elif i == "弾": List.append("E093") elif i == "扉": List.append("E094") elif i == "貫": List.append("E095") elif i == "鎧": List.append("E096") elif i == "七": List.append("E097") elif i == "軌": List.append("E098") elif i == "吐": List.append("E099") elif i == "尽": List.append("E09A") elif i == "浄": List.append("E09B") elif i == "環": List.append("E09C") elif i == "縫": List.append("E09D") elif i == "板": List.append("E09E") elif i == "糸": List.append("E09F") elif i == "甲": List.append("E0A0") elif i == "殊": List.append("E0A1") elif i == "継": List.append("E0A2") elif i == "塞": List.append("E0A3") elif i == "赴": List.append("E0A4") elif i == "網": List.append("E0A5") elif i == "編": List.append("E0A6") elif i == "洋": List.append("E0A7") elif i == "島": List.append("E0A8") elif i == "巫": List.append("E0A9") elif i == "兜": List.append("E0AA") elif i == "頬": List.append("E0AB") elif i == "築": List.append("E0AC") elif i == "頑": List.append("E0AD") elif i == "漢": List.append("E0AE") elif i == "帽": List.append("E0AF") elif i == "薄": List.append("E0B0") elif i == "濃": List.append("E0B1") elif i == "愉": List.append("E0B2") elif i == "輪": List.append("E0B3") elif i == "及": List.append("E0B4") elif i == "喰": List.append("E0B5") elif i == "鮫": List.append("E0B6") elif i == "致": List.append("E0B7") elif i == "鉈": List.append("E0B8") elif i == "駄": List.append("E0B9") elif i == "篭": List.append("E0BA") elif i == "授": List.append("E0BB") elif i == "袋": List.append("E0BC") elif i == "瑠": List.append("E0BD") elif i == "璃": List.append("E0BE") elif i == "佐": List.append("E0BF") elif i == "賢": List.append("E0C0") elif i == "癒": List.append("E0C1") elif i == "偏": List.append("E0C2") elif i == "疾": List.append("E0C3") elif i == "巧": List.append("E0C4") elif i == "伴": List.append("E0C5") elif i == "徐": List.append("E0C6") elif i == "縞": List.append("E0C7") elif i == "瑪": List.append("E0C8") elif i == "瑙": List.append("E0C9") elif i == "験": List.append("E0CA") elif i == "華": List.append("E0CB") elif i == "姫": List.append("E0CC") elif i == "象": List.append("E0CD") elif i == "靴": List.append("E0CE") elif i == "膝": List.append("E0CF") elif i == "蹴": List.append("E0D0") elif i == "枠": List.append("E0D1") elif i == "謎": List.append("E0D2") elif i == "隣": List.append("E0D3") elif i == "徒": List.append("E0D4") elif i == "携": List.append("E0D5") elif i == "塵": List.append("E0D6") elif i == "繰": List.append("E0D7") elif i == "翔": List.append("E0D8") elif i == "閃": List.append("E0D9") elif i == "渦": List.append("E0DA") elif i == "纏": List.append("E0DB") elif i == "垂": List.append("E0DC") elif i == "屠": List.append("E0DD") elif i == "龍": List.append("E0DE") elif i == "叩": List.append("E0DF") elif i == "片": List.append("E0E0") elif i == "跳": List.append("E0E1") elif i == "招": List.append("E0E2") elif i == "規": List.append("E0E3") elif i == "模": List.append("E0E4") elif i == "雷": List.append("E0E5") elif i == "鐘": List.append("E0E6") elif i == "震": List.append("E0E7") elif i == "撼": List.append("E0E8") elif i == "範": List.append("E0E9") elif i == "複": List.append("E0EA") elif i == "弧": List.append("E0EB") elif i == "距": List.append("E0EC") elif i == "鉱": List.append("E0ED") elif i == "棺": List.append("E0EE") elif i == "焉": List.append("E0EF") elif i == "裁": List.append("E0F0") elif i == "漆": List.append("E0F1") elif i == "淵": List.append("E0F2") elif i == "系": List.append("E0F3") elif i == "列": List.append("E0F4") elif i == "限": List.append("E0F5") elif i == "控": List.append("E0F6") elif i == "満": List.append("E0F7") elif i == "隔": List.append("E0F8") elif i == "嘘": List.append("E0F9") elif i == "漏": List.append("E0FA") elif i == "披": List.append("E0FB") elif i == "露": List.append("E0FC") elif i == "令": List.append("E140") elif i == "抵": List.append("E141") elif i == "抗": List.append("E142") elif i == "痺": List.append("E143") elif i == "僅": List.append("E144") elif i == "延": List.append("E145") elif i == "秒": List.append("E146") elif i == "縛": List.append("E147") elif i == "遭": List.append("E148") elif i == "促": List.append("E149") elif i == "械": List.append("E14A") elif i == "瀕": List.append("E14B") elif i == "微": List.append("E14C") elif i == "熊": List.append("E14D") elif i == "洞": List.append("E14E") elif i == "窟": List.append("E14F") elif i == "消": List.append("E150") elif i == "三": List.append("E151") elif i == "々": List.append("E152") elif i == "★": List.append("E153") elif i == "z": List.append("E154") elif i == "…": List.append("E155") elif i == "壺": List.append("E156") elif i == "鎚": List.append("E157") elif i == "亜": List.append("E158") elif i == "翼": List.append("E159") elif i == "殻": List.append("E15A") elif i == "棲": List.append("E15B") elif i == "爬": List.append("E15C") elif i == "閲": List.append("E15D") elif i == "覧": List.append("E15E") elif i == "個": List.append("E15F") elif i == "削": List.append("E161") elif i == "辞": List.append("E162") elif i == "揺": List.append("E163") elif i == "魅": List.append("E164") elif i == "哀": List.append("E165") elif i == "検": List.append("E166") elif i == "還": List.append("E167") elif i == "艇": List.append("E168") elif i == "獲": List.append("E169") elif i == "憎": List.append("E16A") elif i == "恵": List.append("E16B") elif i == "稽": List.append("E16C") elif i == "磨": List.append("E16D") elif i == "銘": List.append("E16E") elif i == "侍": List.append("E16F") elif i == "緊": List.append("E170") elif i == "壺": List.append("E171") elif i == "鎚": List.append("E172") elif i == "亜": List.append("E173") elif i == "翼": List.append("E174") elif i == "殻": List.append("E175") elif i == "棲": List.append("E176") elif i == "爬": List.append("E177") elif i == "閲": List.append("E178") elif i == "覧": List.append("E179") elif i == "個": List.append("E17A") elif i == "削": List.append("E17B") elif i == "瞳": List.append("E17C") elif i == "墜": List.append("E17D") elif i == "燐": List.append("E17E") elif i == "砲": List.append("E17F") elif i == "双": List.append("E181") elif i == "拳": List.append("E182") elif i == "覆": List.append("E183") elif i == "推": List.append("E184") elif i == "測": List.append("E185") elif i == "貼": List.append("E186") elif i == "触": List.append("E187") elif i == "憶": List.append("E188") elif i == "讃": List.append("E189") elif i == "非": List.append("E18A") elif i == "握": List.append("E18B") elif i == "映": List.append("E18C") elif i == "写": List.append("E18D") elif i == "渉": List.append("E18E") elif i == "軸": List.append("E18F") elif i == "述": List.append("E190") elif i == "粋": List.append("E191") elif i == "妨": List.append("E192") elif i == "吉": List.append("E193") elif i == "鍋": List.append("E194") elif i == "銅": List.append("E195") elif i == "柳": List.append("E196") elif i == "丁": List.append("E197") elif i == "凶": List.append("E198") elif i == "陽": List.append("E199") elif i == "河": List.append("E19A") elif i == "脈": List.append("E19B") elif i == "超": List.append("E19C") elif i == "領": List.append("E19D") elif i == "域": List.append("E19E") elif i == "飯": List.append("E19F") elif i == "寿": List.append("E1A0") elif i == "餓": List.append("E1A1") elif i == "司": List.append("E1A2") elif i == "荷": List.append("E1A3") elif i == "担": List.append("E1A4") elif i == "臓": List.append("E1A5") elif i == "ヶ": List.append("E1A6") elif i == "告": List.append("E1A7") elif i == "析": List.append("E1A8") elif i == "透": List.append("E1A9") elif i == "筋": List.append("E1AA") elif i == "励": List.append("E1AB") elif i == "看": List.append("E1AC") elif i == "皿": List.append("E1AD") elif i == "誌": List.append("E1AE") elif i == "碑": List.append("E1AF") elif i == "焚": List.append("E1B0") elif i == "萌": List.append("E1B1") elif i == "吼": List.append("E1B2") elif i == "齢": List.append("E1B3") elif i == "陛": List.append("E1B4") elif i == "姑": List.append("E1B5") elif i == "歓": List.append("E1B6") elif i == "挨": List.append("E1B7") elif i == "拶": List.append("E1B8") elif i == "繊": List.append("E1B9") elif i == "粛": List.append("E1BA") elif i == "専": List.append("E1BB") elif i == "己": List.append("E1BC") elif i == "紹": List.append("E1BD") elif i == "粗": List.append("E1BE") elif i == "往": List.append("E1BF") elif i == "郎": List.append("E1C0") elif i == "懸": List.append("E1C1") elif i == "逢": List.append("E1C2") elif i == "瀬": List.append("E1C3") elif i == "杯": List.append("E1C4") elif i == "岸": List.append("E1C5") elif i == "泳": List.append("E1C6") elif i == "詰": List.append("E1C7") elif i == "耗": List.append("E1C8") elif i == "酬": List.append("E1C9") elif i == "噛": List.append("E1CA") elif i == "虚": List.append("E1CB") elif i == "蓮": List.append("E1CC") elif i == "踊": List.append("E1CD") elif i == "拓": List.append("E1CE") elif i == "崇": List.append("E1CF") elif i == "伸": List.append("E1D0") elif i == "芝": List.append("E1D1") elif i == "脚": List.append("E1D2") elif i == "四": List.append("E1D3") elif i == "墓": List.append("E1D4") elif i == "駒": List.append("E1D5") elif i == "卑": List.append("E1D6") elif i == "劣": List.append("E1D7") elif i == "末": List.append("E1D8") elif i == "克": List.append("E1D9") elif i == "否": List.append("E1DA") elif i == "旗": List.append("E1DB") elif i == "秩": List.append("E1DC") elif i == "序": List.append("E1DD") elif i == "絆": List.append("E1DE") elif i == "酷": List.append("E1DF") elif i == "層": List.append("E1E0") elif i == "研": List.append("E1E1") elif i == "媒": List.append("E1E2") elif i == "閣": List.append("E1E3") elif i == "巡": List.append("E1E4") elif i == "駐": List.append("E1E5") elif i == "屯": List.append("E1E6") elif i == "挑": List.append("E1E7") elif i == "慎": List.append("E1E8") elif i == "臆": List.append("E1E9") elif i == "怯": List.append("E1EA") elif i == "揮": List.append("E1EB") elif i == "謹": List.append("E1EC") elif i == "誕": List.append("E1ED") elif i == "班": List.append("E1EE") elif i == "攪": List.append("E1EF") elif i == "戒": List.append("E1F0") elif i == "老": List.append("E1F1") elif i == "排": List.append("E1F2") elif i == "伏": List.append("E1F3") elif i == "刑": List.append("E1F4") elif i == "乾": List.append("E1F5") elif i == "陥": List.append("E1F6") elif i == "乞": List.append("E1F7") elif i == "至": List.append("E1F8") elif i == "聴": List.append("E1F9") elif i == "符": List.append("E1FA") elif i == "宣": List.append("E1FB") elif i == "脳": List.append("E1FC") elif i == "凌": List.append("E1FD") elif i == "駕": List.append("E241") elif i == "歪": List.append("E242") elif i == "m": List.append("E243") elif i == "k": List.append("E244") elif i == "g": List.append("E245") elif i == "把": List.append("E246") elif i == "漠": List.append("E247") elif i == "隆": List.append("E248") elif i == "録": List.append("E249") elif i == "徹": List.append("E24A") elif i == "氏": List.append("E24B") elif i == "撹": List.append("E24C") elif i == "阻": List.append("E24D") elif i == "渇": List.append("E24E") elif i == "讐": List.append("E24F") elif i == "恨": List.append("E250") elif i == "却": List.append("E251") elif i == "顛": List.append("E252") elif i == "岐": List.append("E253") elif i == "哲": List.append("E254") elif i == "凝": List.append("E255") elif i == "彗": List.append("E256") elif i == "膨": List.append("E257") elif i == "陰": List.append("E258") elif i == "謀": List.append("E259") elif i == "川": List.append("E25B") elif i == "沿": List.append("E25C") elif i == "泉": List.append("E25D") elif i == "犬": List.append("E25E") elif i == "璧": List.append("E25F") elif i == "傲": List.append("E260") elif i == "慢": List.append("E261") elif i == "鹿": List.append("E262") elif i == "委": List.append("E263") elif i == "憩": List.append("E264") elif i == "扇": List.append("E265") elif i == "給": List.append("E266") elif i == "冑": List.append("E267") elif i == "宮": List.append("E268") elif i == "紫": List.append("E269") elif i == "燭": List.append("E26A") elif i == "灯": List.append("E26B") elif i == "憐": List.append("E26C") elif i == "舗": List.append("E26D") elif i == "菌": List.append("E26E") elif i == "課": List.append("E26F") elif i == "庭": List.append("E270") elif i == "衆": List.append("E271") elif i == "厨": List.append("E272") elif i == "遥": List.append("E273") elif i == "仙": List.append("E274") elif i == "央": List.append("E275") elif i == "湯": List.append("E276") elif i == "呂": List.append("E277") elif i == "浸": List.append("E278") elif i == "寺": List.append("E279") elif i == "挿": List.append("E27B") elif i == "昏": List.append("E27C") elif i == "為": List.append("E27D") elif i == "刷": List.append("E27E") elif i == "暑": List.append("E27F") elif i == "季": List.append("E280") elif i == "償": List.append("E281") elif i == "奴": List.append("E282") elif i == "捜": List.append("E283") elif i == "財": List.append("E284") elif i == "奉": List.append("E285") elif i == "師": List.append("E286") elif i == "購": List.append("E287") elif i == "療": List.append("E288") elif i == "池": List.append("E289") elif i == "羅": List.append("E28A") elif i == "憂": List.append("E28B") elif i == "評": List.append("E28C") elif i == "噌": List.append("E28D") elif i == "轟": List.append("E28E") elif i == "五": List.append("E28F") elif i == "縦": List.append("E290") elif i == "輩": List.append("E291") elif i == "勅": List.append("E292") elif i == "請": List.append("E293") elif i == "棄": List.append("E294") elif i == "惧": List.append("E295") elif i == "監": List.append("E296") elif i == "滝": List.append("E297") elif i == "銭": List.append("E298") elif i == "奮": List.append("E299") elif i == "純": List.append("E29A") elif i == "塹": List.append("E29B") elif i == "壕": List.append("E29C") elif i == "郭": List.append("E29D") elif i == "貯": List.append("E29E") elif i == "蔵": List.append("E29F") elif i == "斉": List.append("E2A0") elif i == "維": List.append("E2A1") elif i == "校": List.append("E2A2") elif i == "錬": List.append("E2A3") elif i == "挺": List.append("E2A4") elif i == "猟": List.append("E2A5") elif i == "尉": List.append("E2A6") elif i == "佳": List.append("E2A7") elif i == "慌": List.append("E2A8") elif i == "遂": List.append("E2A9") elif i == "凄": List.append("E2AA") elif i == "炸": List.append("E2AB") elif i == "昌": List.append("E2AC") elif i == "耕": List.append("E2AD") elif i == "批": List.append("E2AE") elif i == "宗": List.append("E2AF") elif i == "爺": List.append("E2B0") elif i == "礎": List.append("E2B1") elif i == "糧": List.append("E2B2") elif i == "蓄": List.append("E2B3") elif i == "輸": List.append("E2B4") elif i == "艦": List.append("E2B5") elif i == "搭": List.append("E2B6") elif i == "載": List.append("E2B7") elif i == "勧": List.append("E2B8") elif i == "卒": List.append("E2B9") elif i == "噂": List.append("E2BA") elif i == "湖": List.append("E2BB") elif i == "宅": List.append("E2BC") elif i == "勤": List.append("E2BD") elif i == "猛": List.append("E2BE") elif i == "皆": List.append("E2BF") elif i == "潔": List.append("E2C0") elif i == "鏡": List.append("E2C1") elif i == "麗": List.append("E2C2") elif i == "曹": List.append("E2C3") elif i == "玄": List.append("E2C4") elif i == "寂": List.append("E2C5") elif i == "壇": List.append("E2C6") elif i == "堕": List.append("E2C7") elif i == "架": List.append("E2C8") elif i == "擬": List.append("E2C9") elif i == "銃": List.append("E2CA") elif i == "貢": List.append("E2CB") elif i == "献": List.append("E2CC") elif i == "砦": List.append("E2CD") elif i == "隅": List.append("E2CE") elif i == "詩": List.append("E2CF") elif i == "吟": List.append("E2D0") elif i == "著": List.append("E2D1") elif i == "膠": List.append("E2D2") elif i == "占": List.append("E2D3") elif i == "百": List.append("E2D4") elif i == "傘": List.append("E2D5") elif i == "敢": List.append("E2D6") elif i == "惨": List.append("E2D7") elif i == "索": List.append("E2D8") elif i == "樹": List.append("E2D9") elif i == "林": List.append("E2DA") elif i == "遮": List.append("E2DB") elif i == "涼": List.append("E2DC") elif i == "粒": List.append("E2DD") elif i == "拍": List.append("E2DE") elif i == "楼": List.append("E2DF") elif i == "鎮": List.append("E2E0") elif i == "牧": List.append("E2E1") elif i == "朴": List.append("E2E2") elif i == "盾": List.append("E2E3") elif i == "核": List.append("E2E4") elif i == "皇": List.append("E2E5") elif i == "律": List.append("E2E6") elif i == "倶": List.append("E2E7") elif i == "幽": List.append("E2E8") elif i == "某": List.append("E2E9") elif i == "淑": List.append("E2EA") elif i == "六": List.append("E2EB") elif i == "冥": List.append("E2EC") elif i == "井": List.append("E2ED") elif i == "戸": List.append("E2EE") elif i == "懐": List.append("E2EF") elif i == "充": List.append("E2F0") elif i == "軟": List.append("E2F1") elif i == "冊": List.append("E2F2") elif i == "僚": List.append("E2F3") elif i == "弁": List.append("E2F4") elif i == "詞": List.append("E2F5") elif i == "督": List.append("E2F6") elif i == "滞": List.append("E2F7") elif i == "慕": List.append("E2F8") elif i == "嘆": List.append("E2F9") elif i == "溶": List.append("E2FA") elif i == "卸": List.append("E2FB") elif i == "兼": List.append("E2FC") elif i == "晰": List.append("E2FD") elif i == "煥": List.append("E2FE") elif i == "凡": List.append("E2FF") elif i == "釣": List.append("E343") elif i == "秋": List.append("E344") elif i == "洒": List.append("E345") elif i == "羊": List.append("E346") elif i == "呑": List.append("E347") elif i == "禄": List.append("E348") elif i == "狭": List.append("E349") elif i == "童": List.append("E34A") elif i == "贅": List.append("E34B") elif i == "沢": List.append("E34C") elif i == "需": List.append("E34D") elif i == "滑": List.append("E34E") elif i == "額": List.append("E34F") elif i == "袖": List.append("E350") elif i == "販": List.append("E351") elif i == "帳": List.append("E352") elif i == "簿": List.append("E353") elif i == "掠": List.append("E354") elif i == "陶": List.append("E355") elif i == "偵": List.append("E356") elif i == "患": List.append("E357") elif i == "症": List.append("E358") elif i == "咲": List.append("E359") elif i == "煎": List.append("E35A") elif i == "俊": List.append("E35B") elif i == "版": List.append("E35C") elif i == "又": List.append("E35E") elif i == "逝": List.append("E35F") elif i == "鎖": List.append("E360") elif i == "猿": List.append("E361") elif i == "窓": List.append("E362") elif i == "慨": List.append("E363") elif i == "俗": List.append("E364") elif i == "睨": List.append("E365") elif i == "競": List.append("E366") elif i == "紳": List.append("E367") elif i == "浪": List.append("E368") elif i == "癖": List.append("E369") elif i == "掴": List.append("E36A") elif i == "惚": List.append("E36B") elif i == "執": List.append("E36C") elif i == "彷": List.append("E36D") elif i == "徨": List.append("E36E") elif i == "楚": List.append("E36F") elif i == "尋": List.append("E370") elif i == "釈": List.append("E371") elif i == "札": List.append("E372") elif i == "秀": List.append("E373") elif i == "肥": List.append("E374") elif i == "雌": List.append("E375") elif i == "飢": List.append("E376") elif i == "繕": List.append("E377") elif i == "姓": List.append("E378") elif i == "墨": List.append("E379") elif i == "慰": List.append("E37A") elif i == "飽": List.append("E37B") elif i == "概": List.append("E37C") elif i == "免": List.append("E37D") elif i == "疫": List.append("E37E") elif i == "泥": List.append("E37F") elif i == "尻": List.append("E381") elif i == "脇": List.append("E382") elif i == "蒸": List.append("E383") elif i == "湿": List.append("E384") elif i == "澄": List.append("E385") elif i == "征": List.append("E386") elif i == "締": List.append("E387") elif i == "春": List.append("E388") elif i == "曇": List.append("E389") elif i == "捉": List.append("E38A") elif i == "剖": List.append("E38B") elif i == "謙": List.append("E38C") elif i == "群": List.append("E38D") elif i == "暇": List.append("E38E") elif i == "焦": List.append("E38F") elif i == "妥": List.append("E390") elif i == "俄": List.append("E391") elif i == "逮": List.append("E392") elif i == "拘": List.append("E393") elif i == "脅": List.append("E394") elif i == "潤": List.append("E395") elif i == "譲": List.append("E396") elif i == "肺": List.append("E397") elif i == "涯": List.append("E398") elif i == "摘": List.append("E399") elif i == "芽": List.append("E39A") elif i == "九": List.append("E39B") elif i == "撤": List.append("E39C") elif i == "勘": List.append("E39D") elif i == "融": List.append("E39E") elif i == "賭": List.append("E39F") elif i == "傾": List.append("E3A0") elif i == "匿": List.append("E3A1") elif i == "誠": List.append("E3A2") elif i == "‥": List.append("E3A3") elif i == "叔": List.append("E3A4") elif i == "浜": List.append("E3A5") elif i == "席": List.append("E3A6") elif i == "彩": List.append("E3A7") elif i == "頻": List.append("E3A8") elif i == "壮": List.append("E3A9") elif i == "液": List.append("E3AA") elif i == "墟": List.append("E3AB") elif i == "谷": List.append("E3AC") elif i == "膳": List.append("E3AD") elif i == "仁": List.append("E3AE") elif i == "盆": List.append("E3AF") elif i == "栽": List.append("E3B0") elif i == "培": List.append("E3B1") elif i == "欄": List.append("E3B2") elif i == "鬼": List.append("E3B3") elif i == "縄": List.append("E3B4") elif i == "梯": List.append("E3B5") elif i == "籠": List.append("E3B6") elif i == "京": List.append("E3B7") elif i == "凛": List.append("E3B8") elif i == "刊": List.append("E3B9") elif i == "漫": List.append("E3BA") elif i == "琢": List.append("E3BB") elif i == "刊": List.append("E3BC") elif i == "漫": List.append("E3BD") elif i == "摩": List.append("E3BE") elif i == "煉": List.append("E3BF") elif i == "刹": List.append("E3C0") elif i == "伯": List.append("E3C1") elif i == "蚊": List.append("E3C2") elif i == "脆": List.append("E3C3") elif i == "餌": List.append("E3C4") elif i == "桃": List.append("E3C5") elif i == "廷": List.append("E3C6") elif i == "掲": List.append("E3C7") elif i == "疎": List.append("E3C8") elif i == "沌": List.append("E3C9") elif i == "菓": List.append("E3CA") elif i == "翌": List.append("E3CB") elif i == "愕": List.append("E3CC") elif i == "釜": List.append("E3CD") elif i == "茹": List.append("E3CE") elif i == "針": List.append("E3CF") elif i == "沼": List.append("E3D0") elif i == "紀": List.append("E3D1") elif i == "礁": List.append("E3D2") elif i == "菓": List.append("E3D3") elif i == "寧": List.append("E3D4") elif i == "聡": List.append("E3D5") elif i == "舌": List.append("E3D6") elif i == "菓": List.append("E3D7") elif i == "畳": List.append("E3D8") elif i == "懲": List.append("E3D9") elif i == "契": List.append("E3DA") elif i == "肢": List.append("E3DB") elif i == "藤": List.append("E3DC") elif i == "α": List.append("E3DD") elif i == "β": List.append("E3DE") elif i == "禍": List.append("E3DF") elif i == "壷": List.append("E3E0") elif i == "馴": List.append("E3E1") elif i == "樺": List.append("E3E2") elif i == "貰": List.append("E3E3") elif i == "馳": List.append("E3E4") elif i == "掟": List.append("E3E5") elif i == "懇": List.append("E3E6") elif i == "嬉": List.append("E3E7") elif i == "挫": List.append("E3E8") elif i == "松": List.append("E3E9") elif i == "鼓": List.append("E3EA") elif i == "較": List.append("E3EB") elif i == "亀": List.append("E3EC") elif i == "貿": List.append("E3ED") elif i == "綿": List.append("E3EE") elif i == "邸": List.append("E3EF") elif i == "雇": List.append("E3F0") elif i == "烏": List.append("E3F1") elif i == "唄": List.append("E3F2") elif i == "剃": List.append("E3F3") elif i == "稿": List.append("E3F4") elif i == "椅": List.append("E3F5") elif i == "旺": List.append("E3F6") elif i == "託": List.append("E3F7") elif i == "盟": List.append("E3F8") elif i == "虐": List.append("E3F9") elif i == "覗": List.append("E3FA") elif i == "戯": List.append("E3FB") elif i == "撮": List.append("E3FC") elif i == "ヱ": List.append("E3FD") elif i == "泡": List.append("E441") elif i == "隕": List.append("E442") elif i == "磁": List.append("E443") elif i == "洩": List.append("E444") elif i == "窃": List.append("E445") elif i == "滴": List.append("E446") elif i == "虎": List.append("E447") elif i == "怨": List.append("E448") elif i == "凱": List.append("E449") elif i == "旦": List.append("E44A") elif i == "那": List.append("E44B") elif i == "崖": List.append("E44C") elif i == "e": List.append("E44D") elif i == "y": List.append("E44E") elif i == "t": List.append("E44F") elif i == "o": List.append("E450") elif i == "y": List.append("E451") elif i == "h": List.append("E452") elif i == "e": List.append("E453") elif i == "a": List.append("E454") elif i == "r": List.append("E455") elif i == "t": List.append("E456") elif i == "妄": List.append("E457") elif i == "鼬": List.append("E458") elif i == "也": List.append("E459") elif i == "貌": List.append("E45A") elif i == "髭": List.append("E45B") elif i == "紛": List.append("E45C") elif i == "盤": List.append("E45E") elif i == "苛": List.append("E45F") elif i == "碧": List.append("E460") elif i == "桜": List.append("E461") elif i == "丼": List.append("E462") elif i == "迅": List.append("E463") elif i == "州": List.append("E464") elif i == "燥": List.append("E465") elif i == "軒": List.append("E466") else: List.append(i) return " ".join(List)
import math import time import random import csv def main(start=10, step=10, count=2000): with open('quicksort.csv', mode='w') as csv_file: fieldnames = ['items_coutn', 'time_to_run'] writer = csv.DictWriter(csv_file, fieldnames=fieldnames) n = start for i in range(count): print("run fo n: %d" % n) start_time = time.time() quickSort([random.randint(1,n) for i in range(n)]) end_time = time.time() writer.writerow({'items_coutn': (' %5.5f' % n), 'time_to_run': (' %5.5f' % (end_time - start_time))}) n += step def quickSort(data_set): quickSortHelper(data_set, 0, len(data_set)-1) def quickSortHelper(data_set, p, q): if p < q: i = quickSortPartition(data_set, p, q) quickSortHelper(data_set, p, i-1) quickSortHelper(data_set, i+1, q) def quickSortPartition(data_set, p, q): x = data_set[q] i = p-1 for j in range(p, q-1): if data_set[j] <= x: i += 1 data_set[i], data_set[j] = data_set[j], data_set[i] data_set[i+1], data_set[q] = data_set[q], data_set[i+1] return i+1 main()
tupler = lambda x,y: (x, y) def cons(a, b): def pair(f): return f(a, b) return pair def car(pair): return pair(tupler)[0] def cdr(pair): return pair(tupler)[1] print(car(cons(3,4))) print(cdr(cons(3,4)))
def general_fibonacci(n, X): cache = [0 for _ in range(n + 1)] cache[0] = 1 for i in range(n + 1): cache[i] += sum(cache[i - x] for x in X if i - x >= 0) return cache[-1] def fibonacci(n): return general_fibonacci(n-1, {1,2}) if __name__ == "__main__": print(f"fibonacci(10) = {fibonacci(36)}")
# Class to do add IDD codes to phone numbers that don't have them. # Part of, https://github.com/johntelforduk/shopify-to-facebook import json class PhoneCode: def __init__(self): code_file = open('International-Dialing-Codes/dialing-codes-data') code_json = (code_file.read()) code_file.close() # Turn the JSON into a list. code_list = json.loads(s=code_json) # Turn the list into a dictionary. self.code_dict = {} for each_country in code_list: self.code_dict[each_country['id']] = each_country['code'] def country_to_idd(self, country: str) -> str: """For parm ISO two-letter country code, return the International Direct Dailing code.""" if country in self.code_dict: return self.code_dict[country] else: return '' def enrich_phone_no(self, phone_no: str, country: str) -> str: """Enrich a phone number by adding country code to front of it (if missing).""" # From Facebook website, https://www.facebook.com/business/help/2082575038703844?id=2469097953376494 # # "Phone numbers must include a country code to be used for matching. For example, the number 1 must precede a # phone number in the United States. We accept up to 3 phone numbers as separate columns, with or without # punctuation. # Important: Always include the country code as part of your customers' phone numbers, even if all of your data # is from the same country." # Some phone numbers have a leading apostrophe, which should be removed. phone_no = phone_no.replace("'", "") idd_code = self.country_to_idd(country) if idd_code == '' or phone_no == '': # In hopeless cases... return phone_no # ... do nothing. assert idd_code[0] == '+' idd_code_without_plus = idd_code[1:] assert len(phone_no) >= 1 if phone_no[0] == '+': # International access code present, return phone_no # ... so return unchanged. # Facebook give examples that start with +, but none that start with 00. So if found replace 00 with +. if phone_no[0:2] == '00': return '+' + phone_no[2:] # If access code is already present at start, then make no changes. if idd_code_without_plus == phone_no[0:len(idd_code_without_plus)]: return '+' + phone_no # For example, '04214 443234' -> '+44 4214 443234' if phone_no[0] == '0': return idd_code + ' ' + phone_no[1:] # If no conditions met, just return the phone number. return phone_no
# %% # Essentially, Python is an object oriented programming language. Hence, everything in Python is pretty much an object # with it's own methods. # First some definitions. # An object is simply a collection of data (variables) and methods (functions) that act on said data. # A class is essentially a blueprint for said object. # Let's make a simple class to start with. class Bandit: health = 5 stamina = 3 def attack(self): print("Skyrim belongs to the Nords!") self.stamina -= 1 def defend(self): print("Mercy! I yield!") self.stamina += 1 if(self.health < 5): self.health += 1 # The reason we pass the "self" parameter in the internal function is because it represents the instance of the class. # With that, you can access the class itself. You don't have to use self if you don't want to. You can use some other # word but its just the common way that everyone does it. # Now let's use this class and show it off. john = Bandit() # Create an object based on our Bandit class john.attack() # Have our "bandit" attack something print("John's stamina is " + str(john.stamina)) # Show off the stamina of our bandit john.defend() # Have our "bandit" defend print("John's stamina is " + str(john.stamina)) # Show off the stamina of our bandit print("John's health is " + str(john.health)) # Show off the health of our bandit # We can see that the attack and defend functions are the methods of the Bandit class. By calling the method # through our created object, we can use the functions within our created class. # %% # %% # Now what if we want to define how much health and stamina our Bandit has at initialization? # Let's reconfigure our class to take that into account. class Bandit: def __init__(self, health, stamina): self.health = health self.stamina = stamina def attack(self): print("Skyrim belongs to the Nords!") self.stamina -= 1 def defend(self): print("Mercy! I yield!") self.stamina += 1 if(self.health < 5): self.health += 1 john = Bandit(10,5) # Create an object based on our Bandit class. We will also give a custom health and stamina level carl = Bandit(5,3) # Create a second "bandit" with different health and stamina print("John will begin to move.") john.attack() # Have our "bandit" attack something print("John's stamina is " + str(john.stamina)) # Show off the stamina of our bandit john.defend() # Have our "bandit" defend print("John's stamina is " + str(john.stamina)) # Show off the stamina of our bandit print("John's health is " + str(john.health)) # Show off the health of our bandit print("Carl will begin to move.") # Have our second bandit do stuff carl.attack() print("Carl's stamina is " + str(carl.stamina)) carl.defend() print("Carl's stamina is " + str(carl.stamina)) print("Carl's health is " + str(carl.health)) # %% ''' You can continue to add on and tinker with this class if you would like. You can try to pass an argument through attack() in the class definition so you can maybe change what the voice line will be or how much stamina is lost. Its your class so you get creative with it if you like. '''
# %% # assign magicNumber and inputNumber an integer value # try changing them and see what happens magicNumber = 10 inputNumber = 10 # if statements evaluate the expression after it. # if the expression is true, then the code under it runs. if inputNumber == magicNumber: print(str(inputNumber) + " is the magic number!") # str() converts an int value to a string value # when the if statement does not run, the else statement will run. # there can only be 1 else statment for every if statment # else statements are optional. It is not needed to make an # if statement work properly. else: print(str(inputNumber) + " is not he magic number.") # Try changing the code so that you assign inputNumber a value # from the terminal. # %%
# Printing any number print(490) # Printing any string print("Hi") ############################################### End ######################################## # 1. Print any number value ? # 2. Print any string value ?
from perceptron import Perceptron import matplotlib.pyplot as plt f = lambda x:x class LinearUnit(Perceptron): def __init__(self, input_num): Perceptron.__init__(self, input_num, f) def get_training_dataset(): input_vecs = [[5], [3], [8], [1.4], [10.1]] labels = [5500, 2300, 7600, 1800, 11400] return input_vecs, labels def train_linear_unit(): lu = LinearUnit(1) input_vecs, labels = get_training_dataset() lu.train(input_vecs, labels, 10, 0.01) return lu def plot(linear_unit): input_vecs, labels = get_training_dataset() fig = plt.figure() ax = fig.add_subplot(111) ax.scatter(list(map(lambda x: x[0], input_vecs)), labels) weights = linear_unit.weights bias = linear_unit.bias x = range(0,12,1) y = list(map(lambda x:weights[0]*x+bias, x)) ax.plot(x, y) plt.show() if __name__ == '__main__': linear_unit = train_linear_unit() print('Work 3.4 years, monthly salary = %.2f' % linear_unit.predict([3.4])) print('Work 15 years, monthly salary = %.2f' % linear_unit.predict([15])) print('Work 1.5 years, monthly salary = %.2f' % linear_unit.predict([1.5])) print('Work 6.3 years, monthly salary = %.2f' % linear_unit.predict([6.3])) plot(linear_unit)
def UpperCase(string): str = string.upper() print(str) x = 'Hello World' y = 'hello world' z = 'hELLO wORLD' UpperCase(x) UpperCase(y) UpperCase(z)
print("first range values are:") for x in range(10): print(x) print("second range values are:") for y in range(22,50,3): #print(y) y = int(y) if (y % 2) != 0: # print(y) # print('{0},it is an odd number'.format(y)) print(y,'it is an odd number') else: # print("{0},it is an even number".format(y)) print(y,'it is an even number') number = 2 print("while loop function is starting from here") while number < 10: print(number) number = number+1
def dating_age(age): age = float(age) range_age = (age/2)+5 return range_age your_age = input("Enter your age: ") dating_age = dating_age(your_age) print("The range of age of your dating girlfriend has to be ",format(dating_age))
foods = ["bacon","cheese","sausage","burger","pizza","pasta"] # for f in foods: for f in foods[1:5]: print(f) # print(len(f)) if f == 'bacon': print("it can be an ingredients of burger") elif f == 'cheese': print("it can be ingredients of burger or pizza or pasta") elif f == 'sausage': print("it can be added to pizza or pasta or burger") else: print(f + " is a food that i wanna eat now")
# importing required libraries import pandas as pd from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import accuracy_score # read the train and test dataset train_data = pd.read_csv('train-data.csv') test_data = pd.read_csv('test-data.csv') # shape of the dataset print('Shape of training data :', train_data.shape) print('Shape of testing data :', test_data.shape) # Now, we need to predict the missing target variable in the test data # target variable - Survived # seperate the independent and target variable on training data train_x = train_data.drop(columns=['Survived'], axis=1) train_y = train_data['Survived'] # seperate the independent and target variable on testing data test_x = test_data.drop(columns=['Survived'], axis=1) test_y = test_data['Survived'] # create the object of the K-Neighbors Classifier model model = KNeighborsClassifier() # fit the model with the training data model.fit(train_x, train_y) # Number of Neighbors used to predict the target print('\nThe number of neighbors used to predict the target : ', model.n_neighbors) # predict the target on the train dataset predict_train = model.predict(train_x) print('\nTarget on train data', predict_train) # Accuray Score on train dataset accuracy_train = accuracy_score(train_y, predict_train) print('accuracy_score on train dataset : ', accuracy_train) # predict the target on the test dataset predict_test = model.predict(test_x) print('Target on test data', predict_test) # Accuracy Score on test dataset accuracy_test = accuracy_score(test_y, predict_test) print('accuracy_score on test dataset : ', accuracy_test)
''' In this project, you will visualize the feelings and language used in a set of Tweets. This starter code loads the appropriate libraries and the Twitter data you'll Need! Tweet file can be downloaded from here: https://drive.google.com/open?id=1F7kzxvfidrwWmzExPty7QoW6eXwDTj7w ''' from wordcloud import WordCloud from os import path from textblob import TextBlob import json import matplotlib.pyplot as plt #Get the JSON data tweetFile = open("/Users/icalvaradoblanco/Desktop/gwc/otherWork/TwitterData/WordCloud/TwitterWordCloud/tweets_small.json", "r") tweetData = json.load(tweetFile) tweetFile.close() #Step 1: Graph the polarity # Selecting the tweets out of the data def TweetsStrings(): TweetStringList=[] for tweet in range(len(tweetData)): Tweet= (tweetData[tweet]["text"]) TweetStringList.append(Tweet) return TweetStringList #Calculating Polarity of TweetString def PolarityofTweets(TweetStringList): TweetPolarity=[] for tweet in range(len(TweetStringList)): testimonial= TextBlob(TweetStringList[tweet]) Polarity= testimonial.sentiment.polarity TweetPolarity.append(Polarity) #X values return(TweetPolarity) #Step 2: Visualize the tweetData #Getting the frequencies of words def TopWords(TweetStringStringB): #freq>10 print("----------------------") Popularity=[] for tweet in range(len(TweetStringStringB.words)): word= TweetStringStringB.words[tweet] numberpopularity=(TweetStringStringB.word_counts[word]) if (numberpopularity>5): if (word!='https'): if word.isalpha(): Popularity.append(word) return(Popularity) #You want redundancy to see the frequency in the wordcloud #Making the Word Cloud def MakeWordCloud(filename): d = path.dirname(__file__) text = open(path.join(d,filename)).read() #Reads the file wordcloud = WordCloud().generate(text) #Generates the WordCloud #This displays the image plt.imshow(wordcloud,interpolation='bilinear') plt.axis("off") #This deals with font size plt.show() #Let's make wordclouds for positive,neutral,and negative def PositiveWords(TweetStringStringB,TweetStringString): PositiveWords=[] for tweet in range(len(TweetStringStringB.words)): word=(TweetStringStringB.words[tweet]) if (word.isalpha()): word=TextBlob(word) polarityofword= word.sentiment.polarity word=(TweetStringStringB.words[tweet]) if ((polarityofword>0.3)) : PositiveWords.append(word) return PositiveWords def NeutralWords(TweetStringStringB,TweetStringString): NeutralWords=[] for tweet in range(len(TweetStringStringB.words)): word=TweetStringStringB.words[tweet] if (word!='https'): if (word.isalpha()): word=TextBlob(word) polarityofword= word.sentiment.polarity word=(TweetStringStringB.words[tweet]) if ((polarityofword<0.3) & (polarityofword>-0.3)): NeutralWords.append(word) return NeutralWords def NegativeWords(TweetStringStringB,TweetStringString): NegativeWords=[] for tweet in range(len(TweetStringStringB.words)): word=TweetStringStringB.words[tweet] if(word.isalpha()): word=TextBlob(word) polarityofword= word.sentiment.polarity word=(TweetStringStringB.words[tweet]) if ((polarityofword<-0.3)) : print("NEGATIVE YEAH") NegativeWords.append(word) return NegativeWords #Flow #gets the tweet text TweetStringList= TweetsStrings() #polarity of tweets TweetPolarity= PolarityofTweets(TweetStringList) #graphs the polarity in a Histogram plt.hist(TweetPolarity,100, facecolor='green') plt.xlabel("Polarity") plt.ylabel("Number of Tweets") plt.title("Polarity of Tweets") plt.axis([-1.0,1.0,0,50]) plt.show() #Makes tweets into TextBlobs TweetStringString= " ".join(TweetStringList) TweetStringStringB= TextBlob(TweetStringString) #gets the most popular words and storing them Popularity=" ".join(TopWords(TweetStringStringB)) f= open("PopularityStringGeneral.txt","w+") f.write(Popularity) #popularity of neutral words NeutralWords= NeutralWords(TweetStringStringB,TweetStringString) NeutralWords= " ".join(NeutralWords) f= open("PopularityNeutralWords.txt","w+") f.write(NeutralWords) #popularity of negative words NegativeWords=NegativeWords(TweetStringStringB,TweetStringString) NegativeWords= " ".join(NegativeWords) f= open('PopularityNegativeWords.txt',"w+") f.write(NegativeWords) #Popularity of the word clouds print("POSITIVE") MakeWordCloud('PopularityPositiveWords.txt') print("NEUTRAL") MakeWordCloud('PopularityNeutralWords.txt') #currently not working as expected #MakeWordCloud('PopularityNegativeWords.txt')
import turtle as t # n = int(input()) n = 60 t.shape('turtle') t.speed('fastest') # t.color('red') # t.begin_fill() for i in range(n): t.circle(120) t.right(360/n) # t.end_fill() t.mainloop()
class Rectangle: def __init__(self, x1, y1, x2, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 rect = Rectangle(x1=20, y1=20, x2=40, y2=30) x = abs(rect.x1 - rect.x2) y = abs(rect.y1 - rect.y2) area = x*y print(area) import math class Point2D: def __init__(self, x=0, y=0): self.x = x self.y = y length = 0.0 p = [Point2D(), Point2D(), Point2D(), Point2D()] p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y = map(int, input().split()) x1 = abs(p[0].x - p[1].x) x2 = abs(p[1].x - p[2].x) x3 = abs(p[2].x - p[3].x) y1 = abs(p[0].y - p[1].y) y2 = abs(p[1].y - p[2].y) y3 = abs(p[2].y - p[3].y) length = math.sqrt(x1**2 + y1**2) + math.sqrt(x2**2 + y2**2) + math.sqrt(x3**2 + y3**2) print(length)
word = input('단어를 입력하세요: ') print(word == word[::-1]) print(list(word) == list(reversed(word)))
class Person: def __init__(self, name, age, address): self.hello = '안녕하세요' self.name = name self.age = age self.address = address def greeting(self): print('{0} 저는 {1}입니다.'.format(self.hello, self.name)) maria = Person('마리아', 20, '서울시 서초구 반포동') maria.greeting() print('이름:', maria.name) print('나이:', maria.age) print('주소:', maria.address) class Knight: def __init__(self, health, mana, armor): self.health = health self.mana = mana self.armor = armor def slash(self): print('베기') x = Knight(health=542.4, mana=210.3, armor=38) print(x.health, x.mana, x.armor) x.slash() class Annie: def __init__(self, health, mana, ability_power): self.health = health self.mana = mana self.ability_power = ability_power def tibbers(self): damage = self.ability_power * 0.65 + 400 print('티버: 피해량 {0}'.format(damage)) health, mana, ability_power = map(float, input().split()) x = Annie(health=health, mana=mana, ability_power=ability_power) x.tibbers()
#!/usr/bin/env python # -*- coding: utf-8 -*- import urllib, json from speech import Speech class Weather(): API_KEY = '01daaa0160eb1f77' LANG = 'US' COUNTRY = 'POLAND' CITY = 'WROCLAW' def __init__(self, country=COUNTRY, city=CITY, lang=LANG, api_key=API_KEY): self.API_KEY = api_key self.LANG = lang self.COUNTRY = country self.CITY = city def check_weather(self): url = 'http://api.wunderground.com/api/{0}/forecast/lang:{1}/q/{2}/{3}.json'.format(self.API_KEY, self.LANG, self.COUNTRY, self.CITY) try: response = urllib.urlopen(url) data = json.loads(response.read()) return data except: data = "Weather: Cannot connect to weather api!" print data if __name__ == '__main__': print "Init..." weather = Weather().check_weather() print weather
name = input("What is your name? ") maths_mark = int(input("What was your Maths mark? ")) chem_mark = int(input("What was your Chemistry mark? ")) phy_mark = int(input("What was your Physics mark? ")) overall = maths_mark + chem_mark + phy_mark if overall >= 70: print("Your grade is, A") elif overall >= 60: print("Your grade is, B") elif overall >= 50: print("Your grade is, C") elif overall >=40: print("Your grade is, D") else: print("You failed")
# conditional (if) statements x = int(input("enter x 1-5 or more: ")) if x == 1: print("its one") if x == 2: print("nigger") if x == 3: print("ur mom") if x == 4: print("GOD!!!!!!") if x == 5: print("lol") if x > 5: print("u can't do that") y = int(input("(hint:what's 9+10)1 or 2")) if y == 1: print("yay") else: print('sry')
def cost_ground_ship(weight): if weight <= 2: return (weight * 1.50) + 20 elif (weight > 2) and (weight < 6): return (weight * 3.00) + 20 elif (weight > 6) and (weight < 10): return (weight * 4.00) + 20 elif weight > 10: return (weight * 4.75) + 20 def cost_drone_ship(weight): if weight <= 2: return (weight * 4.50) elif (weight > 2) and (weight < 6): return (weight * 9.00) elif (weight > 6) and (weight < 10): return (weight * 12.00) elif weight > 10: return (weight * 14.75) premium_shipping = 125.00 def cheapest_shipping (weight): if cost_ground_ship(weight) < premium_shipping and cost_ground_ship(weight) < cost_drone_ship (weight): return "The cheapest method will be ground shipping with a cost of $ " + str(cost_ground_ship (weight)) elif premium_shipping < cost_ground_ship (weight) and premium_shipping < cost_drone_ship (weight): return "The cheapest method will be premiuim shipping with a cost of $ " + str(premium_shipping) else: return "The cheapest method will be drone shipping with a cost of $ " + str(cost_drone_ship (weight)) print(cheapest_shipping())
import argparse import json def load_json(file): with open(file, "r", encoding='utf-8') as reader: return json.load(reader) def write_text(file, text): with open(file, "w", encoding='utf-8') as writer: writer.write(text) def main(args): input_data = load_json(args.input_file) exceptions = ['instrucciones_aplicacion', 'condiciones_aplicacion'] producto = '' if (args.limit): input_data = input_data[0:args.limit] # Entradas del JSON for entry in input_data: # Claves de cada entrada for key in entry.keys(): if(entry[key]): if (key in exceptions): subkey = entry[key] # Subclaves de cada clave for k in subkey.keys(): if(subkey[k]): value = subkey[k].replace(f'\n', '') producto += f"{k} : {value}." #print(k + " : " + str(subkey[k])) else: value = entry[key].replace(f'\n', '') producto += f"{key} : {value}." #print(key + " : " + str(entry[key])); producto += f'\n' write_text(args.output_file, producto) print(f"{args.input_file} transformado correctamente a {args.output_file}") if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--input_file", required=True, type=str, help="File where load the input") parser.add_argument("--output_file", type=str, default='./out.txt', help="File name where store the output" ) parser.add_argument('--limit', type=int, help="Number of product to read.") args = parser.parse_args() main(args)
from tkinter import * import pygame from tkinter import filedialog pygame.init() root = Tk() class Player: def __init__(self, master=None): self.root = root self.window() self.labels() self.buttons() root.mainloop() def window(self, **kwargs): self.w_height = 440 self.w_width = 630 self.root.title('MP3 PLAYER') self.root.configure(background='#dde') try: self.w_width = kwargs['width'] except KeyError: pass try: self.w_width = kwargs['height'] except KeyError: pass self.screenWidht = self.root.winfo_screenmmwidth() self.screenHeight = self.root.winfo_screenheight() self.left = (self.screenWidht / 2) - (self.w_width / 2) self.top = (self.screenHeight / 2) - (self.w_height / 2) self.root.geometry('%dx%d+%d+%d' % (self.w_width, self.w_height, self.left, self.top)) def labels(self): self.winmus = Entry(self.root, bg='white') self.winmus.configure(state='disabled') self.winmus.place(height=300, width=300, x=165, bordermode=INSIDE) def buttons(self): self.previous = Button(self.root, text='<') self.previous.place(x=165, y=300, width=30) self.play = Button(self.root, text='Play/Pause') self.play.place(x=195, y=300, width=100) self.next = Button(self.root, text='>') self.next.place(x=295, y=300, width=30) self.add_ = Button(self.root, text='Adicionar música', command=self.add_msc) self.add_.place(x=325, y=300) def add_msc(self): self.dir = filedialog.askopenfilenames() Player(root)
#creation du triangle rows = 10 k = 2 * rows - 2 lines = [] #Faire un triangle for i in range(rows, -1, -1): line = "" for j in range(k-rows, 0, -1): line += " " k = k + 1 for j in range(0, i + 1): line += "**" line += "*" lines.append(line.ljust(19, " ")) #On ajoute la pointe du triangle line = " " * (2*rows-1) + "*" lines.append(line.ljust(19, " ")) #Tableau vide qui contiendra l'étoile pattern = [""] * (len(lines) + rows//2) #On rempli le tableau depuis le début par la pointe de la pyramide #et la fin du tableau par la base de la pyramide #On supperpose les deux pyramides avec un décalage for i in range(len(lines)): pattern[i] = (lines[len(lines)-i-1]) pattern[len(pattern)-1-i] = fusionneLignes(pattern[len(pattern)-1-i], lines[len(lines)-i-1]) #On affiche le tableau for line in pattern: print(line) def fusionneLignes(l1, l2): while len(l1) < len(l2): l1 += " " while len(l2) < len(l1): l2 += " " line = "" for mot1, mot2 in zip(l1, l2): if (mot1 == "*" or mot2 == "*"): line += "*" else: line += " " return line
import cv2 import numpy as np # Read image img = cv2.imread("imori.jpg") img_origion = img.copy() img = img.astype(np.float) b = img[:, :, 0].copy() g = img[:, :, 1].copy() r = img[:, :, 2].copy() # Grayscale # You could use the cv2.cvtColor() to change the rgb image into grayscale. gray = cv2.cvtColor(img_origion, cv2.COLOR_BGR2GRAY) cv2.imshow("gray",gray) out = 0.2126 * r + 0.7152 * g + 0.0722 * b out = out.astype(np.uint8) # Save result cv2.imwrite("out.jpg", out) cv2.imshow("result", out) cv2.waitKey(0) cv2.destroyAllWindows()
import random long_password = int(input('Enter lenght of your password: ')) password = "" for x in range(long_password): int_character = random.randint(33, 127) password += str(chr(int_character)) print(password)
############################### ## # ## WEEK 4 HOMEWORK # ## # ## \o/ # ############################### # YOUR ASSIGNMENT: # For all the exercises below, test your function by calling it # (if it has parameters, test it with different arguments). ### Exercise 1 # Write a function to check if a number is in a given range. # (Hint: you need 3 parameters, 2 for defining the range, 1 for the number you want to check.) # Example: Given the range 4 to 10, check if 5 is included. The expected result is True. # You could also return a phrase like, “The number 5 is included in the range” # ------ ADD YOUR CODE BELOW: ------ ### Exercise 2 # Create a function that will help us what to take with us by giving the weather # (So the function has a parameter called weather.) # Examples: # If it’s sunny, your function will return “Take sunglasses” # If it’s raining, your function will return “Take umbrella” # If it’s snowing, your function will return “Take your gloves” # If it’s cold, your function will return “Take your jacket” # Add an option for when you don’t have the weather in your examples, something like, "Try again". # Can you think about more conditions? Get creative! # ------ ADD YOUR CODE BELOW: ------ ### Exercise 3 # Create a function that produces a random integer integer between (0,100) and asks for user to guess the number. # If the user guessed the number correctly, it prints "That's right! You guessed it! Congrats" # If the user could not guess it right, it prints "I'm sorry, but that's not correct." # (hint: this function should not have any parameters) # ------ ADD YOUR CODE BELOW: ------ ### Bonus Exercise: # This exercise is totally optional, but you can do it if you are up for a challenge. # Remember the Exercise 2 from week 3 homework? Let's do it using an input() function this time. # Assign a variable called occupation using the input() function, using a description to print, # like "What is your occupation?". # Similarly assign a variable number_of_children by asking a question # (like "Give number of children") to the user using the input() function. # For each child, ask the age of the child to the user similarly using the input() function, # and calculate the total benefit amount. # The description of Exercise 2 from last week: # Situation: Citizens apply for financial benefits from the government whose policy is to # grant government employee benefits for only 2 of his children, 1.000Euro for each child # if he/she is less than or equal to 20 years old. # Write a set of codes using the conditional statements (if, else, elif) that checks # the following conditions: # - If citizen's occupation is a government employee, check if he has kids eligible for benefits, # calculate the total benefit amount # - If citizen's occupation is an entrepreneur, output the message "You make sure you pay your tax!" # - If citizen has other occupation, output the message # "This facility is only for government employees! # # At the end output the message "Total benefit availed: " and total benefit amount # ------ ADD YOUR CODE BELOW: ------
#understanding basic types #types are inferred by runtime automatically a = 10 print(a) print(type(a)) b = 13.6 print(type(b)) c = 'abc' print(type(c)) e = False print(e) print(type(e))
'''consecutive check''' def check_consecutive(d): d if 14 in d: d.append(1) d.sort() strike = 0 maxi = 0 m = 0 while m<len(d): newgroup = [] newgroup.append(d[m]) n=m+1 while n<len(d): if d[n] in newgroup: n=n+1 elif (d[n]-1) in newgroup: newgroup.append(d[n]) n=n+1 else: n=n+1 if len(newgroup)>=5: strike = 1 if max(newgroup)>maxi: maxi = max(newgroup) m += 1 return (strike,maxi) '''duplicate checking''' def check_duplicate(data): t = list(set(data)) double = [x for x in t if data.count(x)==2] triple = [x for x in t if data.count(x)==3] quadruple = [x for x in t if data.count(x)==4] fiveofakind = [x for x in t if data.count(x)==5] return (double,triple,quadruple,fiveofakind) '''check type''' def check_type(suit,data): newdata = [] double,triple,quadruple,fiveofakind = check_duplicate(suit) if len(fiveofakind) == 1: kind = fiveofakind[0] k=0 while k<7: if suit[k]==kind: newdata.append(data[k]) k+=1 if len(newdata)>4: flushstrike,maxflushstrike = check_consecutive(newdata) else: newdata=[0] flushstrike=0 maxflushstrike=0 return (len(fiveofakind),sorted(newdata,reverse=True),flushstrike,maxflushstrike) '''biggest''' def biggest(data,suit): flush,maxflush,flushstrike,maxflushstrike = check_type(suit,data) if flushstrike ==1: return(9*10000000000+maxflushstrike) else: double,triple,quadruple,temp = check_duplicate(data) if len(quadruple) == 1: return (8*10000000000+quadruple[0]) elif len(triple)==2: return (7*10000000000+max(triple)*100+min(triple)) elif len(triple)==1 and len(double)>=1: return (7*10000000000+triple[0]*100+max(double)) elif flush == 1: return (6*10000000000+maxflush[0]*100000000+maxflush[1]*1000000+maxflush[2]*10000+maxflush[3]*100+maxflush[4]) else: strike,maxstrike = check_consecutive(data) if strike == 1: return (5*10000000000+maxstrike) elif len(triple)==1: data.remove(triple[0]) data.remove(triple[0]) data.remove(triple[0]) temp= sorted(data,reverse=True) return(4*10000000000+triple[0]*10000+temp[0]*100+temp[1]) elif len(double)>=2: temp1 = sorted(double,reverse=True) data.remove(double[0]) data.remove(double[0]) data.remove(double[1]) data.remove(double[1]) temp2 = sorted(data,reverse=True) return(3*10000000000+temp1[0]*10000+temp1[1]*100+temp2[0]) elif len(double)==1: data.remove(double[0]) data.remove(double[0]) temp3=sorted(data,reverse=True) return(2*10000000000+double[0]*1000000+temp3[0]*10000+temp3[1]*100+temp3[2]) else: temp4 = sorted(data,reverse=True) return(1*10000000000+temp4[0]*100000000+temp4[1]*1000000+temp4[2]*10000+temp4[3]*100+temp4[4]) '''compare''' '''def compare(suit1,data1,suit2,data2): flush1,maxflush1,flushstrike1,maxflushstrike1 = check_type(suit1,data1) flush2,maxflush2,flushstrike2,maxflushstrike2 = check_type(suit2,data2) if flushstrike1>flushstrike2: return 1 elif flushstrike2>flushstrike1: return 2 elif flushstrike1==1 and flushstrike2==1: if maxflushstrike1 > maxflushstrike2: return 1 elif maxflushstrike1 < maxflushstrike2: return 2 elif maxflushstrike1 == maxflushstrike2: return 0 elif flushstrike1==0 and flushstrike2==0: double1,triple1,quadruple1,temp1 = check_duplicate(data1) double2,triple2,quadruple2,temp2 = check_duplicate(data2) if len(quadruple1)>len(quadruple2): return 1 elif len(quadruple1)<len(quadruple2): return 2 elif len(quadruple1)==1 and len(quadruple2)==1: if quadruple1[0]>quadruple2[0]: return 1 else: return 2 elif len(quadruple1)==0 and len(quadruple2)==0: if (len(triple1)==1 and len(double1) ==1) and (len(triple2)==1 and len(double2)==1): if triple1[0]>triple2[0]: return 1 elif triple1[0]<triple2[0]: return 2 else: if double1[0]>double2[0]: return 1 elif double1[0]<double2[0]: return 2 else: return 0 elif len(triple1)==1 and len(double1) ==1: return 1 elif len(triple2)==1 and len(double2)==1: return 2 else:''' ''' data2 = [14,14,8,10,6,11,5] suit2 = [1,2,3,4,3,4,2] data1 = [13,5,10,13,6,2,7] suit1 = [1,3,3,4,2,2,3] largeness1 = biggest(data1,suit1) largeness2 = biggest(data2,suit2) print(largeness1,largeness2) ''' ''' data = [8,9,10,13,6,7,13] suit = [3,3,3,4,3,3,2] flush,maxflush,flushstrike,maxflushstrike = check_type(suit,data) print(flush,maxflush,flushstrike,maxflushstrike) strike,maxstrike = check_consecutive(data) print(strike,maxstrike) double,triple,quadruple,temp = check_duplicate(data) print (double,triple,quadruple) '''
""" 信号和槽,在之后的学习会了解这两个qt的核心东西 """ import sys from PyQt5.QtCore import QCoreApplication from PyQt5.QtWidgets import QWidget, QApplication, QPushButton class Example(QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): btn = QPushButton('quit', self) btn.resize(btn.sizeHint()) btn.move(50, 50) # 信号和槽的使用 # 当我们按下这个按钮的时候,释放了click这个信号,槽可以是QT或者python btn.clicked.connect(QCoreApplication.quit) self.setGeometry(200, 300, 400, 500) self.setWindowTitle("QUIT") if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() ex.show() sys.exit(app.exec_())
# Seasons month = input("Enter month: ") day = int(input("Enter day: ")) if (month == "March"): if day >= 20: season = "Spring" else: season = "Winter" elif (month == "June"): if day >= 21: season = "Summer" else: season = "Spring" elif (month == "September"): if day >= 22: season = "Fall" else: season = "Summer" elif (month == "December"): if day >= 21: season = "Winter" else: season = "Fall" elif (month == "January" or month == "February"): season = "Winter" elif (month == "October" or month == "November"): season = "Fall" elif (month == "July" or month == "August"): season = "Summer" elif (month == "April" or month == "May"): season = "Spring" print("Season is", season, ".")
# Graduation Condition gpa = float(input("Enter GPA: ")) lecture_num = int(input("Enter lecture number: ")) if (lecture_num < 47): if (gpa < 2.0): result = "Not enough number of lectures and GPA!" else: result = "Not enough number of lectures!" else: if (gpa < 2.0): result = "Not enough GPA!" else: result = "GRADUATED!!!" print(result)
num1 = input("Enter the first number: ") num2 = input("Enter the second number: ") list_num1 = [] list_num2 = [] match = 0 for i in num1: list_num1.append(i) for i in num2: list_num2.append(i) list_num1.reverse() list_num2.reverse() for i in range((min(len(list_num1),len(list_num2)))): if list_num1[i] == list_num2[i]: match += 1 print(match)
# Sum of the last two digits num = input("Please enter an integer number: ") if(len(num) > 1): result = int(num[-1]) + int(num[-2]) else: result = int(num) print("Result is", result)
# Hypotenuse edge1 = float(input("Please enter the first edge: ")) edge2 = float(input("Please enter the second edge: ")) hypotenuse = float((edge1 ** 2 + edge2 ** 2) ** 0.5) print("Hypotenuse is", hypotenuse)
def solution(numbers, target): sup = [0] for i in numbers: sub = [] for j in sup: sub.append(j + i) sub.append(j - i) sup = sub return sup.count(target) from collections import deque def solution_BFS(numbers, target): answer = 0 queue = deque([(0, 0)]) while queue: total, index = queue.popleft() if index == len(numbers): if total == target: answer += 1 else: number = numbers[index] queue.append((total + number, index + 1)) queue.append((total - number, index + 1)) return answer print(solution_BFS([1, 1, 1, 1, 1], 3))
filename_1 = "p1_input.txt" filename_2 = "p2_input.txt" class Deck: def __init__(self, starting_cards): self.deck = starting_cards def peek(self): return self.deck[0] def pop(self): card = self.peek() self.deck = self.deck[1:] return card def push(self, card): self.deck.append(card) def read_input(filename): with open(filename, "r") as f: return [int(ln.rstrip('\n')) for ln in f.readlines()] def play_turn(p1, p2): p1_card = p1.pop() p2_card = p2.pop() if p1_card > p2_card: print("P1 guanya ", p1_card, " a ", p2_card) p1.push(p1_card) p1.push(p2_card) else: print("P2 guanya ", p2_card, " a ", p1_card) p2.push(p2_card) p2.push(p1_card) print(p1.deck) print(p2.deck) def calculate_score(p): score = 0 for i in range(len(p.deck)): score += (p.deck[len(p.deck) - i - 1]*(i+1)) return score def part_1(): p1 = Deck(read_input(filename_1)) p2 = Deck(read_input(filename_2)) print("Inicial: ", p1.deck) print("Inicial: ", p2.deck) while len(p1.deck) > 0 and len(p2.deck) > 0: play_turn(p1, p2) if len(p1.deck) > 0: print("P1 wins!!") score = calculate_score(p1) else: print("P2 wins!!") score = calculate_score(p2) print("Part 1: ", score) def cr_config(p1,p2): return str(p1.deck) + str(p2.deck) def play_turn_2(p1, p2, depth, round_c): print("|" * depth + " " + str(round_c)) p1_card = p1.pop() p2_card = p2.pop() if p1_card <= len(p1.deck) and p2_card <= len(p2.deck): subgame_winner = play_rc_game(Deck(p1.deck[:p1_card]),Deck(p2.deck[:p2_card]), depth + 1) if subgame_winner == 0: print("P1 guanya subjoc") p1.push(p1_card) p1.push(p2_card) else: print("P2 guanya subjoc") p2.push(p2_card) p2.push(p1_card) return 0 if p1_card > p2_card: print("P1 guanya ", p1_card, " a ", p2_card) p1.push(p1_card) p1.push(p2_card) else: print("P2 guanya ", p2_card, " a ", p1_card) p2.push(p2_card) p2.push(p1_card) # print(p1.deck) # print(p2.deck) def play_rc_game(p1, p2, depth): configurations = [] round_counter = 1 while len(p1.deck) > 0 and len(p2.deck) > 0: conf = cr_config(p1,p2) if conf in configurations: return 0 #P1 wins else: configurations.append(conf) play_turn_2(p1, p2, depth, round_counter) round_counter += 1 if len(p1.deck) > 0: print("P1 wins!!") return 0 # P1 wins else: print("P2 wins!!") return 1 # P2 wins def part_2(): p1 = Deck(read_input(filename_1)) p2 = Deck(read_input(filename_2)) winner = play_rc_game(p1, p2, 1) if winner == 0: print("P1 wins!!!") score = calculate_score(p1) else: print("P2 wins!!!") score = calculate_score(p2) print("Part 2: ", score) part_2()
nome = input('Olá! Qual é o seu nome?') print('Olá', nome , '!','seja muito bem vindo ao mundo da programação') # aaaaaaaaaaaaaaaaaaaaaaaaaaa a jfkdls fjdka fdjkla fjkdlsa jdksfla fjkdsla
def binarySearch(arr,low,high,element): while low<high: mid=int((low+high)/2) if(arr[mid]==element): return mid+1; elif(arr[mid]<element): low=mid+1 else: high=mid-1 return low if arr[low]>element else low+1 def binaryInsertionSort(arr): for i in range(1,len(arr)): low,high=0,i-1 p=binarySearch(arr,low,high,arr[i]) j=i elementToBePlaced=arr[i] while j>=p: arr[j]=arr[j-1] j-=1 arr[p]=elementToBePlaced for i in range(len(arr)): print(str(arr[i]),sep=' ') if __name__=="__main__": arr = [40, 24, 1, 2, 25, 50] binaryInsertionSort(arr)
class Node: def __init__(self, lchild = None, rchild = None, value = -1, data = None): self.lchild = lchild self.rchild = rchild self.value = value self.data = data class Bst: """Implements Binary Search Tree""" def __init__(self): self.l = [] #nodes self.root = None def add(self, key, dt): """Add a node in tree""" if self.root == None: self.root = Node(value = key, data = dt) self.l.append(self.root) return 0 else: self.p = self.root while True: if self.p.value > key: if self.p.lchild == None: self.p.lchild = Node(value = key, data = dt) return 0 #success else: self.p = self.p.lchild elif self.p.value == key: return -1 # value already in tree else: if self.p.rchild == None: self.p.rchild = Node(value = key, data = dt) return 0 # success else: self.p = self.p.rchild return -2 #should never happen def search(self, key): """Searches Tree for a key and returns data; if not found returns None""" self.p = self.root if self.p == None: return None while True: # print self.p.value, self.p.data if self.p.value > key: if self.p.lchild == None: return None #Not Found else: self.p = self.p.lchild elif self.p.value == key: return self.p.data else: if self.p.rchild == None: return None #Not Found else: self.p = self.p.rchild return None #Should never happen def deleteNode(self, key): """Deletes node with value == key""" if self.root.value == key: if self.root.rchild == None: if self.root.lchild == None: self.root = None else: self.root = self.root.lchild else: self.root.rchild.lchild = self.root.lchild self.root = self.root.rchild return 1 self.p = self.root while True: if self.p.value > key: if self.p.lchild == None: return 0 #Not found anything to delete elif self.p.lchild.val == key: self.p.lchild = self.proceed(self.p, self.p.lchild) return 1 else: self.p = self.p.lchild # There's no way self.p.value to be equal to key! if self.p.value < key: if self.p.rchild == None: return 0 #Not found anything to delete elif self.p.rchild.value == key: self.p.rchild = self.proceed(self.p, self.p.rchild) return 1 else: self.p = self.p.rchild return 0 def proceed(self, parent, delValue): if delValue.lchild == None and delValue.rchild == None: return None elif delValue.rchild == None: return delValue.lchild else: return delValue.rchild def sort(self): self.__traverse__(self.root, mode = 1) def __traverse__(self, v, mode = 0): """Traverse in: preorder = 0, inorder = 1, postorder = 2""" if v == None: return if mode == 0: print (v.value, v.data) self.__traverse__(v.lchild) self.__traverse__(v.rchild) elif mode == 1: self.__traverse__(v.lchild, 1) print (v.value, v.data) self.__traverse__(v.rchild, 1) else: self.__traverse__(v.lchild, 2) self.__traverse__(v.rchild, 2) print (v.value, v.data) def main(): tree = Bst() tree.add(4, "test1") tree.add(10, "test2") tree.add(23, "test3") tree.add(1, "test4") tree.add(3, "test5") tree.add(2, "test6") #tree.sort() print tree.search(3) print tree.deleteNode(10) print tree.deleteNode(23) print tree.deleteNode(4) print tree.search(3) tree.sort() if __name__ == "__main__": main()
def makeIteration(previous_set, base_set, bound): new_set = set() for x in base_set: for y in previous_set: if x*y < bound: new_set.add(x*y) return new_set def isPrime(x): if x < 2: return False if x == 2: return True for i in xrange(2, int(x**0.5) + 2): if 0 == x % i: return False return True BOUND = 10**8 ITERS = BOUND / 2 + 1 TOP = 5 base_set = set( filter(isPrime, range(2,TOP + 1))) print 'base', base_set previous_set = range(1, TOP + 1) print previous_set for x in xrange(ITERS): previous_set = makeIteration(previous_set, base_set, BOUND) print len(previous_set)
def triangle(n): return n*(n-1)/2 def pentagonal(n): return n*(3*n-1)/2 def hexagonal(n): return n*(2*n - 1) tri_set = set() pent_set = set() hex_set = set() #n1, n2, n3 = 1,1,1 for t in xrange(1, 100000): tri = triangle(t) if ((tri in pent_set) and (tri in hex_set)): print tri else: tri_set.add(tri) pent_set.add(pentagonal(t)) hex_set.add(hexagonal(t))
# arrays 1 import array as arr ar = arr.array('I', [2, 3, 3, 3, 4]) for i in range(0, len(ar)): print(ar[i]) ar.append(8) print(ar) ar.reverse() print(ar) print(str(ar.itemsize)) print(str(ar.buffer_info())) freq = 0 for i in ar: if (i == 3): freq = freq + 1 print(freq) ar.extend(list([8, 6, 48])) print(ar) ar = ar + arr.array('I', [14, 15, 16]) print(ar) ar = arr.array('I', [1]) + ar print(ar) ar.remove(3) print(ar) ar.pop(4) print(ar) # arrays 2 ar = arr.array('I', [1, 2, 3, 4, 34]) if len(set(ar)) == (len(ar)): print("false") else: for i in ar: if(ar.count(i) > 2): print("true") break # arrays 3 ar = arr.array('I', [23, 12, 23, 45, 56, 12]) for i in ar: if(ar.count(i) > 1): print(i) break if i == ar[len(ar)-1]: print(-1)
def bsort(arr): for i in range(len(arr)): for j in range(0,len(arr)-i-1): if arr[j] > arr[j+1]: arr[j],arr[j+1] = arr[j+1],arr[j] for x in range(len(arr)): print(arr[x]) print("iteration") bsort([45,3,78,54,4])
class stack(): def __init__(self): self.stack = [] def isEmpty(self): return self.stack == [] def push(self,item): self.stack.append(item) def pop(self): data = self.stack[-1] # returns the last element added, -2 would give second last etc del self.stack[-1] return data def peek(self): return self.stack[-1] def size(self): return len(self.stack) #instantiate stack and call methods
def fib(n): a,b = 0,1 while a < n: print(a,end =' ')#appends with space instead of newline a,b = b,a+b def area(b,h): a = b * h * 0.5 return a moves = 0 def hanoi(d,l,r,m): while d>1: hanoi(d-1,l,m,r) print("move disk from ",l," to ",r) hanoi(d-1,m,r,l) def fact(n): if n==0 or n==1: return 1 else: return n*fact(n-1) def var(*x): print(x) var("1",123,2.11,True) print("3! =",fact(3)) #hanoi(3,"left","right","middle") fib(3) print("area =",area(2,3)) print("area =",area(b=2,h=3)) print("area =",area(h=3,b=2))# any order
import unittest from format_a_name import format_name """ This file tests both objects with the assertEqual tests to compare input values with the expected values that the program should return. """ class NamesTestCase(unittest.TestCase): """test for the format name function""" def test_first(self): """test names with middle names""" test_name = format_name('John', '', 'Doe') self.assertEqual(test_name, 'John Doe') def test_with_middle(self): """test names with middle names""" test_name = format_name('Jane', 'Nancy', 'Doe') self.assertEqual(test_name, 'Jane Nancy Doe') if __name__ == '__main__': unittest.main()
#File: Assignment_5_1_LewisRebecca.py #Name: Rebecca Lewis #Date: April 12, 2019 #Course: DSC 510 #Usage: Calculator def performCalculation(operator): '''prompt the user to enter two numbers and perform a calculation. print the calculated value''' x,y = input("Enter two numbers separated by a comma:\n").split(",") #check to make sure a number was entered by converting it to a float data type. #if a number is not entered, a while loop will continue to prompt the user until a number is entered try: x = float(x) y = float(y) except: error = True while error: x,y = input("Invalid Entry. Enter two numbers separated by a comma:\n").split(",") try: x = float(x) y = float(y) error = False except: error = True if operator == "+": print("The answer of", x, "plus", y, "is", x + y, ".") elif operator == "-": print("The answer of", x, "minus", y, "is", x - y, ".") elif operator == "*": print("The answer of", x, "times", y, "is", x * y, ".") elif operator == "/": print("The answer of", x, "divided by", y, "is", x / y, ".") else: print("Invalid operator. Please try again. \n") def calculateAverage(): '''prompt the user for the quantity of numbers to input, loop to calculate total and average, print the calculated average''' numQty = input("How many numbers would you like to enter?\n") #check to make sure a number was entered by converting it to an int data type. #if a number is not entered, a while loop will continue to prompt the user until a number is entered try: numQty = int(numQty) except: error = True while error: numQty = input("Invalid entry, please enter a number\n") try: numQty = int(numQty) error = False except: error = True totalsum = 0 for iterVar in range(numQty): currentnumber = input("Enter a number:\n") #if input is invalid - we continue with another interation. To ensure we are collected the correct number of variables #we reduce the iteration value try: currentnumber = float(currentnumber) except: error = True while error: currentnumber = input("Invalid entry, please enter a number\n") try: currentnumber = float(currentnumber) error = False except: error = True totalsum = totalsum + float(currentnumber) print("Average = ", totalsum / numQty) #welcome message print("Welcome to the DSC 510 Calculator!") #allow the user to run through the program until stop is typed. operation = None while operation != "stop": #prompt the user for the operation they want to perform operation = input("Enter a math operation to perform or 'stop' to quit: (+, - , * , / , avg)\n") #call performCalculation function for addition, subtraction or division #call calculateAverage function for average #if anything other than the preferred operators or 'stop' is entered, prompt the user again for a valid operation if operation in ("+", "-", "*", "/"): performCalculation(operation) elif operation == "avg": calculateAverage() elif operation != "stop": print("You have entered an incorrect value. Please try again") continue
import random def bogo(scrambled, match): scrambled, MATCH = reformat(scrambled), reformat(match) count = 0 while scrambled != MATCH: random.shuffle(scrambled) count += 1 print('ITERATIONS: ', count) def reformat(string): return list(string.lower()) bogo('lolhe', 'hello')
from random import randrange def fallout_hacking(filename): LEGNTH, COUNT = introduction() words = Words('words.txt', LENGTH, COUNT) game = Game(words) player = Player() words.output() while player.has_guesses: game.turn(player) class Words: def __init__(self, filename, LENGTH, COUNT): self.LENGTH = LENGTH self.COUNT = COUNT self.filename = filename self.proper_length = Words.get_same_length_words(self) self.group = Words.randomly_select_words(self) self.winner = Words.randomly_select_a_word(self) def get_same_length_words(self): words = [] lines = open(self.filename).readlines() for word in lines: word = word.strip() if len(word) == self.LENGTH: words.append(word) return words def randomly_select_words(self): words = self.proper_length selected = [] for i in range(self.COUNT): random_index = randrange(len(words)) word = words.pop(random_index) selected.append(word) return selected def randomly_select_a_word(self): random_index = randrange(self.COUNT) return self.group[random_index] def output(self): for word in self.group: print(word.upper()) def introduction(): difficulty = ['1', '2', '3', '4', '5'] message = 'Difficulty (1-5)?' level = get_input(difficulty, message) LENGTH, COUNT = set_difficulty(level) return LENGTH, COUNT def get_input(options, message): choice = input(message).lower() while choice not in options: choice = input(options).lower() return choice def set_difficulty(level): level = int(level) LENGTH = 5 + 2 * level COUNT = level ** 2 return LENGTH, COUNT class Player: def __init__(self): self.has_guesses = 4 class Game: def __init__(self, words): self.group = words.group self.winner = words.winner self.LENGTH = words.LENGTH def turn(self, player): message = 'You have guesses ' + str(player.has_guesses) + ' left ' guess = get_input(self.group, message) if guess == self.winner: player.has_guesses = False print('you win') else: correct = get_number_of_matches(self.winner, guess) print(correct, '/', self.LENGTH, ' correct', sep='') player.has_guesses -= 1 def get_number_of_matches(word, comparison): count = 0 for letter, character in zip(word, comparison): if letter == character: count += 1 return count fallout_hacking('words.txt')
import random def game(lower=1, upper=101): response = '' count = 0 while response != 'correct': guess = random.randrange(lower, upper) response = get_user_input(guess) lower, upper = set_bounds(response, lower, upper, guess) count += 1 print_statistics(guess, count) def get_user_input(guess): response = input('Is {0} higher, lower, or correct?'.format(guess)).lower() options = ['higher', 'lower', 'correct'] while response not in options: response = input(options).lower() return response def set_bounds(response, lower, upper, guess): if response == 'lower': return lower, guess return guess, upper def print_statistics(guess, count): print('The number is {0}, and it took {1} trys.'.format(guess, count)) game()
from math import sqrt, asin, acos, sin, cos, pi def main(): triangle = Triangle(a=3, b=4, C=90) while triangle.is_solved() == False: triangle = law_of_sines(triangle) triangle.sides = pythagorean_theorem(triangle.sides) triangle.angles = solve_for_an_angle(triangle.angles) return triangle.sides class Triangle: def __init__(self, a=0, b=0, c=0, A=0, B=0, C=0): self.sides = [a, b, c] self.angles = [A, B, C] self.side_count = len(undefined_occurrences(self.sides)) self.angle_count = len(undefined_occurrences(self.angles)) def is_solved(self): UNKKNOWN = 0 try: self.sides.index(UNKKNOWN) #self.angles.index(UNKKNOWN) return False except ValueError: return True def undefined_occurrences(sequence, find=0): return [i for i, x in enumerate(sequence) if x == find] def pythagorean_theorem(sides): side1, side2, hypotenuse = sides if is_unknown(hypotenuse): found_side = hypotenuse_from_sides(side1, side2) else: found_side = solve_for_side(side1, side2, hypotenuse) return insert_value(sides, found_side) def is_unknown(item): UNKKNOWN = 0 return item == UNKKNOWN def hypotenuse_from_sides(side1, side2): return sqrt(side1**2 + side2**2) def solve_for_side(side1, side2, hypotenuse): known_side = side2 if is_unknown(side2): known_side = side1 return sqrt(hypotenuse**2 - known_side**2) def insert_value(sequence, value): REPLACE = 0 sequence[sequence.index(REPLACE)] = value return sequence def solve_for_an_angle(angles): found_angle = 180 for angle in angles: found_angle -= angle return insert_value(angles, found_angle) def law_of_sines(triangle): angles = triangle.angles sides = triangle.sides angle_indices = undefined_occurrences(angles) side_indices = undefined_occurrences(sides) if len(angle_indices): angles = two_sides_and_angle(sides, angles, angle_indices, side_indices) #else: # sides[] def two_angles_and_side(sides, angles, angle_indices, side_indices): """Given two angles and a side, finds a second side.""" i = side_indices unknown_index = other(angle_indices, i) #found = def two_sides_and_angle(sides, angles, angle_indices, side_indices): """Given two sides and an angle, finds a second angle.""" i = angle_indices[0] unknown_index = other(side_indices, i) found = asin((sides[i] * sin(angles[unknown_index])) / sides[i]) angles[unknown_index] = found return angles def _sin(radians): """Radains to degrees""" return 180 * sin(radians) / pi def other(sequence, find): for item in sequence: if item != find: return item print _sin(90)
def get_information(): user = {} prompts = {'name': 'What\'s your name?', 'age': 'How old are you?', 'username': 'What\'s your reddit username?'} for prompt in prompts: user[prompt] = input('{0} :'.format(prompts[prompt])) print('Your name is {0}, you are {1} years old, and your username is {2}'.format(user['name'], user['age'], user['username'])) get_information()
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import combinations_with_replacement a,b = input().split() for i in combinations_with_replacement(sorted(a),int(b)): print("".join(i))
# Program:Debug #01# Due Date: 10/3/18# Programmer: <your name># Description: This program will track the number of calories burned after # 10, 15, 20, 25, and 30 minutes given that you burn 4.2 calories# per minute.# Note: It should not print calories burned after 5 minutes. # Declare variables and constants Counter = 5 CaloriesPerMinute = 4.2 TotalCalories = 0 # Get user input Name = input("Enter your name: ") # Calculate and display calories burned print("\nHere are the calories burned for ", Name) print("\nMinutes","Total Calories") TotalCalories = TotalCalories + CaloriesPerMinute *10 print(Counter, "\t") Counter = Counter while Counter <= 30: TotalCalories = TotalCalories + CaloriesPerMinute * 5 print(Counter, "\t", TotalCalories) Counter = Counter + 5
#Variables months = int() weeks = int() week_value = int() month_total = int() month_average = float() total_inches = int() ave_inches = float() # Outer loop to determin how nuch snow fell in total for months in range(1,6): # Inner loop determine the monthly total for weeks in range(1,5): week_value = int(input("Enter your weekly snow fell(in inches): ")) # Accumulating month_total = month_total + week_value #End foor loop month_average = month_total / weeks # Add Month total to total inches total_inches = total_inches+ month_total # Printout monthly total and average print() print("monthly total:\t", month_total) print("month average:\t", month_average) #Reset month total to start a new month month_total = 0 # End For ave_inches = total_inches/months #print out and average print("Total snow fall:\t", total_inches) print("Total average inches:\t", ave_inches)
#2/24/2020 import random #Declare Variables guess = int() game_number = int() user_answer = str() counter = int() user_answer = "Y" # Loop to play a Game while user_answer == "Y": game_number = random.randint(1,50) # For Loop for counter in range(0, 3): #ask user for their gues guess = int(input("Enter your guess: ")) #Determine if the user guessed the number if guess == game_number: print("Congratulations You Won!") break elif guess < game_number: print("Guess a Little Higher") else: print("Guess a Little Lower") #end if #End loop #Displaying the message if the user did not win if guess != game_number: print("Sorry you did not win.") #end if print("The number was: ",game_number) user_answer = input("Did you want to continue (Y or N):" )
# Declare variables letterGrade = str() score = int() score = int(input("Enter your test score: ")) # If and else statment if score <= 70: letterGrade = "C" print(letterGrade) elif score <= 80: letterGrade = "B" print(letterGrade) elif score <= 90: letterGrade = "A" print(letterGrade) # Print print("Your Grade is: " , letterGrade)
def include_members(policy: dict, role_members: dict) -> (bool, dict): """ Include a set of members with specific roles in an IAM policy. Args: policy: The policy to include the role members in. role_members: A mapping of role names to iterables of members. Returns: A two-element tuple containing a boolean indicating if the policy changed as a result of the member inclusion and the resulting IAM policy. """ bindings = policy.get('bindings', []) is_modified = False # Track which roles have been found in the policy roles_found = {key: False for key in role_members.keys()} # Look for existing role bindings that need to be modified. for binding in bindings: role = binding.get('role') if role in role_members: roles_found[role] = True for member in role_members[role]: if member not in binding['members']: is_modified = True print(f"Need to add '{member}' to '{role}'") binding['members'].append(member) # Add bindings for roles that did not yet have bindings for role, was_found in roles_found.items(): if not was_found: is_modified = True print(f"Need binding for '{role}'") bindings.append({ "members": list(role_members[role]), "role": role, }) return is_modified, {"bindings": bindings}
name=input("Enter String to be reversed") str="" for i in name: #print(i,"\n") str=i+str print(str)
num=int(input("Enter a Number")) sum=0 for i in range(1,num+1): sum=sum+i print(sum)
list1=[[1,1],[1,1]] list2=[[1,2],[1,2]] list3=[[0,0],[0,0]] count=0 for i in range (0,2): for j in range(0,2): if list1[i][j]==list2[i][j]: count=count+1 print(count,"are the number of matching corresponding elements")