blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
6a15133453da0f79a666718ed57225fcd2b55dba | TangoMango223/Python-Practice-Code | /Hello-World/newmario.py | 581 | 4.25 | 4 | # Repeating some of the basic Mario instructions from the early C projects
#Print 4 lines of ? as with the Mario blocks
print("-----------------")
print("Print a row of ?????")
for i in range (4):
print("?", end = "") #use end = "" to stop each row from printing a new line.
print()
#Print a column of hashtags:
pr... |
93adbae482aabe3b9d08c492dcce66e5fe4aa299 | CA2528357431/python-note-list-pro | /03/main.py | 185 | 3.78125 | 4 | judge='x' in 'frankxx'
print(judge)
judge=1 in [1,2,3]
print(judge)
judge=1 in {1,2,3}
print(judge)
judge='a' in {'a':1,'b':2,'c':3}
print(judge)
judge=1 not in [1,2,3]
print(judge) |
15b1aff6a6ad30c6e3619b551327cc800636758f | chrismvelez97/scrape_menu_to_csv | /don_scraper.py | 2,459 | 4.03125 | 4 | # Guide To Web Scraping(Python3
# To web scrape we will use the beautifulSoup4 module
from bs4 import BeautifulSoup as bs
# Here we'll import requests so we can make url requests
import requests
# Here we'll use json to store our scraped data
import json
# Import of csv
import csv
... |
5036f2780c34b44ac31090bf78f4eb0cae358a3b | mccallkaley/Week3_day1hw | /Regex_project.py | 869 | 3.671875 | 4 | """
Expected Output
Abraham Lincoln
Andrew P Garfield
Connor Milliken
Jordan Alexander Williams
None
None
"""
# ([A-Z][a-z]+) 1st capuring group Capital char followed by lower
# + matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy
# ([A-Z][a-z]*) 2nd... |
528b7e95d54e1b6e7b0ac6ab42fa93a6269590ac | zauddelig/pytest-workshop | /tests/2_classes_in_pyest.py | 2,241 | 3.5625 | 4 | """
Pytest does not need classes, but it may be still easier for the developer
to incapsulate a number of tests for the same feature in the same class.
This may help maintain a clean code.
"""
class Basic:
"""
As you may know the classic Unittest framework relay on tests,
in pytest they are still used b... |
e006d8211852138351674883d7fd6136d80f45ab | maknetaRo/python-katas-with-test | /invert_values.py | 623 | 4.1875 | 4 | """
Given a set of numbers, return the additive inverse of each.
Each positive becomes negatives, and the negatives become positives.
invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5]
invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5]
invert([]) == []
You can assume that all values are integers. Do not mutate the input array/list.
"""
de... |
e6a19c41fd0b579375ae2892976e5f4f59ab49b0 | kylegomez/pycrypt | /monomedinome.py | 2,628 | 3.5 | 4 | from crypto import *
class MonomeDinome:
def __init__(self, letterkw, numberkw):
self.letterkey = self.lettersScramble(letterkw)
self.numberkey = self.digitsScramble(numberkw)
def encrypt(self, pt):
rlist = []
for c in pt.get():
if c == 'J':
c = 'I'
... |
12be6fe12df86301df019de4a896a839beaf3690 | Patryk-Kumor/University | /Python/Zbiory innych zadań/Wprawki/wprawka2.py | 685 | 3.6875 | 4 | # -*- coding: cp1250 -*-
# lista p, wspczynniki wielomianu
x=int(input('Podaj punkt x: '))
def wielomian(x):
w=0
for i in P:
w*=x
w+=i
return w
def surf(P,xs,xf,dx):
pole=0
x=xs
while x <= xf:
malePole=wielomian(x)*dx
pole+=malePole
x=x+dx
return pole
P=[]
n=int(inp... |
c3a4befe057e8748dd40415040021a9d93ccdf9a | Patryk-Kumor/University | /Python/Zbiory innych zadań/silnia.py | 586 | 3.625 | 4 | from math import factorial
print('Silnia liczby naturalnej n,\nto iloczyn wszystkich liczb naturalnych nie większych niż n.\n')
n=int(input('Podaj liczbę n: '))
for i in range(n+1):
print(str(i)+'! ma',len(str(factorial(i))), end='')
X = str(len(str(factorial(i))))
string = X
if i < 4:
if X[-... |
3803616c521f87d1f80d98934dc1c034db361404 | ChenYalun/YACode | /Offer/对称的二叉树.py | 716 | 3.78125 | 4 | # -*- coding:utf-8 -*-
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# 二叉树的镜像
def mirror(self, mRoot, nRoot):
if not mRoot and not nRoot:
return True
if mRoot and not nRoot:
return False
... |
6fb085dbd9358d91593de0a02290ce3d11e282af | ChenYalun/YACode | /Blog/二分查找插入.py | 1,525 | 3.6875 | 4 | # -*- coding:utf-8 -*-
# 2017.03.15
# 陈亚伦
import bisect
#插入排序-二分查找插入(模块实现)
# bisect模块实现了一个算法, 用于向一个有序列表中插入一个元素,不改变列表的序列
# 使用这个模块的函数前先确保操作的列表是已排序的
def insertionSortBisect(tempList):
for i in xrange(1, len(tempList)):
bisect.insort(tempList, tempList.pop(i), 0, i) # 排序列表,移除并插入元素,区间开始,区间结束
return t... |
9a89fc9c76b004f9227306ab3ec0a4aa7ed669f6 | ChenYalun/YACode | /Blog/希尔排序.py | 1,419 | 3.875 | 4 | # -*- coding:utf-8 -*-
# 2017.03.15
# 陈亚伦
#插入排序-希尔排序(我觉得叫分组排序更直观)
def insertionSortShell(tempList):
n = len(tempList)
if n <= 1:
return tempList
# 确定分组,假定n = 6
group = n / 2 # 此时group = 3,分成3组,3组元素索引分别为3与3-3,4与4-3,5与5-3
while group > 0:
#x从3到5
for x in xrange(group,n):
# 每组元素:x,x-group,x-group-group ..... |
d4550d78b661bd098a413e2dfa1e2cd857f8f531 | ChenYalun/YACode | /Offer/04重建二叉树.py | 663 | 3.515625 | 4 | # -*- coding:utf-8 -*-
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# 返回构造的TreeNode根节点
def reConstructBinaryTree(self, pre, tin):
# 空节点
if len(pre) == 0:
return None
# 根节点
rootNode =... |
00dacbb14c8f411aefe23b2667709216b10a40c9 | ChenYalun/YACode | /Offer/*25二叉搜索树的后序遍历序列.py | 1,116 | 3.59375 | 4 | # -*- coding:utf-8 -*-
'''
思路(根本依据):二叉搜索树中,某结点的左子树(若存在)小于该结点,该节点的右子树(若存在)大于该结点
递归实现
5 7 6 9 11 10 8
根结点 8
左 5 7 6
根 6
左 5
右 7
右 9 11 10
根 10
左 9
右 11
'''
class Solution:
def VerifySquenceOfBST(self, sequence):
# 容错处理
if len(sequence) <= 0:
return
# 序列长度
length = len(sequence)
# 根结点
r... |
5557009e4f461ad75f0b2f5c64d955b021328e87 | ChenYalun/YACode | /Offer/*20顺时针打印矩阵.py | 1,592 | 4 | 4 | # coding=utf-8
# -*- coding:utf-8 -*-
'''
思路:
取出左上角坐标和右下角坐标定位一次要打印的数据
一次旋转打印后,往对角线分别前进和后退一个单位
注意单行或单列情况
'''
class Solution:
# matrix类型为二维列表,需要返回列表
def printMatrix(self, matrix):
# 取出行数/列数
row = len(matrix)
col = len(matrix[0])
# 容错处理
if row == 0 or col == 0:
... |
556faaad773b7a8139a06812963098801d0fcb11 | huangruihaocst/leetcode-python | /108. Convert Sorted Array to Binary Search Tree/solution.py | 802 | 3.734375 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def sortedArrayToBST(self, nums):
"""
:type nums: List[int]
:rtype: TreeNode
"""
n = len(nums)
if ... |
e4b8582a9c46220007caab110d1113d9a128ac69 | huangruihaocst/leetcode-python | /95. Unique Binary Search Trees II/solution.py | 1,252 | 3.90625 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def generateTrees(self, n):
"""
:type n: int
:rtype: List[TreeNode]
"""
from functools import lru_cache
... |
b560b378941686533cb90bc7472925fe0526db61 | huangruihaocst/leetcode-python | /232. Implement Queue using Stacks/solution.py | 2,968 | 4.21875 | 4 | class Stack:
def __init__(self):
self.stack = list()
def push(self, x):
self.stack.append(x)
def pop(self):
return self.stack.pop()
def peek(self):
return self.stack[-1]
def size(self):
return len(self.stack)
def is_empty(self):
return len(se... |
8f9737aa1a399f49f543991dc90aa0fdc347884a | huangruihaocst/leetcode-python | /762. Prime Number of Set Bits in Binary Representation/solution.py | 439 | 3.515625 | 4 | class Solution:
def countPrimeSetBits(self, L, R):
"""
:type L: int
:type R: int
:rtype: int
"""
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]
cnt = 0
for i in range(L, R + 1):
ones = bin(i).count('1')
if ones in primes:
... |
80a1f0f092fc10049508b407424436f3df16e06a | huangruihaocst/leetcode-python | /563. Binary Tree Tilt/solution.py | 1,328 | 3.90625 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def findTilt(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if not root:
return 0
... |
a88b7cef967f2748575f3a8bb3b379606898dc3e | huangruihaocst/leetcode-python | /811. Subdomain Visit Count/solution.py | 842 | 3.5625 | 4 | class Solution:
def subdomainVisits(self, cpdomains):
"""
:type cpdomains: List[str]
:rtype: List[str]
"""
d = dict()
for cpdomain in cpdomains:
times = int(cpdomain.split(' ')[0])
domain = cpdomain.split(' ')[1]
domains = domain.sp... |
d38e9a29d227184802861f4d0c2ee71ec6bc072e | huangruihaocst/leetcode-python | /404. Sum of Left Leaves/solution.py | 835 | 4.03125 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def sumOfLeftLeaves(self, root):
"""
:type root: TreeNode
:rtype: int
"""
def DFS(node):
if n... |
6045d7dfcc32b7c0fc568d854b2b055955662ff0 | huangruihaocst/leetcode-python | /878. Nth Magical Number/solution.py | 1,966 | 3.609375 | 4 | class Solution:
def nthMagicalNumber(self, N, A, B):
"""
:type N: int
:type A: int
:type B: int
:rtype: int
"""
# Solution 1: Binary Search
# def lcm(a, b):
# def gcd(_a, _b):
# while _b > 0:
# _a, _b = _... |
a3e15accdadee95b6beaf0cda19456a96030e2ff | huangruihaocst/leetcode-python | /206. Reverse Linked List/solution.py | 1,312 | 4.0625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverseList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
# Solution 1:
# if head is None:
# re... |
98062a26ceac56452f622ef8dd5ad10c6b1b8185 | huangruihaocst/leetcode-python | /812. Largest Triangle Area/solution.py | 1,079 | 3.546875 | 4 | class Solution:
def largestTriangleArea(self, points):
"""
:type points: List[List[int]]
:rtype: float
"""
from itertools import combinations
from math import sqrt
res = 0
for choice in combinations(range(len(points)), 3):
A, B, C = points[... |
34d53998fcb3de4fcdcd66448d8fbae618146b83 | huangruihaocst/leetcode-python | /559. Maximum Depth of N-ary Tree/solution.py | 785 | 3.65625 | 4 | # Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
class Solution(object):
def maxDepth(self, root):
"""
:type root: Node
:rtype: int
"""
# Solution 1: DFS
# if not root:
... |
641cf9521041072d76ea2ded79b343af6bc31738 | huangruihaocst/leetcode-python | /896. Monotonic Array/solution.py | 714 | 3.734375 | 4 | class Solution:
def isMonotonic(self, A):
"""
:type A: List[int]
:rtype: bool
"""
increase = None
for i in range(1, len(A)):
if A[i] == A[i - 1]:
continue
elif A[i] > A[i - 1]:
if increase is None:
... |
f4febace0fcab7835e322a024321290a2233ae27 | JGH85/adventofcode2016 | /day6part1.py | 763 | 3.53125 | 4 |
inputfile = open('inputday6.txt')
filein = (inputfile.read())
# filein = '''eedadn
# drvtee
# eandsr
# raavrd
# atevrs
# tsrnev
# sdttsa
# rasrtv
# nssdts
# ntnada
# svetve
# tesnvt
# vntsnd
# vrdear
# dvrsen
# enarar'''
f = filein.split()
# print(f)
answer = ''
for i in range (0,8):
d = {}
for word in f:
# pr... |
5ad00746364eec965f8932a9045f110a469da769 | homewardgamer/Snake_Game | /scoreboard.py | 991 | 3.78125 | 4 | from turtle import Turtle
class ScoreBoard(Turtle):
def __init__(self):
super().__init__()
self.score= 0
with open("data.txt") as data:
self.high_score= int(data.read())
self.color("white")
self.hideturtle()
self.penup()
self.goto(0,270)
self... |
88abc8036c8ff3ce200d54c316c5cfdabf84dd74 | Daniele/microtrim | /microlib/matcher/leven.py | 560 | 3.578125 | 4 | '''
Levenshtein matcher
'''
import math
import Levenshtein
def build(adapter, args):
'''
Build a Levenshtein matcher with parameters:
- match_only
- stop_after
'''
adapter = adapter[:args.match_only][::-1]
def match(line):
rline = line[::-1]
for j, char in enumerate(r... |
7be2a4c00ae99080271362a5bc7465c93c88e673 | martinmeagher/UCD_Exercises | /Module8_Intro_to_Data_Visualisation_with_Seaborn/1b_Using_Pandas_with_Seaborn.py | 446 | 3.90625 | 4 | # Import Pandas
import pandas as pd
# Create a DataFrame from csv file
df = pd.read_csv(csv_filepath)
# Print the head of df
print(df.head())
# Import Matplotlib, Pandas, and Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# Create a DataFrame from csv file
df = pd.read_csv(csv_fil... |
cc27a1659bb327eb3257fc2be8c36c049502f980 | martinmeagher/UCD_Exercises | /Module8_Intro_to_Data_Visualisation_with_Seaborn/4c_Adding_Titles_Labels_Pt2.py | 645 | 3.8125 | 4 | # Import Matplotlib and Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
# Create line plot
g = sns.lineplot(x="model_year", y="mpg_mean",
data=mpg_mean,
hue="origin")
# Add a title "Average MPG Over Time"
g.set_title("Average MPG Over Time")
# Add x-axis and y-axis lab... |
cd1084b389ceb61e1aff45e07b81294ef12f7ca8 | martinmeagher/UCD_Exercises | /Module8_Intro_to_Data_Visualisation_with_Seaborn/1a_Intro_to_Seaborn.py | 456 | 3.75 | 4 | # Import Matplotlib and Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
# Create scatter plot with GDP on the x-axis and number of phones on the y-axis
sns.scatterplot(x = gdp, y= phones)
# Show plot
plt.show()
# Change this scatter plot to have percent literate on the y-axis
sns.scatterplot(x=gdp, y=p... |
72f6d74d36fa1d58bd05d04528cfa484e24831b0 | kianaghassabi/Data-Structures- | /Sort Algorithms/bubble_sort/Bubble sort.py | 492 | 4.09375 | 4 | #defining a bubble sort function
def bubbleSort(mylist):
for j in range(len(mylist)-1,0,-1):
for i in range(0,j):
if mylist[i] > mylist[i+1]: #swap the the numbers using the temp variable
temp=mylist[i]
mylist[i]=mylist[i+1]
mylist[i+1]=temp
... |
2f825c012cc66c0b1ce15ec6edc919fdb9f2cf22 | rajat1812/Computer-Vision | /Object Detection.py | 880 | 3.6875 | 4 | import cv2
import numpy as np
# we point opencv's cascade classifier function to where our classifier (xml file format) is stored
face_classifier = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml.html')
imgpath = '/Users/rajatbhalla/Downloads/President_Barack_Obama.jpg'
image = cv2.imread(imgpath)
img_gray = ... |
4e3c256a5f4891a288d7743e84095ad68c62fc76 | fkdatm/python | /exercise/day06_exercise.py | 3,773 | 4.03125 | 4 | print("-------------------------------------------第一题-------------------------------------\n")
# 1.已知有列表
# L = [3, 5]
# 用索引和切片操作,将列表改为:
# L = [1,2,3,4,5,6]
# 将列表反转(前后对调), 然后删除最后一个元素
# print(L) # [6,5,4,3,2]
l1_1 = [3,5]
l1_1[0:1] = [1,2,3]
l1_1[3:] = [4,5,6]
print("l的值是:%s" % str(l1_1))
l1_1[::-1] = l1_1
... |
9ba80ebeb22047aa273753c6338f7b3c141545d6 | fkdatm/python | /exercise/day14_exercise/student_manager_sys/menu.py | 594 | 3.953125 | 4 | # 本模块主要是菜单选项
import student_info
def menu():
while True:
print('''
1.增加学生信息
2.查询学生信息
3.修改学生信息
4.删除学生信息
q.退出
''')
option = input("请选择需要进行的操作:")
if option == "1":
student_info.add_student()
elif option == "2":
student_info.select_student()
elif option == "3":
stude... |
252fafb923fd66d39420e81ec55391f497332003 | HarshaR99/Python-Programs | /Python programs/bin.py | 403 | 3.890625 | 4 |
def binarySearch(array,k,end):
first = 0;
while (first < end) :
mid = (first + end)/2;
if k == array[mid] :
return 1;
elif k > array[mid] :
first = mid + 1;
else :
end = mid -1;
return -1;
cases = input()
for i in range(cases):
arr = []
n = int(input())
k = int(input())
for i in range(n... |
aeb3f7ac929840d8d4af726390cf4315603f9aff | alexqfredrickson/code-examples | /gists/python3.7/data_structures/binary_tree.py | 1,113 | 3.84375 | 4 | class BinaryTree:
def __init__(self, value, left_child, right_child):
"""
:type left_child: BinaryTree
:type right_child: BinaryTree
"""
self.value = value
self.left_child = left_child
self.right_child = right_child
@classmethod
def from_list(cls, a... |
6f369c7c2a749394b923f2cbb430463616fe271b | xent3/Python | /Ödev1/Ödev_20.py | 768 | 3.53125 | 4 | def fon(x,y):
if(x > y):
return True
elif(y>x):
return False
a=0
b=1
liste = []
liste1 = []
while True:
i = (input("Değer giriniz:"))
if (i == "q"):
break
liste.append(int(i))
print(liste)
for x in range(1,len(liste)+1):
c = 1
d = 2
for u in range(1,len(li... |
93ae7227e512d97760c2f89c99344f830ffd5778 | xent3/Python | /Pratik/Pratikler For While.py | 380 | 3.984375 | 4 | i = 0
while(i<10):
print("i'nin değeri:",i)
i = i+1
print("------------------------------------------------------")
liste = [1,2,3,4,5,6]
for eleman in liste:
print("Eleman",eleman)
print("-------------------------------------------------------")
liste = [1,2,3,4,5,6,7]
toplam = 0
for eleman in liste:... |
71294d7f22cda67c7580b09aa2b8e15959777ccd | jguerrero10/misiontic2020R1 | /Modulo 1/Seccion 1.2/Turtle/programa3.py | 885 | 4.03125 | 4 | import turtle
import math
t = turtle.Turtle()
def triangulo(Ca1, Ca2, col=None):
hip = math.sqrt(Ca1 **2 + Ca2 **2)
if col != None:
t.color(col)
t.begin_fill()
t.forward(Ca1)
t.left(315)
t.forward(hip)
t.right(315)
t.forward(Ca2)
t.end_fill()
... |
b0897dee96696e1917d11aa040754d22de3fa932 | jguerrero10/misiontic2020R1 | /Modulo 1/Seccion 1.3/while/programa4.py | 1,788 | 4.03125 | 4 | def sumar(x ,y):
return x + y
def restar(x, y):
return x - y
def multiplicar(x, y):
return x * y
def dividir(x, y):
return x / y
while True:
opcion = input("Digite una opcion (s) Sumar (r) Restar (m) Multiplicar (d) Dividir (q) Salir ")
if opcion == "s":
try:
num1 = float... |
8651beec5c410c5d4fe8132778566125553ef291 | jguerrero10/misiontic2020R1 | /Modulo 1/Seccion 1.3/while/programa3.py | 648 | 3.921875 | 4 | """
Programa: Juego adivinar un numero
"""
import random
num_secreto = random.randint(1, 10)
intentos = 1
print("Programa juego de adivinar numero")
while intentos < 5:
try:
numero = int(input("Diga un numero entre 1 y 10 "))
if numero == num_secreto:
print("Ganador....")
... |
6369bad0392ac9f6efe36c87c27cb9e32d940a87 | jguerrero10/misiontic2020R1 | /Modulo 1/Seccion 1.3/diccionario/programa5.py | 699 | 4.125 | 4 | """
Programa de encriptacion/ desencriptacion
Codigo Murcielago
"""
claves = {
'm': 0,
'u': 1,
'r': 2,
'c': 3,
'i': 4,
'e': 5,
'l': 6,
'a': 7,
'g': 8,
'o': 9
}
def encriptar(cadena):
sub = cadena.lower()
for key in claves:
mensaje = sub.replace(key,str(clav... |
451d1ebdeb1a5f1e86020a0a8f07bb7022d41f83 | erezshi/campus_il_advance_python | /iterators/5.3.py | 1,334 | 4 | 4 | class Employee:
def __init__(self, name, age, salary):
self._name = name
self._age = age
self._salary = salary
def get_name(self):
return self._name
class EmployeeManager:
def __init__(self):
self._employee_lst = []
self.eml_index = -1
def add_employee(... |
c887fca81917e520c4f2b2e339f1c75f23dfda53 | erezshi/campus_il_advance_python | /genrators/ex_generators.py | 3,809 | 3.75 | 4 | #first part
def gen_secs():
n = 0
while n <= 59:
yield n
n += 1
def gen_minutes():
n = 0
while n <= 59:
yield n
n += 1
def gen_hours():
n = 0
while n <= 23:
yield n
n += 1
#2nd part
def gen_time():
for h in gen_hours():
for m in gen_... |
933623d5a55199804aab8ad650bd359dc5464a12 | erezshi/campus_il_advance_python | /Objects/polymorphism.py | 1,199 | 4.09375 | 4 | class Animal: #Superclass
def __init__(self, name):
self._name = name
self._hunger = 0
self._fun = 0
def play(self):
self._fun += 1
def eat(self):
if self._hunger > 0:
self._hunger -= 1
def go_to_toilet(self):
self._hunger += 1
cla... |
a188e0e1fedb8408c0abcae04480ec0f2ccf86a9 | kmounish/FileEncrtptionDecryption | /EncryptDecryptFiles.py | 1,354 | 4.28125 | 4 | from cryptography.fernet import Fernet
def encryptFile(file):
#Generates key
key = Fernet.generate_key()
#Saves key a file called mykey.key
with open("mykey.key",'wb') as mykey:
mykey.write(key)
with open(file, "rb") as original_file:
original = original_file.read()
... |
d52f6e08a3b332445c45f77c29af940c9965b0b4 | andreaq/python-Course-6.00.1x- | /Problem_set_4/updateHand.py | 992 | 4.0625 | 4 | def updateHand_foo(hand, word):
"""
Assumes that 'hand' has all the letters in word.
In other words, this assumes that however many times
a letter appears in 'word', 'hand' has at least as
many of that letter in it.
Updates the hand: uses up the letters in the given word
and returns the ne... |
7f9891e73120e198e350843042564eca01daef18 | loicseguin/nyc | /images/standing.py | 1,141 | 3.609375 | 4 | import numpy as np
import matplotlib.pyplot as plt
def standing_wave(xs, L, n, A=1.0):
"""Return the y positions of a standing wave on an attached string.
Parameters
----------
xs : array
List of values at which to evalute y.
L : number
Length of the string.
n : integer
... |
34e0cdfe11d4ecabac7fecfeedd841fef3795139 | Logahn/Harvard_CS50 | /tictactoe.py | 4,971 | 3.8125 | 4 | X = "X"
O = "O"
EMPTY = ""
# returns starting state of the board
def initial_state():
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]]
# returns player who has the next turn on a board
def player(board):
if board == initial_state():
return X
n... |
7ac5a4df60452069bbb569e2695244d04b53b48b | yokomotoh/python_excercises | /alphabet_rangoli.py | 895 | 3.84375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 14 12:03:52 2019
alphabet rangoli
@author: yoko
"""
size = 0
alphabet="abcdefghijklmnopqrstuvwxyz"
#def print_core(num_line, size):
# for i in range(0,num_line+1,1):
# print_alphabet(i, size - i)
def print_alphabet(num_line, size):
... |
fc5c4dccf8620f71b710a37b1c4a4cb9a23983c5 | yokomotoh/python_excercises | /string_sprit_join.py | 454 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 11 15:54:36 2019
String split join
@author: vincent
"""
def split_and_join(line):
# write your code here
tmp_split = ""
tmp_split = line.split(" ")
#print(tmp_split)
tmp_join = ""
tmp_join = "-".join(tmp_split)
#print(tmp... |
455c7c6b02ce1bcadc3d78bad22a5ef71b9606c6 | beast-sh/PG-Management-System | /PGMANAGEMENT.py | 4,351 | 3.828125 | 4 | from tkinter import *
import sqlite3,sys
def connection():
try:
conn=sqlite3.connect("pg.db")
except:
print("cannot connect to the database")
return conn
def verifier():
a=b=c=d=e=f=g=0
if not name.get():
t1.insert(END,"<>Tenent name is required<>\n")
a=1
i... |
c431b4d89f42e4df8d7f58d3817ac36141710fb0 | cafe-com-analytics/titanic-cafe | /src/utils/data_describe.py | 4,517 | 3.65625 | 4 | # -*- coding: utf-8 -*-
class DataDescribe:
"""
Created on Sun Jun 16 22:36:39 2019
@author: Gustavo Suto
"""
import pandas as pd
def __init__(self):
pass
def breve_descricao(df):
"""
Função breve_descricao
Objetivo: Exclui atributos que estejam ... |
3adef8d3072dc4e429dfb2fc24957bf1d3207c52 | AvinashIkigai/Art-of-Doing | /Units/boolean_values.py | 235 | 3.71875 | 4 | soda = 'coke'
print(soda == 'coke')
print(soda == 'Pespi')
print(soda != 'pepsi')
names = ['mike','john','mary']
mike_status = 'mike' in names
bill_status = 'bill' in names
not_bill_status = 'bill' not in names
print(not_bill_status) |
9f88a0979c6f0deb6280d0d94c7f1395f9e89429 | AvinashIkigai/Art-of-Doing | /GuessTheWords.py | 1,691 | 4.1875 | 4 | import random
from typing import List
print("Welcome to the Guess My Word App")
game_dict = {
"sports":['baseball','basketball','soccer','football','tennis','curling'],
"colors":['orange','yellow','purple','aquamarine','violet','gold'],
"fruits":['apple','banana','watermelon','peach','mango','strawberry'],... |
705e9cfbb435ac0fd45493624c993dac5b11d6a7 | AvinashIkigai/Art-of-Doing | /FactorialCalculatorApp.py | 821 | 4.46875 | 4 | #Factorial Calculator App
import math
print("Welcome to the Factorial Calculator App")
#Get user Input
number = int(input("\nWhat number would you like to compute the factorial of: "))
#Display the Mathematical relation Of A Factorial
print(str(number) + "! = ", end="")
for i in range(1, number):
print(str(i), e... |
526b76ac6ca89d366f55fc34315c24fe60f9c7eb | AvinashIkigai/Art-of-Doing | /VoterRegistration.py | 1,043 | 4.34375 | 4 | print("Welcome to the Voter Registration App\n")
name = input("\nPlease enter your name: ").title().strip()
age = int(input("Please enter your age: "))
parties = ['Republican','Democratic','Independent','Libertarian','Green']
if age > 0 and age < 18:
print("Hello, "+name+" you are not eligible to vote! ")
else:
... |
ad8d0920a5d8c958680aee41018d5011e047d756 | AvinashIkigai/Art-of-Doing | /PowerBallApp.py | 2,727 | 4.1875 | 4 | import random
print("------------------------------Power-Ball Simulator------------------------------")
#Determine the size of the lottery
white_balls = int(input("How many white-balls to draw from for the 5 winning numbers (normally 69): "))
if white_balls < 5:
white_balls = 5
red_balls = int(input("How many re... |
bb297a1d5c896734093a9b29fc3d4e81af198e09 | yhs3434/Algorithms | /programmers/h-index.py | 554 | 3.5 | 4 | # H-Index
# https://programmers.co.kr/learn/courses/30/lessons/42747
def solution(citations):
answer = 0
maxVal = max(citations)
for h in range(maxVal,0,-1):
if(numHigh(citations, h)>=h):
answer = h
break
return answer
def numHigh(citations, idx):
i=-1
j=0
... |
965684400e05192be2cd6ffc92badcf423cc15ac | yhs3434/Algorithms | /baekjun/stage solve/10.math2/4153.py | 292 | 3.609375 | 4 | # 직각삼각형
# https://www.acmicpc.net/problem/4153
while True:
x, y, z = map(int, input().split(' '))
if x==0 and y==0 and z==0:
break
pos = [x, y, z]
pos.sort()
if pos[0]**2 + pos[1]**2 == pos[2]**2:
print('right')
else:
print('wrong')
|
e7409ed54acf417ac30183cb6c91c61ab0086de8 | yhs3434/Algorithms | /baekjun/stage solve/08.string/5622.py | 636 | 3.671875 | 4 | # 다이얼
# https://www.acmicpc.net/problem/5622
def getNum(c):
if c=='A' or c=='B' or c=='C':
return 2+1
elif c=='D' or c=='E' or c=='F':
return 3+1
elif c=='G' or c=='H' or c=='I':
return 4+1
elif c=='J' or c=='K' or c=='L':
return 5+1
elif c=='M' or c=='N' or c=='O':
... |
bc75284119695ab1b611bcefa9ff2cf776c83400 | yhs3434/Algorithms | /baekjun/exercise/2020Jan/2443.py | 221 | 3.78125 | 4 | # 별 찍기 - 6
# https://www.acmicpc.net/problem/2443
n = int(input())
for i in range(n, 0, -1):
for j in range(n-i):
print(' ', end='')
for j in range(2*i-1):
print('*', end='')
print('')
|
05ca248f2c066f3b611e10afb7c05f4c392103ff | yhs3434/Algorithms | /programmers/bucketSort.py | 1,154 | 3.609375 | 4 | def bucketSort(A):
B = [List() for i in range(len(A))]
for a in A:
idx = int(len(A)*a)
B[idx].insert(a)
for b in B:
b.print()
print(' ')
class Node:
def __init__(self, data):
self.data = data
self.next = None
class List:
def __init__(self):
h... |
9bc00bb7ffa67884431eef7fd05bfb3e8db30448 | yhs3434/Algorithms | /programmers/2018 KAKAO BLIND RECRUITMENT/fileNameSort.py | 1,177 | 3.5 | 4 | # 2018 KAKAO BLIND RECRUITMENT [3차] 파일명 정렬
# https://programmers.co.kr/learn/courses/30/lessons/17686
def solution(files):
answer = [' ' for i in range(len(files))]
newFiles = []
fileIdx = -1
for file in files:
fileIdx += 1
flag = False
flag2 = False
i = 0
j = 0... |
e3a4f178a5202c3014012b70deaf0be44737371a | yhs3434/Algorithms | /baekjun/classification/realization/10984.py | 424 | 3.6875 | 4 | # 내 학점을 구해줘
# https://www.acmicpc.net/problem/10984
# https://github.com/yhs3434/Algorithms
t = int(input())
for xxx in range(t):
n = int(input())
totalCredit = 0
totalGrade = 0
for yyy in range(n):
credit, grade = map(float, input().split(' '))
totalCredit += credit
totalGrade ... |
86225fbb3d1a28b83ec9eb7318b3fb7f2bdc257f | yhs3434/Algorithms | /baekjun/exercise/202101/5073.py | 324 | 3.65625 | 4 | while True:
a, b, c = map(int, input().split())
if a == 0 and b == 0 and c == 0:
break
if a == b == c:
print('Equilateral')
elif (b+c) <= a or (a+c) <= b or (a+b) <= c:
print('Invalid')
elif a == b or b == c or c == a:
print('Isosceles')
else:
print('Scale... |
be90eee0ca4337f9b58101eae93ac1a755d22dae | yhs3434/Algorithms | /baekjun/exercise/202101/9661.py | 169 | 3.5 | 4 | N = int(input())
n = N % 5
if n == 0:
print('CY')
elif n == 1:
print('SK')
elif n == 2:
print('CY')
elif n == 3:
print('SK')
elif n == 4:
print('SK') |
28f768ce326a0e2b85221e905432874870763c90 | yhs3434/Algorithms | /baekjun/exercise/2020Mar/13241.py | 244 | 3.640625 | 4 | # 최소공배수
# https://www.acmicpc.net/problem/13241
# https://github.com/yhs3434/Algorithms
def getGCD(a,b):
while b > 0:
a, b = b, a % b
return a
a, b = map(int, input().split(' '))
gcdd = getGCD(a, b)
print(a*b//gcdd) |
1059c3beeef9746c9da44f74a2db731c3652d8d0 | yhs3434/Algorithms | /baekjun/exercise/2020Jan/14581.py | 280 | 3.796875 | 4 | # 팬들에게 둘러싸인 홍준
# https://www.acmicpc.net/problem/14581
person = input()
for i in range(3):
print(':fan:', end='')
print('')
print(':fan:', end='')
print(':'+person+':', end='')
print(':fan:', end='')
print('')
for i in range(3):
print(':fan:', end='') |
3d1060fb9dd5a83564061fe33c5f65ead77482f0 | yhs3434/Algorithms | /hansolLibrary/hsDeck.py | 1,789 | 3.75 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
self.prev = None
class MyDeck:
def __init__(self):
self.head = Node(None)
self.tail = Node(None)
self.head.next = self.tail
self.tail.prev = self.head
self.size = 0
def i... |
47b00bffd8a8cd5df4fcc4fcdd59e21ed883bd58 | yhs3434/Algorithms | /programmers/handleString.py | 358 | 3.515625 | 4 | # 문자열 다루기 기본
# https://programmers.co.kr/learn/courses/30/lessons/12918
def solution(s):
answer = True
length = len(s)
if(length!=4 and length!=6):
answer = False
else:
for c in s:
if(c>='0' and c<='9'):
continue
else:
answer = Fa... |
e9c263edcdad5917cecff19c417b3befff016150 | yhs3434/Algorithms | /baekjun/stage solve/08.string/1157.py | 416 | 3.578125 | 4 | # 단어 공부
# https://www.acmicpc.net/problem/1157
strr = input().upper()
hmap = {}
for c in strr:
if c not in hmap:
hmap[c] = 1
else:
hmap[c] += 1
maxCnt = 0
maxChar = []
for key in hmap:
if hmap[key] > maxCnt:
maxChar = [key]
maxCnt = hmap[key]
elif hmap[key] == maxCnt:
... |
ab4e036be6bcff5d3195a1c456ba5d0605d0b4f3 | gustojvalle/AdventOfCode2020 | /AdventOfCode2.2.py | 654 | 3.71875 | 4 | ##Sorting the Data out##
from itertools import combinations
with open('./adventofcalendarinput2.txt') as file:
my_input = file
data=file.readlines()
file.close()
data = [x.replace('\n',"") for x in data]
###Solving the Puzzle ###
count = 0
for entry in data:
policy, password = entry.spl... |
86aca396b2fa4512162b2430244f5d61d2f5f85e | supercym/python_leetcode | /064_Minimum_Path_Sum.py | 3,266 | 3.546875 | 4 | # Author: cym
# ************* Dijkstra *****************
# ************* Low Efficient *****************
# def minPathSum(grid):
# """
# :type grid: List[List[int]]
# :rtype: int
# """
# m = len(grid)
# if m == 0:
# return 0
# ... |
07d251b9ddba399d914c9f5a673d865ae5d7a36b | supercym/python_leetcode | /429_N_Ary_Tree_Level_Order_Traversal.py | 705 | 3.734375 | 4 | # Author: cym
"""
# Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
"""
class Solution(object):
def levelOrder(self, root):
"""
:type root: Node
:rtype: List[List[int]]
"""
... |
d0be924a073f07fb6ff264d02a28e983e02ca1b9 | supercym/python_leetcode | /086_Partition_List.py | 691 | 3.6875 | 4 | # Author: cym
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def partition(self, head: ListNode, x: int) -> ListNode:
lt, ge = ListNode(None), ListNode(None)
node = head
lthea... |
712393460cb287525e9a5115e8f7f09bf2cdfd7c | supercym/python_leetcode | /088_Merge_Sorted_Array.py | 1,237 | 4.0625 | 4 | # Author: cym
def merge(nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:rtype: void Do not return anything, modify nums1 in-place instead.
"""
for i in range(n):
nums1 = insert_list(nums1, m, nums2[i])
m += ... |
192e3018cfd7fd0d08f52800ade94307b5e56ca8 | supercym/python_leetcode | /374_Guess_Number_Higher_or_Lower.py | 745 | 3.609375 | 4 | # Author: cym
# The guess API is already defined for you.
# @param num, your guess
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
# def guess(num):
class Solution(object):
def guessNumber(self, n):
"""
:type n: int
:rtype: int
"""
... |
c57f011d2da4963c89145e5d46b2afde9803decb | jazicorn/superhero | /superheroes.py | 16,202 | 3.90625 | 4 | import random
from pprint import pprint
class Hero:
def __init__(self, name, health=100):
# Initialize starting values
self.abilities = list()
self.name = name
self.armors = list()
self.starting_health = health
self.health = health
self.deaths = 0
... |
1aea19acfa361988e9c5222c53569e2af4a60ce3 | lxj16/leetcode | /array/find_words_that_canbeformed.py | 809 | 3.546875 | 4 | # bad
class Solution:
def countCharacters(self, words: List[str], chars: str) -> int:
chardict = {}
output = ''
for char in chars:
if char in chardict:
chardict[char] += 1
else:
chardict[char] = 1
for word in words:
... |
cdab71866fc328ff841614e1230fd880b9b720ac | asif-iqbal-ba/AI-Class | /compoundintrest.py | 602 | 3.859375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
while True:
p_amount = input("Enter Principle Amount: ")
i_rate = input("Enter Intrest Rate in percentage Here: ")
y_year = input("Enter No of Years Here: ")
try:
a = float(p_amount) * (pow(1 + float(i_rate)/100, float(y_year)))
print("Af... |
1b5fcd507fb9ab8021f5eb749319f108de352082 | asif-iqbal-ba/AI-Class | /nitegersum.py | 337 | 3.953125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[6]:
while True:
try:
n = input("Enter value of n here: ")
sum_n = int((int(n) * (int(n) + 1)) / (2))
print("Sum of n Positive integers till " + str(n) + " is " + str(sum_n))
break
except:
print("Enter value in Numeric") ... |
618e968f271da785047439f6dafdc4b0547c921b | peter-akworo/Strings-Python | /String.py | 6,327 | 4.625 | 5 | # Representing strings
H1 = "Hello World!" # print hello world
print(H1)
H2 = "Hello World!" # print hello world
print(H2)
# Quotes usage
print("It's the day") # double quotes
print('She said "Hello" to everyone') # single quotes
print(
"""
Hello
World
"""
) # triple quotes for multiline stri... |
3a75d759e82880fec4edd0b774ac1fb0d7cf3a38 | petersenea/mycs393 | /Deliverables/2/2.1/backend.py | 1,603 | 4.34375 | 4 | import json
import functools
"""
sorts special_json_list
* expects special_json_list to be a list of 10 special json objects
"""
def sort(special_json_list):
special_json_list.sort(key = functools.cmp_to_key(_is_greater))
return special_json_list
"""
########### private helper functions ####... |
79b0c3e6696dde86ca6572e612146b70eff6acb7 | dev891998/-guviphy | /Largest among 3 numbers.py | 178 | 3.96875 | 4 | a=float(input())
b=float(input())
c=float(input())
if(a>b) and (a>c):
print("a is the largest")
elif(b>a) and (b>c):
print("b is the largest")
else:
print("c is the largest")
|
7723d4e266b664a4159eeda274ee76b3a7e774be | Jacja/HW2 | /HW3-4.py | 952 | 3.734375 | 4 | Определить, какое число в массиве встречается чаще всего.
#1
from collections import Counter
print(*Counter(input('Введите числа: ').split()).most_common()[0][0])
#2
numbers = [2, 4, -8, 38, 45, 4, 36, 4, 86]
i = 0
dictionary = {}
for i, number in enumerate(numbers):
if numbers[i] in dictionary:
dicti... |
612172739b06ff4a37cea2e2097f523da877ff82 | wenchloe/Sentiment-Analysis- | /sentiment_analysis_sentiwordnet.py | 3,689 | 3.578125 | 4 | # Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# (optional) Converting .xls file to .csv
inputf_path = ''
df = pd.read_excel(inputf_path, encoding='utf-16')
df.to_csv(inputf_path, encoding='utf-16')
# Importing the dataset
text_col_num =
X = df.iloc[:, text_col_num... |
9bdedf7b7432350bb214eb9d167031234a35a9b2 | kleinma/deep_features | /scripts/polygon.py | 6,021 | 4.25 | 4 | """
A Python program to check if a given point lies inside a given polygon
Refer https://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/
for explanation of functions on_segment(), orientation() and do_intersect()
Transcribed into Python from the C++ code at the following website
https://www.geeksforg... |
941e2015850c633b7d70c713f4c6c6105bc109a8 | Lcch/ImageGallery | /webutils.py | 1,757 | 3.703125 | 4 | """
web utils:
1. download a page by url
2. download an image by url
"""
import sys
import os
import requests
from PIL import Image
def download_page(url):
# return the content of page
if not url:
return ''
try:
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537... |
ff5dfb85172099a69f85ad66b10a97c924422960 | d-nct/compendium | /derivative.py | 1,912 | 3.8125 | 4 | #! utf-8
# Derivada Central
# ----------------
def df(f, x: float, h: float=1e-6):
"""Retorna a derivada numérica central de f no ponto x, com aproximação de h.
Parameters
----------
f : function
Função a ser derivada em x.
x : float
Ponto em que f será derivada.
h :... |
0ed2b89214f9f705f40aebd0fddcb590ae627f8e | piotrszacilowski/practice-python | /07-list-comprehensions/task.py | 208 | 3.609375 | 4 | a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
even = [num for num in a if num % 2 == 0]
print(even)
# even = []
#
# for element in a:
# if element % 2 == 0:
# even.append(element)
#
# print(even)
|
20fe4574d1b1ec389a0180a738bb58e3182ba549 | sirtaj/maze | /dungeon.py | 5,860 | 4.125 | 4 | # Copyright (C) Sirtaj Singh Kang, 2006
__doc__=\
'''Dungeon Generator.
Algorithm Specification:
Start with a rectangular grid, x units wide and y units tall. Mark each
cell in the grid unvisited.
Pick a random cell in the grid and mark it visited. This is the
current cell.
From the current cell, pick a random dire... |
b5a048d933e657ce35aa6efb57fd211ea8650170 | bigcanbigbig/bigcanbigbig | /week5hw3.py | 448 | 3.5625 | 4 | # -*- coding: utf-8 -*-
f=open("index.txt","r")
space=0
e=0
n=0
count=0
word=f.read()
for x in word:
if x==' ':
space+=1
if x=='e':
e+=1
if x=='\n':
n+=1
count+=1
all=count-n
print 'space:%d' %space
print 'percentage of... |
af812d35e39cf53186dfe8bc574109623afd94bd | sallyjyl/Visual-Audio | /visualaudio_webapp/text_to_speech.py | 3,534 | 3.546875 | 4 | """Synthesizes speech from the input string of text or ssml.
Note: ssml must be well-formed according to:
https://www.w3.org/TR/speech-synthesis/
"""
from google.cloud import texttospeech
from google.cloud import translate
##Hardcoded list for supported list"
VOICE={
"en-US": {
"f" : {
"Standard": ... |
43248e833465b32b64b07ca9b78e180b7db75a1a | DGarvik/tutorial1 | /FizzBuzz.py | 498 | 4.21875 | 4 | ###### Solution for the Fizz Buzz problem #####
#Description: Prints out numbers between 0 and 100, for multiples of 3 it prints Fuzz
# and for multiples of 5 it prints Buzz.
def fizzbuzz():
list_of_nums = []
num = 0
for num in range(0, 100):
num += 1
if num % 3 == 0:
list_of... |
b90916bff30e75c988f78c182cc8e7cac9d5f42e | rafalwilk4ti1/software_intern | /task_2.py | 6,480 | 3.5625 | 4 | """
Task 2: scraping the “site” command (optional)
"""
# -*- coding: utf-8 -*-
from googlesearch import search
from serpapi import GoogleSearch
import pandas as pd
"""
Created on Thur. Sep. 02 11:30:00 2021
@author: rafalwilk4ti1
"""
""" The risk of using this program is enormous. Web scraping can simply
o... |
93a502948a6493a4990f68b030182cf760fcad04 | Amrit-stack/python-assignments-I | /func_Q14.py | 317 | 4.0625 | 4 | Bike = [{'name':'Pulsar', 'lot':100, 'color':'Black'}, {'name':'Honda', 'lot':88, 'color':'Red'}, {'name':'TVS', 'lot':97, 'color':'Blue'}]
print("Original list of dictionaries :")
print(Bike)
sorted_Bike = sorted(Bike, key = lambda x: x['color'])
print("\nSorting the List of dictionaries :")
print(sorted_Bike) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.