blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2b7eab50904664194aaf601e3ea4f21bf4f46cc1
D3ee/StudentManagerSystem
/student.py
225
3.515625
4
class Student(object): def __init__(self,name,gender,tel): self.name=name self.gender=gender self.tel=tel def __str__(self): return f'{self.name},{self.gender},{self.tel}'
680671eb632109b18486520bbf0201824b2089d3
mjjk88/game_of_life_simulation
/game_of_life_simulation_package/life_simulation.py
2,082
3.78125
4
import random from dataclasses import dataclass @dataclass class LifeSimulation: alive_cells_coordinates: set box_length: int @staticmethod def empty_simulation(): # factory method return LifeSimulation(alive_cells_coordinates=set(), box_length=100) def generate_initial_state(self, ali...
855b5993cf3c4780102c22cb0e60a0823da7abc1
andreplacet/exercicios_python
/exercicio43.py
420
3.78125
4
nome = str(input('Qual seu nome? ')).strip() altura = float(input('Qual Sua Altura? (m)')) peso = float(input('Qual o seu peso? (kg)')) imc = peso / (altura ** 2) print('O seu imc {}, é de {:.1f}!'.format(nome.capitalize(), imc)) if imc < 18.5: print('Voce esta abaixo do peso normal') elif imc >= 18.5 and imc < 25:...
b7ec4f2a20af2386b112ffe81571ad593ac87fb3
profnssorg/claudioSchefer1
/6_11.py
461
3.8125
4
"""Programa 6_11.py Descrição:Modificar programa da listagem 6.15 usando for. Autor:Cláudio Schefer Data: Versão: 001 """ # Declaração de variáveis L = [] n = int(0) # Entrada de dados n # Processamento while True: # este while não pode ser alterado para for pq não sabemos o número de repetições. n =...
a7d0cf53b9402e50619ff78ff09aa71686f9c98c
systembase-kikaku/python-learn
/chapter3/for.py
219
3.5625
4
def myfor(itr, cb): _itr = iter(itr) while True: try: v = next(_itr) cb(v) except StopIteration as e: break nums = [1, 2, 4] myfor(nums, lambda x: print(x))
c3014098006e4bb1e67e81bd1dcd2c8dcd0fca43
jochasinga/mini-hashmap
/hashmap.py
1,715
3.515625
4
import hashlib from collections import deque class HashMap(object): def __init__(self, size = 100): """ Create a HashMap object. size default to 100. Anywhere less than that is very likely to get high collisions. """ if size is not None: self._array = [deque() for x in range(size)] else: raise V...
73234d5bb1da9ee85dc39f96a57c2fa08a8329b4
FrontEndART/SonarQube-plug-in
/test/python/LIM2Metrics/py2/base/common/Python060/Python060.py
214
3.578125
4
from Tkinter import * root = Tk() root.title('Canvas') canvas = Canvas(root, width =400, height=400) xy = 10, 105, 100, 200 canvas.create_arc(xy, start=0, extent=270, fill='gray60') canvas.pack() root.mainloop()
6125147983456c0e4e2ab42ec1dd29acc81a5c7b
yl29/pe
/q0021.py
1,293
3.53125
4
from time import * import math # Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). # If d(a) = b and d(b) = a, where a != b, then a and b are an amicable pair and each of a and b are called amicable numbers. # For example, the proper divisors of 220 are 1, 2, 4, 5,...
dbf6c21846c7b9b62d25ef38fbc0647d2f7ef3f6
ian0510/MTA-python
/day2-4.py
378
3.875
4
import random ans = random.randint(1,10) time = 1 while True: guess = int(input("guess number?")) if ans == guess: print("right") print(time) break elif guess < ans: print("guess a bigger number") print("wrong") elif guess > ans: print("guess ...
adfe5b7e8e210ddce1521fcbcf511beb807e38e9
enlambdment/my_pcc
/ch_8/input_albums.py
399
3.65625
4
from make_album import make_album while True: print("Enter artist name, album title, & optional tracks number: ") print("\n(Type q to quit at any time) ") art_n = input("Artist name: ") if art_n == 'q': break alb_t = input("Album title: ") if alb_t == 'q': break trk_n = input("Tracks number (optional): "...
06387130ab2c2a4099c3285871335d26186fc1dd
jk72/learning-python
/week-01-python/class-test.py
721
3.59375
4
# 사칙연산 계산 클래스 class fourcal: # 두 숫자 입력 받는 함수 def setdata(self, first, second): self.first = first self.second = second # 더하기 계산 함수 def sum(self): result = self.first + self.second return result # 곱하기 계산 함수 def mul(self): result = self.first * self.second re...
b5886117f95e5062de50632a3267a8daf74a5972
yossibaruch/learn_python
/learn_python_the_hard_way/ex11.py
462
3.734375
4
print "How old are you?", age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weigh?", weight = raw_input() print "So, you're %r old, %r tall and weigh %r." % (age, height, weight) print "How old are you?", nage = int(raw_input()) print "How tall are you?", nheight = i...
da29798e872e83d535004009a8076cb5b4c755ef
vivekanandabhat/PYTHON-LEARNING
/S05Q04_Fibonacci.py
747
4.3125
4
""" Take a number as input from the user. Find which Fibonacci number is nearest to that number and print it. """ def print_near_fibo(num) : a = 1 b = 1 c = 2 while (c < num) : a = b b = c c = a + b if (( c - num ) > ( num - b )) : print...
fa4aeaa73fc1197cc6bdc7bef9f0452ea5bcf286
dylanbram354/Robots_vs_Dinosaurs
/Robos vs dinos - pycharm/dinosaur.py
839
3.515625
4
import random class Dinosaur: def __init__(self, type, attack_power, energy_drain=-10): self.type = type self.energy = 100 self.attack_power = attack_power self.health = 100 self.energy_drain = energy_drain def attack(self, robot): attack_types = ('claw', 'bite...
a1ef1a9053430ce9213179c1a95c97942a40a7c1
alfonsochie/task-week-5
/number 12 week 5.py
283
4.40625
4
def make_form(): Word = input('Enter a word: ') if Word.endswith('y'): New_word=Word[:-1]+'ies' elif Word.endswith(('o', 'ch', 's', 'sh', 'x' ,'z')): New_word=Word+'es' else: New_word=Word+'s' print(New_word) make_form()
b4e2eff0500b7a4666a4dba665c582c1848004d1
sherinfazer/python
/python29.py
222
3.953125
4
time = float(input("Input time in sec: ")) day = time // (24 * 3600) time = time % (24 * 3600) hour = time // 3600 time %= 3600 min = time // 60 time %= 60 sec = time print("d:h:m:s-> %d:%d:%d:%d" % (day, hour, min, sec))
993525192fa165f20f1810c7ee23f02680456edb
ervaneet82/python
/practice/EDABIT/letter_check.py
177
3.6875
4
def letter_check(lst): s1, s2 = lst for char in s2: if char.lower()in s1.lower(): pass else: return False return True print(letter_check(["compadres", "DRAPES"]))
f01a2ca6b050f9ebc8fddc2dab8fc605b5fbb66e
gaochenchao/test
/MyQueue.py
2,222
3.75
4
# -*- coding: utf-8 -*- # from mystack import MyStack __author__ = 'gaochenchao' class QueNode(object): def __init__(self, value, next): self.value = value self.next = next def __repr__(self): return self.value class MyQueue(object): def __init__(self): self.head = Qu...
7732160732a552293600ff7cc200b53b64f983fc
PhoenixGreen/Python-GUI
/Version 1/2.3 GUI - Image slideshow - Version 2.py
944
3.65625
4
from tkinter import * image_list = [ "trees1.gif", "image 1 description", "trees2.gif", "image 2 description", ] current = 0 #Main window & Background image - Tkinter: window = Tk() window.title("Background Image and lables") # Action After Button Press def after_click(): global current global imag...
43a2e9822ae4639bd94923f8d581e6544f72ff52
SMAK-OPERATOR/cp
/bisection.py
993
3.9375
4
def fn(x): return x ** 3 - 3 * x ** 2 + 9 * x - 8 def check(r, e): return abs(r) < e def bisection(f, e, xl, xr): max_step = 10 steps = 0 print("Погрешность e = %.5f, отрезок [%.5f; %.5f]" % (e, xl, xr)) print("Максимальное количество шагов %d" % max_step) print("Проверяем границы отрезка") print(...
e6d867d0037bbb2013383872a426c5311585c700
drliebe/python_crash_course
/ch7/three_exits.py
897
4.0625
4
prompt = 'Enter your age to find out the price of your ticket.' prompt += "\n('quit' to stop): " active = True while active: age = input(prompt) if age == 'quit': active = False elif int(age) < 3: print('Your ticket is free.') elif int(age) < 12: print('Your ticket is $10.') ...
46afe3887f368c39ee37c2c2dbc0d3de351c48d9
Jeffereyy/houses
/random.py
1,191
3.59375
4
from graph import * import random canvasSize(2000, 2000) windowSize(2000, 2000) x, y = 100, 100 colors = ["red", "green", "blue", "pink", "yellow", "brown", "black", "gray", "white", "orange"] def base(): penColor (random.choice(colors)) brushColor (random.choice(colors)) rectangle (x, y, x + 100 * rate...
2cd404e2be4504e4f9ee44c5b3d9de357b09b76e
Qinpeng96/leetcode
/100. 相同的树.py
1,314
4.15625
4
""" 100. 相同的树 给定两个二叉树,编写一个函数来检验它们是否相同。 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 示例 1: 输入: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] 输出: true 示例 2: 输入: 1 1 / \ 2 2 [1,2], [1,null,2] 输出: false 示例 3: 输入...
8bed2bd1693684d0e266c66b94a5c2f09622bc65
GustavoSeibel/Python3
/counter.py
275
4.34375
4
counter = 5 while counter != 0: print("Inside the loop.", counter) counter -= 1 print("Outside the loop.", counter) #another way to use counter counter = 5 while counter: print("Inside the loop.", counter) counter -= 1 print("Outside the loop.", counter)
f50b08ed9d4dca2d624df7913f661d6e344553c3
thiagomfl/python-studies
/functional_programing/map.py
415
3.6875
4
list_1 = [1,2,3] double = map(lambda x: x * 2, list_1) print(list(double)) list_2 = [ {'name': 'John', 'age': 31}, {'name': 'Mary', 'age': 37}, {'name': 'Joseph', 'age': 26} ] only_names = map(lambda p: p['name'], list_2) print(list(only_names)) only_ages = map(lambda p: p['age'], list_2) print(sum(only_ages)) ...
7d712c87282365848b8df3e8412808aa66c8140a
sandance/CodePrac
/EDUCATIVE/Sliding_Window/find_all_anagram_in_a_pattern.py
884
3.65625
4
from collections import defaultdict def find_string_anagram(str, pattern): window_start = 0 matched = 0 char_freq = defaultdict(int) result = [] for char in pattern: char_freq[char] += 1 for window_end in range(len(str)): right_char = str[window_end] if right_char in ...
287486b79dcf318f38eeac6441b0068313b1eb03
lalet/Test_Qz
/string_gt_ls.py
999
3.984375
4
from functools import reduce import argparse #Split the string based on dot character and return the product def findVal(str1,str2): str1_list = str1.split(".") str2_list = str2.split(".") total1 = get_reduced_val(str1_list) total2 = get_reduced_val(str2_list) return total1,total2 #Function to fi...
3ae43289d9030b6cbc6616764201834bb611bb21
FMachiavello/tp-python
/TP5/EJ5.py
1,033
4.09375
4
def primeraLetra(cadena): """Muesta la primera letra de cada palabra""" if type(cadena) not in [str]: raise TypeError("Ingrese una cadena correcta") cadenaSplit = cadena.split(' ') letra = "" for c in cadenaSplit: letra += c[0] print("(a) ", letra) return("OK (a)") def letr...
e8a239e11075205edec433d52ab0904cf92cc953
serenysdfg/learning_codes
/book推荐系统开发实战/标准化方法.py
2,560
3.890625
4
# -*-coding:utf-8-*- """ Author: Thinkgamer Desc: 代码4-1 Python实现标准化方法 """ import numpy as np import math class DataNorm: def __init__(self): self.arr = [1, 2, 3, 4, 5, 6, 7, 8, 9] self.x_max = max(self.arr) # 最大值 self.x_min = min(self.arr) # 最小值 self.x_mean = sum(...
55d129a149ea283dadfdf10eb8247db3db82e84f
Raj-Bisen/python
/Divisibilityby3&5.py
580
4.21875
4
# Accept number from user and check whether no is divisible by 3 & 5 or not. # input : 15 # output : true #input : 4 #output : false def ChckDivisible(no): if ((no % 3)==0)&((no % 5)== 0): return True else: return False def main(): print("Enter the number") valu...
6c26d19534d0d7e0e39981bbdf21b91cb5b00d4c
cyct123/LeetCode_Solutions
/189.rotate-array.py
2,392
3.796875
4
# # @lc app=leetcode id=189 lang=python3 # # [189] Rotate Array # # https://leetcode.com/problems/rotate-array/description/ # # algorithms # Medium (39.32%) # Likes: 13295 # Dislikes: 1553 # Total Accepted: 1.4M # Total Submissions: 3.6M # Testcase Example: '[1,2,3,4,5,6,7]\n3' # # Given an integer array nums, r...
6756d3d2ca53edf452780844168cd178f77e6690
islambayoumy/Python-Data-Structure
/Singly LinkedList/LinkedList.py
9,956
4.1875
4
# Singly Linked List class LinkedListNode: def __init__(self, data): self.data = data self.next = None def get_data(self): # pragma: no cover """ Return data/value inside Node """ return self.data def get_next(self): # pragma: no cover """ ...
9e20838910dc48c07cad4997f3bfc23444d4e7d8
myuakash96/OPS435-NAA
/lab5c.py
830
3.921875
4
#!/usr/bin/env python3 #Author ID: myuakash def add(number1, number2): # Add two numbers together, return the result, if error return string 'error: could not add numbers' try: return(int(number1)+int(number2)) except: return('error: could not add numbers') def read_file(filename): # Read a file, return...
1c6e09f1f5c3657ba06c7ba1ce6b851e13f4bc8b
ecastan960/holbertonschool-higher_level_programming
/0x03-python-data_structures/5-no_c.py
304
3.546875
4
#!/usr/bin/python3 def no_c(my_string): i = 0 Lmy_string = list(my_string) for x in my_string: if 'c' == x: Lmy_string.pop(i) elif 'C' == x: Lmy_string.pop(i) else: i = i + 1 my_string = ''.join(Lmy_string) return my_string
0b827aaded1dd5f4adbaa2d4c952c5dc8070e0c2
gabriellaec/desoft-analise-exercicios
/backup/user_026/ch74_2020_04_13_14_22_59_302529.py
274
3.609375
4
def conta_bigramas(palavra): dic = {} a = 0 for i in range(len(palavra)-1): bigrama = palavra[a] + palavra[a+1] a+=1 if bigrama not in dic: dic[bigrama] = 1 else: dic[bigrama]+=1 return dic
6a375694a8e2b3546cbaa52334658d03b0199c28
iuga/MiniFlow
/miniflow/losses.py
1,913
4.21875
4
import numpy as np from miniflow.layers import Layer """ Loss/Cost/Objective Functions ----------------------------- Function that maps an event or values of one or more variables into a real number intuitively representing some "cost" associated with the event. Intuitively, the loss will be high if we're doing a poor...
b1b2a9a03bbbb001e5cb2b47b04cb915cd9878ce
mchen7588/python_bday
/program.py
852
4.0625
4
import datetime def header(): print('------------------------') print('----------bday----------') print('------------------------') def get_bday(): print('bday??') year = int(input('year [YYYY]: ')) month = int(input('month [MM]: ')) day = int(input('day [DD]: ')) return datetime.da...
4f6d030d9f0ee39ccee47f15d3f3d29230e481ee
minxiii/TIL_python
/day4/funcLab3.py
520
3.890625
4
def expr(a,b,c): if c == '+': ans = a + b elif c== '-': ans = a - b elif c== '*': ans = a * b elif c== '/': ans = a / b else : ans = None return ans s = '연산 결과 : ' result = expr(6,3,'+') if result!= None: print(s,result) else: print('수행불가') re...
74b9d801dc363655e1c48a9320ee9593fcb010a8
jacobpad/CSE250
/week01/w1a.py
1,428
3.796875
4
# %% import pandas as pd import altair as alt # %% alt.data_transformers.enable("json") # %% # Reading in data url = ( "https://github.com/byuidatascience/data4python4ds/raw/master/data-raw/mpg/mpg.csv" ) mpg = pd.read_csv(url) mpg # %% displ_vs_hwy = alt.Chart(mpg).encode(x="displ", y="hwy").mark_circle() displ...
413fa1999b89775f35620ca787fd6004d6b13faf
dallasmcgroarty/python
/General_Programming/CSV/writing.py
1,310
3.953125
4
# writing to csv files # can use lists of dicts to write to csv # writer - creates a write object for writing to csv # writerow - method on writer to write a row to the CSV from csv import writer, DictWriter, DictReader # with open('CSV/cats.csv', 'w') as f: # csv_writer = writer(f) # csv_writer.writerow(["Nam...
e500693fc24d1d6e6dc55a7291e96469e5f7faff
acbueff/coursera-network-data
/project6.py
332
3.703125
4
import json import urllib address = raw_input('Enter json: ') url = urllib.urlopen(address) input = url.read() info = json.loads(input) print 'Retrieved ',len(info),' characters' print (info) sum = 0 count = 0 for item in info['comments']: count +=1 sum += item['count'] print 'Count: ',count print ...
03dc07949fa91805fbaaf3e7fe64ea6b2165688e
omaribrahim4/decisionMakingSystem
/DecisionMakingSystem/utils/KeybordListener.py
955
3.625
4
''' Created on Jan 9, 2018 @author: Ibrahim Ali Fawaz this class listens to keyboard entries from the user. ''' from pynput import keyboard import time def on_press(key): if key==keyboard.Key.left: setsteering(-1) if key==keyboard.Key.right: setsteering(1) def on_release(...
b6b95b693de1829ee700dd6a2f759640f7778e21
viswan29/Leetcode
/Dynamic Programming/buy_&_sell_with_transaction_fee.py
1,662
4.09375
4
''' https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/ Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee representing a transaction fee. You may complete as many transactions as you l...
4837418eced7f89ee2c81cdd1c8f9d39991943a4
Shikha8789/Python-Programs
/Loops/Program3.py
302
4.3125
4
# Write a python program to print all alphabets from a to z. - using while loop res = "" index = 97 # Integer value of a = 97 while index!=123: # Integer value of z = 123 res+=chr(index) # chr() take iterable as input and convert them into ASCII character index = index+1 print(res)
29531eb9bbbd52bc0c947e4bcc7269bc2a4f0abb
Aasthaengg/IBMdataset
/Python_codes/p02713/s409854027.py
163
3.671875
4
from math import gcd k=int(input()) cnt=0 for i in range(1,k+1): for j in range(1,k+1): a=gcd(i,j) for k in range(1,k+1): cnt+=gcd(a,k) print(cnt)
9e66dee2773fc2104cb150247d7ec8300a14fa97
vividwang/python-start
/7-5.py
194
4.0625
4
age = int(input('How old are ya?')) if age < 3: print('You are for free.') elif age > 3 and age < 12: print('You have to pay 10 dollers.') else : print('You have to pay 15 dollers.')
af42d627ea55450d85c0412f9e6659272a5a67cd
PatiKoszi/FirstStepsPython
/Wisielec.py
775
3.765625
4
import random print("Podaj pseudonim: ") nick = input() #haslo = "skarpeta" lista = ["jedenastopietrowiec", "ostatni"] haslo = str(lista[random.randint(0, len(lista)-1)]) tablica = list(haslo) for i in range(len(haslo)): tablica[i] = '_' # print(tablica) print(' '.join(tablica)) zycia = 6 while zycia > 0: ...
91bdb3c66f875337fb8a3a9e97df6875b577cca5
Omkar02/FAANG
/G_418_SentenceScreenFitting.py
673
3.796875
4
# import __main__ as main # from Helper.TimerLogger import CodeTimeLogging # fileName = main.__file__ # fileName = fileName.split('\\')[-1] # CodeTimeLogging(Flag='F', filename=fileName, Tag='String', Difficult='Medium') def wordsTyping(sentence, rows, cols): sentence = " ".join(sentence) + " " n = len(sente...
461bdc0d0e6ad4c7f056fe0cd949e49ba9e00fa1
Bjolav/INFO135_Assignments
/zit010_assignment1.py
1,819
3.78125
4
def task1(): oxford = 171476 korean = 1100373 italian = 260000 counter = 0 while oxford > 1: oxford = oxford / 2 if oxford >= 0.5: counter += 1 print(f"The Oxford dictionary requires", counter, "steps") counter = 0 while korean > 1: korean = korean / ...
f758a5c4d437d5e33960a1db74ed6377d5147beb
hfujikawa/DataSci
/pd_df_diff.py
1,163
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Feb 15 09:34:00 2020 https://teratail.com/questions/184798 @author: i2m """ import pandas as pd import numpy as np df1 = pd.DataFrame([[1,1,2], [1,2,3]]) # この行がペアになる df2 = pd.DataFrame([[1,2,4,5], # この行がペアになる [...
603ed622d3a77237245a40b0090b4c5c1bf7547b
JangHwanBae132/CodingTest
/solution/210806/위장.py
428
3.640625
4
def solution(clothes): answer = 0 dic = {} makeDic(dic, clothes) answer = 1; answer = makeAnswer(answer, dic)-1 return answer def makeDic(dic, clothes): for c in clothes: if c[1] not in dic.keys(): dic[c[1]] = [c[0]] else: dic[c[1]].append(c[0]) de...
f5bf0c32645b3861412eda39df000c3cecd1b679
fatadel/cs50
/pset6/credit/credit.py
1,571
4.4375
4
import sys # "counter", shows current digit's position count = 1 # final "checksum" checksum = 0 # After the last step of the while loop last digit will be stored in n; # The digit before it will be stored here in penultimateDigit # We knowingly initialize it with invalid number since its unknown and can be determined...
51f7f78310ee79c40c71261a3b815790b9a845d3
faseehahmed26/Python-Practice
/forloop.py
90
3.953125
4
sum=0 x=int(input("enter n value")) for val in range(1,x+1): sum=sum+val print(sum)
fa10ec9ed25ee23d4a383d6f320a6a1aacb03e03
SuperLavrik/Home_work
/test_3.py
190
3.59375
4
# a = float(input("Input a - ")) # b = float(input("Input b - ")) # c = float(input("Input c - ")) a = 50 b = 42 c = 88 print("( a * b + 4) / ( c - 1 ) = %.2f" % (( a * b + 4) / ( c - 1 )) )
d991e3275452bafae7673f2da7262c978f8b411a
aileentran/coding-challenges
/minidxsumoftwolists.py
2,269
3.765625
4
"""leetcode challenge: 599. Minimum Index Sum of Two Lists Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their common interest with the least list index sum. If there is a choice tie between answe...
0cc03a5f14c14bd5b825e5099e04e5590c987366
BubbaHotepp/code_guild
/python/rot13.py
569
3.90625
4
import string def main(): cypher_text = [] user_input = input('Please enter plain text to encode: ') alphabet_lower = string.ascii_lowercase alphabet_upper = string.ascii_uppercase x = 13 for chr in user_input: if chr in alphabet_lower: cypher_text += alphabet_lower[(...
ebed4f45812fc4921999d7176c1f06b2830755e4
psy1088/Algorithm
/Programmers/메뉴 리뉴얼.py
815
3.546875
4
from itertools import combinations def check(dict): arr = [] if not dict: return arr else: max_val = max(list(dict.values())) if max_val < 2: return arr for d in dict: if dict[d] == max_val: arr.append(''.join(d)) return a...
39ae1de8b5d31a4e39f9b2df9451db1b9e4dcbe0
LukeMurphy/RPI
/testing/tkinter and threading/tkinter_test_2.py
1,176
3.65625
4
import random import time from Tkinter import * root = Tk() root.title = "Game" root.resizable(0, 0) root.wm_attributes("-topmost", 1) canvas = Canvas(root, width=500, height=400, bd=0, highlightthickness=0) canvas.pack() class Ball: def __init__(self, canvas, color): self.canvas = canvas self.id = canva...
6da537a6786f641973b74e8439b0df14f3d5f095
Bublinz/Python-Expert
/Assignments/student_fidel/assignment3.py
904
4.15625
4
# welcome to our office. while True: print('what is your name?') name = input() if name != 'vicTOria': continue print('hello, vicTOria you are welcome.') print('please enter your email account?') email = input() if email != 'ViCtOrIa@gmail.com': continue print('please en...
9eacf5a0f00d9d21ce2d734ac840fb100c4e464a
Dongzi-dq394/leetcode
/python_solution/0247.py
1,524
3.515625
4
class Solution: def findStrobogrammatic(self, n: int) -> List[str]: # Solution by myself: Brute Force + Palindrome (160ms: 24.60%) if n==1: return ['0', '1', '8'] ele = {'0':'0', '1':'1', '6':'9', '8':'8', '9':'6'} res = [] for i in range(n//2): if i==0: ...
96b4e316c06131bcb1df4d745cd13dadf6dd4fd3
zachMelby/TicTacToe
/tic_tac_toe.py
4,570
4.34375
4
__author__ = 'zacharymelby' # Global list to represent the board, initialized to all blank spaces BOARD = ['', '', '', '', '', '', '', '', ''] # Chars to represent the board locations numbering (i.e., the values # the user will enter to specify their play) LOCATION_LIST = [1, 2, 3, 4, 5, 6, 7, 8, 9] def welcomeMess...
d0c0960c9613b012e1c4970b39522bef039e6a69
bhanuponguru/ag_py
/agpy/timer.py
1,177
3.546875
4
# Initial code written by Stevo. import time class TimerException(Exception): pass class Timer: def __init__(self): self.start_time = get_current_ms() self.running = True self.current_time = 0 def restart(self): self.start_time = get_current_ms() self.running = ...
1603fdb19fb341049a51f67382d5c5755b489563
RyanT0m/Uno-Multiplayer
/Server.py
1,612
3.71875
4
#!/usr/bin/env python3 import socket class Server(socket.socket): ''' Server represents the server side communication for Uno ''' def __init__(self, *args, **kwargs): super.__init__(socket.AF_INET, socket.SOCK_STREAM) self.port = kwargs.get("port") self.host = kwargs.get("host"...
06cc32021053708b5512612fc154ce3aabcfdc49
akenYu/learnpy
/showme/04/countword.py
437
4.0625
4
# 第 0004 题:任一个英文纯文本文件,统计其中的单词出现的个数 filename = 'hello.txt' line_counts = 0 word_counts = 0 char_counts = 0 with open(filename, 'r') as f: for line in f: word = line.split() line_counts += 1 word_counts += len(word) char_counts += len(line) if __name__ == '__main__': print('line counts', line_counts) pri...
232ef2abad728705e82715a5465d64c4730bc5c5
ShadowKyogre/project-euler
/problem35.py
727
3.65625
4
import math from collections import defaultdict def isPrime(num): if num == 2: return True divisor=2 while divisor < math.sqrt(num): if divisor % num == 0: return False divisor+=1 else: return True cache=defaultdict(lambda: bool(1)) def primeSieve(maxnum): sqrt=math.sqrt(maxnum) for i i...
0668b6517d686599c6d049cd3dddfd0c478348f7
SudhamathiAthi/Codekata
/PositiveORNegORZero.py
202
4.1875
4
num=input("Enter the number to test:") if(num>0): print +str(num),"is a positive number" elif(num<0): print +str(num),"is a negative number" else: print "It is zero"
1a6990528fd61328ad23280663176275d1737b5e
eronekogin/leetcode
/2020/add_digits.py
344
3.5
4
""" https://leetcode.com/problems/add-digits/ See https://leetcode.com/problems/add-digits/discuss/68580/Accepted-C%2B%2B-O(1)-time-O(1)-space-1-Line-Solution-with-Detail-Explanations for more details. """ class Solution: def addDigits(self, num: int) -> int: if not num: return 0 r...
4ebada4c62f2b17535bee347cab6a870c1c8de10
jingjuanwang/Python_project
/hanoi.py
277
3.953125
4
def move(n, fr, to, sapce): print str(n) + ' ' + 'from' + ' ' + str(fr) + 'to' + str(to) def hanoi(n, fr, to, space): if n == 1: return move(n, fr, to, space) else: hanoi(n-1, fr, space, to) hanoi(1, fr, to, space) hanoi(n-1, space, to, fr) hanoi(3, 'p', 'q', 'r')
aa19c231a58cdd8cc4ec1d2e630fa16705e4ea04
ylana-mogylova/Python
/Examples/is_s2_rotation_of_s1.py
1,028
4.46875
4
""" Assume you have a method isSubstring which checks if one word is a isSubstring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring(e.g., "waterbottle" is a rotation of "erbottlewat"). """ def is_substring(s2, s1): if s2 in s1: ...
ceb4789679f4fa8f0b7dccca275347344a824e0e
rajeshsurana/PythonPortfolio
/WordGame/hand_class.py
3,067
4.125
4
import random class Hand(object): def __init__(self, n): ''' Initialize a Hand. n: integer, the size of the hand. ''' assert type(n) == int self.HAND_SIZE = n self.VOWELS = 'aeiou' self.CONSONANTS = 'bcdfghjklmnpqrstvwxyz' # Deal a new hand...
d303413fd396b9e36d0d96b14afc581e7b6f5486
aiktcprogrammersclub/Python_Workshop
/DAY2/palindrome.py
120
3.921875
4
n = str(raw_input("Enter no ::",)) a=list(n) if(a==a[::-1]): print "palindrome" else: print "not palindrome"
e68999f68ebc66d5476fdbda627384d83c8ee9cf
vehery/seven-segment-ocr
/image_selection.py
1,908
3.5625
4
""" image_selection.py This module gives the user an image to specify selections in and returns those selections @author: Suyash Kumar <suyashkumar2003@gmail.com> """ import cv2 import sys # Shared variable declarations refPts = [] image=1 numSelected=0 """ Called every time a click event is fired on the displayed im...
577ac407e10ef23d7b1d142a3b997d24d11acde9
omkarindulkar/Python-Training
/Regular Expression/regex4.py
801
3.5
4
# ? (0 or 1) import re # batregex = re.compile(r'bat(wo)?man') # text = batregex.search("I like batman") # print(text.group()) # * (0 or more) # batregex = re.compile(r'bat(wo)*man') # text = batregex.search("I like batwowoman") # print(text.group()) # + (1 or more) # batregex = re.compile(r'bat(wo)+man') # tex...
3f3790b0a3a20d306b620a591f38a3f673a23092
Soliloquiess/Luckyday
/data/triangle.py
502
3.734375
4
class Triangle: def __init__(self, name, under, height): self.name = name self.under = under self.height = height def triangle_print(self): print(f'이름 = {self.name}\n밑변 = {self.under}\n높이 = {self.height}') def triangle_area(self): print('*'*40) print(f'삼각형의 ...
fef5f6c0f816d8dad21f2fb5ea5bdfbd57734dee
spaceymacey/pythonintro
/hangman.py
3,139
4
4
# Let's make Hangman import random HANGMANPICS = [''' +---+ | | | | | | =========''',''' +---+ | | O | | | | =========''',''' +---+ | | O | | | | | =========''',''' +---+ | | O | |\ | | | =========''',''' +---+ | | O | /|\ | ...
d9e3dcc0687ef81e48f7a6d842958901c83a8b0b
optionalg/cracking_the_coding_interview_python-1
/ch8_recursion_and_dynamic_programming/8.12_eight_queens.py
1,210
4.15625
4
# [8.12] Eight Queens: Write an algorithm to print all ways of # arranging eight queens on an 8x8 chess board so that none # of them share the same row, column, or diagonal. In this case, # "diagonal" means all diagonals, not just the two that bisect # the board. import unittest def queens(num_queens): results = ...
6092fa2b31b24d8537cb609bcb82037bdd619ca3
psr1981/data-structure-and-algorithms
/sorting/selection-sort.py
408
3.65625
4
def selection_sort(a): for i in range(len(a) - 1): maxPos = 0 for j in range(len(a) - i ): if a[j] > a[maxPos]: maxPos = j; print ('exchangin value of ', str(maxPos) , ' and ' , str(j) ) temp = a[j] a[j] = a[maxPos] a[maxPos] = temp ...
b4cbc2310d61cdc85cd0df25c8a050a5cc2e4f32
charles-fowler/SOM_neural_net
/graph.py
2,920
3.671875
4
class Vertex(object): def __init__(self,node): self.id = node self.adj = {} def __str__(self): return str(self.id) + ' adjacent: ' + str([x.id for x in self.adj]) def add_neighbor(self, neighbor, weight=0): self.adj[neighbor] = weight def get_connections(self): ...
594d1bfc8ec055b5a407ab5091761beccb404924
harshnisar/masstoeba
/masstoeba/scripts/sentencesplitter.py
1,941
3.546875
4
'''Module to define functions required to tokenize any language in the world. ''' import nltk import csv from collections import namedtuple import re, os #TODO # Convert the file data into static hardcode data in the end. #The sentence splitter, will split the given text, in sentences using Punkt Tokenizer. Lang ...
48abc77a1f9b7899a7950b6240a894a761bc6a46
PrasamsaNeelam/CSPP1
/cspp1-practice/m3/iterate_even_reverse.py
50
3.578125
4
i=10 print('Hello!') while(i>1): print(i) i-=2
2664f6fe291cd7071bb776bc21714fbebef5d629
tuxerman/snippets
/montyHallStatCheck.py
1,048
3.890625
4
import random switchDoors = True # whether player changes his choice after host opens a door sampleTries = 100 timesWon, timesLost = 0,0 for iters in range (sampleTries): # put the car behind a random door car = (int)(random.uniform(0,3)) #print "Car is behind",car # pick one door out of the remaining...
47dd74481eec01ef1ba0ef9c69bf7a59d8a2f424
Wcy20010925/rickandmorty
/Tkinter.py
1,421
3.5
4
''' GuessNumberGame ''' import tkinter as tk import tkinter.messagebox #s1: creat window GussNum = tk.Tk() GussNum.minsize(400,300) GussNum.title('MyGameGussNumber') #s2: creat components and #s3: distribute components lableshow = tk.Label(GussNum,text='Wellcome to our game!\nplease input yourNumber',height =2) lables...
3a118a56e0b1fddc85bc8d20eda81378cc716687
dalon1/webscrapper
/csv_utils.py
1,204
3.53125
4
import csv class CSVUtils(object): @staticmethod def createCSVFile(file_name, records): # removing that extra blank line created by default between records. with open(file_name, 'w', newline='') as csvfile: # Creating file writer (python) or stream writer (c#) file_writ...
398bea63c04800553156e680e798ccfb515f4c60
piyushPathak309/100-Days-of-Python-Coding
/Print Half Pyramid Using Loops.py
899
4.375
4
# Write a Python program that prints a pyramid pattern made with asterisks. # # The number of rows should be determined by the value of the variable n. This value will be entered by the user. # # You may assume that the value of n is a positive integer. # # 🔹 Expected Output: # If the value of n is 5, this is t...
1a13e0773950b0acc3ba3880e13dfcd218a62ea0
bendikjohansen/euler
/projecteuler/level_1/p12.py
1,240
3.921875
4
from typing import List from functools import reduce def product(numbers: List[int]): return reduce(lambda x, y: x * y, numbers, 1) def find_primes(limit: int) -> List[int]: is_prime = [False, False, True] + [True] * limit primes = [2] for i in range(3, limit, 2): if is_prime[i]: ...
dcbf94b8bc529f81f2951a857e76a6038a33e7ae
wewakeprasad/Learning_Python
/UsingJava.py
320
3.65625
4
planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune'] #for planent in planents: #print(planent,' ') #short_planets=[planet for planet in planents if len(planet)<6] #short_planets loud_short_planents=[planet.upper()+' ! ' for planet in planets if len(planet)<6 ] loud_short_planents
cc1c6b2216495cc28771462074fe6f7b7fb3dff3
MathieuTuli/python-shape-grammars
/src/python_shape_grammars/vector.py
3,330
4.21875
4
'''2D Vector for grid-based alignment of the Graph ''' import math class Vector: def __init__(self, x: float, y: float) -> None: self.x: float = float(x) self.y: float = float(y) def __str__(self) -> str: return f"{type(self).__name__} ({self.x}, {self.y})" def __add__(self, othe...
d950c1a1c8b58ffe73f05a92724681fe1a67af26
jasdestiny0/Competitive-Coding
/Algo Experts/Merge Linked Lists/solution.py
484
3.90625
4
# This is an input class. Do not edit. class LinkedList: def __init__(self, value): self.value = value self.next = None def mergeLinkedLists(headOne, headTwo): p1=headOne p2=headTwo prev=None while p1!=None and p2!=None: if p1.value <p2.value: prev=p1 p1=p1.next else: if prev i...
3c2e81b0127a727ee8bed0df39eb65506159fc3b
Aasthaengg/IBMdataset
/Python_codes/p02418/s544575939.py
110
3.75
4
import re s=input() p=input() s_s=s+s match=re.search(p,s_s) if match: print('Yes') else: print('No')
c81928abeb8b5375f83feb2be4619e9c6f1cc6cf
clodonil/python-exercicios
/jogo_adivinha_numero.py
2,399
4
4
''' O Jogo consiste em sorteador 2 numeros, um para cada jogador. Os jogadores tem 3 tentativas de acertar e quem acertar primeiro leva ou quem chegar mais perto do numero sorteado. ''' import random # Controle do while controle=1 # Lista para guardar quem chegou mais perto dif_jogador1=[] dif_jogador2=[] ...
08a83fcdc2cc2bf1cac59d33e8b30fbd5e140a20
SingleDreamer/Blog_Project
/app.py
3,319
3.53125
4
from flask import Flask, render_template, request#, redirect, url_for import sqlite3 app = Flask(__name__) #x=0 #conn = sqlite3.connect("blog.db") #p ="create table posts(post_id integer, post_title text, post_author text, post_content text);" #comm = "create table comments(comment_id integer, comment_content text, c...
6db473b21fb149a295a10d8d30891d80276211d7
Eunaosei24788/lista3
/oi4.py
1,061
4.125
4
print("Este programa serve para calcular a média entre duas notas de 0 a 10") a = int(input("Insira a primeira nota: ")) while a > 10 or a < 0: print("Este número não é valido") a = int(input("Insira uma outra nota: ")) b = int(input("Insira a segunda nota: ")) while b > 10 or b < 0: print("Este número não é vali...
3c486ab9ab9d7c2aa9bdaee9f2257ba5baf2a3d6
yashpal-choudhary/gitlearn
/assignments/task3.py
627
3.90625
4
''' Problem statement : Write a function which takes a string s as input and prints the frequencies of all the words in the string. eg: quick fox lazy dog quick donkey fire fox input returns {quick: 2, fox: 2, lazy: 1, dog: 1, donkey: 1, fire: 1}. Use <space> as the delimiter to identify what a word is. ''' class Ta...
1d0f3d6c1e62065bfd56a0c5cea6cdec1ffda2cd
akaptur/GlassJack
/pickMove.py
2,069
3.828125
4
# determine which card you should play import readCard from theBook import card_book #returned from cardReader --> card 1 and card 2 test_ace =[('A', 'S', 'A'), ('J', 'H', '10'), ('3', 'H', '3')] test_pair =[('7', 'S', '7'), ('7', 'H', '7'), ('3', 'H', '3')] #consider adding a turn count. this is not adequate for all...
582f8093b9d80ce512cd4daedee6045bc269d917
Govrie/Govrie.github.io
/HW2-1.py
307
3.5
4
#!/usr/bin/env python3 -tt """File: hello.py """ def number_of_matches(J, S): k = 0 for i in J: for j in S: if i == j: k += 1 return k #Run only if called as a script if __name__ == '__main__': J = 'aA' S = 'aAABBB' print(number_of_matches(J,S))
ba113ae8de53cd7d69d23ccbf4abb2bbabfade07
Adelaide95/laba3
/individual.py
576
4.125
4
import math x1 = int(input("Введи координату X1: ")) y1 = int(input("Введи координату Y1: ")) x2 = int(input("Введи координату X2: ")) y2 = int(input("Введи координату Y2: ")) x3 = int(input("Введи координату X3: ")) y3 = int(input("Введи координату Y3: ")) a = math.sqrt( pow(x2 - x1, 2) + pow(y2 - y1, 2) ) b = math...
18a4ce53a12e6ff61f64d1408d9e931d3293d0d7
kill-git/p5-datavisualisation
/project/density.py
532
3.546875
4
import pandas import matplotlib.pyplot as plt plt.style.use('ggplot') weather = pandas.read_csv("./data/oxforddata.txt", sep='\t') target = 'rain' weather['Period'] = weather['yyyy'].apply(lambda x: 'Before' if x < 1991 else 'After') weather = weather.groupby(['mm','Period']).mean().reset_index().pivot(index='mm', co...
e01c4e3e50eee6d6557580433a850eb5892bd27b
windniw/just-for-fun
/leetcode/397.py
910
3.90625
4
""" link: https://leetcode.com/problems/integer-replacement problem: 给定n,定义一次操作为 n = n // 2 if n is even else n + 1 or n - 1,问至少多少次操作后,n可以为1 solution: 贪心。本质上,操作为消除末位0,当n为偶数时右移,当n为奇数时通过进1或退1将末位置为0;只关注末两位,当其为 11 时的最优操作是 11 -> 00 -> 0 -> nil,而非 11 -> 10 -> 1 -> 0 -> nil,当且仅当 n 为 3 时特殊情况(这时不是尽可能消0,而是要保留倒数第二位的1...
5efd4a2ae6d2a0d5ff6eded8f00c0f6bd4e0b26f
viren3196/Python
/sumprimes.py
199
3.515625
4
def prime(n): if n<=1: return(False) for i in range(2,n): if n%i==0: return(False) return(True) def sumprimes(l): s = 0 for i in range(0,len(l)): if(prime(l[i])): s+=l[i] return s
205333d55f3bacd98a752f884b2ecd25d5c087ac
qfma/ohnolog-dc
/utilities/runner.py
4,684
3.515625
4
#!/usr/bin/env python2.7 ''' Run different programs This file provided various python functions that use the os and sys modules in order to list files, folders etc. ''' import sys import os import time from subprocess import Popen, list2cmdline import subprocess import multiprocessing import functools import logging ...