blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7538252ca6b2cb4282581e475324b16a595d1acb
voxelvortex/RITCovidStatusChecker
/serial_comms.py
1,605
3.671875
4
""" Author: Michael Scalzetti (github.com/voxelvortex) serial_comms.py This file contains helper functions that allow the program to send alert information from RIT's website to an arduino so that it can display that information. """ from serial import Serial from serial.tools import list_ports_windows import time d...
4221dcc73be5f6280e322e40644fa3eb4ba68b14
nptit/checkio
/check_command.py
898
3.671875
4
#!/usr/bin/env python # -*- coding:utf8 -*- def check_command(pattern, command): bin_str = format(pattern, '0'+str(len(command))+'b') bin_command = ''.join(['1' if x.isalpha() else '0' for x in command]) return bin_str == bin_command if __name__ == '__main__': #These "asserts" using only for self-che...
9802d00310d91f542a59ae0e00e496227f597fac
smckownasdf/block_breaker_pygame
/block_breaker_pygame.py
33,108
3.53125
4
""" ------------- Requirements: ------------- Libraries: - Python3 (and the included CSV module) - pygame (python3 -m pip install -U pygame --user) - pygame_textinput (found here: https://github.com/Nearoo/pygame-text-input) File Assets: - an image of a ball, titled ball.png - bblevels.py (should have been downloaded ...
3722ed2111afd4ed5ffaf28a6aa2ee61b51a6c37
ganqzz/sandbox_py
/web/requests/requests_auth_demo.py
1,188
3.734375
4
import requests from requests.auth import HTTPBasicAuth, HTTPDigestAuth from utils import print_response def basic(): # Access a URL that requires authentication - the format of this # URL is that you provide the username/password to auth against url = "https://httpbin.org/basic-auth/HogeFuga/passw0rd" ...
cfc9a56c9cf99f1867336e89f7c29aead73e6d9b
thedog2/dadadsdwadadad
/часть 2(week2)/3 chisla.py
128
3.578125
4
a=int(input()) b=int(input()) c=int(input()) if a>b: a,b=b,a if b>c: b,c=c,b if a>b: a,b=b,a print(a,b,c)
474ba7b0efad30e91bef8106cf3fce07c7d6a311
steventakeshita/IW_Spring_2017
/BruteForce.py
6,684
3.59375
4
#################################################### # BruteForce.py # description: BruteForce.py will take in a random # beginning board from Randomizer.py and find the sets # using the brute force method ##################################################### from Randomizer import * import itertools class BruteForc...
db1f64e2e7428b67017c9ea7ba8efa97e221df1f
fhtuft/inf4331
/assignment3/my_unit_testing/my_unit_testing.py
816
3.921875
4
"""This is the unit test class""" class UnitTest(object): def __init__(self, func, args, kwargs, res): # make test """ init the class Args: func: the function to test args: the args to the func kwargs: more args res: th...
011eae9aee9a793f9ded98c33314f85d2afc17f0
ebalcomb/code-challenges
/lowercase/lowercase.py
180
3.828125
4
from sys import argv def lowercase(n): f = open(n).readlines() for line in f: copy = "" for character in line: copy += character.lower() print copy, lowercase(argv[1])
4329ffe22ac49391a78d01837c6bea7c797d032f
wondershow/CodingTraining
/Python/LC219_ContainsDuplicateII.py
650
3.53125
4
class Solution: def containsNearbyDuplicate1(self, nums: List[int], k: int) -> bool: freq = defaultdict(int) for i, num in enumerate(nums): if freq[num] > 0: return True freq[num] = freq[num] + 1 if i >= k: freq[nums[i - k]] -=...
5728b851a4e1f2772fc7a2be19230480cf0957bc
liyong6351/python_sbs
/shell/7第七章/2practise7.1.py
387
3.859375
4
car=input("please input the car brand:") print("let me find out the " + car.title()) num = input("please input how many people u followed:") if int(num) > 8: print("人太多了,没桌子!") else: print("快来吧,来晚了就没桌子啦~") num = input("请输入一个整数:") if int(num) % 10 == 0: print("是10的整数倍") else: print("不是10的整数倍")
52be011dcbac97761241921656b26cf9e1f4fde6
erikknaake/randomFileRenamer
/randomRename.py
926
3.59375
4
import os import argparse import random parser = argparse.ArgumentParser(description='A random file renamer') parser.add_argument('-f', '--folder', default='./', help='The folder to rename all files for', type=str) parser.add_argument('-a', '--alphabet', default='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012...
5d9a2799d39ef84ede8573efdeb96ad248bfcf3d
babakpst/Learning
/python/105_l_decorators/4_challenge.py
2,731
3.53125
4
# babak poursartip # May 10, 2023 # ========================================================== # ========================================================== # part 1: how to use a decorator with a wrapper def addItem(func): '''decorator function to add header/footer''' def wrapper(): '''this is the wrapper fu...
c38dac91d36bb2885068bad8fd81ed517532a92e
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 18. Nested Lists/demos/image.py
1,567
4.09375
4
""" Module to demonstrate what an image might look like in memory. This module has a function that constructs a table of RGB objects, which is what an image is in memory. The image is the smilely face represented in smile.xlsx. Author: Walker M. White Date: June 7, 2019 """ import introcs def wh(): """ R...
b7108ab10bde8d56f49bc1221cfe02cab5eef1b3
hr4official/python-basic
/clc.py
1,404
4.21875
4
# This function adds two numbers def add(x, y): return x + y # This function subtracts two numbers def subtract(x, y): return x - y # This function multiplies two numbers def multiply(x, y): return x * y # This function divides two numbers def divide(x, y): return x / y print("Select operation...
db9a48f57c8c38db927e6d6e47c36b2b3f5fa5d1
five510/atcoder
/20191019/binary.py
641
3.78125
4
def binary_area_search(target_list, target_item): low = 0 high = len(target_list) - 1 while low <= high: mid = (low + high) //2 guess = target_list[mid] if guess > target_item: if mid == 0: return 0 if target_item > target_list[mid-1]: ...
5c8ca10a18cdc472a193801101231857504ac3c7
TOM-SKYNET/AL_NIELIT
/ML/Day3_Nov12/q2.py
690
4.0625
4
""" 2. Develop an ML model to predict the home price from interest rate.(loan.csv file) """ from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn import metrics import matplotlib.pyplot as plt import pandas as pd import numpy as np data=pd.read_csv("loan....
5e1ee54b085f58e2b2cbc3212d7fc3de6fd4239a
ggddessgxh/aron
/2.py
316
3.53125
4
m=eval(input("输入当月利润(万元):")) a=int() if m<=10: a=m*0.1 elif m<=20 and m>10: a=10*0.1+(m-10)*0.075 elif m<=40 and m>20: a=10*0.1+10*0.075+(m-20)*0.05 elif m<=60 and m>40: a=10*0.275+(m-40)*0.03 elif m<=100 and m>60: a=10*0.335+(m-60)*0.015 else: a=10*0.395+(m-100)*0.01 print(a)
87dd4ce49665503c34f350fd26896b268f228128
dudulima17/exercicios_python
/custo_fabrica(2).py
524
3.90625
4
#O custo ao consumidor de um carro novo é a soma do custo de fábrica com a percentagem do distribuidor e dos impostos (aplicados ao custo de fábrica). Supondo que a percentagem do distribuidor seja de 28% e os impostos de 45%, escrever um algoritmo que leia o custo de fábrica de um carro e escreva o custo ao consumidor...
88c634fd96288713bf8e850f8c57328e988bb472
rh01/gofiles
/offer/ex19/zhiPrint.py
1,802
3.625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- ''' Filename: zhiPrint Created Date: 2019/10/8 15:10 Author: Shine 请实现一个函数按照之字形打印二叉树, 即第一行按照从左到右的顺序打印, 第二层按照从右至左的顺序打印, 第三行按照从左到右的顺序打印, 其他行以此类推。 Copyright (c) 2019 41sh.cn ''' # -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # ...
8a9762336a43d14f6e102d50a286b2cf3147f8ce
szilviagyapay/clone_of_math_python
/p18.py
1,345
3.59375
4
sum_of_digits_to_4 = 0 sum_of_numbers = 0 for n in range(0,32806): sum_of_digits_to_4 = 0 for j in range(len(str(n))): sum_of_digits_to_4 += math.pow(int(str(n)[j]),4) if (n == sum_of_digits_to_4): sum_of_numbers += n print("n = ", n) print("sum_of_numbers = ", sum_of_numbers) ...
c7277ed7ad4ea0f7fa1612fc2591867289776ba7
arjlucas/Study
/Coursera Python Training - Part I/Week 4/w4_ext1.py
336
3.828125
4
# Coursera Python Training 1 # Lucas Silva # Week 4 - Exercício Extra 1 - Verificação Primo n = int(input("Insira o valor de n:")) i = 1 cdiv = 0 cdivpr = 0 while i <= n: if n % i == 0: cdiv+=1 if i == 1 or i == n: cdivpr += 1 i += 1 if cdiv == cdivpr: print("primo") else: p...
7083f7fa4ada7ed2949ae574e5241149dedf1a9b
sforaaleksander/calendar
/storage.py
531
3.96875
4
def write_to_file(entry, file_name): file_name = f"plans/{file_name}.txt" with open(file_name, "a+") as f: f.write(entry) print("Plan added.") def read_from_file(file_name): file_name = f"plans/{file_name}.txt" try: with open(file_name, "r") as f: return f.readlines() ...
6aaeba5d3a37f2fb99698fcf385352b2b02215f9
codizard/Coding-problems
/ctci/binaryTree.py
7,359
4.0625
4
import Queue class Node: def __init__(self, val): self.data = val self.left = None self.right = None currentSum = 0 class BinarySearchTree: def __init__(self): self.root = None def addNode(self, val): if self.root is None: self.root = Node(val) else: self.addNodeHelper(self.root, val) def add...
f0450f68f017b680da1e563fba2ba739e5fad769
iepoch/Graphs
/projects/graph/graph.py
6,700
4.1875
4
""" Simple graph implementation """ from util import Stack, Queue # These may come in handy class Graph: """Represent a graph as a dictionary of vertices mapping labels to edges.""" def __init__(self): self.vertices = {} def add_vertex(self, vertex): """ Add a vertex to the gra...
ddfc1619e97a154b0e1a5b03f2858cfa0072a195
ramitch91/rmtest_repo
/TalkPython/10Apps/wizard-game.py
2,019
3.609375
4
import random import time from actors import Wizard, Creature, SmallAnimal, Dragon def main(): print_header() game_loop() def print_header(): print() print('-----------------------------') print(' WIZARD GAME APP') print('-----------------------------') print() def game_loop(): ...
4a920c0a8fba3fbba0a2a0a5295cdccc4bbe606d
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/3119/codes/1594_2043.py
247
3.859375
4
a = float(input("digite o valor da nota: ")) b = float(input("digite o valor da nota: ")) c = float(input("digite o valor da nota: ")) d = float(input("digite o valor da nota: ")) media = ((a*1) + (b*2) + (c*3) + (d*4))/10 print(round(media,2))
bb2cf29df032de5254dc244548c4ac19136ed4ce
alankrit03/HackerRank_Algorithms
/Happy Ladybugs.py
836
3.765625
4
"""NOT YET COMPLETE SOLUTION""" def happyLadybugs(b): # # Write your code here. # data = sorted(list(b)) n = len(data) if n==1: if data[0] == "_": return 'YES' else:return 'NO' i = 0 while i < n: if i == 0: if data[i] != data[i+1]: ...
476d32d4236daf4f1d555e637d26d403bf78a5ef
monnn/Programming101
/week0/sevens_in_a_row.py
160
3.59375
4
def sevens_in_a_row(arr, n): if arr[n-1] == 7: return True else: return False print(sevens_in_a_row([10, 8, 7, 6, 7, 7, 7, 20, -7], 3))
7d5debcb154c68148a7a9cd76050c3d1cd7f6234
graceekerr123/practice-python
/muti_dimention_list.py
891
3.921875
4
# test file def double_loop(L): for i in range(0, len(L)): output = "{} : {}".format(i, L[i]) print (output) for j in range(0, len(L[i])): output = "{} : {}".format(j, L[i][j]) print(output) def main(): my_list=[["JJ", "Blond", 21], ["John B", "Sandy...
e5a8c6bbbe37dfdd5250b86ba4f8c4415515da3a
Prashanth031/EE1390
/CircleAsMatrix.py
2,377
3.625
4
import numpy as np import matplotlib.pyplot as plt # equation given X^T*X + 2*[-2,3].X-12 = 0 # (X-C)^T . (X-C) = R^2 ... Equation of a circle # C = [2,-3] , R^2 - C^T.C = 12 C = np.array([2,-3]) R = np.sqrt(12 + np.matmul(C.T,C)) # Square of the Radius of the circle # print(R) n=100 theta = np.linspace(0,2*n...
f1c2a8dc40ef3370a8ef26f20135157b79b5a2b9
cwong168/py4e
/chapter_7/ch_7_ex_3.py
616
4.5
4
''' Exercise 3: Sometimes when programmers get bored or want to have a bit of fun, they add a harmless Easter Egg to their program Modify the program that prompts the user for the file name so that it prints a funny message when the user types in the exact file name "na na boo boo". The program should behave normall...
148fcb1ef734bd33be167541633432758f5e3d40
lagarridom/PythonSemestral19_1
/TiposDatos/listas.py
1,777
4.375
4
# Las listas son secuencias que pueden contener # cualquier tipo de dato # Se crean utilizando corchetes lista1 = [3,True,"hola",4+3j] # Estas pueden incluso contener otras listas lista2 = [4,5,7,["hola",3,4.5]] # Accedemos a sus elementos de la misma forma # que con las cadenas de texto print(lista1[2...
524455307e513f11aafab905a6965828379d109b
williamsyb/mycookbook
/algorithms/BAT-algorithms/Tree/二叉树-的最大深度.py
589
3.78125
4
""" 一、题目 给定一个二叉树,找出其最大的深度 二、思路 用递归的思路,求左孩子的高度,求右孩子的高度,哪个大,就加1 三、同 leetcode-104 """ class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def max_depth(root): if root is None: return 0 return max(max_depth(root.left) +...
2da1e76bdbdf4dab16f120ffa4d27118803e9071
lets-code-together/lets-code-together
/BaekjoonAlgorithms/04-IfLoop/Python/9498.py
333
4
4
# 시험 성적에 따라 등급 매기기 test_score = int(input()) def grade(x): if 90 <= x <= 100: grade = 'A' elif 80 <= x < 90: grade = 'B' elif 70 <= x < 80: grade = 'C' elif 60 <= x < 70: grade = 'D' else: grade = 'F' return grade print(grade(test_score))
4187f865e45652496dc1a02c36c3079ec1b8c5c5
adedomin/CSC231-Assignments
/doc/papers/algo_pcode.py
434
4.21875
4
# note in Python 3 // operator is truncated division. for row in range(0,height): if (0 <= abs(height//2-row) <= 2): count = abs(abs(height//2-row)-2)) for column in range(0,width): if (width//2-count <= column <= width//2-count): print("*") ...
981a24b0991668250797f7d8c81e7161b0146468
yashasGowda21/Build-neural-networks-from-scratch
/basic_function_numpy.py
4,468
4.375
4
import math # GRADED FUNCTION: basic_sigmoid def basic_sigmoid(x): """ Compute sigmoid of x. Using math library Arguments: x -- A scalar Return: s -- sigmoid(x) """ # (≈ 1 line of code) # s = # YOUR CODE STARTS HERE # sigmoid : x = 1/1+e^(-t) s = 1/(1+math....
eb74042bc0cb71a9871fd3d4d754fd82e46a254d
grgoswami/Python_202004
/source/lesson0.py
4,368
4.625
5
# lesson0.py: This is our first lesson, a bottom up approach # Hi everyone """ A multi line comment. Hi Mr. President. This is also called a 'doc string' """ # Lets print print("Hello world!" ) print('Hello world!') print("Hi There") print('Hello world! , Hello World, Hi there, have fun an...
5028c76803f736103b473b62fc50ce9b5fef2e10
Yamase31/cs112
/project06/tokens.py
2,452
4.15625
4
""" Author: YOUR NAME GOES HERE File: tokens.py Tokens for processing expressions. """ class Token(object): """Represents a word in the language.""" UNKNOWN = 0 # unknown INT = 4 # integer MINUS = 5 # minus operator PLUS = 6 # plu...
c0035b986410b04e9f42d2048bf1902746de79ef
JJJOHNSON22/Python-fundamentals
/for_loop_basic1.py
2,323
4
4
#1) Basic - Print all integers from 0 to 150. def print_ints(): output = "" for x in range(0, 151, 1): output = output + str(x) if (x == 150): print(output) else: output = output + "-" print_ints() #2) Multiples of Five - Print all the multiples of 5 from 5 to ...
be157b0b957520a6da1e20c0b774b0ee14ec18aa
PeriCode/PythWinter2018
/py_kids2018/l12/dice2.py
1,982
3.71875
4
import random player_1 = {'счет': 1000} player_2 = {'счет': 1000} player_1['имя'] = input('Имя первого игрока: ') player_2['имя'] = input('Имя второго игрока: ') while True: player_1['ставка'] = int(input('Ставка 1-го игрока: ')) if player_1['ставка'] > player_1['счет']: print('У тебя нет столько денег!') con...
97d5a0854c79a5fab47491b12a504e558b69f3d9
usupsuparma/Belajar-Python
/part 16 stacking and queing/antrian.py
538
3.671875
4
from collections import deque antrian = deque([1,2,3,4,5]) print("Data Sekarang: ",antrian) # menambahakan data pada antrian antrian.append(6) print("data masuk: ",6) print("Data Sekarang: ",antrian) jumlah = input("masukan jumlah data") j = int(jumlah) n = int(input("mauskan nilai n: ")) for i in range(n,j) : ...
65ebc41295cfc8059e9a0e0b3663621c9ebda5d7
a1ip/useful_little_things
/dfu_matrix.py
1,886
4.0625
4
#Подключить модули numpy и numpy.linalg: import numpy as np import numpy.linalg as alg #Создать матрицу A в виде двухмерного массива, вывести ее на экран («\n» используется для перехода на следующую строку при выводе): a = np.array([[3, 4, -2],[-2, -1, 4],[1, 2, 1]]) #array_list = [ ] #for i in range(n):...
be59dbedcc2016ea4d3a999208373525569a898c
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH06/EX6.10.py
403
3.953125
4
# 6.10 (Use the isPrime Function) Listing 6.7, PrimeNumberFunction.py, provides the # isPrime(number) function for testing whether a number is prime. Use this # function to find the number of prime numbers less than 10,000. from CH6Module import MyFunctions count = 0 for i in range(1, 10001): if MyFunctions.isPrim...
5fa31cf2764deb516b0d92728be0ccf63705154c
lendoly/RestBot
/util/models.py
2,396
3.6875
4
import datetime import dataset import sqlite3 from settings import database class DateCreationModelMixin(object): """An abstract model for creation date. This mixin add a field to the model creation_date, which contains the object creation datetime. Note: django metaclass for models requires that the...
6a8130d24de307de61d263b0bdc358a602cfd985
khelryst/Learning-Python
/gradechecker.py
444
4.21875
4
grade = input('Enter your grade: ') try: grade = float(grade) except: grade = input('Enter a number from 0.0 - 1.0: ') if float(grade) >= 0.9: grade = 'A' elif float(grade) >=0.8: grade = 'B' elif float(grade) >= 0.7: grade = 'C' elif float(grade) >= 0.6: grade = 'D' elif float(grade) < 0.6: ...
1aae372df4069a7ccf1f1e967e4bebc2b47d63aa
act65/FAT
/implementation/FAT.py
4,398
3.65625
4
import types class Fatrix(object): #child of a fuction class? """ Using the matrix relations, make a computational graph. Use n-d matrix multiplication on (func , var) to make the graph. Matrix multiplication has a change... Inputs: #all funcs need a _call method. #and recieve only one...
271c79fe9257e66c30f568238b56298f09f930ad
weixiangtoh/daily_interview
/DeepestNodeInBinaryTree.py
1,540
4.21875
4
""" You are given the root of a binary tree. Return the deepest node (the furthest node from the root). Example: a / \ b c / d The deepest node in this tree is d at depth 3. Here's a starting point: class Node(object): def __init__(self, val): self.val = val self.left = None self.right = ...
a28ee5ff8b9acaa86cdc3a9833a5e091aca7ce4e
sanjay0202/python
/Calculator .py
916
4.28125
4
# initializing a integer varible to store the solution solution = 0 # list to store number and the operation num_opr = [] while True: #getting a ineger value to perform operation num = int(input("")) #opr = input("Select a operation Add(+) \n Sub(-)\nDiv(/)\nMul(*)\n\nsolution(=) ") #getting the...
10e661ed1ee6be4877676ec8c5885d0e2a04f285
gladguy/PyKids
/GameDevelopment/IfAndElseOnly.py
168
4.40625
4
x = input("Enter your number") x = int(x) # We are converting the string to Integer if(x > 10): print("X is greater than 10") else: print("X is less than 10")
8c64fd30d0eda96f7ec183c7802b5dae6d75c780
Vovanuch/python-basics-1
/elements, blocks and directions/lists/lists_power.py
1,064
3.65625
4
''' Выведите таблицу размером n×n n \times n n×n, заполненную числами от 1 до n2 по спирали, выходящей из левого верхнего угла и закрученной по часовой стрелке, как показано в примере (здесь n=5 n=5 n=5): Sample Input: 5 Sample Output: 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 ''' n = i...
bd9d0ec34bc766356d98635b19241ff0f7123a0a
Divisekara/Python-Codes-First-sem
/PA2/PA2 2013/PA2-15/Asitha/pa2-15-2013.py
1,304
3.828125
4
def is_prime(x): isPrime=True if x==0 or x==1: return False else: for i in range(2,int(x**.5)+1): if x%i==0: isPrime=False break return isPrime def palindrome(x): if str(x)==str(x)[::-1]: return True else: retur...
27e43e4dae039f82abc129aeda14e1598b5345fb
yangyiko/helloworld
/01-基本语法/Python4数据类型转换.py
280
3.703125
4
# num = "6" # print(type(num)) # print(4 + int(num)) # print(str(4) + num) score = input("请输入一个数字") print(type(score)) print(int(score) + 6) # num = "123a" # result = int(num) # print(result) # int a = 10; score = "123" score = 123 print("a" + str(1))
ac0b1772a67c77aabb5757a64709f52e68f481ce
nahkim/PythonProgramming
/0514/프로그램 작성.py
555
3.6875
4
# 영문 소문자로 이루어진 문자열을 입력 받아 암호문으로 변환하는 프로그램 작성 def encipher(p,k): n = len(p) c = '' i = 0 while i < n: a = ord(p[i]) if a == 32: a = 96 t = a + k if t > 122: t = t - 27 if t == 96: t = 32 c = c + ch...
839f96f454c4f7f27277faadbf4fb9c935a3b9db
EmoryWalsh/line01
/draw.py
2,230
4.125
4
from display import * def draw_line( x0, y0, x1, y1, screen, color ): #so x0 is always smaller than x1 if(x0 > x1): x0, x1 = x1, x0 y0, y1 = y1, y0 #variables x,y x = x0 y = y0 #HORIZONTAL LINE if(y0 == y1): while(x <= x1): plot(screen, color, int(...
16a35c077aa15d3f8fc5da4a73737b5d67fb1da8
Pooripat/CP3-Pooripat-Pongkittanakorn
/Assignment/Exercis5_1_Pooripat_P.py
260
4.0625
4
n1 = int(input("First Number : ")) n2 = int(input("Second Number : ")) plus = n1 + n2 minus = n1 - n2 times = n1 * n2 divided = n1 / n2 print(n1, "+", n2, "=", plus) print(n1, "-", n2, "=", minus) print(n1, "*", n2, "=", times) print(n1, "/", n2, "=", divided)
8b53728a5fa96efc714e29640879bfb925c87580
ROXER94/Project-Euler
/225/225 - TribonacciNon-Divisors.py
529
3.78125
4
# Calculates the 124th odd number that does not divide any terms in the Tribonacci sequence cache = {1:1,2:1,3:1} def tribonacci(n): if n not in cache: cache[n] = tribonacci(n-1) + tribonacci(n-2) + tribonacci(n-3) return cache[n] for i in range(1,101): tribonacci(230*i) odds = [n for n...
4ee86d97db603a493aec0b78bfc4d251e6592139
jordantiu/ICP3_Python
/Lesson_3_Employee_Class.py
2,477
4.0625
4
class Employee: number_of_employees = 0 # data member for number of employees total_salary = 0 # data member for total salary of all employees def __init__(self, first, last, salary, department ): # employee class self.first = first self.last = last self.salary = sala...
1e272642ad485d4ed1e6e1b56e80e1a646bf6482
Maxim-chernets/geekbrains_HW
/lesson4/task_5.py
181
3.53125
4
from functools import reduce def my_func(prev_el, el): return prev_el*el list = [i for i in range(100, 1001) if i % 2 == 0] print(list) print(reduce(my_func, list)) # done
957b1bf486b2e681ce06eec45d40c95b0668becd
langlois5454/ISN
/POO/Classe Point and Co/point.py
989
4.09375
4
import math class Point: '''Classe Point permettant de manipuler un point 2D''' def __init__(self,x,y): self.x = x self.y = y def __str__(self): return "("+str(self.x)+","+str(self.y)+")" def copie(self): return Point(self.x,self.y) def distance(self,p...
f3707e51d8dc07d4e6237fdf52f783569589636c
RaadUH/RBARNETTCIS2348
/FinalProjectInput.py
1,008
3.609375
4
# Raad Barnett 1231583 import csv class ReadWrite: def getCSVFileData(self,filename): #get data from csv file and return data as dictionary f = open(filename+".csv",'r') f_read = csv.reader(f, delimiter=',') dict1 = {} #key is itemID for row in f_r...
b2c1fe4af06c897505627b67fbaf4664d9fc238e
monk-boop/Midnight-musings
/exercise61.py
274
3.8125
4
print("Enter numbers ! Enter 0 to stop") num = [] c=0 while True: num.append(int(input()) if num[c]==0: break else: c+=1 sum = 0 if num[0] == 0: print("invalid") else: for i in range(len(num)-1): sum += num[i] print("Average is ",float(sum/count))
7f3a1398afed9d0c45acfcd31407c0400b00e48d
zhangdavids/workspace
/Algorithm/select_sort.py
425
3.984375
4
# 选择排序 def select_sort(array): count = len(array) for i in range(0, count): min = i for j in range(i + 1, count): if array[min] > array[j]: min = j temp = array[min] array[min] = array[i] array[i] = temp # array[min], array[i] = array[i...
68c03e43266dc6b9d41f041ab4bf4d61a2bc99cc
adrianme213/PythonCourse
/Section_04/assignment_08.py
1,117
3.84375
4
# Assignment 8 """ Return the sum of the numbers in the list, except ignore sections of numbers starting with a 7 and extending to the next 8 (every 7 will be followed by at least one 8). Return 0 for no numbers. EXAMPLE: sum78([1, 2, 2]) → 5 sum78([1, 2, 2, 7, 99, 99, 8]) → 5 sum78([1, 1, 7, 8, 2]) → 4 """ #Your ...
038fb11b438c12dc33d8ada6ec2cc8de19dea7bd
forloveandlemons/ml-functions
/linear_regression.py
696
3.546875
4
# input X, y import numpy as np def get_gradient(w, X, y): y_estimate = X.dot(w).flatten() error = (y.flatten() - y_estimate) gradient = -(1.0/len(X)) * error.dot(X) return gradient, np.power(error, 2) w = np.random.rand(3) learning_rate = 0.5 tolerance = 1e-5 max_iter = 100 iteration = 0 train_X =...
22361f3c1950836dbb2151107638fb38f9423f67
Lunerio/holbertonschool-higher_level_programming
/0x03-python-data_structures/8-multiple_returns.py
213
3.53125
4
#!/usr/bin/python3 def multiple_returns(sentence): length = len(sentence) char = "" if length == 0: char = None else: char = sentence[0] new_t = (length, char) return new_t
fe117ec6818a6afa89e4c7eca81ba04cab909193
sercand/scripting-hw
/components/flip_flop.py
1,966
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from wand.image import Image import pprint class Flip_Flop(): """ Crop image """ def description(self): """ description returns a string describing what component does. """ return "Using flip, user can create a vertical mir...
9698e6f5a36664f3b2894387212e916126420322
epicsaeed/pythonrepo
/unit testing tutorials/calculator.py
360
3.640625
4
def validInput(x,y): if type(x) is int and type(y) is int: return True return False def add(x,y): validInput(x,y) return x + y def subtract(x,y): validInput(x,y) return x - y def multiply(x,y): validInput(x,y) return x * y def divide(x,y): validInput(x,y) if y == 0...
ecf56ead98dd352a4e52ff388ed12369daef4817
zihuaweng/leetcode-solutions
/leetcode_python/836.Rectangle_Overlap.py
419
3.875
4
#!/usr/bin/env python3 # coding: utf-8 # Time complexity: O() # Space complexity: O() # https://leetcode.com/problems/rectangle-overlap/ class Solution: def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool: l1, b1, r1, u1 = rec1 l2, b2, r2, u2 = rec2 width = min(r1, r2)...
5b818ede34cf9456ccc6beee10441d09bc6f6487
cxm17/python_crash_course
/do_it_yourself/chapter_8/8-10.py
348
3.765625
4
magicians = ["Whoodini", "Cooperfield", "Dillahunty"] def show_magicians(magicians_list): for magician in magicians_list: print("Hello " + magician) def great_magicians(magicians): for index in range(0, len(magicians)): magicians[index] = "Great " + magicians[index] great_magicians(magician...
280bf71f34e6b540eb9b212863d853be171e422e
IncredibleQuark/pythonIntro
/dataVisualization/main.py
1,277
3.5625
4
import matplotlib.pyplot as plt import pandas as pd # Basic plot years = [1950, 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015] pops = [2.5, 2.7, 3.0, 3.3, 3.6, 4.0, 4.4, 4.8, 5.3, 5.7, 6.1, 6.5, 6.9, 7.3] deaths = [1.2, 1.7, 1.8, 2.0, 2.2, 2.2, 2.3, 2.1, 2.7, 3.0, 3.3, 3.0, 3.4, 3.5] l...
2ca7b0f1349510d1bde5b60b5b5b69ccaafe7c61
harrybonsu/RBootcamp
/cw/03-Python/2/Activities/03-Stu_HouseOfPies-AdvancedLoops/Unsolved/house_of_pies_bonus.py
960
3.953125
4
# Initial variable to track shopping status shopping = 'y' # List to track pie purchases pie_purchases = [0,0,0,0,0,0,0,0,0,0] # Pie List pie_list = ["Pecan", "Apple Crisp", "Bean", "Banoffee", "Black Bun", "Blueberry", "Buko", "Burek", "Tamale", "Steak"] # Display initial message print("Welcome to the H...
7c7ac789b5cbd8f25a49dea63f97663e4237fc2c
OUGREIN/chipscoco-python-learning
/chenzhan/calc_extreme_of_10numbers.py
384
3.875
4
""" @author:chenzhan @date:2020-08-16 desc:求两个数值型变量的极值 """ numbers = [3,4,5,6,7,13,7,110,33,-7] # 先定义列表其中一个元素为变量最值!!!!...!!! max = min = numbers[0] for number in numbers: max = max if max>number else number min = min if min<number else number else: print("最大值为:%d/n最小值为:%d"%(max,min))
49d000f50a13a581bd919c314f1d0b373f9a608c
boelnasr/Python_3_programing
/Course_2/Quiz_3.py
4,389
4.375
4
######################## ######Question_1######## """The dictionary Junior shows a schedule for a junior year semester. The key is the course name and the value is the number of credits. Find the total number of credits taken this semester and assign it to the variable credits. Do not hardcode this – use dictionary a...
7dbcc71b1f3a2a68c8d7111d2e01d4a6d607d4c2
analytics2go/horizon
/Assignment2/1014901Wofford_Assignment2_c.py
234
3.609375
4
# CPSC-442-11/Python - Assignment 2 Problem c # Author: Wofford, Juana 1014901 # # Program prompts the user # # ----------------------------------------- # Prompt the user to enter print('\n') # Display what the user has entered for the
5eb7cd3c53b3d1a1669f7e43e56196de75d1ef74
taquayle/CSS458
/Assignment 6/Tyler Quayle - Assignment 6 - Burning Forest Simulation.py
3,691
3.8125
4
################################################################################ # Name: Tyler Quayle # Assignment: Cellular Automaton Simulations, Problem 2 # Date: May 3, 2016 ################################################################################ import numpy as np import numpy.random as ra import ma...
b9bb2c6c061d96babe0aeb8e7ccd5fe3eb03f745
iperetta/iperetta.github.io
/python/continua.py
2,576
3.859375
4
# tipos de dados a = None if a is None: print("Nada!") b = list(i for i in range(5)) b = None if not (b is None): print(b) lista = [2,3,4,5] tupla = tuple() # tupla vazia tupla = (2,3,4,5) print(lista, tupla) dic = dict() # dicionário vazio dic = { 'zero' : 0, 'um' : 1, 'dois' : 2, 'três' : 3...
87d9dc7d6a8fb1485705a71d6855f04cf067cc0b
nakhan98/CodeEval
/easy/set_intersection.py
835
4.0625
4
#!/usr/bin/env python2 # CodeEval - Set Intersects # https://www.codeeval.com/open_challenges/30/ import sys def show_intersects(list_1, list_2): intersect_list = [i for i in list_1 if i in list_2] if len(intersect_list) == 0: return None intersect_list = [ int(i) for i in intersect_list ] int...
fd0259a76fda4f0128bbb38245e1f0b4bf34412b
italormb/Exercicio_python_basico
/Curso_de_Python_3_Basico/Fase_9/desafio24.py
122
3.6875
4
#desafio 24 nome=str(input('Digite seu nome:')) print('Tem santos no primeiro nome: {}' .format('SANTOS' in divisao[0]))
0659ad3396c681b334cdcc7b83a1d98e410204f1
clhchtcjj/Algorithm
/Tree/leetcode 671 二叉树的第二大节点.py
912
3.953125
4
# -*- coding: utf-8 -*- __author__ = 'CLH' # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def findSecondMinimumValue(self, root): """ :type root: Tr...
b0fd52336a63df4fb19c9a2863ab94e87ff5a2e0
ZenoFP/CS50
/Problem Sets/pset6/hello/hello.py
73
3.5625
4
name = input ("Hi, sir. What's your name?\n") print(f"hello, {name}")
3f63858df1080e112376b0d2dcad5d15b020d2d3
paulo-sk/introduction-python-programming
/2-intro/review-questions/11_kg_pounds.py
125
3.984375
4
# convert km in to pounds kg = int(input("Enter the kg amout: ")) pounds = kg * 2.20462 print(f"{kg}kg = {pounds:.2f}pounds")
b01e73ea7ca4a7af1421f24c2d208887061d93e9
raiyan1102006/leetcode-solutions
/0127_word_ladder.py
1,142
3.515625
4
# 127. Word Ladder # https://leetcode.com/problems/word-ladder/ # Runtime: 116 ms, faster than 79.37% of Python3 online submissions for Word Ladder. # Memory Usage: 17.9 MB, less than 17.77% of Python3 online submissions for Word Ladder. class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList...
f7f1c0f88ecfb9e7fb0543b9787fb2b6c59f5484
fe-sts/CampinasTech
/Trilha_Python_001/Exercício_014.py
822
3.921875
4
''' 14. Fazer um sistema de biblioteca (Deve imprimir uma lista com 10 livros, pedir o nome do solicitante do empréstimo, pedir para selecionar um livro e imprimir o livro selecionado) ''' lista_livros = ['Harry Potter e a Pedra Filosofal', 'Harry Potter e a Câmara Secreta', 'Harry Potter e o Prisioneiro de Azkaban', ...
80441b95dba596a2b023ded5042c0a01c6d21dbd
vkmb/py101
/database/dbinsert.py
543
4.28125
4
''' database insert import sqlite module connect to the database create a cursor perform your database operations (select, insert,delete, update, create, drop) close the connection ''' import sqlite3 conn = sqlite3.connect('knowledge.db') cur = conn.cursor() while True: question = input("Question: ") if le...
b254aa7fd31458bd62a269f17001c308a8ec099f
reddyprasade/Python-Basic-For-All-3.x
/Operators/add.py
432
3.859375
4
"""# Get the input for the two variables num1, num2 = map(int, input().split()) sum_integer =0 # Write the logic to add these numbers here: sum_integer= num1+num2 # Print the sum print(sum_integer) """ numArray = map(int, input().split()) # Get the input sum_integer = 0 # write your logic to ...
82d55d9a251b16423ece1f7bfc88cfc1ca5ce995
colin-bethea/competitive-programming
/codeforces/A_Beautiful_Year.py
277
3.671875
4
__author__ = 'Colin Bethea' from collections import Counter def main(year): ans = None while not ans: if (len(Counter(str(year))) == str(year)): ans = year break year += 1 return ans if __name__ == "__main__": print(main(int(input())))
2d410d4172d0a7f66dd9e38ebb5d9ee479e77eef
kpatro/datastructure-python
/BinaryTree.py
3,789
3.828125
4
class BinarySearchTree: def __init__(self, data): self.value = data self.left = None self.right = None def add_child(self, par): if self.value == par: return # node already exists # traverse right if par > self.value: if self.right: ...
65ccde4e8a45b7e0c4323194f17d198b75f0dae2
arnaringig/MatPlotLibExample
/commented_plot.py
2,554
3.53125
4
import matplotlib.pyplot as plt import csv # Helping a friend in geoscience understand how matplotlib can # be easily used to plot data he fetched with Google Earth Engine with open('alldata.csv') as f: fig, ax = plt.subplots() reader = csv.DictReader(f, delimiter=',') timestamps = reader.fieldnames[1:]...
10937181c70c55750a210e37c06ca4393f5d74ef
CodeInDna/Machine_Learning_with_Python
/04_Dimensionality Reduction in Python/01_Exploring_High_Dimensional_Data.py
3,502
4.25
4
# Removing features without variance # A sample of the Pokemon dataset has been loaded as pokemon_df. To get an idea of which features have little variance you should use the IPython Shell to calculate summary statistics on this sample. Then adjust the code to create a smaller, easier to understand, dataset. # Leave th...
3ec5b94861fecc55c0680c0162972671938d2fa4
ayanakshi/journaldev
/Python-3/multiprocessing_examples/queue_example.py
390
3.890625
4
from multiprocessing import Queue colors = ['red', 'green', 'blue', 'black'] cnt = 1 # instantiating a queue object queue = Queue() print('pushing items to queue:') for color in colors: print('item no: ', cnt, ' ', color) queue.put(color) cnt += 1 print('\npopping items from queue:') cnt = 0 while not que...
4da2dfa56d2bb9b24bc84840e2171d72f74b559d
AGiantSquid/python_utilities
/tests/python_utils/test_sequence_utils.py
1,216
3.609375
4
#!/usr/bin/env python3 from python_utils.sequence_utils import unpack_apply capitalize = str.capitalize upper = str.upper def test_unpack_apply(): x = ('bob', '33', 'fbi') res = unpack_apply(x, capitalize, int, upper) assert res == ('Bob', 33, 'FBI') def test_unpack_apply_more_elements(): x = ('b...
eb26a68710d25174c2eaeed23a868fcb6268a951
Poncheele/Montpellier_Biking
/montpellier_biking/vis/program.py
6,530
3.546875
4
"""This program is a graphic interface to modelise bike traffic in Montpellier : First step select the week you want to modelise : Second step select days you want to modelise : Then press make video ! It will create you a video by day. """ import os import tkinter as tk import tkinter.messagebox from PIL i...
e5af656459b8569f6a6bd45f9d17e2fd6fb47517
TheL4rios/Player_py
/data_structure/Node.py
295
3.609375
4
class Node: LIST = 0 TREE = 1 def __init__(self, player, previous, next, type): self.player = player if type == self.LIST: self.previous = previous self.next = next return self.right = next self.left = previous
257fa146702de295efe8861291141a085eecbf19
sshantel/leetcode
/204_count_primes.py
258
4.15625
4
""" Count the number of prime numbers less than a non-negative number, n. """ def countPrimes(n): primes = [] print(type(n)) print(int(n)) for i in range(2,((n)/2)): if i % 2 != 0: primes.append(i) return len(primes)
aee10bb8b6356e79dfefcac45e2bf06b22e6a0d3
steff456/WorkshopTransposones
/solution/transposon.py
1,327
3.75
4
# Clase de transposon class Transposon(): # Definir inicializacion del objeto def __init__(self, seq_name, first, last, score): self.sequence_name = seq_name self.first = first self.last = last self.score = score # Definir si hay sobrelape con otro transposon def is_over...
2179d10259cd7db80e94f2832c02fe454e4f0358
sazzadrupak/python_exercise
/reverse_name.py
575
3.96875
4
def reverse_name(name): if ',' in name: comma_index = name.index(',') first_name = name[:comma_index].strip() last_name = name[comma_index + 1:].strip() if len(first_name) > 0 and len(last_name) > 0: correct_name = last_name + " " + first_name return correct_n...
4c39246156ec33803ea064b30bfecc7212e926fd
colinjpaul/chimpparadox
/pythonthehardway/ex11.py
281
3.765625
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 and %r tall and weigh %r' %(age, height, weight) print 'enter a number', x = int(raw_input()) print type(x)
6cfd3bc98e795296c430ea9b059988b0cee89aad
ashishjsharda/PythonSamples
/dictionary.py
178
3.625
4
''' Created on Aug 26, 2019 Dictionary in Python @author: asharda ''' dict={'Name':'Sai','Age':10000} print(dict['Name']) print(dict['Age']) print(dict) dict.clear() print(dict)
ad6b2d6cd3fbba78ede96d986a3eb5f42b4a1f39
chrislockard21/ise589
/python_files/homework/hw1/hw1_p9.py
716
3.96875
4
''' @author: Chris Lockard Problem 9: Write a program that converts specified days into years weeks and days. ''' print('Input:') # Ensures the value the user enters is a whole number try: days = int(input('Enter the number of days: ')) # Calculates the years from the total days print('\nOutput:') ...
b9d4358dd2f4c9a1605380f8e9eced4459242c75
Katuri31/Problem_solving_and_programming
/Python/Lab_model_questions/q_1/q_1.py
112
3.953125
4
def sum(n): if n<=1: return n return n + sum(n-1) print("The sum of 10 numbers is:",sum(10))