text stringlengths 5 121k |
|---|
import queue
def nextNode(trie,currentNode,letter):
nextNodes = len(trie[str(currentNode)][1])
if nextNodes == 0:
return None
else:
for i in range(nextNodes):
nextNode = trie[str(currentNode)][1][i]
if trie[str(nextNode)][0][-1] == letter:
... |
n = int(input())
if n <= 2:
print('NONE')
quit()
if n == 5:
print(0,1)
quit()
three = 0
four = n // 4
n = n % 4
if n == 2:
four -= 1
three = 2
n = 0
elif n == 1:
four -= 2
three = 3
elif n == 3:
three = 1
print(str(three)+'\n'+str(four)) |
"""
EXAMPLES:
delete_nth ([1,1,1,1],2) # return [1,1]
delete_nth ([20,37,20,21],1) # return [20,37,21]
"""
def delete_nth(order, max_e):
simple = list()
for i in order:
if simple.count(i) < max_e:
simple.append(i)
return simple
|
"""
Created on Wed Sep 11 21:41:35 2019
@author: aquib
"""
def is_leap(year):
leap = False
if year%4==0:
leap=True
if year%100==0:
leap=False
if year%400==0:
leap=True
return leap
|
"""
Created on Thu Sep 12 02:43:36 2019
@author: aquib
"""
class Complex(object):
def __init__(self, real, imaginary):
self.real=real
self.imaginary=imaginary
def __add__(self, no):
return Complex(self.real+no.real, self.imaginary+no.imaginary)
def __sub__(self, no):
... |
"""
Created on Thu Sep 12 02:43:22 2019
@author: aquib
"""
def print_from_stream(n, stream=None):
if stream is None:
stream=EvenStream()
for _ in range(n):
print(stream.get_next())
|
"""
Created on Wed Sep 11 21:54:10 2019
@author: aquib
"""
num_e=int(input())
roll_e=set(map(int,input().split()))
num_f=int(input())
roll_f=set(map(int,input().split()))
diff=roll_e-roll_f
print(len(diff),end='')
|
"""
Created on Wed Sep 11 21:52:43 2019
@author: aquib
"""
num_e=int(input())
roll_e=list(map(int, input().split()))
num_f=int(input())
roll_f=list(map(int,input().split()))
total=roll_e+roll_f
print(len(set(total)),end='')
|
"""
Created on Wed Sep 11 22:12:23 2019
@author: aquib
"""
import re
valid_structure = r"[456]\d{3}(-?\d{4}){3}$"
no_four_repeats = r"((\d)-?(?!(-?\2){3})){16}"
filters=valid_structure, no_four_repeats
output=[]
num_cc=int(input())
for _ in range(num_cc):
cc=input()
if all(re.match(f, cc) for f in filters... |
"""
Created on Wed Sep 11 22:23:14 2019
@author: aquib
"""
if __name__ == '__main__':
s = input()
print(any([c.isalnum() for c in s]))
print(any([c.isalpha() for c in s]))
print(any([c.isdigit() for c in s]))
print(any([c.islower() for c in s]))
print(any([c.isupper() for c in s]))
|
"""
Created on Wed Sep 11 22:09:07 2019
@author: aquib
"""
setA=set(map(int,input().split()))
cond=[]
numB=int(input())
for _ in range(numB):
setB=set(map(int,input().split()))
cond1=all([b in setA for b in setB])
cond2=len(setA)>len(setB)
cond.append(cond1 and cond2)
print(all(cond),end='')
|
from compare import cmp
def heapsortCmp(c, A):
def heapify(c, A):
start = (len(A) -2) / 2
while (start >= 0):
fixdown(c, A, start, len(A) - 1)
start -= 1
def fixdown(c, A, start, end):
root = start
while root * 2 + 1 <= end:
child = root * 2 + 1
if (child + 1 <= end and cmp(c, A[child],... |
import os
def reverse(num):
rev = 0
while (num > 0):
rem = num % 10
rev = (rev * 10) + rem
num = num // 10
return rev
def beautifulDays(i, j, k):
count = 0
for num in range(i, j + 1):
rev = reverse(num)
if (abs(num - rev) % k) == 0:
count... |
import os
def appendAndDelete(s, t, k):
common_length = 0
for i, j in zip(s, t):
if i == j:
common_length += 1
else:
break
if ((len(s) + len(t) - 2 * common_length) > k):
return "No"
elif ((len(s) + len(t) - 2 * common_length) % 2 == k % 2... |
def number_spiral(ind1, ind2):
diagnol = 0
if ind1 == ind2:
print(ind2*(ind2-1) + 1)
return
if ind1 < ind2:
diagnol = ind2*(ind2-1) + 1
if ind2%2 == 0:
print(diagnol - (ind2 - ind1))
else:
print(diagnol + (ind2 - ind1))
elif ind1 > i... |
import random
def merge(left, right):
global swaps
left_pointer = 0
right_pointer = 0
res = []
if left == None:
return right
if right == None:
return left
while left_pointer < len(left) and right_pointer < len(right):
if left[left_pointer] < right[right_pointer... |
import time
def bubble_sort(arr):
n = len(arr)
for i in range(n - 1, 0, -1):
for j in range(i):
if arr[j] > arr[i]:
arr[j], arr[i] = arr[i], arr[j]
print(arr)
arr = [int(x) for x in input().split()]
arr1 = arr.copy()
start = time.... |
def repetitions(string):
longest = 1
curr_long = [string[0]]
for i in range(1, len(string)):
if string[i] == string[i - 1]:
curr_long.append(string[i])
else:
if len(curr_long) > longest:
longest = len(curr_long)
curr_long = [... |
ans = 0
def queens_rec(q_no, taken, taken_clone, diff_arr, main_board):
global ans
if q_no == 2:
ans += 1
for i in range(8):
for j in range(8):
if main_board[i][j] != ".":
continue
else:
if i in t... |
from collections import defaultdict
def find_climb(n, steps):
dp = defaultdict(lambda:[0] * (n + 1))
steps = [0] + steps
dp[0][0] = 1
for i in range(1, len(steps)):
if steps[i] > n:
continue
dp[i][:steps[i]] = dp[i - 1][:steps[i]]
for j in range(steps[i], n... |
diff = 0
final_ans = 0
def division_rec(arr, i, s, target):
global diff
global final_ans
if i == -1:
return
if abs(s - target) < abs(diff):
final_ans = s
diff = s - target
return division_rec(arr, i - 1, s, target) or division_rec(arr, i - 1, s - arr... |
import random
def merge(left, right):
left_pointer = 0
right_pointer = 0
res = []
while left_pointer < len(left) and right_pointer < len(right):
if left[left_pointer] < right[right_pointer]:
res.append(left[left_pointer])
left_pointer += 1
else:
... |
import tkinter
james_root = tkinter.Tk()
james_root.title("Harrison GUI")
james_root.geometry("1020x920")
def left_click(event):
tkinter.Label(text = "Left Click!!!").pack()
def middle_click(event):
tkinter.Label(text = "Middle Click!!!!").pack()
def right_click(event):
tkinter.La... |
import scrabble
longest_word_length_so_far = 0
longest_words = []
for word in scrabble.wordlist:
if word[0] == 'q':
current_word_length = len(word)
if current_word_length == longest_word_length_so_far:
longest_words.append(word)
elif current_word_length ... |
import scrabble
for letter in "abcdefghijklmnopqrstuvwxyz":
exists = False
for word in scrabble.wordlist:
if letter + letter in word:
exists = True
break
if not exists:
print("There are no English words with a double " + letter)
|
import math
t=int(input())
while(t!=0):
n=int(input())
if(n==0):
print("1")
else:
print(math.factorial(n))
t=t-1 |
def findPath(maze, start,end) :
qu = list()
visited = set()
result = list()
qu.append(start)
visited.add(start)
while qu :
path = qu.pop(0)
print(path)
print('v', visited)
v = path[-1]
if v == end :
result.append(path)
... |
def linearSearch_2(listofNum, findNumList):
numidxList = list()
for i in range(0, len(listofNum)):
for findNum in findNumList :
if listofNum[i] == findNum :
numidxList.append(i)
findNumList.remove(findNum)
return numidxList
def linearSearch_3(listofNum... |
def binarySearch(listofNum, num) :
start = 0
end = len(listofNum)-1
while start <= end :
mid = (start+end) //2
if listofNum[mid] == num :
return mid
elif listofNum[mid] < num :
start = mid +1
elif listofNum[mid] > num :
end = mid-1
... |
a = int(input())
for i in range(a):
x = int(input())
m = set(map(int,input().split()))
y = int(input())
n = set(map(int,input().split()))
if(m.intersection(n)==m):
print("True")
else:
print("False")
|
import math
n1=list(map(int,input().split()))
n2=float(input())
n3=list(map(int,input().split()))
def norm(x):
c=0.5+0.5*math.erf((x-n1[0])/(n1[1]*math.sqrt(2)))
return c
a=norm(n2)
print("%.3f"%a)
b=norm(n3[1])
d=norm(n3[0])
z=b-d
print("%.3f"%z)
|
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if x <= -2**31 or x >= 2**31-1:
return 0
xString = str(x)
if(x < 0):
xString = xString[1:]
reserved = "-" + xString[::-1]
... |
class Solution(object):
def productExceptSelf(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
length = len(nums)
left = [0]*length
right = [0]*length
result = [0]*length
if(length == 1):
return [0]
... |
class Solution(object):
def isIsomorphic(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
exist1 = {}
exist2 = {}
pattern1 = []
pattern2 = []
for i in range(len(s)):
if(s[i] not in exist1):
... |
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def mergeTwoLists(self,l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
... |
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def isSameTree(self, p, q):
if not p and not q:
return True
if not p or not q:
... |
def digits(number):
return [int(d) for d in str(number)]
def bulls_and_cows(guess, target):
guess, target = digits(guess), digits(target)
bulls = [d1 == d2 for d1, d2 in zip(guess, target)].count(True)
bovine = 0
for digit in set(guess):
bovine += min(guess.count(digit), target.count(digit))
... |
import traceback
def main():
try:
print("before exception.")
raiseException()
print("after exception.")
except Exception as e:
print(traceback.format_exc())
else:
print("not exception.")
finally:
print("finally.")
def raiseException():
print("before ... |
names = ["John","Kwesi","Ama","Yaw"]
print(names[-1])
names = ["John","Kwesi","Ama","Yaw"]
print(names[::2])
names = ["John","Kwesi","Ama","Yaw"]
names[0] ="Jon"
print(names)
numbers = [3,4,9,7,1,3,5,]
max = numbers[0]
for number in numbers:
if number > max:
... |
is_hot = False
is_cold = True
if is_hot:
print("It's a hot day")
print("drink plenty of water")
elif is_cold:
print("It's a cold day")
print("Wear warm clothes")
else:
print("It's a good day")
pr... |
x=int(input())
count = 0
for i in range(1,x//2+1):
if(x%i==0):
count+=1
if(count==1):
print("yes")
else:
print("no")
|
x=list(input())
count=0
for k in x:
if((k=='a')or(k=='e')or(k=='i')or(k=='o')or(k=='u')):
count=count+1
if(count>0):
print("yes")
else:
print("no")
|
from src import *
def encrypt(start_text, keyword):
end_text = []
for e, let in enumerate(start_text):
if let.isalpha():
len_sum = char_position(let) + char_position(keyword[e])
end_text.append(pos_to_char(len_sum % 26, let))
else:
end_text.append(let)
re... |
with open("robin.txt") as f:
words = f.read()
split_words = words.split()
cache = {}
for word in split_words:
if word not in cache:
cache[word] = '#'
else:
cache[word] += '#'
items = list(cache.items())
items.sort(key = lambda x: x[1], reverse= True)
for key, value in items... |
class Solution:
def balancedStringSplit(self, s: str) -> int:
stack = []
res = 0
for i in s:
if len(stack)>0 and stack[-1]!=i:
stack.pop(-1)
if len(stack) == 0:
res += 1
else:
stack.append(i)
... |
def switch_statement(cases, value):
""" Simulate a swithc statement """
return cases[value] if value in cases else cases["default"] if "default" in cases else False
def extract_value_from_dict(parameter: str, values: dict):
""" Extract a value from values dict
Args:
parameter (str): What we ... |
'''
实现基数排序RadixSort, 分为:
最高位优先(Most Significant Digit first)法
最低位优先(Least Significant Digit first)法
'''
def radixSortLSD(alist):
if len(alist) == 0:
return
if len(alist) == 1:
return alist
tempList = alist
maxNum = max(alist)
radix = 10
while maxNum * 10 > radix:
newAr... |
nota = int(input("Digite a nota do aluno: "))
if nota >= 60:
print("Aprovado")
else:
print("Reprovado") |
import pyodbc
conn = pyodbc.connect('Driver={SQL Server};''Server=DESKTOP-CAFAM2K\SUJEETPATIL;''Database=Agsdb;''Trusted_Connection=yes;')
mycursor = conn.cursor()
mycursor.execute("select * from table1")
for row in mycursor:
print(row) |
def partition(the_list, p, r, compare_func):
pivot = the_list[r]
i = p-1
j = p
while not j == r:
if compare_func(the_list[j], pivot):
i += 1
temp = the_list[i]
the_list[i] = the_list[j]
the_list[j] = temp
... |
import random
n = random.randint(1, 99)
g = int(input("ENTER A NUMBER FROM 1-99: "))
while n != g:
print
if g < n:
print ("guess is low")
g = int(input("ENTER A NUMBER FROM 1-99: "))
elif g > n:
print ("guess is high")
g = int(input("ENTER A NUMBER FROM 1-99: "))
... |
def sod():
n=int(input("Enter a number:"))
tot=0
while(n>0):
dig=n%10
tot=tot+dig
n=n//10
print("The total sum of digits is:",tot)
sod()
|
import pygame
pygame.init()
white = (255, 255, 255)
red = (255, 0, 0)
black = (0, 0, 0)
screen_width = 900
screen_height = 600
gameWindow = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("SnakesWithSunny")
pygame.display.update()
exit_game = False
game_over = Fa... |
"""
Author - Aiman
Date : 6/Dec/2019
Write a program which will find factors of given number and find whether the
factor is even or odd.
"""
given_number=9
sum=1
while given_number>0:
sum=sum*given_number
given_number-=1
print(sum)
if sum%10!=0:
print("odd number")
else:
print("Even number")
|
name = "Nurul Iman"
if len(name) < 3:
print("Less than 3")
elif len(name) > 50:
print("More than 50")
else:
print("Name look good")
|
"""
In this exercise, you'll be playing around with the sys module,
which allows you to access many system specific variables and
methods, and the os module, which gives you access to lower-
level operating system functionality.
"""
import sys
print("sys.argv command line arguments, one per line:")
print(sys.argv, '... |
""" combineString """
def main():
""" Write a Python program to get a single string from two given strings, s
eparated by a space and swap the first two characters of each string. """
data = input()
data2 = input()
print(data2 +" " + data)
main()
|
""" Coffee Shop """
def main():
"""The IT coffee shop sells 3 different types of coffess as follows:
Robusta coffee 390 baht per kg, ***Promotion Free 2 kg of Robusta coffee,
every 15 kg Robusta coffee order.
Liberica coffee 380 baht per kg, ***Promotion Free 2 kg of Liberica coffee,
every 15 kg Lib... |
""" dayOfWeek """
def main():
""" dayOfWeek """
import datetime
date = input()
day, month, year = date.split(":")
day, month, year = int(day), int(month), int(year)
dayofweek = datetime.date(year, month, day).strftime("%A")
print(dayofweek)
main()
|
line = int(input("Enter the total line to print:"))
for i in range(1,line+1):
for j in range (i,line):
print(' ', end='')
for k in range (0, 2*i-1):
print('*', end='')
print() |
names = ['Bruce', 'Art', 'Peter', 'Tony', 'Steve']
heros = ['Batman', 'Joker', 'Spiderman', 'Iron Man', 'Captain America']
print(list(zip(names, heros)))
my_dict = {}
my_dict = {name: hero for name, hero in zip(names, heros) if name != 'Peter'}
print(my_dict)
|
line = int(input("Enter the total line to print:"))
for x in range(1,line+1):
for y in range(1, x+1):
print('* ', end="")
print() |
def packing(*args):
sum = 0
for x in range (0, len(args)):
sum += args[x]
return sum
print(packing(1,2,3,4,5)) |
class Dog():
species = 'Mammal'
myDogBreed = ['Lab', 'German', 'Country']
def __init__(self, breed, name):
self.breed = breed
self.name = name
def bark(self):
for breed in Dog.myDogBreed :
if self.breed == breed:
print('Woof!!!')
brea... |
def collatz(number):
if number % 2 == 0:
print(number/2)
else:
print(number * 3 + 1)
collatz(3)
collatz(4) |
pair = int(input('Enter the total pair of numbers:'))
list1 = []
list2 = []
for i in range(0,pair):
number1, number2 = input().split()
list1.append(int(number1))
list2.append(int(number2))
min = []
for i in range(0,pair):
if list1[i] > list2[i]:
min.append(list2[i])
else:
min.appen... |
from sys import argv
script, fileName = argv
txt = open(fileName)
print('The opened file {}', fileName)
print(txt.read())
fileAgain = input('Enter the file name again:')
print('The opened file {}', fileAgain)
txt_again = open(fileAgain)
print(txt_again.read()) |
myName = 'SKK'
myJob = 'Data Scientist'
print('My name is ', myName)
print('My Name is {}, and Im working as a {}'.format(myName, myJob))
x = 10
y = 20
print('The given value is:%i' % x)
print('The Values are: %i %i' % (x,y))
print('The Values are: %d %d' % (x,y))
for i in range(11):
print('Number:{:.2f}'.format(... |
def make_bricks(small, big, goal):
return (goal%5)<=small and (goal-(big*5))<=small
print(make_bricks(3,1,8))
print(make_bricks(3, 2, 9)) |
class ExampleClass:
def __init__(self, val = 1):
self.first = val
def setSecond(self, val):
self.second = val
exampleObject1 = ExampleClass()
exampleObject2 = ExampleClass(2)
exampleObject2.setSecond(3)
exampleObject3 = ExampleClass(4)
exampleObject3.third = 5
print(exampleObject1.__dict_... |
nums = [1,1,1,2,2,2,2,3,3,4,4,4,5,5,5,5]
print(set(nums))
mySet = set()
for num in nums:
mySet.add(num)
print(mySet) |
pair = int(input('Enter the total pair of numbers:'))
list1 = []
list2 = []
for i in range(0,pair):
number1, number2 = input().split()
list1.append(int(number1))
list2.append(int(number2))
sum = []
for i in range(0,pair):
sum.append(list1[i]+list2[i])
for i in sum:
print(i, end=' ')
print() |
def isYearLeap(year):
if year % 4 == 0 and year % 100 != 0:
return True
elif year%100 == 0 and year%400 == 0:
return True
else:
return False
def daysInMonth(year, month):
if month in (1,3,5,7,8,10,12):
return 31
elif month in (4,6,9,11):
return 30
elif mo... |
nums = [1,2,3,4,5,6,7,8,9,10]
def gen_func(nums):
for n in nums:
yield n*n
my_gen = gen_func(nums)
print(list(my_gen)) |
def method_decorator(name, func):
def wrapper(cls):
def _dec(*args, **kwargs):
instance = cls(*args, **kwargs)
if hasattr(instance, name):
method = getattr(instance, name)
setattr(instance, name, func(method))
return instance
retur... |
favorite_languages = {
'jen': ['python', 'ruby'],
'sarah': ['c'],
'edwin': ['ruby', 'go'],
'phil': ['python', 'haskel'],
}
for name, languages in favorite_languages.items():
if len(languages) > 1:
print(f"\n{name.title()}'s favorite languages "
f"are: ")
elif len(languages... |
""" This is a Python script for running the ancient game of Ur. As I write this
on 05/07/2020, before actually coding anything, I hope it's not going to be too
complicated, but then again, you never know...
"""
from numpy.random import binomial
def roll_dice():
""" In Ur, instead of rolling one die (such as a D... |
def creditPayment(b,ai,mr):
b = b/1.0
annualInterestRate = ai
monthlyPaymentRate = mr
monthlyInterestRate = ai / 12.0
for i in range(12):
minimumMonthlyPayment = monthlyPaymentRate*b
b = b - minimumMonthlyPayment
b = b + b*monthlyInterestRate
print ("Remaining Balance: "+ str(i) + " " + str(round(b,2)))
r... |
str = input()
substr = 'G'
substr1 = 'C'
p = str.upper().count(substr)
p1 = str.upper().count(substr1)
print (((p + p1) / len(str)) * 100)
|
class Solution(object):
def reverseString(self, s):
def helper(left,right):
if left < right:
s[left], s[right] = s[right], s[left]
helper(left + 1, right - 1)
helper(0, len(s) - 1)
|
import random
default_options = ['paper', 'scissors', 'rock', 'paper', 'scissors', 'rock']
def game(points, possible_inputs, lenght = 3):
user_option = ''
while user_option != '!exit':
user_option = input()
computer_option = possible_inputs[random.randint(0, len(possible_inputs)-1)]
... |
import math
'''
getRoot gets a number; calculate a square root of the number;
separates 3 digits after
decimal point and converts them to list of numbers
'''
def getRoot(nb):
lsr=[]
nb=math.floor(((math.sqrt(nb))%1)*1000)
ar=str(nb)
for i in ar:
lsr.append(int(i))
return lsr
'... |
'''
Created on Oct 12, 2018
Scientific Notation
input: 9000
output: 9*10^3
@author: Roman Blagovestny
'''
def scinotdown(n):
cz=0
n=float(n)
if n<1 and n>-1:
while n<1 and n>-1:
cz+=1
n*=10
return str(n)+"*10^-"+str(cz)
if n>1 or n<-1:
whil... |
print('hello world!')
print('Count', 'of 100 + 200 is:', 100 + 200)
print('Hi, %s! You have %d emails!' % ('Momo', 8))
print('please type your name:')
name = raw_input()
print('hello,', name)
abc = raw_input('hey, please type something')
print('[format] your type is: {0}, another type {1}'.format(abc, 999))
print(... |
age = 10
if age > 18:
print('your age is', age)
elif age > 10 and age <= 18:
print('teenager')
else:
print('child')
l = []
if l:
print(True)
else:
print(False)
str = input('please input a integer:')
birth = int(str)
if birth > 2000:
print('00后')
else:
print('00前')
|
"""
Author: Luis_C-137
First example to compare epsilon greedy
"""
import numpy as np
import matplotlib.pyplot as plt
class Bandit:
def __init__(self,m):
self.m = m
self.mean = 0
self.N = 0
def pull(self):
return np.random.rand() + self.m
def update(self, x):
self.N += 1
self.mean = (1 -1.0/self.N)... |
from sklearn.cross_validation import KFold
import utils
import tensorflow as tf
import random
import pickle
num_iter = 2000
n_gram = 3
batch_size = 2
num_folds = 2
data_subset = 8
eval_acc_every = 10
num_classes = 5
keep_probability = 0.5
... |
import math
import random
import cmp
def getLength(x1, x2, y1, y2):
val = ((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))
result = math.sqrt(val)
return result
x1 = random.random() * 100
x2 = random.random() * 100
y1 = random.random() * 100
y2 = random.random() * 100
x11 = random.random() * 100
x12 =... |
class Solution:
def longestCommonPrefix(self, strs):
if not strs:
return ''
prefix = []
first = strs[0]
if not first:
return ''
strs = strs[1:]
for i, c in enumerate(first):
for s in strs:
if not s or i >= len(... |
class Solution:
def lengthOfLastWord(self, s):
w_list = filter(None, s.split())
if not w_list:
return 0
return len(w_list[-1])
|
class Node:
def __init__(self, nummer):
self.nummer = int(nummer)
self.friends = set()
def merge(self, b):
self.friends = self.friends|b.friends
b.friends = self.friends
self.friends.add(b)
b.friends.add(self)
def friends_with(self, b):
re... |
class Cup:
def __init__(self, color, size):
self.color = color
self.size = size
cases = int(input())
cups = []
for i in range(cases):
tmp = input().split()
if tmp[0].isnumeric():
cups.append(Cup(tmp[1], float(tmp[0])/2))
else:
cups.append(Cup(tmp[0], float(tmp[1])))... |
import re
patterns = [ 'Tuffy', 'Pie', 'Loki' ]
text = 'Tuffy eats pie, Loki eats peas!'
for pattern in patterns:
print('"%s"에서 "%s" 검색 중 ->' % (text, pattern),)
if re.search(pattern, text):
print('찾았습니다!')
else:
print('찾을 수 없습니다!')
text = 'Diwali is a festival of lights, Holi is a fes... |
myList=[10,11,12,13,14,15,16,17,18,19,20]
myOtherList=[0,0,0,0,0]
myEmptyList=[]
myOtherList=[]
i=0
while i<5:
myOtherList
print(myOtherList)
i=i+1
theFifthList=["a",5,"doodle",3,10]
print(len(theFifthList))
theFifthList.append(90)
print(theFifthList)
theFifthList[0]=8.4
print(theFifthList)
th... |
from tkinter import *
from textblob import TextBlob
from tkinter.messagebox import *
def select(event):
inputword.get()
def clearall():
inputword.delete(0,END)
correctedword.delete(0,END)
def correction():
input_word = inputword.get()
blob_obj = TextBlob(input_word)
corrected_word = str(blo... |
"""
@Project : text-classification-cnn-rnn
@Module : LongestPalindromicSubstring.py
@Author : Deco [deco@cubee.com]
@Created : 5/31/18 1:16 PM
@Desc :
5. Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s.
You may assume that the maximum length of s is 1000.
Exa... |
menu = ("""\nTELEFON REHBERIM
1. Rehbere isim ekle
2. Rehberden Kisi Sil
3. Rehber Guncelleme
4. Rehberi Listele
5. Cikis
""")
rehber = {}
while True:
print(menu)
secim = input("Seciminiz:\t")
if secim == "1":
print("Not: Rehberde tekrarlayan isim olmamaktadir.")
ad_soyad = input("Re... |
def substitionKeyCipher(userCipherText,userKey):
cipherText = convertToASCII(list(userCipherText))
key = convertToASCII(list(userKey))
def switchChar(cipherChar):
alphaPerm = 0
newChar = 0
while alphaPerm < len(alphabetASCII):
if cipherChar == key[alphaPerm]:
... |
class BankAccount:
def __init__(self, int_rate=.01, balance=0):
self.balance = balance
self.int_rate = int_rate
def deposit(self, amount):
self.balance += amount
return self
def withdraw(self, amount):
self.balance -= amount
return self
def display_account_info(self):
print("Balance:",self.balance,"In... |
class Anilam(object):
def __init__(self, name, age, num):
self.name = name
self.age = age
self.num = num
def drink(self):
print('----喝------')
def say(self):
print('-----看-----')
print('----张三增加的-----')
print('----陈金增加的-----')
print()
def main():
dog ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.