blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a4914ff88648056203b5dbc002212033e663c1d2
AlexUrtubia/ordenamiento-py
/bubble/bubble-sort.py
1,418
3.984375
4
arr = [8,5,2,6,9,3,1,4,0,7] def bubblesort(lista): contador = 0 #print("Orden original :",lista) for j in range (len(lista)-1): # print("\n","-"*60,"\nIteración número n",j,"(Desde",lista[0],"hasta",lista[len(lista)-1-j],")") for i in range (len(lista)-1-j): # Al colocar "-j", estoy indicando...
289890765775d8902825ad2f61a7145ef89f254c
SokolovAM/cardgame
/Drunkard.py
3,130
3.6875
4
# Card game "Drunkard" class Card: suits=['spades','hearts','diamands','clubs'] values=[None,None,'2','3', '4','5','6','7','8','9','10', 'Jack','Queen','King','Ace'] def __init__(self,v,s): """suit & values - integers""" self.value = v self...
6f75090e24993f2d59d06c3988cbf63052aa5795
adamchalmers/eliot_quantified_health
/raw_generator.py
8,332
3.578125
4
import datetime import os import subprocess import string from collections import defaultdict """ This generates a .html file with a visualization of data from a .csv file. This file MUST be placed in the same folder as "data.csv" """ # These are the config parameters. Change them if you're using a different CSV stru...
930769a7763c346dbb9b1a4723146a7e5aadec0b
asalex04/11_duplicates
/duplicates.py
1,586
3.515625
4
import os import hashlib import argparse import collections def get_parser(): parser = argparse.ArgumentParser() parser.add_argument( 'path', help='path to root directory' ) return parser def get_duplicates(dir_path): filenames_with_pathes_dict = collections.defaultdict(list) ...
2719ae133af19405f7e3d048695f861129ea5d97
nicollebanos/Programacion
/Clases/listas.py
1,693
4.21875
4
nombres = ['Santy','Samu','Aleja','Dani'] print(nombres) print(nombres[2]) nombres.append('Mauricio') print(nombres) print(nombres[2]) edades = [18, 19, 20, 17,32, 12, 15, 13] estaturas = [1.62, 1.80, 1,67, 1.89] # al último print(edades[-2]) print(edades[0:2]) print(edades[:3]) print(edades[2:]) print(edades[:]) #O...
294165904c563f79a9207ecf9aae40eb35de0dff
deanantonic/exercises
/zhiwehu/q14.py
559
3.953125
4
""" Question 14 Level 2 Question: Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters. Suppose the following input is supplied to the program: Hello world! Then, the output should be: UPPER CASE 1 LOWER CASE 9 Hints: In case of input data being supplied to the...
05a5bc5093d9fe8b60042b422cb74073065937eb
muru4a/python
/reverse_integer.py
279
3.65625
4
#reverse interger def reverse1(s): if s < 0: return -reverse(-s) result=0 while (s>0): result=result*10+s%10 s//=10 return result if result <= 0x7fffffff else 0 if __name__ == "__main__": print(reverse(121)) print(reverse1(456))
551827fa90839d534ee75975a12dbb39ccc98f32
Administrator859/Countdown-GUI
/count.py
626
3.78125
4
from tkinter import * t = 0 def set_timer(): global t t = t+int(e1.get()) return t def countdown(): global t if t > 0: l1.config(text=t) t = t-1 l1.after(1000, countdown) elif t==0: print("end") l1.config(text="Goo") root = Tk() root.geometry("180x150") l1 = Label(root, font="times 20") l1.grid(r...
484a8fdf6cbedf1d97112f44cc84b02cc75ae7ad
adityachhajer/CST_JIET_Assignments
/Aditya_Chhajer/13may2020/3.py
293
3.90625
4
def gcd(a, b): if (a == 0): return b if (b == 0): return a if (a == b): return a if (a > b): return gcd(a - b, b) return gcd(a, b - a) a=int(input()) b=int(input()) print("gcd: ",gcd(a,b)) print("lcm is:",(a*b) / gcd(a,b))
af70a32360e0a630988d6ec0ef59aa9c5012365e
pjok1122/Interview_Question_for_Beginner
/DataStructure/codes/max_heap.py
1,671
3.625
4
SIZE = 1024 class heap: def __init__(self): self.list = [-1]*SIZE self.len = 0 def push(self, val): self.len += 1 self.list[self.len] = val index = self.len while index//2: if self.list[index] > self.list[index//2]: self.list[index]...
7677ccf0294d4d9c0583a5e55ea8a0130cbfdd7f
deb91049/leetcode
/盛最多水的容器/solution.py
893
3.53125
4
# 给你 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0) 。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 # # 说明:你不能倾斜容器。 # # 来源:力扣(LeetCode) # 链接:https://leetcode-cn.com/problems/container-with-most-water # 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 class Solution: def maxArea(self, height: List[in...
ce610be1f371fe02b7e89c0e926b20f0b0fcbc4d
Bahram3110/d11_w3_t1
/task4.py
184
3.640625
4
dict_ = {'a': 6, 'b': 3, 'c': 10} test_dict = {key:'Foo'if value%3==0 else 'Bar' if value%5==0 else "none" for key,value in dict_.items()if value%3==0 or value%5==0} print(test_dict)
43645f5ab668731f2909b37094dfb3801bdeef69
LucasMonteiroi/python-course
/exercises/dictionaries.py
671
4.03125
4
# We will use dictonaries and some methods person = {'name': 'Lucas', 'age': 27, 'country':'Brazil'} print('Person: ' + str(person)) print('Person Keys: ' + str(person.keys())) print('Person Values: ' + str(list(person.items()))) print() print('Formated values') print() for k, v in person.items() : print(str(k) + ...
35d666bfcb06cc2836fe0dd184227fb84f763b1c
xiaolinzi-xl/Play-Leetcode-Explore
/algorithm/primary_algorithm/array/leetcode_217.py
219
3.65625
4
class Solution: def containsDuplicate(self, nums): duplicate = set() for ele in nums: if ele in duplicate: return True duplicate.add(ele) return False
d96634989ab1c28f5154087cc88ca21869a293f3
raphoshi/Microlon
/Games/Modulo-01/Python/04-Loops/Exercicio de input e outros comandos.py
937
4.34375
4
#!/usr/bin/env python # coding: utf-8 # Crie um código onde o usuário entre com: # Nome: # Senha: # A mensagem sugira se o nome e a senha forem iguais # # In[ ]: nome = input ("Qual o seu nome? ") senha = input ("Insira uma senha ") while nome == senha: print ("Nome de usuário e senha são iguais") senha = inpu...
abc2a57d310a0e1f242551f7af79f17b34535ff7
eyasyasir/COMP208
/Assignment 2/parentheses.py
2,639
4.3125
4
# Author: [Eyas Hassan] # Assignment 1, Question 2 def find_first(s, letter): #function which searches for first parenthesis '(' from left of string for i in range(len(s)): #for loop evaluates every characte in string 's' and compares it to variable 'letter', if true, the index at which the condition is true is re...
cd655b76261484257e0eebf5962464b17b825013
sammyrTX/Python-Baseball_Project
/Baseball_Proj_Main.py
973
3.875
4
############################################################################### """Baseball Game Simulator Python v3.7 This is a simple simulator that runs through a baseball game. It shows the results of each at bat by team for each inning. Results at bat are determined at random. If there is a tie afte...
ddb16179e34289a654bec5eb5459f1c9020d4af2
Emanoel580/ifpi-ads-algoritmos2020
/Lista 03 Repetição for/fabio_q25_for.py
657
3.90625
4
n = int(input('Eleitores: ')) c1 = 0 c2 = 0 c3 = 0 votos_nulos = 9 votos_brancos = 0 for i in range(1, n+1): opção_voto = int(input("voto:" )) if opção_voto == 1: c1 +=1 if opção_voto == 2: c2 +=1 if opção_voto == 3: c3 += 1 if opção_voto == 9: votos_nulos +=1 i...
0064137166184504f8e31ce0e8f22eb2e1a10269
macloo/python_examples
/dice_with_random.py
597
4.09375
4
# this dice game is not the greatest, but it runs and # can be used a basis for a better dice game from random import randint score = 0 again = "y" print # blank line def dice(score, again): d1 = randint(1, 6) d2 = randint(1, 6) roll = d1 + d2 if roll == 7: print "Rolled %d and %d. You los...
bb53ddab382a1b2ea4e4695e2c720768faaca524
ShashankPatil20/Crash_Course_Python
/Week_2/Functions.py
471
4.21875
4
def greeting(name, department): print("Welcome", name) print("You are from ", department) greeting('Bill', 'Admin') ''' Flesh out the body of the print_seconds function so that it prints the total amount of seconds given the hours, minutes, and seconds function parameters. Remember that there are 3600 second...
ea535304df854f10c4179fe8a6fbe5976a5cc691
tic0uk/python-100daysofcode
/day-15-coffee_maker.py
3,308
4.1875
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "cappuccino": { ...
d7499d5577c65a56fff6ca174a47c3a20c8706a7
kji0205/py
/cookbook/CHAPTER02/2.9.py
492
3.59375
4
"""유니코드 텍스트 노멀화""" import unicodedata s1 = 'Spicy Jalape\u00f1o' s2 = 'Spicy Jalapen\u0303o' # print(s1) # print(s2) # print(s1 == s2) # print(len(s1)) # print(len(s2)) # t1 = unicodedata.normalize('NFC', s1) t2 = unicodedata.normalize('NFC', s2) print(t1 == t2) print(ascii(t1)) t3 = unicodedata.normalize('NFD', s1)...
f4b93bab8e9d12b569fd63fec07dcfc90dd86233
tkremer72/Python-Masterclass
/3.ListsAndTuples/1.Sequences/buy_computer.py
2,520
3.953125
4
available_parts = ["computer", "monitor", "keyboard", "mouse", "mouse pad", "hdmi cable", "dvd drive", "memory", "webcam", "speakers", ...
f7c16810757eecbd20e5968950ceacb03b9a1c2b
Isaac-d17/Final
/HerenciaAnimales.py
593
3.921875
4
import Animales class Elefante(Animales.Animales): """Importamos el modulo Animales y le heredamos todos sus metodos y atributos, construimos metodos especificios para los elefantes""" def tomar_agua(self,tipo_agua,cantidad_agua): if(tipo_agua.lower()=="limpia"): self.cantidad_agua+=cantidad_agua else: ...
d131648e39e5362d0b9605a9e185ab56c1422710
mhossain25/CIS1051_Final_Project
/cashFlowDiagram.py
8,475
4.09375
4
import matplotlib.pyplot as plt def checkIntInput(arg): # found code on https://pynative.com/python-check-user-input-is-number-or-string/#:~:text=To%20check%20if%20the%20input%20string%20is%20an%20integer%20number,using%20the%20int()%20constructor.&text=To%20check%20if%20the%20input%20is%20a%20float%20number%2C%20conv...
343187bde5fc4dfd641e7cbfa9a17b53e0e5e180
AaronAS2016/Sudoku_Solver_EDD
/solver.py
2,118
3.75
4
class Solver(): def valid(self, board, number, position, dimension=9): # Check row for i in range(len(board[0])): if board[position[0]][i] == number and position[1] != i: return False # Check column for i in range(len(board)): if board[i][pos...
26e3e01baf2733a8416c0c43b1fbcaff9f76d3b9
Zahirgeek/learning_python
/OOP/8.1.py
545
4.1875
4
#属性案例 #创建Student类,描述学生类 #学生具有Student.name属性 #但name格式并不统一 #可以用增加一个函数,然后自动调用的方式,但很蠢 class Student(): def __init__(self, name, age): self.name = name self.age = age #构造函数调用setName self.setName(name) def intro(self): print("Hi,my name is {0}".format(self.name)) def setNa...
86b341befaac9cadcfb6eb21f382ef8b7a0f45a9
wantwantwant/tutorial
/L2基础类型控制语句/判断类型《6》.py
407
4.03125
4
# 判断变量类型 #类型不同,input()返回字符串 # '1' + 3 # type(), 判断变量类型 a = 1 b = 1.5 c = 'hello' d = True type(a) # <class'int'> type(b) # <class'float'> type(c) #<class'str'> type(d) #<class'bool'> # isinstance(值,类型) # 如果值属于类型的话返回True isinstance(1,int) # True isinstance(1,float) # False isinstance('小明',float) # False ...
0890fff49cda921df2c555719ef1df96c874b4fc
lf2225/Python-the-Hard-Way-exercises
/Blackjack/Deck.py
905
3.890625
4
import random import itertools Suits = 'cdhs' Ranks = '23456789TJQKA' class Deck(object): def __init__(self): print 'I am entering the init routine of Deck' self.CardShoe = tuple(''.join(card) for card in itertools.product(Ranks, Suits)) self.NumberOfCards = len(self.CardShoe) self.Shuffle() print 'I am ex...
73230e25e6194575e682ff6d5d6f5a4f8fa73dd1
KephM/Python_Portfolio
/Term 1/Mad Libs Assignment/Mad Libs Assignment.py
242
3.5
4
#Kephryn Merkley #Mad Libs Input Assignment #9-11-19 name = "Pierre" noun = "Bat" verb = "run" num = 50 msg = str.format("Last week at practice {} forgot his {} at home. So the coach made him {} {} laps!",name,noun,verb,num) print(msg)
c1d7901b3e27966f28a24d3688c6d07d5066e088
Mahadevan007/c-and-python-problems
/arrange_adjacent.py
421
3.8125
4
def arrange_adjacent(arr): mid = len(arr)/2 firstarr = [] secondarr = [] resultarr = [] for i in range(0,mid): firstarr.append(arr[i]) for i in range(mid,len(arr)): secondarr.append(arr[i]) for i range(0,mid+1): resultarr.append(firstarr[i]) resultarr.append(...
4fbe75d4600b72423e6ea7c5498635fd3f1055e9
a-abramow/MDawsonlessons
/lessons/Chapter 06/6_01.py
879
3.90625
4
def instructions(): print( """ Добро пожаловать на ринг игры Крестики Нолики. Чтобы сделать ход, ыыедите число от 0 до 8. Числа соответствуют полям, как указано ниже: 0 | 1 | 2 --------- 3 | 4 | 5 --------- 6 | 7 | 8 Приготовься к бою, ...
594fa0f2af78a35ac7654e273dcaf120449829e5
mingweihe/leetcode
/_0164_MaximumGap.py
1,364
3.546875
4
import math class Solution(object): def maximumGap(self, nums): """ :type nums: List[int] :rtype: int conclusion: linear sort: 1. bucket sort 2. radix sort 3. counting sort """ # Approach 2 bucket sort if l...
504a9ab1c07b2f30306974538839bb535c7c7b6b
ErioY/Choose_Exerceses-Python
/对三个变量排序.py
621
3.8125
4
''' @Autor: ErioY @Date: 2019-10-16 20:56:13 @Email: 1973545559@qq.com @Github: https://github.com/ErioY @LastEditors: ErioY @LastEditTime: 2019-10-18 11:50:43 ''' # 设有三个变量a,b,c,分别对三个变量赋值,并对三个变量进行排序。如a=5,b=7,c=6,则排序结果为b>c>a # a = int(input("请输入第一个值:")) # b = int(input("请输入第二个值:")) # c = int(input("请输入第三个值:")) a = 5 b =...
68b71ef9186a843d67280d2f75c125b76ca3e54b
kaushikamaravadi/Python_Practice
/Transcend/spiral.py
618
3.90625
4
"""Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 It can be verified that the sum of the numbers on the diagonals is 101. What is the sum of the numbers on the diagonals in a ...
994ab0491deacb237765e492ae45bbc53a2310f7
irekpi/Flynerd
/4/zbiory.py
388
3.671875
4
zbior = {'adam': 'men', 'alex': 'men', 'kasia': 'wom', 'ola': 'wom'} imie = input('podaj imie') if imie in list(zbior.keys()): print(imie, zbior[imie]) else: print('podaj imie bo nie ma w bazie') gender = input('podaj m lub z') if gender == 'm': zbior[imie] = 'men' ...
bad7d0e70f189c663faf7152accf4b96ef0e2a2e
ferromauro/python3_dojo
/Modulo_5/lezione_5_6.py
852
3.609375
4
#! /usr/bin/env python3 ############################### ### EREDITARIETA' ### ############################### class Animale: def __init__(self, name, sound): self._name = name self._sound = sound print('Ho creato un animale') def restituisci_nome(self): print(self._n...
af19a64aa1bfa2d2e3833a29ee2473aeed464e9e
Cantimploras/ArenaOfValorDB
/aovdb/sqlite_DB.py
1,770
3.78125
4
import sqlite3 from personajes import Personaje conn = sqlite3.connect('jDbArena.db') c = conn.cursor() ''' # CREACION DE LA TABLA c.execute("""CREATE TABLE personajes ( nombre text, apodo text, rol text, precioOro real, precio real, maxHP rea...
83d166f26a25566c6505fd1cdb2a7d98071f08ba
ogbanugot/Queuing-theory
/interface.py
3,846
4.125
4
import queue_formula ''' interface with the queue_formula module ''' menu = ''' Here is a list of the functions available\n 1. Traffic intensity 2. Average number of items in the system \n 3. Average number of elements in the queue, when there is queue\n 4. Average number of elements in the queue inlcuding times when ...
4136cd98b721da791ece7c0fcb68e36da4876c59
thientt03/C4E26
/C4E26/Dark.py/checklogin.py
708
4
4
# username = input("Nhập username : ") # password = input("Nhập password : ") loop = True while loop: username = input("Nhập username : ") password = input("Nhập password : ") if not (username.isalnum() and password.isalnum()): print("Sai username hoặc password") else: ...
66c643563261cb4c695da13d93d2b3689c02711a
quanaimaxiansheng/1805python
/17day/2-不定长参数.py
339
3.546875
4
def d_sum(a,b,*args,**kwargs): ''' print(a) print(b) print(*args) print(**kwargs) ''' while True: p=0 for i in range(*args): p+=i if i>6: continue for j in range(**kwargs): z=int(j['values']) x=int(j['values']) print("和为%d"%(a+b+p+z+x)) d={"age":12,"weight":24} t=(1,2,3,4,5,6,) d_su...
f4c7d6226d25444f032dab840410b6503d9de31b
estensen/algorithms
/data_structures/binary_search_tree.py
1,366
3.796875
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def insert(self, val): if val <= self.data: if not self.left: self.left = Node(val) else: self.left.insert(val) else: ...
be6b2b70fada6629166f0d05887f426274fdf22d
Photooon/spell-correct
/tokenize_model.py
590
3.6875
4
import nltk def word_tokenize(sent: str): nltk.data.path.append('/Users/lw/Code/toolkit/nltk_data') words = nltk.word_tokenize(sent) # words = [word_trim(word) for word in sent.split(' ') if word] # split and remove the empty string return words def word_trim(word): # remove the front punctuat...
7eacb8f8bf513b12c445b5e6c158f48f47a5dd6f
mhrmm/csci377
/code/resolution/cnf.py
2,593
3.625
4
def l(s): if s[0] == '!': return Literal(s[1:], True) else: return Literal(s, False) def c(s): """ Convenience method for constructing CNF clauses, e.g. for Exercise 7.12: c0 = c('a || b') c1 = c('!a || b || e') c2 = c('a || !b') c3 = c('b || !e'...
8eee8d492361922d3ac9419421833df48a482ad7
lindycoder/AdventOfCode
/2016/day01_2.py
1,612
3.546875
4
import unittest from hamcrest import assert_that, is_ X = 0 Y = 1 def compute(input): visited = [] pos = [0, 0] directions = [ (0, 1), (1, 0), (0, -1), (-1, 0) ] facing = 0 commands = [(m[0], int(m[1:])) for m in input.split(", ")] for command in commands...
36525f7587201ce39f147bdd6c7fda0f9272299c
NikhilCG26/Python-For-Everyone-Coursera
/Assign-9/9.4.py
464
3.609375
4
name = input('Enter Name: ') fh = open(name) count = dict() for line in fh : if line.startswith('From:') : words = line.split() if words[1] not in count : count[words[1]] = 1 else : count[words[1]] = count[words[1]] + 1 bigword = None bignum = None for...
54de0811bb4433a500c5d18eb151c6bccf1baee9
anjaligeda/pythonbasic-branch
/lnbcal.py
485
3.9375
4
'''q=[] for i in range(2): a=int(input('enter number = ')) q.append(a)''' num1=int(input("Enter the first number: ")) #input value for variable num1 num2=int(input("Enter the second number: ")) #input value for variable num2 mul=num1*num2; #perform multiplication operation print("the product of given ...
651b097790ee3267b88e99ee7a82525c4f8ff7ed
Kendoll10/Python-Programs
/WhileLoop.py
792
4.25
4
# Make sure to copy and run the codes separately on your editor to see the results # Using while loop in our python program i=1 while i<=6: print(i) i+=1 # using flag to stop looping in python i = "" name = "What is your name?\n" while (i != "q"): i = input(name) # this programme will keep on lo...
c7e15aa7518855691706c487514af7b61683e5b1
dwagon/pydominion
/dominion/cards/Card_Improve.py
1,943
3.640625
4
#!/usr/bin/env python import unittest from dominion import Game, Card, Piles import dominion.Card as Card ############################################################################### class Card_Improve(Card.Card): def __init__(self): Card.Card.__init__(self) self.cardtype = Card.CardType.ACTIO...
0e4479668874a84b0dd8cdc570e1c5285acb67e0
Qhupe/Python-ornekleri
/Döngü Yapıları/ForDöngüsü.py
829
3.71875
4
toplam=0 sayac=0 liste =[1,2,3,4,5,6,7,8] s = "Python" for eleman in liste:#burada ise in parametresi listede gezinmemize yardımcı oluyo toplam = toplam+eleman sayac=sayac+1 if (eleman%2==0):#burada ise gezindiğimiz elemanın 2 ile bölümünden kalanı k...
12d015280733393147ee1f62fb7acd9f653512e7
ivoryli/myproject
/class/phase2/MySql/read_db.py
555
3.5
4
''' 数据库读操作演示 select ''' import pymysql #创建连接 db = pymysql.connect(host='localhost',user='root',passwd='123456',database='stu',charset='utf8') # 创建游标 cur = db.cursor() sql = "select * from myclass where age = 20" #执行语句 cur拥有查询结果 cur.execute(sql) #获取从查找结果第一个 one_row = cur.fetchone() print(one_row) # 游标指向下一个,不重复 # ...
faf8184e2a28b7fd22c8d6c592b91347d9553e81
amiraliakbari/sharif-mabani-python
/by-session/ta-921/j11/class1.py
251
3.65625
4
class Circle: def __init__(self): self.r = 0 self.x = 0 self.y = 0 #x = 0 #a = [] #x = None #x = 0 #x = [] c1 = Circle() c2 = Circle() c1.r = 1 c2.r = 3 print c1.r print c2.r print c1.x
a6d8c873c470672024a4196ee2975e11e2a4a44e
ajinmathew/Python
/reverse-string.py
137
4.15625
4
def reverse(s): str="" for i in s: str=i+str; return str inp=input("Enter a String : ") print("Op : "+reverse(inp))
1cc45030fc33fc1823a3e6ff319fc7f581a8e31f
5Hanui/algorithm
/BOJ/BOJ_12904.py
229
3.5625
4
S = list(input()) T = list(input()) answer = 0 while T: if T[-1] == "A": T.pop() elif T[-1] == "B": T.pop() T.reverse() if S == T: answer = 1 break print(answer)
8dfc9d9257a4ed6854ece19e2470eb89e7bd57ce
SiERic/paradigms-au-2017
/hw5/yat/model.py
4,378
3.671875
4
class Scope: def __init__(self, parent=None): self.data = dict() self.parent = parent def __setitem__(self, key, value): self.data[key] = value def __getitem__(self, key): if key in self.data: return self.data[key] if self.parent: return sel...
31f6ceb9736dc10647aaeda029fadd85473b5694
abrosen/classroom
/itp/spring2020/interloops.py
1,242
3.703125
4
def numVowel(text): count = 0 text = text.lower() vowels ="aeiou" for letter in text: if letter in vowels: count = count + 1 return count def numEvens(num): if num == 0: return 1 count = 0 #num = str(num) #for digit in num: # digit = int(di...
218b48490de7d74e8f7de996f2746ce19f4d914a
jtquisenberry/PythonExamples
/Interview_Cake/dynamic_programming/fibonacci_recusion_memoization.py
1,368
3.734375
4
import unittest import pytest # https://www.interviewcake.com/question/python/nth-fibonacci?section=dynamic-programming-recursion&course=fc1 # Includes recursion and memoization. # The memo should be a dictionary where the key is the # being passed to the first argument of fib and the value # is the result of the com...
c81a722d29f4dda2dc18d96780fc5ba750884e6c
Krit-NameWalker/6230401848-oop-labs
/Krit-623040184-8-lab4/prob3_debug_correct.py
493
4.09375
4
import sys import pdb def divide(dividend, divisor): return dividend / divisor #pdb.set_trace() while True: dividend = int(input("Please enter the dividend:")) if dividend < 0: break divisor = int(input("Please enter the divisor:")) if divisor < 0: break try: ...
e1f7204178de396ba407999e1f8380ccd0cb3d76
RajavelJeyabalan/Practicing-Code
/Aug 03 Task.py
1,720
4.3125
4
#!/usr/bin/env python # coding: utf-8 # In[3]: #the function table(n) prints the table of n def table(n): return lambda a:a*n # a will contain the iteration variable i and a multiple of n is returned at each function call n = int(input("Enter the number:")) b = table(n) #the entered number is pas...
3811af30bf4b0505d03cc2003c0d616e150beb76
jedzej/tietopythontraining-basic
/students/nartowska_karina/lesson_01_basics/first_digit_after_decimal_point.py
81
3.5625
4
# Read an integer: a = float(input()) # Print a value: print(int((a-int(a))*10))
2f920a6c4279b1ec5ac66e2fb959cea08fcc5c8f
artreven/fca
/fca/algorithms/factors.py
9,573
3.578125
4
""" Holds functions for finding optimal factors for decomposition of context. Created on Jan 8, 2014 @author: artreven """ import itertools import collections import random from typing import Tuple, Set import fca def make_factor_cxts(factors=None): """ Make two contexts: objects-factors and factors-attrib...
9137910f100b17f4bc73a517ac3dc1641975cbdb
VaibhavRast/SLLAB
/SLLAB_FINALS/1/1a.py
419
3.9375
4
li=[] n=int(input("Enter no of elements to be inserted:")) for i in range(0,n): li.append(int(input("Enter:"))) print(li) print("Max:",max(li)," Min:",min(li)) ele=int(input("Enter element to be inserted:")) li.append(ele) print(li) ele=int(input("Enter element to be deleted:")) li.remove(ele) print(li) ele=int(...
22f8acefdb525aa303583aa8e83097388761a4c4
Umang070/Python_Programs
/set.py
366
3.796875
4
s = {1,2,34,34,"umang",2} s1 = {1,2,"umang",45,47} # print(s) # l=[1,2,3,43,43,2,5,6] # s=list(set(l)) print(s) s.add(4) # s.remove(3) #if it is not in set thenn throw error.... s.discard(4) #if it is not in set thenn do not throw error.... # print(s.clear()) # for i in s: # print(i) union = s | s1 print(unio...
682b3e1d6d40f4b279052ac27df19268d227fef8
pypi123/machine_learning_ZZH
/Unit5/Unit5_5.py
4,609
3.671875
4
'''引入数据,并对数据进行预处理''' # step 1 引入数据 import pandas as pd with open('D:\\Desktop\西瓜数据集3.0.csv', 'r', encoding='utf-8') as data_obj: df = pd.read_csv(data_obj) # Step 2 对数据进行预处理 # 对离散属性进行独热编码,定性转为定量,使每一个特征的取值作为一个新的特征 # 增加特征量 Catagorical Variable -> Dummy Variable # 两种方法:Dummy Encoding VS One Hot Encoding # 相同点:将Cat...
c043dca76223b46286fd7ad05c13e2b5d337b727
SeelamVenkataKiran/PythonTests
/Numpy/npex2.py
1,406
3.9375
4
import numpy as np #first numpy array first_numpy_array = np.array([1,3,5,7]) print(first_numpy_array) #array with zeroes array_with_zeroes = np.zeros((3,3)) print(array_with_zeroes) #array with ones array_with_ones = np.ones((3,3)) print(array_with_ones) array_with_ones.shape array_with_ones.size array_with_ones....
8c5fd9db07f87e199f5759bee4009bdaba35f3fd
maurogome/platzi
/python_intermedio/lists_and_dicts.py
830
3.921875
4
def run(): #my_list = [1, True, "Que onda", 3.5] #my_dict = {"first_name": "Mauricio", "last_name": "Gomez"} super_list = [ {"first_name": "Mauricio", "last_name": "Gomez"}, {"first_name": "Maria", "last_name": "Gonzalez"}, {"first_name": "Jose", "last_name": "Arango"}, ...
0ba8e5d96873233de71c9a2d2fdd881531404ac7
Gwarglemar/Python
/Exercises/Kattis/2_9_beekeeper.py
845
4.21875
4
#Given test cases, identify the word with the most double vowels vowels = {'a','e','i','o','u','y'} double_vowels = {'aa','ee','ii','oo','uu'} while True: num_w = int(input()) if num_w == 0: break words = [] for _ in range(num_w): words.append(input()) most_doub...
8e25ee266aaebbf75455560518c9e3b4eae38c5b
CarolineXiao/AlgorithmPractice
/TopologicalSorting.py
1,242
3.8125
4
""" Definition for a Directed graph node class DirectedGraphNode: def __init__(self, x): self.label = x self.neighbors = [] """ class Solution: """ @param: graph: A list of Directed graph node @return: Any topological order for the given graph. """ def topSort(self, graph): ...
ff0c82d1a0e1f923c2e1cf350377fdd1fdaaa297
c00t/python_playground
/python-basics/ch14/sqlscripts.py
319
3.546875
4
import sqlite3 sqlscripts = """ DROP TABLE IF EXISTS People; CREATE TABLE People( FirstName TEXT, LastName TEXT, Age INT ); INSERT INTO People VALUES ( 'Rex', 'Temple', 21 ); """ with sqlite3.connect("test_database.db") as conn: cursor = conn.cursor() cursor.executescript(sqlscripts)
1a50e002aa63808b22679152026f3b03acf2542a
fvega-tr/Python-begins
/python_code/roman_numerals.py
952
3.515625
4
class Roman: def __init__(self): self.dictionary = {"M": 1000, "CM": 900, "D": 500, "CD": 400, "C": 100, "XC": 90, "L": 50, "XL": 40, "X": 10, "IX": 9, "V": 5, "IV": 4, "I": 1} self.dic = {"M":1000, "D":500, "C":100, "L":50, "X":10, "V":5, "I": 1} def ord_to_roman(self, num): result = "" ...
4b7318f8c3ed8649b40a20a17a31623faaaf5a8a
vladislavneon/style-based-plagiarism-detection
/tokenizer.py
368
3.609375
4
import re def tokenize(line): re.sub(r'. . .', '...', line) tokens = line.split() return tokens def tokenize_file(filename): text = [] with open(filename, 'r') as inf: for line in inf: text.append(tokenize(line)) return text def main(): text = toke...
a371865760b22b90a370348fe720d731ef57724e
caroljunq/data-structure-exercises
/dijkstra.py
4,018
3.8125
4
# Dijkstra algorithm from sys import maxsize as INF import heapq # Return the minimal distances from start to every node in graph def dijks_distances(graph, start): queue = [] distances = {} prev = {} for v in graph: distances[v] = INF prev[v] = None queue.append(v) distanc...
dd58f7f1fb49839df1d59771d840aabe8e1f19c4
VamsiKrishnaRachamadugu/python_solutions
/problemset3/7.letters_in_word.py
520
4.4375
4
"""7.Write a function named using_only() that takes a word and a string of letters, and that returns True if the word contains only letters in the list. Can you make a sentence using only the letters acefhlo? Other than "Hoe alfalfa?" """ def using_only(word, letters_string): for char in word: if char no...
1c6fb0b34434bca7552b7d1243a30cd014bcc478
frclasso/revisao_Python_modulo1
/cap04-tipos-variaveis/04_tuple_variables.py
466
4.28125
4
#!/usr/bin/env python3 minhatupla = ('abcd', 786, 2.23, 'john', 70.2) tinytupla = (123, 'john') print(minhatupla) print(minhatupla[0]) print(minhatupla[1:3]) print(minhatupla[2:]) print(tinytupla * 2) print(minhatupla+tinytupla) # o codigo abaixo eh invalido para tuplas, mas funciona para listas #minhatupla[2] = 10...
0917bf1dd26bb0353c1238a9cc9b23f3a60b4b8b
xodud001/coding-test-study
/peacecheejecake/brute_force/12919_A와B2.py
537
3.71875
4
# https://www.acmicpc.net/problem/12919 # def check(s, t, backward): if s[0] == 'B' and t[0] == 'A': return False s = s[::(-1) ** backward] start, end = 0, len(s) is_possible = False while end <= len(t): u = t[start:end] if (u == s and t[:start].count('B') == t[...
80ac03ec59b5907203947d278c3ccd2144399bac
pelletier197/Sudoku-Python
/game/SudokuSolver.py
6,311
3.984375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This module contains the sudoku solver for a sudoku grid """ __auteur__ = "SUPEL55" __date__ = "2016-11-21" __coequipiers__ = "RABOU264", "ANMIG8" class SudokuSolver: """ Grid solver for a sudoku grid. """ def solve(self, sudokugri...
9eb23079d2c7c9aa894fd4f94dfc36c79855888a
SunnyLyz/image_augmentation
/image_augmentation/image/layers.py
4,673
3.5
4
"""Pre-processing layers for few image op(s).""" import tensorflow as tf from tensorflow.keras import backend as K from tensorflow.keras.layers import Layer from tensorflow.python.keras.utils import conv_utils from image_augmentation.image.image_ops import cutout class RandomCutout(Layer): """Apply random Cutou...
582e1f8bc603d2c797f1f588a55630584e73114b
dhrubach/python-code-recipes
/binary_tree/e_search_clone_tree.py
1,357
3.703125
4
###################################################################### # LeetCode Problem Number : 700 # Difficulty Level : Easy # URL : https://leetcode.com/problems/search-in-a-binary-search-tree/ ##################################################################### from binary_search_tree.tree_node import TreeNode ...
62487eef2cc592ff9803b1fe544d95113d5518ac
corinnejachelski/code_challenges
/recursion.py
1,237
4.4375
4
def decodeVariations(S): """ @param S: str @return: int A letter can be encoded to a number in the following way: 'A' -> '1', 'B' -> '2', 'C' -> '3', ..., 'Z' -> '26' A message is a string of uppercase letters, and it is encoded first using this scheme. For example, 'AZB' -> '1262' Give...
f2db6eafb673806eaec3e21ff32bab2b5e1eb103
VictorFAL/PythonProjects
/Submarine/dataclass_version/main.py
2,742
4.21875
4
from Submarine import Submarine # x validation def x_input(): while True: try: x = int(input('X = ')) except: print('X value must be a number.') continue break return x # y validation def y_input(): while True: try: y = int(in...
181ca89ed4ac43879baee932c1bbeb181eaa61cd
Farhana-Afrin-Maysha/chor_police_game_python
/chor_police_PREVIOUS.py
1,305
3.765625
4
import random def call_police(): print('The index of Boss is: ', mylist.index(100)) print('The index of Police is: ', mylist.index(80)) y = int(input('Say the index no of thief. ')) if (y == mylist.index(00)): print('You are correct') else: print('You are not correct') msg = "Welco...
8da246bb5ddd3806dbe6debfe06db7cdce4f57fc
Savely-Prokhorov/DifferentPythonSolutions
/UniLecsTasks/15. WaterVolumeInHist.py
699
3.71875
4
""" Задача: Дана гистограмма, она представлена числовым массивом: [3, 6, 2, 4, 2, 3, 2, 10, 10, 4] Нужно посчитать объем воды (1 блок в гистограмме), ктр наберется внутри нее. """ from matplotlib import pyplot as plt arr = [3, 6, 2, 4, 2, 3, 2, 10, 10, 4, 5, 6, 4, 10] plt.bar(range(len(arr)), arr) plt.sh...
79ce1866c7b88ea10407873aa097e08567c99de0
chisness/aipoker
/poker_ai-master/new_python/kuhn3p/players/TE.py
7,186
3.640625
4
import random from kuhn3p import betting, deck, Player class TE(Player): def __init__(self, rng=random.Random()): self.rng = rng self.betting_round = 0 # A list of where each player is seated for the round self.agent_p1_p2_positions = [] # Checks track of the total n...
42402da2fb1e4e09ca337de057da35a3cafc5bee
lucassaporetti/castlevania_inventory_system
/src/core/enum/item_type_enum.py
651
3.578125
4
from enum import Enum class ItemType(Enum): UNIQUE = 1 FIST_WEAPON = 2 SHORT_SWORD_WEAPON = 3 SWORD_WEAPON = 4 CLUB_WEAPON = 5 TWO_HANDED_WEAPON = 6 THROWING_SWORD_WEAPON = 7 BOMB_WEAPON = 8 PROJECTILE_WEAPON = 9 SUB_WEAPON = 10 HEAD_ARMOR_CLOTHE = 11 BODY_ARMOR_CLOTHE ...
589c3023cea1c8829193516da449ae10202fd71e
cielo-cerezo-tm/tutoring
/plantshop.py
861
4.125
4
class Plant: def __init__(self, number_of_leaves, root_system, growth_in_inches): self.number_of_leaves = number_of_leaves self.root_system = root_system self.growth_in_inches = growth_in_inches def grow(self, no_inches): self.growth_in_inches = no_inches def wither(sel...
2c7310ab0e80ce9e0fb5d18556f596a07d23c535
ggozlo/Python_training
/section10.py
3,426
3.71875
4
#파이썬 예외처리의 이해 # 예외 종류 # 문법적으로 에러가 없지만, 코드 실행(런타임)프로세스 에서 발생하는 예외 처리도 중요 # linter : 코드 스타일, 문법 체크 # SyntaxError : 잘못된 문법 # print('test # if True # pass # x => y # NameError = 참조변수 없음 a = 10 b = 15 #print(c) # ZeroDivisionError : 0 나누기 에러 # print(10/0) # IndexError : 인덱스 범위 오버 x = [10,20,30] print(x) # print...
4f9e1e66b133e2e5b52f9fde0470d41f386b4638
collins-m/comparative_programming_languages_2
/object_oriented/src/classes/Node.py
2,547
3.984375
4
class Node: def __init__(self, data): """ initialize with a data value and left/right links """ self._data = data self._left = None self._right = None def data(self, param=None): """ getter/setter for data """ if param == None: return...
cf0e44ee58df6369796469f3643233e12e7e3d39
WillyNathan2/Python-Dasar
/T02_2072037/T02A_2072037.py
1,922
3.78125
4
# File : T02A_2072037 # Penulis : Willy Natanael Sijabat # Deskripsi : Mencari karakter dalam string yang sudah diberi value integer # Kamus : NamaDepan = string # : NamaBelakang = string # : Words = integer # : FineWords = code (string) def main (): #program NamaDepan = str(input(...
c2f362a31e0748dd8c2a7ab128131286ae505da4
lxh1997zj/Note
/廖雪峰python3教程/廖雪峰python3基础部分/test.py
86
3.65625
4
#!/usr/bin/python #-*-coding:utf-8-* num=input("please input your name:") print(num)
f08569394e820e6e3ef087e925d7d5606757a3f8
Wondrous/web
/wondrous/utilities/rank_utilities.py
1,638
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Company: WONDROUS # Created by: John Zimmerman # # RANK_UTILITIES.PY # import operator class RankUtilities(object): @staticmethod def rank_score(up_votes, down_votes): """ *** NOT IN USE, BUT KEPT SO IF WE WANT TO ALGORI...
fdc7ca61b9b54708df311ab62759cdb4fc643fda
arminAnderson/CodingChallenges
/ProjectEuler/Python/LargestPalindrome.py
368
3.59375
4
def IsPalindrome(num): flip = 0 og = num while num > 0: flip *= 10 flip += num % 10 num //= 10 return og == flip i = 999 j = 999 largest = 0 while i > 99: while j > 99: if IsPalindrome(i * j): if largest < i * j: largest = i * j j...
1ebde6854e10d2ba935f33a180b92eefe83c897a
Vladooha/Python_Labs
/Lab2/Zad2/Zad2.py
745
3.53125
4
import csv with open('items.csv', 'r+', newline="", encoding="utf8") as items_file: items = csv.DictReader(items_file, delimiter=';') columns = items.fieldnames min_price_item = None max_price_item = None for item in items: price = item["Цена"] if min_price_item is None or min_price...
70a050f9a71292b511f869b10cb72ceb5682b40e
Kaustubh05334/defang_ip
/defang_ip.py
158
3.703125
4
def defang_ip(ip): d_ip = ip.split(".") defanged_ip= "[.]".join(d_ip) return defanged_ip x= input("Enter a ip address: ") print(defang_ip(x))
942c9b149cbff794c6e57ec7c4045ea49d1b5f18
HarikaSabbella/EulerServer
/Euler/euler-project/src2/EulerDAG/aaa.py
1,752
3.5625
4
import itertools #remove the duplicate tuples in list def remove_dup_tuples_in_list(l): l.sort() return list(l for l,_ in itertools.groupby(l)) def tuple_not_in_list(t,li): for aTuple in li: if t == aTuple: return False return True o_list = [("B","C"),("A","B"),("C","D"),("D","E")...
c4975c4fe9ae111c151e6aba8755b6476eb657bf
alangm7/Learn_Python_MIT_course_EdX
/Palindrome.py
510
4.1875
4
"""Write a Python function that returns True if aString is a palindrome (reads the same forwards or reversed) and False otherwise. Do not use Python's built-in reverse function or aString[::-1] to reverse strings. This function takes in a string and returns a boolean.""" def isPalidrome(word): result = {} x = len(...
adec3acd2ec46bbec6f4413de4d1d486b2962a2e
gg4race/projecteuler
/problem41/problem41.py
936
4.15625
4
def main(): import itertools def isPrime(n): '''check if integer n is a prime''' # make sure n is a positive integer n = abs(int(n)) # 0 and 1 are not primes if n < 2: return False # 2 is the only even prime number if n == 2: return...
6b18cfe8f5fad25069031b76cc2c13c1c20774f7
ogradybj/tangent_rev00
/tangentgame.py
12,634
3.890625
4
import pygame import random import math import numpy #colors defined BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 220, 0) RED = (220, 0, 0) BLUE = (0, 0, 255) YELLOW = (235, 235, 35) GAMEOVER = False class Block(pygame.sprite.Sprite): """ This class represents the blocks at either end of the game ...
c9be14e5b9a621183a37e6178cfad9de3250f693
claytonchagas/ML-arules-noW
/teste2.py
136
3.921875
4
print("hello world!") x = ["d", "a", "c", "b", ] print(x) x.sort() print(x) string = "ola_mundo" pos = string.find("_") print(pos)
f18653289b09af6a5ab6fd3f073d0e4b9058d26a
Abdur15/100-Days-of-Code
/Day_018/Challenge 32 - Draw different shapes.py
1,510
4.03125
4
from turtle import Turtle,Screen screen = Screen() screen.screensize(2000,1500) my_turtle = Turtle() my_turtle.shape("turtle") def triangle(): m = 0 while m < 3: my_turtle.pencolor("red") my_turtle.forward(100) my_turtle.right(120) m+=1 def square(): m = 0 while m < 4: ...
dec46f857ef2ad6c4a896bc5aaa609f184e8bf79
MohamedNagyMostafa/Facial-Keypoints-Detection
/recognize facial over many faces/main.py
413
3.71875
4
import numpy as np from utils import * #read an image image = readImage('obamas.jpg',3) #display image show(image) #detect faces in image faces = cascadeFaces(image) #display image with cascaded faces image_detected_Faces = np.copy(image) image_faces = showFacesCascade(image, faces) #using the trained model to get...