blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
bcb0793a5ba8769b2f81aa2643cf9023a2edf337 | ztankdestroyer/pre-ap-cs | /menu gui, enhanced.py | 3,919 | 3.515625 | 4 | from tkinter import *
class Application(Frame):
def __init__(self, master):
super(Application, self).__init__(master)
self.grid()
self.create_widgets()
self["background"] = "#ADEBF7"
self["borderwidth"] = 0
def create_widgets(self):
Label(self,
... |
c75a1774b3d16f850f66a24a24ee1b206adbb9e9 | bashmastr/CS101-Introduction-to-Computing- | /Assignments/05/a05.py | 1,458 | 4.125 | 4 | ## IMPORTS GO HERE
## END OF IMPORTS
#### YOUR CODE FOR is_prime() FUNCTION GOES HERE ####
def is_prime(y):
if y > 1:
x = int(y)
if x==y:
if x == 1:
return False
if x == 0:
return False
if x == 2:
return True
... |
ad9f1e68d6171a96f2cda9cb80e11034793bd1cc | Pawan300/Algorithms-Python | /mergesort.py | 978 | 4.0625 | 4 | def merge(arr,start,middle,end):
i=0
j=0
k=start
nl=int(middle-start+1)
nr=int(end-middle)
l=[0]*nl
r=[0]*nr
for i in range(0,nl):
l[i]=arr[i+start]
for j in range(0,nr):
r[j]=arr[j+middle+1]
while i<nl and j<nr:
if l[i]<=r[j]:
... |
7480b2b936688709b70d7ce8f484cde408b32e46 | Pawan300/Algorithms-Python | /insertionboth.py | 883 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 8 21:51:20 2018
@author: pawan_300
"""
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 30 12:38:05 2018
@author: pawan_300
"""
l=[]
def insertionmax(l,temp):
for i in range(1,temp):
lamda=l[i]
j=i-1
while((j>=0)&(lamda>l[j])... |
76a3ccadcb3e7bf263594fe40f803e37e46614be | ureka712/freshworkassign | /crd.py | 2,161 | 3.609375 | 4 | import json
def create():
def writejson(data,filename="datastore1.json"):
with open (filename,"w") as f:
json.dump(data,f,indent=3)
with open("datastore1.json") as jfile:
data = json.load(jfile)
temp=data["employee_details"]
per = {}
vem=input("enter employ... |
3041326059164187c5fb2bca7f0693f23e001333 | rsdefever/mws | /mws/signac.py | 700 | 3.515625 | 4 | def check_simulation(filen, nsteps):
"""Check the energy file to determine if the simualtion is complete
Parameters
----------
filen : string
energy file name to check
nsteps : int
number of steps in simulation
Returns
-------
complete : bool
True if the simulat... |
f01a4b935750f250b57fbf8f9f73edb4a8a8aa0f | Tonovasquez/python3 | /Ejercicios 33/ejercicio30.py | 190 | 4.03125 | 4 | #Hacer un programa que me muestre la raiz cuadrada de cualquier numero ingresado.
numero = float(input("Ingresa un numero:."))
raiz = numero **(1/2)
print("La raiz es de:. {}".format(raiz))
|
952f8170b5cd7423f72983c7bf56f25ef3b1dd60 | Jeff-Osbourn/Sorting-App | /SortTest.py | 1,486 | 3.8125 | 4 | # Ask the user to enter the names of files to compare
fname1 = input("Enter the first filename: ")
fname2 = input("Enter the second filename: ")
# Open the file so we can start comparing them
file1 = open(fname1)
file2 = open(fname2)
# Get the first line in each file
check1 = file1.readline()
check2 = file2... |
6832a42539daa56e2f4c04a1238236a2cfc31e98 | mmuratardag/DS_SpA_all_weeks | /DS_SpA_W10_Recommender_System/03_19/TeachMat/flask-recommender/recommender.py | 1,270 | 4.1875 | 4 | #!/usr/bin/env python
import random
MOVIES = ["The Green Book", "Django", "Hors de prix"]
# def get_recommendation():
# return random.choice(MOVIES)
def get_recommendation(user_input: dict):
m1 = user_input["movie1"]
r1 = user_input["rating1"]
m2 = user_input["movie2"]
r2 = user_input["rating... |
01db284a5ef14f2625b3e86f41e84c1450bf8cf6 | jundoopop/self_june | /onlypractice/datastructure/stack/boj1874.py | 1,401 | 4.0625 | 4 | # https://www.acmicpc.net/problem/1874
"""
Stacked Array
push, pop, LIFO
-> Those three features are characters that Stack data has.
- Assuming implementing an array same as the input array.
- From the ascending array.
If the number of pushed numbers are more than one,
but requires ascending order -> It cannot be... |
704a6d87fe7515bfc10ad924222255d0fe32d588 | jundoopop/self_june | /onlypractice/datastructure/stack/boj10828.py | 1,307 | 4.03125 | 4 | # https://www.acmicpc.net/problem/10828
# stack implmlentation
"""
The stack stores integers by input.
The stack has the following commands:
push X: Push the integer 'X' into the stack
pop: Pop the top element of the stack and print. If the stack is empty, print -1
size: Print the size of the stack
em... |
cfe614c9161aed2a4f736ef119e23d90912aff12 | G-noname/G-noname-001 | /Challenge1/calculator_eg2.py | 1,182 | 3.734375 | 4 | #!/usr/bin/env python3
from collections import namedtuple
#使用nametuple给元组索引命名,这样就可以像调用字典value一样调用元组元素(代码易读、规范)
IncomeTaxQuickLookupItem = nametuple(
'IncomeTaxQuickLookupItem'
['start_point','tax_rate','quick_subtractor']
)
INCOME_TAX_START_POINT = 3500
INCOME_TAX_QUICK_LOOKUP_TABLE = [
IncomeTaxQuickLookupItem(80... |
0ccaec346448df5b1ca16f290e6529b014bdab19 | G-noname/G-noname-001 | /Python3_simple_course/Challenge1/CircleArea.py | 102 | 3.75 | 4 | #!/usr/bin/env python3
import math
r = 2
PI = 3.1415926535898
s = r*r*PI
print('{:.10f}'.format(s))
|
5eb17e387d9411fbc389e498a0760446844c9821 | G-noname/G-noname-001 | /EX_1/ex5_2.py | 781 | 4.0625 | 4 | #!/usr/bin/env python3
class Animal(object):
owner = 'jack'
def __init__(self,name):
self._name=name
@classmethod
def get_owner(cls):
return cls.owner
def get_name(self):
return self._name.lower().capitalize()
def set_name(self,value):
self._name=value #?
def make_sound(self):
pass
class Dog(Animal)... |
a524265be08d938587ac1d1f732d2839f80d40d2 | isaac-ped/project_euler | /euler89.py | 1,378 | 3.53125 | 4 | numerals = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
def to_int(roman):
numbers = []
for char in roman:
numbers.append(numerals[char])
integer = 0
for i in range(len(numbers)):
if i==len(numbers)-1:
integer+=numbers[i]
else:
if numbers[i+1]>numb... |
abb0cfa3c2367a896708a751ad12107f193c0ece | cydnr/Problem_Solving | /BOJ/IM 대비 필수문제/[2669] 직사각형 네개의 합집합의 면적 구하기.py | 346 | 3.71875 | 4 | # 각 사각형의 왼쪽 아래 점을 point에 겹치지 않게 저장해서 개수 반환.
point = []
for t in range(4):
square = list(map(int, input().split()))
for x in range(square[0], square[2]):
for y in range(square[1], square[3]):
if (x,y) not in point :
point.append((x,y))
print(len(point)) |
08eeceab2af80dd8b8a6fec95b5b45953ed755f4 | cydnr/Problem_Solving | /BOJ/단계별로 풀어보기/+) 실습1/실습1.py | 1,222 | 3.515625 | 4 | # 10039 평균 점수
scores = []
for i in range(5) :
score = int(input())
if score < 40 :
score = 40
scores.append(score)
print(sum(scores)//5)
# 5543 상근날드
minburger = minbev = 2001
for i in range(3) :
burger = int(input())
if burger < minburger :
minburger = burger
for i in range(2) :
... |
b4a69edff326c2c839e5156764581ea784c62600 | k2345rftf/fuzzy_search_string | /tanimoto.py | 393 | 3.65625 | 4 | def tanimoto(s1, s2):
c = 0
s1 = set(s1)
s2 = set(s2)
a = len(s1)
b = len(s2)
for ch in s1:
if ch in s2:
c+=1
return 1 - c/(a+b-c)
if __name__=='__main__':
word_1 = 'лызина'
word_2 = 'лыткина'
print(f'Расстояние левенштейна между словами \'{word_1}\' и \'{word_2}\' равно {tanimoto... |
b47a6aa5ca393d9fe3dbdc5e50589b1ef99ac40a | scheng95/cs51finalproject | /roommateproblem/graph.py | 722 | 3.828125 | 4 | # graph class
class Graph(object):
nodes = []
edges = []
nodemap = {}
edgemap = {}
def add_edge(self,v,w,k):
if v in self.nodes:
self.nodemap[v].append(w)
else:
self.nodemap[v] = [w]
if w in self.nodes:
self.nodemap[w].append(v)
el... |
d8984f6f3e351929d70d75dc1d375793cc126844 | terrepta/Programming | /Practice/08/Python/08.py | 390 | 4.03125 | 4 | a, sign, b = input().split()
a = float(a)
b = float(b)
if b == 0 and sign == "/":
print("Ошибка. Деление на ноль невозможно. Введите новые значения.")
else:
if sign =="+" :
print(a + b)
elif sign =="-" :
print(a - b)
elif sign =="*" :
print(a * b)
elif sign =="/" :
... |
f46c9e0e9d1928c5a029f0eaf125a6e1d7440d83 | terrepta/Programming | /Practice/15/Python/15.py | 941 | 3.640625 | 4 | ident=1
while ident == 1:
i = 0
import random
numb = random.randint(0,100)
print("\tПриветствую!\n Сейчас компьютер загадает число. У вас будет 5 попыток, чтобы его отгадать.\n Введите целое число.\n")
while i < 5:
answ = int(input())
if answ < numb :
print("Загаданное ч... |
4e95715cc1bc7ca17499548114ad99b73f96e876 | zcmsmile/aaa | /chengfa.py | 137 | 3.546875 | 4 | #!/usr/bin/python3
#-*- coding:utf-8 -*-
for i in range(1,10):
for j in range(1,i+1):
print('%d*%d=%d'%(i,j,i*j),end='\t')
print('')
|
c5933770e7491e0221726dcda7e2a6cd83710783 | lunakoj/Python-Projects-Begginers-Level- | /test_KM to MILES.py | 173 | 4.3125 | 4 | print("Convertion of Kilometers KM to Miles")
km = float(input("Type the number of Kilometers : "))
miles = km/1.609344
print(km, "Kilometer = ", round(miles,4), "Mile : ")
|
85e801eef8d350aad25e97a8f9f98c019efa97f5 | amughal2/Portfolio | /python_work/alien_dictionary.py | 965 | 3.71875 | 4 | #alien_0 = {}
#alien_0['color'] = 'green'
#alien_0['points'] = 5
#alien_0['x_position'] = 0
#alien_0['y_position'] = 25
#print(alien_0)
#alien_0 = {'color': 'green'}
#print("The alien is " + alien_0['color'] + ".")
#alien_0 = {'color': 'yellow'}
#print("The alien is now " + alien_0['color'] + ".")
alien_0 = {'x_po... |
9f2cc03fdb154528b37d7701b63051cb468148ea | amughal2/Portfolio | /python_work/user_class.py | 1,435 | 3.828125 | 4 | class User():
def __init__(self, first_name, last_name, age, user_name, phone_number):
self.first_name = first_name
self.last_name = last_name
self.age = age
self.user_name = user_name
self.phone_number = phone_number
self.login_attempts = 0
def describe_user(self):
print("Here is a list of the user ... |
94475b5654e0b027180cdc8109760bff68e351eb | amughal2/Portfolio | /python_work/rw_visual.py | 663 | 3.828125 | 4 | import matplotlib.pyplot as plt
from random_walk import RandomWalk
#Keep making new walks, as long as the program is active.
while True:
rw = RandomWalk(50000)
rw.fill_walk()
#Set the sixe of the plotting window
plt.figure(figsize=(10,6))
point_numbers = list(range(rw.num_points))
plt.scatter(rw.x_values, rw.... |
3ab9456ef8b59e639315bc52089ac1f08a8a6ea9 | imanehmiddou/HandsOnPython2020 | /Cours03/boucle_for.py | 226 | 3.640625 | 4 | # boucle "for" sur une plage d'entiers (attention, range(10) corresponds à la plage de 0 à 9)
for i in range(10):
print(" " * i, "*")
# boucle "for" utilisant une chaîne de caractères
for c in "Bonjour":
print(c)
|
b432b81259df7c1ef6ac5ed17fc124a5530468ad | DjamilaBENNACER/Blockchain | /functionSpyder.py | 1,777 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
l'indentation est très importante en python'
"""
def myFunct(int_in) :
return int_in/5
print("HELLO")
if __name__ == '__main__':
print(myFunct(21))
else:
print("primer imported, not invoked")
"""
class myClass:
de... |
97933b85293a234ab43529ac1e1a7be4f85ff064 | stacywebb/ledypi | /src/utils/modifier.py | 1,996 | 3.953125 | 4 | from utils.color import scale
class Modifier:
"""
Modifier class used for variable attributes in the Patterns
"""
def __init__(self, name, value, minimum=None, maximum=None, options=None, on_change=None):
"""
:param name: str, the name of the modifier, the one shown in the interfaces... |
e47781a543e7ab3ccca376d773ebdcd13e6cc77b | yveslox/Genesisras | /practice-code-orange/programme-python/while-loop.py | 245 | 4.125 | 4 | #!/usr/bin/python3
#while loop
num=1
while(num<=5):
print ("num : ",num)
num=num+1
print ("")
# else statement with while loop
num=1
while(num<=5):
print("num : ",num)
num=num+1
else :
print("second loop finished.")
|
bcf9dd36b372e4a70c599534c62865ce39b1767b | yveslox/Genesisras | /practice-code-orange/programme-python/gcd.py | 127 | 3.859375 | 4 | #!/usr/bin/python
def gcd(a,b):
if(b==0):
return a
else:
return gcd(b,a%b)
print("gcd(60,100):", gcd(60,100))
|
73b78708165de719b599a58daaafdad9b47c140b | yveslox/Genesisras | /practice-code-orange/programme-python/classes-objects.py | 519 | 3.84375 | 4 | #!/usr/bin/python
class books:
totalbooks=0
def __init__(self, name, id):
self.name=name
self.id=id
books.totalbooks+=1
def totalnumberofbooks(self):
print("total books : ",books.totalbooks)
def bookinformation(self):
print("book name : "... |
d32914bd0052e90d7fd0d87727d67ec5ca99b3e4 | yveslox/Genesisras | /practice-code-blue/programme-python/for-loop.py | 360 | 4.0625 | 4 | #!/usr/bin/python
name="Python programming"
print("Loop 1")
for ch in name:
print(ch),
print("")
#iterate using sequence index
print("loop 2")
len=len(name)
for i in range(len):
print (name[i]),
print("")
#else statement with for loop
print("loop 3")
for ch in name:
print(ch),
else :
print("... |
46e4aa41d0222a52ae31f58f11d80f351ade1f62 | yveslox/Genesisras | /practice-code-orange/programme-python/if-else.py | 161 | 4.1875 | 4 | #!/usr/bin/python
num=12
if(num==12):
print("num : 12")
elif(num==13):
print("num : 13")
elif(num==14):
print("num : 14")
else:
print("num is :",num)
|
26fded563d3655f5f06e2cdf582d0cdc564ab9dc | yveslox/Genesisras | /practice-code-blue/programme-python/lists.py | 672 | 4.34375 | 4 | #!/usr/bin/python
list=[1,2,3,4,5,6,7,8];
print("list[0] :",list[0])
print("list[1] :",list[1])
print("list[2:5] :",list[2:5])
#updating list
list[3] = 44
print("list(after update):",list)
#delete element
del list[3]
print("list(after delete) :",list)
#length of list
print("length of list : ",len(list))
#appendi... |
ca76c152c79f8b50a5f326a9ecef808b3e71cc01 | NoCool14/GrowingBall | /triangle.py | 3,892 | 4.5 | 4 |
import random
import pygame
class Triangle(pygame.sprite.Sprite):
'''
Created on May 4, 2015
The constructor has 6 required parameters: surface, color,
starting x and y coordinates, speed and the size
This class draws a triangle with the giv... |
7851912c02fd2481ace43d7727b3ceb42153a088 | amtfbky/hfpy191008 | /base/0005_input.py | 2,249 | 4.125 | 4 | # -*- coding:utf-8 -*-
# import urllib # 关于互联网的类
# print "Enter your name: ", # 逗号用来把多个print语句合并到同一行上,且增加一个空格
# someone = raw_input()
# raw_input的简便方法
# someone = raw_input("Enter your name: ")
# print "Hi, " + someone + ", nice to meet you!"
# temp_string = raw_input()
# fahrenheit = float(temp_string)
# 以上两句可简写
... |
f7dff08a1ac455a6ae1b4eb3981c610bf3e6378d | amtfbky/hfpy191008 | /base/teach/class.py | 11,172 | 4.0625 | 4 | # -------------class and object----------
# class Car:
# # define four fields
# brand = ""
# model = ""
# color = ""
# license_plate = ""
# # define method turn_on
# def turn_on(self):
# print("The car turns on")
# # define method turn_off
# def turn_off(self):
# print("The car turns off")
# # define m... |
d2e572ab8fd662c84b714993a7caf4f9c0d7c9cc | amtfbky/hfpy191008 | /teach3QXhf/chapter11/ch11-filled-octagon.py | 330 | 3.84375 | 4 | import turtle
t = turtle.Pen()
def octagon(size, points, filled):
if filled == True:
t.begin_fill()
for x in range(0, points):
t.forward(size)
t.right(360 / points)
if filled == True:
t.end_fill()
t.color(0, 0.85, 1)
octagon(80, 8, True)
t.color(0, 0, 0)
octagon(80, ... |
85bd9efb8b4b789dfb286b5d74b71a1b71896a89 | amtfbky/hfpy191008 | /teach3QXhf/chapter12/a.py | 4,270 | 3.703125 | 4 | # -*- coding: UTF-8 -*-
'''
用from 模块名 import *,就不用模块名使用模块的内容了
Tk类创建一个基本的窗口,可在上面增加东西如按钮、输入框或画布
这是tkinter模块最主要的类
Button创建了一个按钮,把tk作为第一个参数
还要pack让按钮显示
+++++++++++++++++++++++++++++++++++++++++++++
画图:canvas画布
#ffd800,金色,16进制表示法
print('%x' % 15),把15转成十六进制f
print('%02x' % 15),把15转成十六进制,有两位0f
'''
# from tkinter import *
fro... |
cbfb4516032f507a384496265b2140ed2d9c5cdd | amtfbky/hfpy191008 | /base/0004_data.py | 651 | 4.1875 | 4 | # -*- coding:utf-8 -*-
print float(23)
print int(23.0)
a = 5.99
b = int(a)
print a
print b
a = '3.9'
b = float(a)
print a
print b
a = '3.7'
b = 3.7
print type(a)
print type(b)
# cel = 5.0 / 9 * (fahr - 32)
# cel float(5) / 9 * (fahr - 32)
# cel 5 / float(9) * (fahr - 32)
# excise
# int()将小数转换为整数,结果是下取整
# cel = fl... |
110d1a1d58f790b7ebe60292da87f744a7f7257d | amtfbky/hfpy191008 | /base/teach/02_def.py | 6,277 | 3.953125 | 4 | # def get_sum(num1, num2):
# result = num1 + num2
# return result
# def get_sum(num1, num2):
# return num1 + num2
# def get_sum_dif(num1, num2):
# s = num1 + num2
# d = num1 - num2
# return s, d
# func_name()
# 1
# def cube(num):
# result = num ** 3
# return result
# x = float(input("Num: "))
# # the 1st
#... |
c6c9270ab9a8e4728e566f9e3c9d6823af14728b | amtfbky/hfpy191008 | /teach3QXhf/chapter09/max_and_min.py | 356 | 3.671875 | 4 | numbers = [ 5, 4, 10, 30, 22 ]
print(max(numbers))
strings = 's,t,r,i,n,g,S,T,R,I,N,G'
print(max(strings))
print(max(10, 300, 450, 50, 90))
numbers = [ 5, 4, 10, 30, 22 ]
print(min(numbers))
guess_this_number = 81
player_guesses = [ 12, 15, 70, 45 ]
if max(player_guesses) > guess_this_number:
print('Boom! You a... |
f9c3e7819119950b0401db092de7e3429904e17c | amtfbky/hfpy191008 | /teach3QXhf/chapter11/ch11-octagon.py | 188 | 3.90625 | 4 | '''
八边形
360/8=45
'''
import turtle
t = turtle.Pen()
def octagon(size, points):
for x in range(0, points):
t.forward(size)
t.right(360 / points)
octagon(100, 10)
|
61ebb558ce36cb8908eb8bdf6d1996e9ec17a142 | vkobinski/tarefa2 | /exercicios_aula/sistema.py | 1,943 | 3.546875 | 4 | import time
import os
import q11
import q12
import q13
import q14
import q15
import q16
import random
continuar = True
while(continuar):
print("\n" * os.get_terminal_size().lines)
print("1 - Converte real para dólar.")
print("2 - Quantidade tinta.")
print("3 - Desconto de 5%.")
print("4 - Aumento d... |
b125993b5d64b3b8d0ddb100d9269f3b5d4844d0 | diegogonzalez96/Seminario_Python | /Practica2/ejer7.py | 222 | 4.0625 | 4 | print("Ingrese palabra: ")
word1 = input()
word2 = word1[::-1] #invierte la cadena de string
if word1.lower() == word2.lower():
print("La palabra es un palindromo.")
else:
print("La palabra no es un palindromo.") |
9595b9959110f11bdb2389cbc231f287cf879ddf | diegogonzalez96/Seminario_Python | /Practica1/ejer5.py | 921 | 3.8125 | 4 | frase = "Si trabajás mucho CON computadoras, eventualmente encontrarás que te \n" \
"gustaría automatizar alguna tarea. Por ejemplo, podrías desear realizar una \n" \
"búsqueda y reemplazo en un gran número DE archivos de texto, o renombrar y \n" \
"reorganizar un montón de archivos con fotos de... |
cf9f9780ce5e06fe973693c60cb796e98f130a9c | diegogonzalez96/Seminario_Python | /Practica2/ejer8.py | 763 | 3.625 | 4 | word = input("Ingrese una palabra:")
dicc = {}
list = []
def num_primo(num):
if num <= 1:
return False
elif num == 2:
return True
else:
for i in range(2, num):
if num % i == 0:
return False
return True
for i in word:
if i in dicc: #comprueba... |
151ebd3146f00ed33cfef4f09585227339a88e1b | nathanfryy/Hangman | /player.py | 766 | 3.59375 | 4 | import toolbox
class Player(object):
def __init__(self):
pass
def guess(self):
letter = toolbox.get_string('What is your letter guess?')
while len(letter) != 1:
print('Your guess has to be one character.')
letter = toolbox.get_string('What is your le... |
ba4b330e59695e10bf7d90cfe1e3472acc04caa2 | calvinvbigyi/project-euler | /bit_string_question.py | 1,591 | 3.8125 | 4 | #Given an input "bit pattern" which is a string containing only the characters '0', '1' and '?'
# output a list of all "bit strings" which match the pattern where '?' acts as a wild card.
#For example: "?01?" -> ["0010", "0011", "1010", "1011"]
#test_str = '?01?'
#test_output = ['0010', '0011', '1010', '1011']
import ... |
465df1bd32caec4fb5581fd92d1586fa12842dc9 | sapan/graph_cnn | /code/MNIST_learn_graph.py | 6,424 | 3.59375 | 4 | '''
MNIST experiment comparing the performance of the graph convolution
with Logistic regression and fully connected neural networks.
The data graph structured is learned from the correlation matrix.
This reproduce the results shown in table 2 of:
"A generalization of Convolutional Neural Networks to Graph-Structur... |
0d4b1c1c28c231208b47a2da2d2046d4c070c669 | Hachirota/PPandA | /mergesort.py | 228 | 3.75 | 4 | def merge(a1, a2, a):
i = j = 0
while i + j < len(a):
if j == len(a2) or (i < len(a1) and a1[i] < a2[j]):
a[i+j] = a1[i]
i += 1
else:
a[i+j] = a2[j]
j += 1
|
c9dde4191b35597750190d75bd5b308ccb8b8d2a | LucasPayne/geometry | /Python/randomize.py | 369 | 3.6875 | 4 | """
Random data generation
"""
from shapes import *
from triangulation import *
from random import random
def random_convex_polygon(xmin, xmax, ymin, ymax, n, shift=0):
points = [Point((xmax - xmin) * random() + xmin, (ymax - ymin) * random() + ymin) for _ in range(n)]
shifted = Point.random(shift)
re... |
e5963aa274311fdc475c49cfd5d00a31aeac1fe0 | anfasnujum/sudokuSolver | /sudokuSolver.py | 5,695 | 3.578125 | 4 | class Solution:
def solveSudoku(self, board):
"""
Do not return anything, modify board in-place instead.
"""
remaining = [[[str(x) for x in range(1,10)] for x in range(9)] for x in range(9)]
self.updateRemaining(board,remaining)
next = self.findNext(board,0,0)
... |
f435dbf930d8fa29598d06d6b565fe0c5dc1c69f | Innodogs/Innodogs | /app/utils/pages_helper.py | 2,225 | 3.875 | 4 | import math
from typing import List
__author__ = 'Xomak'
class Pages:
"""
Pages class is intended to store data, relevant to pagination
"""
def __init__(self, endpoint, rows_per_page, current_page, total_number, request_args):
"""
Creates Pages object.
:param endpoint: Flask ... |
9bb549365104929566fa87c29f01cd5cbd380a10 | Ri8thik/Python-Practice- | /Linked_List/singly_ll/insertion_in _singly_linked_list.py | 2,906 | 3.921875 | 4 | class Node:
def __init__(self,data):
self.data=data
self.ref=None
class Sll:
def __init__(self):
self.head=None
self.tail=None
def insert_data(self,data,location):
new_node=Node(data)
if... |
9bac38cd3bc1014cc19216e4cbcda36f138dfef1 | Ri8thik/Python-Practice- | /creat wedge using loop/loop.py | 2,269 | 4.40625 | 4 | import tkinter as tk
from tkinter import ttk
root=tk.Tk()
# A) labels
#here we create a labels using loop method
# first we amke a list in which all the labels are present
labels=["user name :-","user email :-","age:-","gender:-",'state:-',"city:-"]
#start a for loop so that it print all the labels which are given in a... |
6f7282a12f6a377ada3d9171c24a7e5c31a8c2f4 | Ri8thik/Python-Practice- | /Linked_List/Circular_singly_ll/Create_Circular_Single_linked_list.py | 2,139 | 4.03125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.ref=None
class circular:
def __init__(self):
self.head=None
self.tail=None
def circular_ll(self,data):
new_node=Node(data)
new_node... |
8ccd3e730ae643d75f40263e027090f9c0f353a2 | kkxujq/leetcode | /answer/0082/82.linningmii.py | 816 | 3.765625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
node_counter = 0
def find_next_different_node(self, head):
self.node_counter += 1
if head.next is None:
return None
if he... |
fca8a93a245b027c0cfee51200e9e603c737f5df | rchu6120/python_workshops | /comparison_operators.py | 234 | 4.21875 | 4 | x = [1, 2, 3]
y = list(x) # create a NEW list based on the value of x
print(x, y)
if x is y:
print("equal value and identity")
elif x == y:
print("equal value but unqual identity")
else:
print("unequal")
|
1ef7c763b40ab15b9bb07313edc9be70f9efd5d6 | rchu6120/python_workshops | /logic_hw.py | 852 | 4.375 | 4 | ############# Ask the user for an integer
### If it is an even number, print "even"
### If it is an odd number, print "odd"
### If it is not an integer (e.g. character or decimal #), continue asking the user for an input
### THIS PROGRAM SHOULND'T CRASH UNDER THESE CIRCUMSTANCES:
# The user enters an alphabet
#... |
4b0b9bf92dd3045dcee5e99d3cd657d8328bfb40 | zhaofujian0723/ALG | /zsfz.py | 418 | 3.84375 | 4 | """
整数反转
"""
class Solution:
"""
@param number: A 3-digit number.
@return: Reversed number.
"""
def reverseInteger(self, number):
# write your code here
g = number % 10
s = int(number / 10 % 10)
b = int(number / 100)
return int(str(g) + str(s) + str(b))
if ... |
5f5f657ef5fad9d08ad0a1657a97cbe83535cb09 | HeyChriss/BYUI-Projects-Spring-2021 | /Maclib.py | 1,453 | 4.25 | 4 | print ("Please enter the following: ")
adjective = input("adjective: ")
animal = input("animal: ")
verb1 = input("verb: ")
exclamation = input("exclamation: ")
verb2 = input("verb : ")
verb3 = input("verb: ")
print ()
print ("Your story is: ")
print ()
print (f"The other day, I was really in trouble. It all s... |
083898331a90863833b1ee0db5d70a05b0ece14a | Pahahot/Mission | /곽호준/5장.py | 2,339 | 3.734375 | 4 | #5-1
# class Calculator:
# def __init__(self):
# self.value = 0
# def add(self, val):
# self.value += val
# def minus(self, val):
# self.value -= val
# class UpgradeCalculator(Calculator):
# pass
# cal =UpgradeCalculator()
# cal.add(10)
# cal.minus(7)
# print(cal.va... |
270f2c4c0494965f643448de5909b42dcb0ec101 | Pahahot/Mission | /김민호/Week03_5장연습문제_김민호.py | 1,134 | 3.515625 | 4 | #01
class Calculator:
def __init__(self):
self.value = 0
def add(self, val):
self.value += val
class UpgradeCalculator(Calculator):
def minus(self, val):
self.value -=val
cal = UpgradeCalculator()
cal.add(10)
cal.minus(7)
print(cal.value)
#02
class MaxLimitCalculator(Calculator... |
f1e95a2ca6c0243090f6af46fb1c9257239effc2 | boiidae/py4me | /counters_with_dictionaries.py | 169 | 3.546875 | 4 | # One common use of dictionaries is counting how often we see something
ccc = dict()
ccc['csev'] = 1
ccc['cwen'] = 1
print(ccc)
ccc['cwen'] = ccc['cwen'] + 1
print(ccc)
|
8f16c36cb9ed64bd78c662ccfff594809ca5213e | boiidae/py4me | /nested_decision.py | 284 | 4 | 4 | # Example of a nested decision
# A one-branch if statement showing an if statement within an if statement
# Try it with numbers below and above 100 to see the different results
x=42
if x > 1:
print('More than one')
if x < 100:
print('Less than 100')
print('all done')
|
0c6ef58bbed17665b541028822a4603eafaf3af1 | Aayush360/opencvprojects | /hough_line.py | 869 | 3.59375 | 4 | # find the canny edge before finding the hough line
import cv2
import numpy as np
# load the image
image = cv2.imread('../images/sudoku.jpg')
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
canny = cv2.Canny(gray,100,170,apertureSize=3)
# run HoughLines using rho accuracy of 1px,
# theta accuracy of np.pi/180 which... |
b4541fb13f3a87aad37bd489b9b2caca7fbbceb8 | stopslavery404/Data-Structures | /Stack using linked list.py | 1,193 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 17 23:29:48 2020
@author: rahul
"""
class Node:
def __init__(self, data):
self.data = data
self.next = None
class Stack:
def __init__(self):
self.size = 0
self.head = None
def __repr__(self):
arr = []
node ... |
bb3825dc1f91cec3127d75c1d35fd0c921206d8f | stopslavery404/Data-Structures | /Treap.py | 7,585 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 22 06:13:15 2020
@author: rahul
"""
from random import randint
K=2**32-1
class Node:
def __init__(self, data):
self.parent = None
self.left = None
self.right = None
self.data = data
self.priority = randint(0, K)
class Treap:... |
3d9b0433f6b300d8e2d6da2bda5b54f4c1033d7b | stopslavery404/Data-Structures | /minimum stack.py | 301 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 19:34:01 2020
@author: rahul
"""
stack=[]
def add(item):
if stack:
stack.append((item,min(item,stack[-1][1])))
else:
stack.append((item,item))
def pop():
return stack.pop()[0]
def minimum():
return stack[-1][1]
|
8bdb6f6d68d804d2387699ebaf0e83e0e100ab61 | Helloworld-0718/testcode | /demo01.py | 395 | 3.84375 | 4 | """
"""
# 判断一个数是否为质数
def isprime(num):
if num>1:
for i in range(2,num):
if num%i==0:
break
else:
return num
print(isprime(1))
# 给定范围内所有质数求和
def sum_prime(a,b):
sum=0
for i in range(a,b):
if isprime(i)==i:
sum+=i
return... |
be4bef4be78db2c0986c8fa73bc3aacabd5c1b3c | kaphie/PassLocker-1 | /util/user.py | 1,617 | 3.890625 | 4 | import json
import random
import string
import pyperclip
accounts = "accounts.json"
def login(username, password):
""" Log in a new user """
global accounts
accounts = list_accounts()
for account in accounts:
if account['account'] == username and account['password'] == password:
r... |
875f5ae6b9aeccb15135404cad5581cf4982408f | LatencyTDH/coding-competitions | /trie.py | 945 | 3.96875 | 4 | import collections
class TrieNode(object):
def __init__(self):
self.children = collections.defaultdict(TrieNode)
self.is_word = False
class Trie(object):
def __init__(self):
self.root = TrieNode()
def insert(self, word: str) -> None:
node = self.root
for c... |
d40a0420ff782e33bb26d868435e778eb9bd5750 | LatencyTDH/coding-competitions | /test3222.py | 1,432 | 3.65625 | 4 | from threading import Condition
class FizzBuzz:
def __init__(self, n: int):
self.n = n
self.work = Condition()
# printFizz() outputs "fizz"
def fizz(self, printFizz: 'Callable[[], None]') -> None:
for i in range(self.n):
if i % 3 == 0 and i % 5 != 0:
pri... |
d3029863995ede2a505f84593ea59e3bd887a3f6 | LatencyTDH/coding-competitions | /nqueens.py | 1,831 | 3.578125 | 4 | from typing import List, Set
import pprint
class NQueensSolver(object):
def __init__(self, n: int):
self.n = n
def get_all_solutions(self):
self.rows = [0] * self.n
self.cols = [0] * self.n
self.diags = [0] * (2 * self.n + 1)
self.antidiags = [0] * (2 * self.n +... |
2ffcaa31322c70839d94b1b90df2edd84a3d4eae | LatencyTDH/coding-competitions | /kickstart/2019/q1.py | 545 | 3.609375 | 4 | from heapq import heappop, heappush
def compute_hindex(citations):
q = []
hindices = []
hi = 0
for cit in citations:
while q and q[0] <= hi:
heappop(q)
if cit > hi:
heappush(q, cit)
if len(q) > hi:
hi += 1
hindices.append(hi)
return hindices
def main():
tcs = int(input())
for case in range(1, ... |
df9d75439310e15f3c10e2173d6a02e37f2bed7f | GenericWaffler/SDD | /ChatBot/ChatBot.py | 5,097 | 4.0625 | 4 | from contextlib import contextmanager
@contextmanager
def nested_break():
class NameNestBreak(Exception):
pass
try:
yield NameNestBreak
except NameNestBreak:
pass
print("Hello! I am a food-ordering chatbot for WaffleInc! Please answer in full sentences.")
#start
while True:
... |
613f00cd9cf150c7681ce926c1dfe0c5a984ad0c | ShilpuSri/Leetcode | /ReverseInteger.py | 509 | 3.515625 | 4 | class Solution:
def reverse(self, x: int) -> int:
if x >= pow(-2, 31) and x <= (pow(2,31) - 1):
rev=0
orig=x
if orig < 0:
x=x+(2*(-x))
while x > 0:
rem=x%10
rev=rev*10+rem
x=int(x/10)
... |
f805a58fe126f72e2cca7fabdb2bbbc4bda44926 | douglasliralima/ArtificialIntelligence | /Aprendendo/matplotlib/CarregandoManipulandoDados.py | 964 | 3.90625 | 4 | import matplotlib.pyplot as plt
import numpy as np
'''
Uma coisa muito comum é querermos abrir documentos de dados em csv ou outros arquivos
para usarmos o matplotlib, o segredo do sucesso aqui é muito simples, nos precisaremos entratanto
usar o numpy para nos auxiliarmos nessa empreitada e deixar as coisas muuuuuuuuu... |
0d857a1b7ce5d9fc148f9d6fb9f2f3a88dfb478f | douglasliralima/ArtificialIntelligence | /Aprendendo/Pandas/ConcacAppending.py | 2,050 | 3.609375 | 4 | import pandas as pd
#Vamos usar esses dicionarios para criarmos os nossos dataFrames apenas para exemplificação
df1 = pd.DataFrame({'HPI':[80,85,88,85],
'Int_rate':[2, 3, 2, 2],
'US_GDP_Thousands':[50, 55, 65, 55]},
index = [2001, 2002, 2003, 2004])
df2 = pd... |
c95319622f1a8a1c98a74ee630516de3b6232d7b | douglasliralima/ArtificialIntelligence | /Aprendendo/matplotlib/Customizacao1.py | 2,197 | 4.03125 | 4 | import matplotlib.pyplot as plt
x = [1,2,3,4,5]
y = [2,4,6,8,10]
'''plt.plot(x,y, label="y=2x")
plt.xlabel("Valores em x")
plt.ylabel("Valores em y")
plt.title("CustomizacaoBasica")
#Nos podemos guardar a figura resultante dessas nossas manipulações em uma variável
#graf1 = plt.figure()
'''
tipo_rotacao = int(input("... |
8170af80d41093e0c296be267195d811c939f4c8 | hirofumi0810/algorithm | /AOJ/Python/5_Recursion_Divide_and_Conquer/exhausive_search.py | 781 | 3.65625 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
''' 全探索 '''
# 各要素を選ぶか選ばないかで2^n通りあるので
# 計算量:O(2^n)
# 深さ優先探索
# DPでやんないと通らない
def check(n, target, i, sum):
if i == n:
return sum == target
# A[i]を使う場合
if check(n, target, i + 1, sum + A[i]):
return True
# A[i]を使わない場合
if check(n, targ... |
b94ea95ac7231caa39b49873cce09210406e8f41 | mikesm11/EasyPnP | /easypnp_networksys_cz/model/isecredentials.py | 2,895 | 3.5625 | 4 | import tkinter as tk
class ISECredentials:
""" Class responsible for setting user credentials to Cisco ISE """
__root = None
__ip = None
__user = None
__pwd = None
__ip_val = None
__user_val = None
__pwd_val = None
@staticmethod
def prompt_credentials():
""" Method to ... |
219d48f4a2db2fcb1b0ec2b7298a547365372284 | UnimaidElectrical/PythonForBeginners | /Random_code_store/Functions/Function_types.py | 5,520 | 4.5625 | 5 | Nested Functions
def f1():
x = 88
def f2():
print(x)
f2()
f1() # prints 88
# called a closure as it remembers the values of the enclosing scopes even though the scopes are not around anymore
def f1():
x = 88
def f2():
print(x)
return f2
action = f1() #Make, return function
acti... |
7e46e20703c0a192343772c52686b4846904537d | UnimaidElectrical/PythonForBeginners | /Algorithms/Sorting_Algorithms/Quick_Sort.py | 2,603 | 4.375 | 4 | #Quick Sort Implementation
**************************
def quicksort(arr):
"""
Input: Unsorted list of intergers
Returns sorted list of integers using Quicksort
Note: This is not an in-place implementation. The In-place implementation with follow shortly after.
"""
if len(arr) < 2:
ret... |
1ab91009e990c5f8858a019968d8a1616a9e4c09 | UnimaidElectrical/PythonForBeginners | /Algorithms/Sorting_Algorithms/selection_sort.py | 2,740 | 4.46875 | 4 | # Selection Sort
# Selection sort is also quite simple but frequently outperforms bubble sort.
# With Selection sort, we divide our input list / array into two parts: the sublist
# of items already sorted and the sublist of items remaining to be sorted that make up
# the rest of the list.
# We first find the smalles... |
f949e5a7df0a1d2bcb6e93ef475731c1ae707cae | UnimaidElectrical/PythonForBeginners | /Random_code_store/Dictionaries/Dictionaries_2.py | 8,023 | 4.40625 | 4 |
# Create a mapping of state to abbreviation
from click import prompt
states ={
'Oregon': 'OR',
'Florida': 'FL',
'California':'CA',
'New York': 'NY',
'Michigan': 'MI'
}
#Create a basic set of states and some cities in them
cities = {
'CA': 'San Francisco',
'MI': 'Detroit',
'FL': 'Ja... |
b3508867c0fb6b42dc531a7fed445aa5d36d9d70 | UnimaidElectrical/PythonForBeginners | /Algorithms/Sorting_Algorithms/merge_sort.py | 5,385 | 4.4375 | 4 | #Merge sort
#The implementation of merge sort will be done in small chuncks so a new user can really grasp the full picture
def merge_sorted(arr1,arr2):
print("Merge function called with lists below:")
print(f"left: {arr1} and right {arr2}")
sorted_arr=[]
i,j=0,0
if arr1[i] < arr2[j]:
sor... |
cb50f49fe64e2121093ea0ccbea3bf7ecc6c7135 | UnimaidElectrical/PythonForBeginners | /Algorithms/Recursion.py | 5,306 | 4.25 | 4 | **************************************************
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
root = TreeNode(1)
root.right = TreeNode(2)
root.right.left = TreeNode(3)
def ... |
38baa3eb890530cac3a056140908e23015070428 | UnimaidElectrical/PythonForBeginners | /Random_code_store/If_Else_Statement/If_Else_statement.py | 2,375 | 4.375 | 4 | """This mimicks the children games where we are asked to choose our own adventure
"""
print("""You enter a dark room with two doors.
Do you go through door #1 or door #2?""")
door = input ("> ")
if door == "1":
print("There's a giant bear here eating a cheese cake.")
print("What do you want to do?")
prin... |
0f509b10fd23df81cd306ea05a6ae07e6b9c13b3 | UnimaidElectrical/PythonForBeginners | /Random_code_store/Lists/In_Operators.py | 453 | 4.34375 | 4 | #The In operator in python can be used to determine weather or not a string is a substring of another string.
#what is the optcome of these code:
nums=[10,9,8,7,6,5]
nums[0]=nums[1]-5
if 4 in nums:
print(nums[3])
else:
print(nums[4])
#To check if an item is not in the list you can use the NOT operator
#In th... |
cca57e8aa3e2772372aea9fc82223e9d8e6e9a0f | srgiola/Python-on-Raspberry-PI-OS | /Lab 6.py | 679 | 3.5625 | 4 | from datetime import datetime
import time
from os import system
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.OUT) # este pin es de salida
GPIO.setup(2, GPIO.IN) #Este pin es una entrada.
estadoAnterior = 0
while True:
tiempo = datetime.now()
if GPIO.input(2) and ... |
1c3bd79a6f6177339484a4fc5e00432aa2703093 | KeerthanaP/pickyourtrail | /src/solutions/minimum_unique_array_sum.py | 4,655 | 3.96875 | 4 | """
Minimum unique sum array Given an array, you must increment any duplicate elements until all its
elements are unique. In addition, the sum of its elements must be the minimum possible within the
rules. For example, if arr = [3, 2, 1, 2, 7], then arr = [3, 2, 1, 4, 7] and its elements sum to a
minimal value of 3 + ... |
b1f80cf1bc0d144789dc230085f694fe9d94a673 | KeshavSharma-IT/Python_all_concept | /2.Data_Type.py | 2,169 | 4.0625 | 4 |
# veriables
# x=5
# z=5.5
# p=x+z
# print(p)
# print(x)
# y="keshav"
# print(y)
#DATA TYPES python is dynamic type means u not need to define any veriable
#1.Numbers
# x=12
#
# print(type(x))
# print(type(p))
# m=12
# print(type(m))
# m=float(12)
# print(type(m))
#2.String
# a="k"
# b="kesha... |
ff97e60837bf32c1dc1f65ef8afda4f658a7116b | lchristopher99/CSE-Python | /CSElab6/turtle lab.py | 2,207 | 4.5625 | 5 | #Name: Jason Hwang, Travis Taliancich, Logan Christopher, Rees Hogue Date Assigned: 10/19/2018
#
#Course: CSE 1284 Section 14 Date Due: 10/20/2018
#
#File name: Geometry
#
#Program Description: Make a geometric shape
#This is the function for making the circle us... |
92ceeb475d5cb45cebb83f77e3e08c4f9fd2227d | lchristopher99/CSE-Python | /CSElab10/reading_level.py | 1,323 | 3.78125 | 4 | # Name: Logan Christopher Date Assigned: 11/14/18
#
# Course: CSE 1284 Sec 11 Date Due: 11/14/18
#
# File name: reading_level.py
#
# Program Description: Program calculates reading level of a given text.
import urllib
from urllib.request import urlopen
def calc_level(ASL, ASW):
level = (0.39 * ASL) + (11.8 * ASW) -... |
55054417d6e1122b865b5ae3812409a6e63c9589 | julianl092/Blocking | /universalalgorithm.py | 4,407 | 3.59375 | 4 | from cs50 import SQL
import itertools
import math
#https://networkx.github.io/
#NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks.
import networkx as nx
db = SQL("sqlite:///blocking.db")
#Defines function to return the total utility o... |
9aec5ccf0463820a7d47445080d6d18919cbf57c | taojingcong/homework | /计算理论/第一次作业/RE-NFA.py | 16,171 | 3.75 | 4 | """
题目2:正则表达式转NFA
"""
import copy
EPSILON = 'ϵ'
class state(object):
__state_no: int = 0 # 建议的类型,初始为0
def __init__(self):
state.__state_no = state.__state_no + 1 # 每有一个新的状态就加1
self.name: str = str(state.__state_no) # 与下面对应,直接会输出名字
self.func = {}
def __str__(self):
ret... |
661c3d8e3186b7c9cca9865515de8ea0213ed24d | Starfox68/Sudoku | /solver.py | 1,161 | 3.671875 | 4 | def solve(bo):
find = find_empty(bo)
if not find:
return True
else:
row, col = find
for i in range(1, 10):
if valid(bo, i, (row,col)):
bo[row][col] = i
if (solve(bo)):
return True
bo[row][col] = 0
return False
def valid(bo, num, pos):
row = pos[0]
col = pos[1]
#check row
for i in rang... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.