blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4ee2461848475915a819dfdf6ee064efcf009067
sidazhong/leetcode
/leetcode/easy/67_Add_Binary.py
292
3.5
4
class Solution(object): # python 特殊写法,直接加 def addBinary(self, a, b): """ :type a: str :type b: str :rtype: str """ return "{0:b}".format(int(a, 2) + int(b, 2)) a = "1010" b = "1011" print(Solution().addBinary(a,b))
e2cb70160aac6a5abc66ee38094fc674629b300d
AKASHRANA931/Python-Program-Akash-Rana-
/binary search.py
532
3.90625
4
def binary(list,key): low=0 high=len(list)-1 Found = False while low <= high and not Found: mid = (low + high) // 2 if key == list[mid]: Found = True elif key > list[mid]: low = mid + 1 else: high = mid - 1 ...
6596b2055eaaa5c7dcfd538ebeadd27202660f58
JonathanC13/python_ref
/35_BirthdayPlot/BD_months.py
2,194
3.53125
4
import json from collections import Counter # need to import at least 3 things to make your # bokeh plots work from bokeh.plotting import figure, show, output_file class BD_months(): def getMonthCount(self): BdaysAll = [] # open file for reading with open('BD_Json.json', 'r') as open_file...
e9ce0adb0c27ce15b11ef0602040454e1fc0af76
gabriellaec/desoft-analise-exercicios
/backup/user_072/ch65_2019_12_05_09_57_06_957795.py
199
3.5
4
def acha_bigramas(string): bigrama=[] i=0 while i<len(string)-1: x=string[i]+string[i+1] if x not in bigrama: bigrama.append(x) i+=1 return bigrama
eb3c64f00680ff9aff5ada60d9a60a42f7dd3798
ChaeSangJung/hankerrank_python
/Algorithms/easy/greedy/re_Beautiful Pairs.py
400
3.90625
4
https://www.hackerrank.com/challenges/beautiful-pairs/problem def beautiful_pairs(A, B): A = sorted(A) B = sorted(B) count = i = j = 0 while i < n and j < n: if A[i] == B[j]: count += 1 i += 1 j += 1 elif A[i] < B[j]: i += 1 else: ...
a39e73931b14fe1373d76c36ce9a881ae6fd09c4
zoog15/python_practice
/시간순삭 파이썬/0712 8장 연습문제6 거미줄 그리기.py
182
4.03125
4
import turtle t= turtle.Turtle() t.shape("turtle") t.speed(0) def draw_line(): t.forward(100) t.backward(100) for i in range(12) : draw_line() t.right(30)
ec668fc4fcad4597d78d59ce1690112e2135b23a
lock19960613/SCL
/Daily/PY/Leetcode5706-句子的相似性.py
567
3.53125
4
#往两边剔,前后一定要有一个能匹配 class Solution: def areSentencesSimilar(self, s1: str, s2: str) -> bool: if s1 == s2: return True if len(s1) > len(s2): s1,s2 = s2,s1 a1 = s1.split() a2 = s2.split() while a1: if a1[0] != a2[0] and a1[-1] != a2[-1]: ...
ab9e2b113a318f6bfab391424eab7901cc28752e
Rajat986/Python-Learning
/Sudoku.py
794
3.53125
4
class board: def __init__(self): self.a=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]] def compute(self): for i in range(9): r=getrow(i) ...
8831aa1272830231d34528bf2812b595571d7cee
MarceloBritoWD/URI-online-judge-responses
/Iniciante/1010.py
383
3.65625
4
# -*- coding: utf-8 -*- peca1 = input().split() peca2 = input().split() peca1_codigo = int(peca1[0]) peca1_numero = int(peca1[1]) peca1_valor = float(peca1[2]) peca2_codigo = int(peca2[0]) peca2_numero = int(peca2[1]) peca2_valor = float(peca2[2]) valor_total = (peca1_numero*peca1_valor) + (peca2_numer...
7c97a398fda66b5cc46c4d5373fb0904e6380969
HonniLin/leetcode
/history/138.py
1,796
3.984375
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @File : 138.py @Time : 2020/03/16 07:57:28 @Author : linhong02 @Desc : 遍历原来的链表并拷贝每一个节点,将拷贝节点放在原来节点的旁边,创造出一个旧节点和新节点交错的链表。 迭代这个新旧节点交错的链表,并用旧节点的 random 指针去更新对应新节点的 random 指针。比方说, B 的 random 指针指向 A ,意味着 B' 的 random 指针指向 A' 。 现在 random 指针已经被赋值给正确的节点, next...
fe3a43ed4b476adfc2256014608d5114c54b202a
GanquanWen/Deduplicator
/main/fileretrieve.py
1,159
3.5
4
## Copyright 2018 Ganquan Wen wengq@bu.edu import sys def retrieve(file, path): '''get the list of hash then retrieve the file according to hash in order ''' file_name = 'list_' + file f = open(path+file_name, "r") line = f.readline() f.close() org_list = line.split(", ") parts_list = [] for n in range...
32acae746470cd7085870a128d2364da627059d0
Akshay-agarwal/DataStructures
/General Problem/Rps.py
1,403
4.21875
4
import random print("----------------------Welcome To Rock Paper Scissors Lizard Spock------------------") print("0)Rock") print("1)Spock") print("2)Paper") print("3)Lizard") print("4)Scissors") player_wins=0 comp_wins=0 ties=0 game_playing='' while game_playing!='y': user_choice = int(input("Choose the number corr...
096d2b83fb090eb9369ce790b8197174f8488873
ValentinaArokiya/python-basics
/try_except_finally_1.py
234
3.875
4
try: result = int(input("Please provide a number: ")) except: print("Whoops! That is not a number") else: print("Thank you") finally: print("End of try/except/finally") print("I will always run at the end")
e4fa0e86ce87ac3baff53a82e79a989f806b15b1
Kirktopode/Python-Homework
/12Program1.py
339
3.84375
4
import urllib website = raw_input("What website do you want to visit?") fhand = urllib.urlopen(website) chars = 0 pcount = 0 for line in fhand: chars += len(line.strip()) pcount += line.count("<P>") if chars < 3000: print line.strip() print chars, "CHARACTERS TOTAL IN DOCUMENT\n" + str(pcount), "<P>...
0af0f02438e24084a384e392f2ce2eb1e882e4b7
Marlon-Poddalgoda/ICS3U-Unit3-05-Python
/month_program.py
1,459
4.4375
4
#!/usr/bin/env python3 # Created by Marlon Poddalgoda # Created on December 2020 # This program identifies the month from a value def main(): # this function identifies the month from a value print("This program identifies the month from a given value.") # input month_value = int(input("Enter a num...
60d6d6bad0f0b8e14d9c57dac9458e13d1f1c62a
danicon/MD3-Curso_Python
/Aula16/ex08.py
856
3.8125
4
listabr = ('São Paulo', 'Atlético - MG', 'Flamengo', 'Palmeiras', 'Internacional', 'Grêmio', 'Fluminense', 'Santos', 'Atlético - GO', 'Corinthians', 'Ceará', 'Red Bull Bragantino', 'Fortaleza', 'Athletico Paranaense', 'Sport', 'Bahia', 'Vasco da Gama', 'Coritiba', 'Goiás', 'Botafogo') for c in range(0, len(listabr)): ...
1f75fc532322a2e34068e0ceedb1f59326ef32bf
MitiaEfimov/Coursera
/DataStructures/week3_hash_tables/1_phone_book/phone_book_test.py
3,824
3.640625
4
# Python 3 """ In this test used cases given from week3_hash_tables's resource page. """ import sys import unittest #from ..phone_book import process_queries as fast #from ..phone_book import process_queries_naive as naive #from ..phone_book import read_queries FILE_PATH = "tests/" def get_data(file_path, need_answe...
974e8e8966a122d9f7d253b2552d1f804a58ac0c
humayun-ahmad/full_stack_web_developer
/Python - Level Two/objectOfCircle.py
320
4.0625
4
class Circle(): pi = 3.14 def __init__(self,radius): self.radius = radius def area(self): return self.radius * self.radius * Circle.pi def set_radius(self,new_r): self.radius = new_r # Circle parameter is the radius value obj = Circle(3) # set the new value of radius obj.set_radius(4) print(obj.area())
2a0fc3228947f0fa585eb179b1704a0decddebf5
msahu2595/PYTHON_3
/in_and_iterations_118.py
1,086
4.0625
4
# in keyword and interarions in dictionary user_info = { 'name' : 'harshit', 'age' : 24, 'fav movies' : ['coco', 'kimi no na wa'], 'fav tunes' : ('awakening', 'fairy tale') } # check if key exist in dictionary if 'name' in user_info: print('present') else: print('not present') # check if valu...
69581dbacd411dac2412471b97c541d0a51d3f9f
Lithak/Data_Analysis
/DAdaDistribution.py
378
3.5
4
import numpy as np #Data Analysis import matplotlib.pyplot as plt test_scores = [12, 99, 65, 85, 42] test_names = ["Andy", "Martin", "Zahara", "Vuyo", "Ziyaad"] x_pos = [i for i, _ in enumerate(test_names)] #labels on the x-axis #labeling and visuals plt.bar(x_pos, test_scores, color='blue') plt.xlabel("Names") plt.y...
cec1ab5a78cc0f09a8e4287e73d67023be1b8671
shcpark/PythonSampleCodes
/Algorithm/HackerRank/Strings/Capitalize.py
274
3.796875
4
def capitalize(string): sa = string.split(' ') for i in xrange(len(sa)): if len(sa[i]) == 0: sa[i] = sa[i].upper() else: sa[i] = sa[i][0].upper() + sa[i][1:] return ' '.join(sa) a = raw_input().strip() print capitalize(a)
d002ff326cc0325864e060a5d3c8ea4b76eae8a0
Dan-Teles/URI_JUDGE
/2712 - Rodízio Veicular.py
661
3.96875
4
import re n = int(input()) for i in range(n): s = input() if len(s) == 8: if s[3] == '-' and re.match("[A-Z]", s[:3]) and re.match("[0-9]", s[4:]): if s[-1] == '1' or s[-1] == '2': print('MONDAY') elif s[-1] == '3' or s[-1] == '4': print...
c8976fc1119201daeba44ff6c62c066443780b6b
IvanWoo/coding-interview-questions
/puzzles/add_strings.py
1,521
3.8125
4
# https://leetcode.com/problems/add-strings/ """ Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100. Both num1 and num2 contains only digits 0-9. Both num1 and num2 does not contain any leading zero. You must not use a...
b2fba7cf532916ec121981ee78632a6a610c0de2
MagidElgady/PyDataScience
/5_Pandas/2_pandas_operations.py
2,918
4.65625
5
# Python Full Course - Learn Python in 12 Hours | Python Tutorial For Beginners | Edureka # This lesson looks at all the basic operations that can be performed using pandas. import pandas as pd from matplotlib import style import matplotlib.pyplot as plt # Dictionary showing data about a website XYZ_web = {'Day': [1,...
270f01f01f54f8c135a754838fd0ae21417919a8
yakovitskiyv/algoritms
/Вставка_элемента.py
836
4.21875
4
class Node: def __init__(self, value=None, next=None): self.value = value self.next = next def print_linked_list(vertex): while vertex: print(vertex.value, end=" -> ") vertex = vertex.next print("None") def get_node_by_index(node, index): while index: node = n...
998bb62c5e8f57632bca45aca435ef139be818f0
sdshah5796/Data-Structures
/PycharmProjects/Data-Structures/Trees/mirror_image.py
840
3.796875
4
# https://leetcode.com/problems/symmetric-tree/ class Node: def __init__(self, key): self.left = None self.right = None self.data = key def isMirrorImage(root): if root is None: return True return isMirrorImageUtil(root, root) def isMirrorImageUtil(root1, root2): if ...
f86795ef7e7cf1c787b09cdf8892161f37df52d7
hw9603/Easy-Sing
/vocaloid/syllablesParser.py
746
4.40625
4
""" Parse syllables from lyrics. Example usage: 1. from utils import * lyrics = get_lyrics_from_file("lyrics.txt") syllables = parse_syllables(lyrics) 2. lyrics = "These are some lyrics stored in a string" syllables = parse_syllables(lyrics) """ import pyphen def parse_syllables(lyrics): """...
56674abc0867a053205836fc8588fc12e4d19489
KillerAK/agecalculator
/agecalc.py
207
4.03125
4
x = int(input ("year of birth")) years = 2019 - x if years <= 18: print("you are a minor") elif years <= 35: print("you are a god damn youth") else: print ("you are an elder")
f9870046bec00bd53ce49734edac412da3e1dc18
shenez/python
/test1.py
154
3.53125
4
def change(a,b): a = 10 b += a a = 4 b = 5 def main(): a=4 b=5 change(a,b) print(a,b) if __name__=='__main__': main()
3e34391f9f56772af5f33dda21e6c532e654b216
Sakisanprprpr/-
/alien_invasion/ship.py
2,525
3.875
4
import pygame from pygame.sprite import Sprite class Ship(Sprite):#创建一个飞船的类,包含飞船的所有属性 def __init__(self,screen,ai_settings):#添加两个形参 """初始化飞船并设置初始位置""" super().__init__() self.screen = screen#初始化两个形参 self.ai_settings = ai_settings #加载飞船图像并获取外接矩形 self.image...
0097b2ae46273a675ced917374d4b13ae4c0a878
coolsnake/JupyterNotebook
/new_algs/Number+theoretic+algorithms/Shor's+algorithm/pyshor.py
4,653
4.15625
4
#!../venv/Scripts/python.exe # -*- encoding : utf-8 -*- """ @Description: This project provides a Python implementation of Shor's algorithm. For more details see : https://arxiv.org/abs/1907.09415 @Author: Quentin Delamea @Copyright: Copyright 2020, PyShor @Credits: [Quentin Delamea] @License: MIT @Ver...
e536066384f58f3fbc5c6b215a16a701fd8c1989
Danutelka/Coderslab-Python-progr-obiektowe
/1_Zadania/Dzien_2/3_Zaawansowana_obiektowosc/zad_2.py
769
3.5
4
class BankAccount: __next_acc_number = 1 def __init__(self, ): self.number = BankAccount.__next_acc_number BankAccount.__next_acc_number +=1 self.cash = 0.0 def deposit_cash(self, amount): if amount > 0: self.cash += amount def withdraw_cash(self, amount):...
b5a89c301aaaea43b51f322ead064ce3cabababf
KrishAjith/Python
/FindLargeNum.py
295
4.25
4
Num1=int(input("Enter your 1st Number :")) Num2=int(input("Enter your 2nd Number :")) Num3=int(input("Enter your 3rd Number :")) if(Num1 > Num2): print(Num1," is Largest Number") elif(Num2 > Num3): print(Num2," is Largest Number") else: print(Num3," is Largest Number ")
ffb7601930a99ce57185784c404c2f2431c6e060
complex-systems-lab/Machine-learning-asssited-Chimera-and-Solitary-states-in-Networks
/Machine learning on multilayer network/neuralNetworkCriticalDelay.py
969
3.515625
4
import numpy as np import matplotlib.pyplot as plt from sklearn.neural_network import MLPClassifier from sklearn.model_selection import train_test_split from statistics import mean data = np.loadtxt("Naveen bhaiya paper\\dataMLCombined.txt") features = np.delete(data , 3 , 1) labels = data[:,3] X_train, X_test, ...
c437346e13375fd1400e7d386a57c130912c4acb
igorvrykolakas/training.py
/média aritmética.py
193
3.703125
4
n1 = float(input('Qual a nota da primera prova?')) n2 = float(input('Qual a nota do trabalho?')) t = n1 + n2 print('Uau! Sua nota média nesse trimestre é {:.2f}. Parabéns.'.format(t/2))
1275f1247b89ebd594ea6a20a1d5e1a29cbb302f
MingkaiMa/Project-Euler
/Problem_47.py
2,946
3.65625
4
##Prpblem_47 ##from math import sqrt ## ##def prime_factors(n): ## L = [] ## i = 2 ## while i * i <= n: ## if n % i: ## i += 1 ## else: ## n //= i ## L.append(i) ## ## if n > 1: ## L.append(n) ## return L ## ##for i in range(647,100000000): ## a = ...
cf8327bee6d65bbf426355b4398ae3407d4798e6
roman-baldaev/elastic_vs_sphinx_test
/src/parsers/file-parser.py
486
3.796875
4
import textract def parse_file(path_to_file, encoding_for_return="utf-8"): """ Method parses the file and returns the contents as a string with the specified encoding. :param path_to_file: path to file for parse by textract :param encoding_for_return: encoding of the returned string (textract.process ...
b44c9311edb4f000f3464b4338fa25cbbaec2203
ladosamushia/PHYS639F19
/NathanMarshall/Warmup2/Numerical Derivatives.py
1,294
4.46875
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 3 13:06:11 2019 Nathan Marshall This program contains functions that compute the numerical 1st and 2nd derivatives of a function f(x). As an example, f(x) is set to x**3 to test if the derivative functions are working properly. """ #%% dx = 0.0001 #the step size in x us...
9df28ee801b330150de42ac4556cc8f43fa7615d
jiangxiao24/onlinestudy
/day17/17生成器.py
3,425
3.953125
4
#__author__:jiangqijun #__date__:2018/11/17 #1、列表生成式,可以在前边加入表达式或者函数 # a = [x*2 for x in range(10)] # print(a) # # def f(n): # return n*n*n # b = [f(x) for x in range(10)] # print(b) #2、a.生成器,每次使用得时候才会计算,每次只能取下一个而不能跳跃取值.生成器就是一个可以迭代得对象 #下边得i取值得是接着上边一起取得,由于上边已经取完了所以下边就没有了 #在循环中,i这个变量每次只引用一个值,所以只有一个值是占用内存,前面得引用都消失 #在...
6c54029057a7358bb4135ed4ac46ce78c3ce9439
lexm/hackerrank-code
/Python/Regex_and_Parsing/re-group-groups.py
105
3.515625
4
import re input1 = re.search(r'([a-zA-Z0-9])(\1+)', input()) print(input1.group(0)[1] if input1 else -1)
75a178edf1c8cbb907abb7afb4705aacfb5e245a
Esot3riA/KHU-Algorithm-2019
/0926_Merge_Sort.py
2,057
3.6875
4
class MergeSortAlgorithm: def mergeSort(self, n, S): h = int(n / 2) m = n - h if n > 1: U = S[:h] V = S[h:] self.mergeSort(h, U) self.mergeSort(m, V) self.merge(h, m, U, V, S) def merge(self, h, m, U, V, S): i, j, k = 0...
5c1676eb19cf1beaba16d1f53a008329974086fb
ChrisDuhan/2143-OOP-Duhan
/Assignments/homework-02.py
8,871
3.578125
4
""" Name: Chris Duhan Email: chris.m.duhan@gmail.com Assignment: Homework 2 - War card game Due: 17 Feb @ 11:59 p.m. """ """ So this was a fun program, it's still got a few things that could be implimented more effectivly, plus it goes on till the last card, meaning that the game could possibly end during war. I also ...
c8896aa0bc61c8ea6144569f683c1da47a9b0130
vmirisas/Python_Lessons
/lesson8/part5/exercise4.py
966
3.6875
4
string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sed libero vitae est rhoncus cursus at eget eros. Phasellus laoreet lobortis suscipit. Duis pretium felis quis tristique lacinia. Nulla id convallis dolor, ac dapibus lectus. Maecenas gravida ut arcu sit amet ultrices. Quisque ut massa sit amet ...
d321a965bea65065fa2a0462efdff86c1f5f97a4
dygksquf5/python_study
/Algorithm_python/Permutations.py
1,027
3.640625
4
# 꼭 복습 해보기!! import itertools from typing import List def permute(nums: List[int]) -> List[List[int]]: result = [] prev_elements = [] def dfs(elements): # 리프 노드일 때 결과 추가 if len(elements) == 0: # 변수를 그대로 넣지말고, 안에있는 값을 복사해서 넣는식으로 넣자! 파이썬은 객체를 참고하는 형태로 처리되니까 에러방지! res...
cd498860827e743e7d355c37d6bbe01c1c83a578
SravanKumarMenthula/Python
/DSA/LinkedList/Swap.py
1,630
4.125
4
class Node: def __init__(self,data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def swap(self,x,y): currentX = self.head currentY = self.head prevX = None prevY = None #find X ...
6870e3e6844dc748da5c6d394100727dff6916f6
MrHamdulay/csc3-capstone
/examples/data/Assignment_6/grhisa001/question3.py
845
3.953125
4
""" Bella Gorham voting 20/04/2014""" # empty lists parties = [] finalparties= [] answerlist= [] vote="" # ask for input until done print("Independent Electoral Commission\n--------------------------------\nEnter the names of parties (terminated by DONE):") while vote != "DONE": vote=input() parties.append(vo...
096e39b381e13cc6621c50f45d3fb38d37bc3502
nuttapol-kor/Final-project-Year1-Semester1
/games/Pok_deng.py
12,800
3.625
4
import sys class Deck: def __init__(self): """ Initialzing a deck for play """ self.__rank = ["2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"] self.__suit = ["Clubs", "Diamonds", "Hearts", "Spades"] self.__deck = [] for rank in self.__rank: ...
16383c707c0d2146b5cb3d88683788e5d80b899a
malhotraguy/FUN_WITH_JSON
/code.py
1,739
3.515625
4
import json import requests response = requests.get('https://jsonplaceholder.typicode.com/todos') todos = json.loads(response.text) # Map of userId to number of complete TODOs for that user todos_by_user = {} print("todos[:5]=",todos[:5]) # Increment complete TODOs count for each user. for todo in todos: if todo["c...
6de0b8f9eff5e0eee722726db9f9dd31d2b80377
e7k8v12/ProjectEuler
/0001_0100/0024/0024.py
1,379
3.75
4
# https://projecteuler.net/problem=24 # A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, # 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The # lexicographic permutations of 0, 1 and 2...
d154b81b26a9b77011ac618c035f4cde2e4ef677
ne0de/passner
/src/database.py
2,528
3.546875
4
import sqlite3 from sqlite3 import Error class PassnerDatabase(): def __init__(self, path): self.path = path self.conn = None self.cursor = None self.mainTable = """ CREATE TABLE IF NOT EXISTS main ( id integer PRIMARY KEY, user text NOT ...
9795f1767285ef52dbe3ee8b60a2087c75e6a97a
ViktorWase/TootieRootie
/dual_numbers.py
1,627
3.578125
4
from math import sin, cos, exp, log, sqrt, asin, acos from sys import version_info class DualNumber(): """ A dual number is a+b*e, where e*e=0. It's very useful for automatic differentiation. """ def __init__(self, a, b): self.a = a self.b = b # Overloads the standard operations: +, -, *, /. def __add__(se...
01ecad8bd5b5f6a8d4cf667035ff3e225c444453
rubyclaguna/Intro-Python-II
/src/player.py
904
3.609375
4
# Write a class to hold player information, e.g. what room they are in # currently. from item import Item class Player: def __init__(self, name, room): self.name = name self.room = room self.inventory = [] def move(self, direction): if direction in ['n', 's', 'e', 'w']: ...
15d088d1411f7534c77b0658f9e8e9d55387b733
conservativeghosts/CT_codesandstuff
/listAppV2.py
2,599
4.3125
4
import random """ Program Goals: 1. Get the input from the user! 2. Convert that input to an INT 3. Add that input to a list 4. Pull values from a specific intex positions """ listyBoi = [] def mainProgram(): while True: try: print("yo, we're gonna work with some lists now") ...
e5604b1991ceacd307b40f140c57ab94d72b4a03
nymoral/euler
/p59.py
1,100
3.53125
4
import itertools def char_table(): chars = [] for c in range(128): good = False if 32 <= c < 127: good = True chars.append(good) return chars def guess_keys(cipher): table = char_table() src = tuple(range(97, 123)) step = 3 for key in itertools.product...
d5a329edec5ccbce37ab1f77ea254eaff74c9433
dimikout3/ComputationalGeometry
/jimBeam.py
415
3.671875
4
def areaTriangle(x1,y1,x2,y2): return abs(x1*y2 - x2*y1)/2 if __name__ == '__main__': x1, y1 = 2,2 x2, y2 = 3,3 xm, ym = 1,1 OAOM = areaTriangle(x1,y1,xm,ym) OMOB = areaTriangle(xm,ym,x2,y2) OAOB = areaTriangle(x1,y1,x2,y2) MAMB = areaTriangle(x1-xm,y1-ym,x2-xm,y2-ym) # cooli...
99654b9c3230de9e712d5b33104a550e47b52351
kbhat1234/Python-Project
/python/dictionary1.py
225
3.890625
4
Dict = {'Tim': 18,'Charlie':12,'Tiffany':22,'Robert':25} print Dict.keys() print Dict.values() print Dict print Dict['Tiffany'] Dict1 = {10: 2008,5: 2007,15:2009, 1:2010} print Dict1.keys() print Dict1.values() print Dict1
59895778cbd8ad4d0ef745f973b1814cef22b865
anandvimal/data-structures-and-algorithms
/1 Algorithmic toolbox/week2/lcm.py
586
3.78125
4
def gcd_eucledian(a,b): if a==0: #print(f"return b:{b}") return b if b==0: #print(f"return a:{a}") return a #print(f"a:{a} b:{b}") holder = a%b a=b b=holder #print(f"a:{a} b:{b} holder:{holder}") return gcd_eucledian(a,b) if __name__ == "__main__": ...
9d865b16e709e1e6718fe4da86fac786940be836
dltmdtn0128/Python_Programming
/Ch7/Ch7_1.py
135
3.609375
4
for i in range(1,101): if i%5==0 and i%7==0: print('FizzBuzz',i) elif i%5==0: print('Fizz',i) elif i%7==0: print('Buzz',i)
4d38bac22a93371b5d0040bd280788b52816d374
Robinzzs/pythonlearning
/basic-function-learning/format.py
149
3.53125
4
# -*- coding: utf-8 -*- print('%2d-%02d'%(3,1)) print('%.2f'%3.1415926) a='hello,{0},update{1:.1f}'.format('xiaoming',90.4534) print(a)
f4973e8b36ed07b2b91af5cc2eff46436bf9e8f7
AdamZhouSE/pythonHomework
/Code/CodeRecords/2736/58585/317751.py
500
3.703125
4
a=input() b=input() c=input() d=input() if a=='8 3' and b=='13 32 11 34 7 22 45 12': print(22) print(13) elif a=='5 3' and b=='3 2 1 4 7' and c=='Q 1 4 3': print(3) print(6) elif a=='5 3' and b=='3 2 1 4 7' and c=='Q 1 5 3' and d=='C 1 0': print(3) print(2) elif a=='5 3' and b=='3 2 1 4 7' and c...
6d8aaa7cab5626baf5b8c55bff48d3b567d1bca6
shuai-yang/SVM-classifier
/svm.py
3,391
3.953125
4
# Scikit-learn’s make_blobs function allows us to generate the two clusters/blobs of data from sklearn.datasets import make_blobs # Scikit-learn’s train_test_split function allows us to split the generated dataset into a part for training and a part for testing from sklearn.model_selection import train_test_split impor...
56bc5ec2c21cf4081d47d175b23aec54770e0424
JansenRachel/functions_intermediate1
/functions_intermediate1.py
286
3.65625
4
import random def randInt(min=0, max=100): num = random.random()*(max-min) + min return round(num) print(randInt()) # print(randInt(max=35)) # print(randInt(min=66)) # print(randInt(min=16, max=85)) print(randInt(max=5)) print(randInt(min=95)) print(randInt(min=20, max=25))
a805b2df50168e571d46fa5edb514f9b2da6095a
davidchuck08/InterviewQuestions
/src/NthUglyNumber.py
501
3.53125
4
#!/usr/bin/python def getNthUglyNumber(n): if n is None: return 0 if n<=0: return 0 list=[] list.append(1) i=0 j=0 k=0 while len(list)<n: m2=list[i]*2 m3=list[j]*3 m5=list[k]*5 minNum = min(m2, min(m3,m5)) if minNum =...
81582ed1fd71ce8d246ca41c7c36b77700baeaeb
RainingComputers/pykitml
/pykitml/datasets/boston.py
2,823
3.546875
4
import os from urllib import request from numpy import genfromtxt from .. import pklhandler ''' This module contains helper functions to download and load the boston housing dataset. ''' def get(): ''' Downloads the boston dataset from https://archive.ics.uci.edu/ml/machine-learning-databases/housing/ ...
cff7a455e2d46fd02528d2eb583d3a568a810e0c
kgaurav123/Python-Projects
/course/seven.py
751
4.09375
4
while True: try: number=int(input("Enter a number")) break except ValueError: print("You didn't entered any number") except: print("Unknown error occured") print("Thanks for your response") secret_number=7 while True: n=int(input("Enter a number")) if(n==secret_nu...
f2a1cccafced8623596a883abd65cf966f49c5a7
mnogom/python-project-lvl1
/brain_games/engine.py
1,836
3.984375
4
"""Module create templates for game status and describe engine of any game.""" import prompt COUNT_OF_ROUNDS_TO_WIN = 3 TEMPLATE_QUESTION = "Question: {task}" TEMPLATE_ON_RIGHT_ANSWER = "Correct!" TEMPLATE_ON_WRONG_ANSWER = ("'{user_answer}' is wrong answer ;(. " "Correct answer was '{ri...
43fd0b72dd8b594ace0936201a9d4499656d7b1c
0318648DEL/python-practice
/untitled/13.1.py
215
3.59375
4
filename=input("파일 이름을 입력하세요 : ") f=open(filename) erase=input("제거할 단어를 입력하세요 : ") content=f.read() new=content.replace(erase,"") f.close() f=open(filename,"w") f.write(new)
2b0039eb72257642ed9c2a3125a741d455a7f555
CollinsMbogori/SYSC3010_collinsmwenda_mbogori
/Lab 2/temp_emulator.py
209
3.90625
4
import random def get_temperature(): temp = random.randint(-1,41) if temp >= 0 or temp <= 40: print("Temperature within range", temp) else: print("Temperature out of range", temp)
3b26ca32ac3ac1d798a951b82a7b5670f2e53ee7
WinrichSy/Codewars_Solutions
/Python/6kyu/CountLettersInString.py
181
3.53125
4
#Count Letters in String #https://www.codewars.com/kata/5808ff71c7cfa1c6aa00006d import collections def letter_count(s): s = collections.Counter(list(s.lower())) return s
96f7499a9736e2a0e2dff903d5ffb9480f672814
BertDaNerd/IntroToPython
/madlib.py
428
3.71875
4
print("""Welcome to Madlibs You ll be asked for different nouns and verbs, try to make' em funny""") plural_noun = raw_input("please provide a plural noun:") noun1 = raw_input("please provide a noun:") noun2 = raw_input("please provide a noun:") song = raw_input("please provide the title of a song:") verb = raw_input(...
5ee6a24923051820f028beb82f09f4a1d0bef2f9
pavanmsvs/hackeru-python
/capitalise-string.py
139
3.75
4
name = input("Enter a name \n") n=list(name.split(" ")) j=[] for i in n: j=i[0].upper()+i[1:len(i)] print(j,end=" ")
aa46dfc57fd0a402f8810f2560c2aed9f358dda5
Teinstein/mathstein
/Mathstein/mathmatcalc.py
5,601
4.25
4
#!/usr/bin/env python # coding: utf-8 # In[36]: def mataddition(A,B): """ Adds two matrices and returns the sum :param A: The first matrix :param B: The second matrix :return: Matrix sum """ if(len(A)!=len(B) or len(A[0])!=len(B[0])): return "Addition not possible" ...
09338353395039297870a5a0cc37d2fd71371c81
AdamZhouSE/pythonHomework
/Code/CodeRecords/2686/60627/299554.py
109
3.546875
4
n = int(input()) for i in range(n): k = input() input() num=input() s = k + num print(s)
ef8c036ea6cbbada34a9965c22667fc2d79103bc
seanschneeweiss/RoSeMotion
/app/resources/b3d/math3d.py
5,557
3.6875
4
import math # Converts angle from degree to radian def to_radian(angle): return angle / 180.0 * math.pi # Constructs a quaternion from a rotation of degree 'angle' around vector 'axis' def quaternion(axis, angle): angle *= 0.5 sinAngle = math.sin(to_radian(angle)) return normalize((axis[0] * sinAngle, axis[1] ...
5fc4e39a1bee76d12b39b8e5d55640f8c338798b
aidanrfraser/CompSci106
/sumList.py
192
3.859375
4
from cisc106 import assertEqual def sum_list(alist): """ Sums all elements in a list """ if not alist: return 0 else: return alist[0] + sum_list(alist[1:])
a9436c5b003d394405d5604ed2d7057a1b06c5aa
xndong1020/python3-deep-dive-02
/8. itertools/4.infinite_iterator.py
1,094
3.71875
4
from itertools import count count1 = count(10) # start from 10, step default to 1 print(count1) # lazy, infinite iterator ### 10 11 12 13 14 15 16 17 18 19 ### for _ in range(10): print(next(count1)) count2 = count(1, 2) for _ in range(10): print(next(count2)) ### 1 3 5 7 9 11 13 15 17 19 ### count3 = ...
d0cf8346c5aa4fad44093bb5b339b2e8edc7b0dd
eshaw2/SoftwareDesign
/fermat.py
552
4.28125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 9 14:47:52 2014 Based on user input, this program verifies whether Fermat's Last Theorem holds for the inputted values. @author: elena """ # part 1 def check_fermat(a,b,c,n): summ = a**n+b**n expo= c**n if n > 2 and summ == expo: print 'Holy smo...
6270d6ea71e4323a47d68ade434cc04f85cf5f0d
GourBera/ProjectPython3
/ProjectPython3/OOPS/OOPS2.py
1,187
3.921875
4
''' Created on Mar 7, 2018 @author: berag ''' class Student(): no_of_Std = 0 per_rise = 1.05 def __init__(self, first, last, marks): self.first = first self.last = last self.marks = marks self.email = first + '.' +last + '@gmail.com' Student.no_of_St...
011362f6a420257421f28ecda74353e7d06cdb4b
Anson008/Think_Python_Exercise
/Exercise_6_5.py
220
4.03125
4
def gcd(a, b): """Take parameters a and b and returns their greatest common divisor. a, b: integer """ r = a % b if r == 0: return b else: return gcd(b, r) print(gcd(6, 8))
58b846f75bbf29ee0f882f9a318740778af09f03
DevJ5/CS50
/reference.py
1,722
4.03125
4
from sys import argv print(argv[0]) print("Enter a number: ") x = int(input()) print("Enter a number: ") y = int(input()) print(f"x + y = {x + y}") print(f"x / y = {x / y:.2f}") print(f"x // y = {x // y}") # For flooring division. print("Enter y or n: ") answer = input() if answer == "y" or answer == "Y": print...
90140bcaa185ec3016c4fe23c1694f1eb45fee35
yoBuhler/POOFacul
/LISTA 9 - Encapsulamento/main.py
1,815
3.75
4
class Conta: def __init__(self, cpf, nome, saldo): self._cpf = cpf self._nome = nome self._saldo = saldo self._numero_alteracoes = 0 @property def cpf(self): return self._cpf @cpf.setter def cpf(self, cpf): self._cpf = cpf self._numero_altera...
8a0511a700895b69ed4daa9200ace9a6dd4be70d
Vignettes/PythonBootcamp
/Section_20_Lambdas_and_Built_In_Functions.py/abs_sum_round.py
2,235
4.40625
4
### abs ### stands for absolute value. Returns the absolute value of a number. ### The argument may be an integer or a floating point number. print(abs(-23)) # You can import math to turn everything to float first import math print(math.fabs(-4)) # returns 4.0 ### Sum ### takes an iterable and an optional start. #...
c58ea977b1f3d7ed33b64ca329d3d7647e229cd8
suifengqjn/python_study
/12file/file_deep.py
2,671
3.640625
4
# # # open() 函数常用形式是接收两个参数:文件名(file)和模式(mode)。 # # open(file, mode='r') # 完整的语法格式为: # # open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) # 参数说明: # # file: 必需,文件路径(相对或者绝对路径)。 # mode: 可选,文件打开模式 # buffering: 设置缓冲 # encoding: 一般使用utf8 # errors: 报错级别 # newline: 区分换行符 # ...
52cc76a89a90743c1d3eb18a31af7c5599e8c374
linfangzhi/py
/00003.py
325
3.6875
4
def Dec2Bin(dec): temp = [] result = '' while dec: quo = dec % 2 # 取余 dec = dec // 2 # 地板除 temp.append(quo) while temp: result += str(temp.pop()) # 移除最后的一个字符 return result Dec2Bin1 = input("heiheihei") a = int(Dec2Bin1) print(Dec2Bin(a))
7394c5c6319a8656dc6040037af8cd9f7b64f11f
Liang-Jian/EKIA
/python/ModelDesign/door/door_marry.py
4,149
3.609375
4
''' page57 门面模式的应用 ''' # # class EventManager(object): # def __init__(self): # print("Event Manager :: Let me talk to the folks \n") # def arrange(self): # self.hotelier = Hotelier() # self.hotelier.bookHotel() # # self.florist = Florist() # ...
a94469345630c5d14a329c9b85e465e5395825e2
anikahussen/algorithmic_excercises
/functions/myfunctions.py
4,541
4.375
4
#line drawing module def horizontal_line(width): ''' Create horizontal line based on width value parameter ''' print ("*" * width) def vertical_line(shift, height): ''' Create vertical line based on the shift and height value paramaters ''' for line in range(0, height): print (...
dad3c01797dcfdea61b05d6c984d722043bafb29
PyStudyGroup/clases
/Unidad 2/Desafios/Sem2Des1_KelvinProvincia.py
686
4.28125
4
#! /usr/bin/env python #version de python 3 #obtener numero decimal a partir de un numero binario def getDecimal( binario ): contador = 0 acumulador = 0 #invertimos el binario: 110 -> 011 binarioInvertido = "" for i in binario: binarioInvertido = i + binarioInvertido #trabaja...
c1f6e2d38b920a9f052479ad26af08ec44ea06cb
Kso-ai/school
/initDev/td2.2.3.py
1,411
3.875
4
from math import e def methode_1(): x = -1 while x != 0: while x < 0: x = int(input("Entrez une valeur: ")) if x > 0: a = int(x) for i in range(1, 101): a = 0.5 * (a + x/a) print(f"La racine carrée de {x} est {a}.") def methode_2(): ...
b9db59fd650648fb101bb6b082ff29d7c362136a
udaraweerasinghege/ADT-methods
/LinkedListRec/Non-mutating/4suml.py
267
3.671875
4
from linkedlistrec import LinkedListRec, EmptyValue def sum(L): if L.first is EmptyValue: return 0 else: return L.first + sum(L.rest) test = LinkedListRec([0]) print(sum(test) == 0) test1 = LinkedListRec([0,1,2,3,4]) print(sum(test1) == 10)
5f79d35de2b7d43ab1259232d5bdce9e1981bad4
haominhe/Undergraduate
/CIS210 Computer Science I/Projects/p6/grid.py
6,423
4.03125
4
""" Grid display. Displays a rectangular grid of cells, organized in rows and columns with row 0 at the top and growing down, column 0 at the left and growing to the right. A sequence of unique colors for cells can be chosen from a color wheel, in addition to colors 'black' and 'white' which do not appear in the ...
daa830c71d61d18ddd464c6de80395ecef6e7e90
kr0t/ya_algo
/combination.py
456
3.78125
4
NUMBERS = { '2': 'abc', '3': 'def', '4': 'ghi', '5': 'jkl', '6': 'mno', '7': 'pqrs', '8': 'tuv', '9': 'wxyz' } def combination(numbers: str, s: str, length: int, idx: int) -> str: if length == 0: print(s, end=' ') else: for symbol in NUMBERS[numbers[idx]]: ...
caba112b6f4e703fe30d1254cf36502782353bab
MelihCelik00/GEO106E
/geo106e_lab projeler/LabWork13/resection.py
3,541
4.21875
4
# -*- coding: utf-8 -*- """ Created on Tue May 08 14:12:43 2018 @author: isiler """ import math x1 = float(input("ENTER THE X COORDINATES OF KNOWN POINT P1: ")) y1 = float(input("ENTER THE Y COORDINATES OF KNOWN POINT P1: ")) x2 = float(input("ENTER THE X COORDINATES OF KNOWN POINT P2: ")) y2 = float(inp...
4c418fd67a626f395eb5141b4158a71214b7466c
ibirdman/PythonLearning
/linear_regression.py
1,379
3.71875
4
import numpy as np W = [0.3, 0.1, 0.2] # 线性参数列表 (W[0] is bias) DIM = len(W) - 1 # 属性数量 # sample point count for training. m = 30 x_data = np.float32(np.random.rand(m, DIM)) # 随机输入 w_data = np.array(W[1:]).reshape(DIM, 1) y_data = np.dot(x_data, w_data) + W[0] # print(x_data) # print(y_data) # Points x-coordina...
b70018e815ec7178c40ab088582788e3456746ea
jeffreytjs/100DayOfCode
/condition_and_loop/construct_number_pattern.py
375
4.0625
4
# Day 10 - Problem 13 # Challenge # Write a Python program to construct the following pattern, # using a nested loop number. # Example # 1 # 22 # 333 # 4444 # 55555 # 666666 # 7777777 # 88888888 # 999999999 def num_pattern(n): """ Print a pattern as above with a loop. :params n: """ for i in ra...
e3782f893ba68dd5e196a68e66ec014033d6ebf7
ramanaditya/beginners
/python/bmi_calculator.py
619
4.5
4
# getting input from the user and assigning it to user height = float(input("Enter height in meters: ")) weight = float(input("Enter weight in kg: ")) # the formula for calculating bmi bmi = weight/(height**2) # ** is the power of operator i.e height*height in this case print("Your BMI is: {0} and you are: ".forma...
9b762ae8abcf5d4c14d94c4677519b52827996f8
hyu-likelion/Y1K3
/week1/hyungeun/0-1/2908.py
119
3.671875
4
a, b = input().split() num1 = int(a[::-1]) num2 = int(b[::-1]) if num1 > num2: print(num1) else: print(num2)
9615920dca520c085b93739cc2a1fe54d305ad19
varun1414/Xformations
/Scrappers/to_csv.py
467
3.625
4
import csv def convert(data,name): csv_columns = ['comp','date','result','teams','score','formation'] dict_data = data csv_file = name try: with open(csv_file, 'w') as csvfile: writer = csv.DictWriter(csvfile, fieldnames=csv_columns) writer.wri...
665430b853fbdc5a616d8036cd3a20bc6a8e8738
ballaneypranav/ucsd-dsa
/1-algo-toolbox/2-algorithmic-warmup/7_last_digit_of_the_sum_of_fibonacci_numbers_again/fibonacci_partial_sum.py
1,475
3.609375
4
# Uses python3 import sys def fibonacci_partial_Sum(from_, to): period = -1 fibListMod = [0, 1] if from_ < 2 and to >= 1 : Sum = 1 else: Sum = 0 for i in range(2, to+1): fibListMod.append((fibListMod[i-1] + fibListMod[i-2]) % 10) if fibListMod[i] == 1 an...
153290c7fc7494fb260a1601a6e9ac87ac70bdb6
niteenmore/python-npci-assignments
/AtmTransaction.py
1,215
3.53125
4
fixedCash=60000 userbalnce=70000 n=3 lst=[] def main(): print("Total amount in ATM :",fixedCash) print("Total amount in your account",userbalnce) amount=int(input("How much amount you want to withdraw ?")) def withdraw(amount): global fixedCash global userbalnce ...
884e411f308b4f9d157054cac4310d94d04cb6d9
karbekk/Python_Data_Structures
/Interview/DSA/Array/max_sum_subarray.py
354
3.6875
4
def max_sub_array(my_array): max_sum = 0 max_now = 0 for i in range(0,len(my_array)): max_now = max_now + my_array[i] if max_now < 0: max_now = 0 elif max_now > max_sum: max_sum = max_now if max_sum <= 0: return 5 return max_sum print max...