blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
64b9fb900ef32b855f310f5184aecdbf12ffe730
fly2rain/LeetCode
/fraction-to-recurring-decimal/fraction-to-recurring-decimal.py
1,874
3.78125
4
class Solution(object): def fractionToDecimal(self, numerator, denominator): """ :type numerator: int :type denominator: int :rtype: str """ def abs(num): return num if num > 0 else -num def fractionUnder1(numerator, denominator): if...
40f4288a83c1913e13683084e91d4b99e1d43a8d
fly2rain/LeetCode
/best-time-to-buy-and-sell-stock/best-time-to-buy-and-sell-stock.py
574
3.546875
4
class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ sum, max = 0, 0 for i in range(len(prices)-1): sum += prices[i+1] - prices[i] sum = sum if sum > 0 else 0 max = max if max > sum else...
01508f88fd0979a34a3c8372e410365472fa4ddf
DevDiana/meu-primeiro-programa-em-python
/primeiro.py
312
3.890625
4
a = 10 b = 5 soma = a + b subtracao = a - b multiplicacao = a * b divisao = a / b resto = a % b print('soma: ' + str(soma)) #print('soma: ' + soma) print(soma) print(subtracao) print(multiplicacao) print(int(divisao)) print(resto) #como converter uma string para inteiro x = '1' soma2 = int(x) + 1 print(soma2)
e9e3d156423b749649515a2629f71d9485f270b8
Nitesh-kumar-Reddy/Technical-Challenge
/Challenge-3/testgetvalue.py
918
3.640625
4
import unittest from getValue import findvalue class TestgetValue(unittest.TestCase): def test_valid_pair_1(self): obj = {"x": {"y": {"z": "a"}}} key = "x/y/z" result = findvalue(obj, key) self.assertEqual(result, "a") def test_valid_pair_2(self): obj = {...
6e38efbae37f320e152101ed39bfc6216e7c3206
Mohrezasharifi/10DaysOfCodeVvce
/CycleDetection.py
1,175
4.15625
4
# Python program to detect cycle in a linked list # Node class class Node: # Constructor to initialize the node object def __init__(self, data): self.data = data self.next = None class LinkedList: # Function to initialize head def __init__(self): self.head = None # Function to i...
8acf7ca816846361cc19023fefeffad7e1a377e8
AIF333/Python_src
/Mon1-20181220/装饰器.py
605
3.53125
4
#实现不论是否有无参数,有无返回值都可接受 import time def warrie(func): def timeer(*args,**kwargs):#任何参数都可以接手,不论有无 start=time.time() time.sleep(0.5) aa="AIF333" res=func(*args,**kwargs) end=time.time() print("program is running %s" % str(end-start)) return res return timeer...
446bbeb31fd81c8d87c7e7aa872bc9de8f6b8c36
AIF333/Python_src
/Mon1-20181220/携程yield.py
796
4.09375
4
#定义一个能初始化的装饰器,因为不用next初始化生成器,无法使用send调用 def init(func): def warrper(*args,**kwargs): g=func(*args,**kwargs) next(g) return g return warrper @init # eater=init_eater(eater) def eater(): print("Yeteng beign eat:") food_list=[] while True: food=yield food_list #相当于一个r...
94dfab6e62308230b309bd1d3f588775cfea91c7
AIF333/Python_src
/Mon1-20181220/lambda.py
1,008
4
4
#匿名函数 f=lambda x,y,z:x+y+z print (f(1,2,3)) #用匿名函数取 value最大的key dic={'a':3,'b':2,'c':1} print(max(dic,key=lambda x:dic[x])) #按照value值取最大 等价于下面的 print(max(zip(dic.values(),dic.keys()))[1]) #也等价于下面的有名函数 key等于的是函数地址 def get_value(key): return dic[key] print(max(dic,key=get_value)) #将列表中非 AIF的值后面加一个 333 l1=['AIF','B...
3286cbad05fcab96ec78e44ff9d5fb06fce14429
ritz-bot/Rock-paper-scissors-game
/gM.py
833
3.953125
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____)...
edeeedaf4db7f1edfe243b50dffcc9a0fd346bec
durbanie/ProjectEuler
/src/P1/Problem34.py
1,396
3.859375
4
''' Problem: Find the sum of all the numbers which are equal to the sum of the factorial of their digits Strategy: Brute force. Notes: The max value that n can possibly have is 7*9! = 2540160. This is because if there was an eighth digit, even the sum of the factorial of all 9's would have less than 8 digits. ...
bc5a578f67e46c9f859f332d24669db548d7b8e6
durbanie/ProjectEuler
/src/P1/Problem37.py
2,204
3.96875
4
''' Problem: Find the sum of the only eleven primes that are both truncatable from left to right and right to left. Strategy: Brute force, similar to circular prime strategy. Notes: No idea what the theoritical limit is, or why we can know that there are only 11. For the purposes of this problem, I will take the hi...
f964faccb4fdd7dfbe4e42d9f9fcc202570b0b8e
durbanie/ProjectEuler
/src/P1/Problem32.py
2,904
4.1875
4
''' Problem: We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 x 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pan...
d737f0c70363695a1b64a24d7da8224134115f4c
TongLing916/alien_invasion
/settings.py
1,653
3.515625
4
class Settings(): """ a class to store all settings""" def __init__(self): """initialize settings for the game""" # settings for screen self.screen_width = 1200 self.screen_height = 800 self.bg_color = (230, 230, 230) # settings for ship self.ship_speed_...
0b7b810b3e82cc96494e1a68d8f1101e2cdb0f03
hengma1001/ud120-projects
/outliers/outlier_cleaner.py
698
3.734375
4
#!/usr/bin/python def outlierCleaner(predictions, ages, net_worths): """ Clean away the 10% of points that have the largest residual errors (difference between the prediction and the actual net worth). Return a list of tuples named cleaned_data where each tuple is of the ...
ff9cd38e4e29baf2b22a2b237c5ed01dce4ea44d
Darkbx/ejercicios_colecciones_clases
/practica_6_py/contacto.py
1,031
4.09375
4
class contacto(): """CLASE""" def __init__(self): self.nombre = 0 self.apellido = 0 self.telefono = 0 self.direccion = 0 def SetContacto(self): """ATRIBUTOS""" print("Ingrese sus datos a continuacion:\n") self.nombre = input("Ingrese su Nom...
7b939571bde3b0b3bdbef6d4c6af2ca2d5327bb4
ghousekw/python
/lib/Code/OOP/p6.py
1,153
4
4
class Employee: raise_amount = 1.04 num_of_emp = 0 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + "." + last + "@email.com" Employee.num_of_emp += 1 def full_name(self): return f"{self.first...
afa9ec5500b00071436a282998172bd2a57ad5fb
ghousekw/python
/lib/CountWordsOnFile.py
679
3.59375
4
import os currentPath = os.getcwd() # get file name from user name = input("Enter file name: ") # read file from user handle = open(currentPath,name) # create a dict() to store data counts = dict() # by using for loop reading all the lines for line in handle: # split the line words = line.split() # loopi...
47a81b8bc58b37d58bd32cc676417536e09a4bd4
Sonnelon888/pythonStudy
/Area_Triangle_Square_Cicrcle.py
402
3.90625
4
figure = input() if figure == "треугольник": a, b, c, = int(input()), int(input()), int(input()) print((((a + b + c) * 0.5) * (((a + b + c) * 0.5) - a) * (((a + b + c) * 0.5) - b) * (((a + b + c) * 0.5) - c)) ** 0.5) elif figure == "прямоугольник": print(int(input()) * int(input())) elif fi...
28c53ade2fc23c2ef29f26e5e7f8c981ffa820c0
Sonnelon888/pythonStudy
/abbreviate.py
242
3.5625
4
phrase, b, prev = input()+'.', 0, 0 for i in phrase: if prev == i: b += 1 elif prev == 0: prev = i b += 1 elif prev != i: print(str(prev) + str(b), end='') prev = i b = 1
9941c81d1b6fed4552cfb9573a4e385716d9c315
bkemmer/ML-algorithms
/modelos/regressao_linear.py
2,763
3.90625
4
# Regressão linear import numpy as np import matplotlib.pyplot as plt from .utils import acuracia def regressao_linear(X, y, lamdba=0): """ Cálculo da regressão linear na forma vetorial sem regularização Arguments: X {Matriz} -- Matriz dos exemplos de entrada já com a coluna com x_0 = 1 adicionada ...
7872103516373fdeeacb0fabca85d7d6e38913a0
PranjalGupta3105/python_learnings
/App2.py
247
4
4
def create_student(name): mark=[] for i in range(5): mark.append(int(input())) stu_dictionary={"name":name,"Marks":mark} return stu_dictionary name=input("Enter Student Name:==") result=create_student(name) print(result)
5d179c6a151390ed005efbf81431c6e29503eb7c
MugoHattsson/AlgoDat
/1stablemarriage/Main.py
2,090
3.53125
4
from typing import Deque from collections import deque import sys menList: Deque = deque([]) womenList: dict = {} N: int = int(sys.stdin.readline()) def main(): createLists() while len(menList) != 0: man = menList.popleft() woman = womenList[man.propose()] if woman.single: ...
e15b4517a47afb2d22f8a05a97ecc1550abd2439
NakulK48/aoc-2020
/02b.py
397
3.53125
4
with open("2.txt") as file_obj: lines = file_obj.readlines() valid = 0 for line in lines: rule, password = line.split(": ") counts, letter = rule.split(" ") lowest, highest = [int(x) for x in counts.split("-")] first_match = (password[lowest-1] == letter) second_match = (password[highest-1] ==...
179a2e13162cebb614657311b260da5b91ca392a
4whitp37/COM404
/1-basics/4-repetition/1-while-loop/1-simple/bot.py
198
4.15625
4
#while statement removedcables = 0 print("How many cables should I remove?") cables = int(input()) while(cables > removedcables): print("Removed cable.") removedcables = removedcables + 1
8ceefb8b0bcf7fd4cfb2040bcc84d15462c191e5
4whitp37/COM404
/1-basics/3-decision/01-simple-decision/05-comparison-operators/bot.py
331
4.125
4
#work out what the smallest number is print("please enter the first number.") number1 = input() print("please enter the second number.") number2 = input() if number1 < number2: print("the first number is smallest") elif number2 < number1: print("the second the number is smallest") else: print("the numbers ...
81ea9cab178808fb4286b750ed13459c9d928524
4whitp37/COM404
/1-basics/4-repetition/2-for-loop/2-count-down/bot.py
194
4.21875
4
#for loop - count down count = 0 print("How far are we from the cave?") steps = int(input()) for count in range(steps,count,-1): print(str(steps) + " steps remaining") steps = steps -1
f11df3d8166f46d822c70980d8356e78b31dc621
4whitp37/COM404
/1-basics/4-repetition/1-while-loop/4-len/bot.py
192
4.0625
4
#while loop based on characters in a phrase word = 0 print("Please enter a phrase:") character = input() charlen = len(character) while (word < charlen): print("Bop") word = word+1
c28d6149e64ae7ff8824b57bfeedbb9ce774514f
4whitp37/COM404
/1-basics/TCA/Q7 Modules/main.py
648
3.9375
4
#Modules - main def wordinput(): print("please enter a word") global word word = input() return word wordinput() def options(): print("These are the options:") print("1 - under") print("2 - over") print("3 - both") print("4 - grid") print("please select an option 1- 4") optio...
fd1f39e14b692b66a4808d4ca59b9a319f17c71f
CA2528357431/python-note-string
/01/PythonApplication42.py
291
4
4
#字符串 word="hello world" print(word[4]) #可将字符串视为一个list print() for x in word: print(x) #for的利用 print() print(word.count("ll")) #对某字符/字符串计数 print(len(word)) #统计长度 print(word.index("rld")) #找某 字符 / 字符串首字 位置
01f6bacd4f233dc66842b9651205ba6beab15040
ryliemn/leetcode-python-solutions
/solutions/0136_single_number/singleNumber.spec.py
511
3.765625
4
import unittest from singleNumber import singleNumber class TestSingleNumber(unittest.TestCase): def testOrdinaryExample(self): nums = [1, 5, 3, 1, 5] returned = singleNumber(nums) expected = 3 self.assertEqual(returned, expected) def testLargeExample(self): nums = [1...
f73996777c5027febb147f689898fd535fc0d1e8
Changissnz/SAO
/Functions.py
1,829
3.9375
4
""" this file contains some examples of Shame/Align functions """ ''' standard bool function is by float range ''' def make_func_bool_standard(minVal, maxVal): return lambda x: True if x >= minVal and x <= maxVal else False ''' standard float function is by direct mapping ''' def make_func_float_standard(): r...
b9d0d19b7997a15d2eac8c3189aa88d40840ff67
Edvard88/leetcode
/Python/559_maximum_depth_of_n_ary_tree.py
1,597
3.5
4
G_object_1 = { 1 : [3, 2, 4], 2 : [], 3 : [5,6], 4 : [], 5 : [], 6 : [] } G_object_2 = { 1 : [2, 3, 4, 5], 2 : [], 3 : [6,7], 4 : [8], 5 : [9,10], 6 : [], 7 : [11,14], 8 : [12], ...
bf38c0043362875eadf8d965cbc827aef78735b7
megadubcev/pygame
/yellow_ball.py
638
3.703125
4
import pygame pygame.init() size = width, height = 800, 600 screen = pygame.display.set_mode(size) pygame.display.flip() clock = pygame.time.Clock(); def draw(): pygame.draw.circle(screen, pygame.Color("yellow"), pos, r) ball = False running = True while running: tick = clock.tick(30) screen.fill(pygam...
3a9f1c76808685d0a0d46d4f0eec968eadfcd7b8
IamBirender/Dynamic-Programming
/Longest-common-subsequence/longest_repeating_subsequence.py
1,706
3.53125
4
class solution(object): def __init__(self, str1): self.str2 = self.str1 = str1 self.len2 = self.len1 = len(str1) self.result = "" self.memo = [[0 for i in range(self.len2+1)] for j in range(self.len1+1)] def _get_subsequence(self): # self.__recursive_solution(self.le...
65ed93c5820938ddf7fbe662a5ae00122e3c8323
IamBirender/Dynamic-Programming
/Knapsack/knapsack01/video_3.py
875
3.625
4
class video_3(object): def __init__(self, weight, value, capacity): self.weight = weight self.value = value self.capacity = capacity self.result = 0 def _get_combinations(self): result = self.__recursion(self.weight, self.value, self.capacity) return result ...
ee6719afd24762ba98f5cb880c07ecdf48230950
league-python-student/level1-module1-ShivamPansuria07
/_01_creating_objects/_c_turtle_race.py
2,179
4.15625
4
""" Turtle Race """ import turtle from random import randint from PIL import Image # ================= Instructions at the bottom of this file =================== def screen_clicked(x, y): print('You pressed: x=' + str(x) + ', y=' + str(y)) def draw_background(): filename = 'race_track.gif' try: ...
56a3b75eab11ef5dc8e221035121f2558d227b13
NDRoberts/PPL
/SParse/parser.py
23,316
3.5625
4
''' CS3210 - Principles of Programming Languages Programming Assignment 1: Lexical / Syntax Parser @author Nate Roberts I do hereby solemnly swear that I whacked this train wreck of code together all by myself, excepting only those blocks expressly credited to other authors. No one else is to blame. ''' import sys fr...
cbe6085abfae1b38b9becec00e6959d36b40d5e7
HasifAhmed/wkshop
/18_listcomp/listcomp.py
456
3.671875
4
# Xiaojie(Aaron) Li, Hasif Ahmed # Softdev2 pd8 # K18 -- PPFTLCW # 2019-04-15 def triples(n): return [ (a,b,c) for a in range(2, n + 1) for b in range(a, n + 1) for c in range(b, n + 1) if ( a * a ) + ( b * b ) == (c * c)] def quicksort(list): pivot = list[0] small = quicksort([x for x in list[1:] if x ...
5148bf0c1c50fe4a8c75c081c058a183802f598f
AlKoAl/-10
/12.py
523
4
4
# Напишите программу, которая считывает текст состоящий одной строки # и все слова с нечетным номером переводит в верхний регистр(заглавные буквы), # а с четным - в нижний(прописные). Ar = [i for i in input().split()] n = (len(Ar)) for i in range(n): if i % 2 == 0: Ar[i] = Ar[i].upper() else: ...
e995272d75004f2277f04070582517f441c4431b
AlKoAl/-10
/02.12/2.py
1,494
3.703125
4
# Задача №2 # Напишите программу, содержащую функцию вычисляющую функцию Эйлера для произвольного натурального числа. # Программа должна считывать из файла массив чисел и находить среднее геометрическое значений функции # Эйлера чисел массива def prime(n): i = 2 j = 0 while i**2 <= n and j != 1: ...
e26b5a848079c3973861714fc11689be7cdd6460
enkejill/kriegerbund-bot
/dice.py
1,290
3.546875
4
import random from utils import * def cmd_roll(message, args): if len(args) < 1: return roll_dice(1, 6) if args[0] == 'help': return '''\ ```Usage: !dice or !roll !dice XdY or !roll XwY e.g.: !roll 5d6```''' return roll_dice_str(message, args) def roll_dice(count, type): msg ...
391a0edb694fe2245a834e6f26c9cd23f5b88f29
bc10353782/PFBD_10353782
/CA_04/BC_changes.py
1,956
3.625
4
import csv # open the file - and read all of the lines. changes_file = 'changes_python.txt' # use strip to strip out spaces and trim the line. data = [line.strip() for line in open(changes_file, 'r')] return data # print the number of lines read print(len(data)) sep = 72*'-' # create the commit class to hold each o...
0bdb90cb8210846cff26c6d7415f89535b7a05ec
2gisprojectT/n.paristov
/3003/lion.py
1,481
3.765625
4
__author__ = 'whitefoxnsk' class Lion: def __init__(self, l_dict, status): if status == "": raise Exception("Empty status") self.status = status if l_dict == {}: raise Exception("Empty dict") self.l_dict = l_dict self.action = "" def result(self...
2e432d790c67db62ce773c317d32ab9689fbe929
pierreelliott/genetic_algorithms
/mutations.py
2,229
3.671875
4
import random from utils import available_characters class NCharRandomMutation: """ Mutate n characters randomly in the sequence """ def __init__(self, n): self.n = n def __call__(self, individual): charidx_to_mutate = random.choices(range(len(individual.genotype)), k=self.n) ...
3c564850dd39bc7422f22b115cf8775621d4593c
annarbecker/hadoop_practice
/reducer.py
848
3.53125
4
import sys # Data from mapper # Store Sale # San Jose 12.99 # Key: store name, Value: sale amount salesTotal = 0 oldStore = None # Loop through the data which is in key \t value format # All the sales for a particular store will be presented, then the key will change and we'll move on to the next store for line ...
c898fded9945a65effcfbfa6279e97c19351dca7
Bhavya-Agrawal/backup_ubuntu
/os_demo.py
312
3.5
4
#!/usr/bin/python3 import os #os.system(espeak) string = input("Enter something here!!!!\n") output = os.system(string) # os.system returns the unix value for showing success of os.system() command print(output) #os.system('echo %s|festival --tts' % os.system(string)) os.system(string+" | festival --tts")
3e1a6c75f10b110eeb35d18da5e83122f318b6ed
Bhavya-Agrawal/backup_ubuntu
/List_demo.py
279
3.5
4
import numpy as np a = np.array([[2,3,4,5]]) b = np.array([[4,5,6,7]]) d = np.array([[4,5,6,7]]) c = np.concatenate((a,b,d)) print(c) '''list_data = [[[2,3],[4,5]]] a = [[7,8],[9,0]] b= [[0,1],[2,3]] print(type(a)) list_data.append(a) list_data.append(b) print(list_data)'''
fb52846a91b86db1697a464d429ed1987d36c323
luchaoet/python-test
/day12-21/reduce.py
302
3.546875
4
# reduce把一个函数作用在一个序列[x1,x2,x3,x4,...]上,接收两个参数 reduce把结果继续和下一个元素累积计算 # 效果类似于 reduce(f,[x1,x2,x3,x4]) = (f(f(x1,x2),x3),x4) from functools import reduce def add(x, y): return x + y print(reduce(add, [1, 3, 5, 7, 9])) # 25
4a9346f9c370a72c22294d25815ddf6400bae7a6
agupta88ccs/Pi-Assignments
/quadraticsolver.py
749
3.953125
4
# Quadratic Solver # Written by Asha Gupta def quadSolve(a,b,c):#function that inputs the three number in equation import math disc=b**2-4*a*c #discriminant formula if disc < 0:#if the discriminant is less than 0 no real roots print("No real roots") return ["...
9d14e515369e2a4d44aea941dfa160f24606059d
mflinn92/pythonChallenges
/word_break.py
929
3.625
4
import unittest from collections import deque def word_break(s, word_dict): word_hash = set(word_dict) queue = deque([0]) visited = set() while queue: start_idx = queue.popleft() if start_idx not in visited: for end in range(start_idx + 1, len(s) + 1): if s[...
9fcbf0570b6660a7cb7f5f569f16318b3afd65d0
mflinn92/pythonChallenges
/island_counter.py
1,956
3.5625
4
import unittest def islandCounter(grid): #iterate through grid until island is found num_islands = 0 for i in range(len(grid)): for j in range(len(grid[0])): if grid[i][j] == "1": num_islands += 1 #used for dfs of adjacent land stack = [(i...
0180e0a10267ee8215ea2b91152f944b18b22434
tsaoyu/AOC2019
/day3/day3.py
1,342
3.828125
4
class Day3: def __init__(self): pass def closest_intersection(self, path1, path2): m = {"R":(1,0), "L":(-1,0), "U":(0,1), "D":(0,-1)} trace1 = {} current_pos = (0, 0) length = 0 for move in path1: direction, distance = m[move[0]], int(move[1...
b54908f60361c48d50ffc414d2025b2033516a49
abbybernhardt/Bernhardt-MATH361B
/FinalProject/F3_Prob116_Bernhardt.py
930
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Apr 23 13:20:58 2019 @author: abigailbernhardt """ #%% N = 10 # represents number of units of black tiles, change this number red = 2 green = 3 blue = 4 def tiles (NewColor, N): # NewColor = number of black tiles covered by a new color and N is tota...
6191f1a3531e62f3b17353098bb31adca591f310
maria-yankova/crystallographic-texture
/crystex/numutils.py
2,639
3.515625
4
import numpy as np from numpy import linalg as la def zero_prec(A, tol=1e-12): """ Sets elements of an array within some tolerance `tol` to 0.0. """ A[abs(A) < tol] = 0.0 return A def plane(x, y, a, b, c): z = a * x + b * y + c return z def fit_plane(points): """ Fit points to...
3d3f22ce26e76daab4c44089908cbeb08a8d2e68
CJLakey/Python-OOP-School-Projects
/DVD_Class_Activity.py
6,250
4.0625
4
def display_dvd_information(dvds): # Create function to display dvd title, cost, and type for obj in dvds: # Create loop to print the list of dvds print(obj.title) print(obj.dvd_type) print(obj.cost) def display_total_and_average_cost(dvds): # Create function add = 0 # star...
6e4224d628b99cdacb608ae98bd46c9219a0e6af
cminnera/DataStructures-Algorithms
/PythonAssignments/Assignment3/assign3.py
4,452
3.59375
4
""" Clare Minnerath Assignment 3: #42 implementation 02/03/2020 """ import matplotlib.pyplot as plt import numpy as np import time count = 1 # Tiling problem #42 def tile(T, n, top_left, pos): global count # figure out what quadrant forbidden square is in & tile accordingly # forbidden square i...
f22434c1c43678dad4444d73df639db697e54529
cminnera/DataStructures-Algorithms
/PythonAssignments/Assignment2/assign2.py
369
3.59375
4
""" Clare Minnerath Assignment 2 01/30/2020 """ # Binary Search w/ guaranteed find def binary_search(low,high,L,x): mid = int((low+high)/2) if x == L[mid]: return mid elif x<L[mid]: return binary_search(low,mid-1,L,x) else: return binary_search(mid+1,high,L,x) S = [4,6,12,15...
1a163d70b800da9c3cd307409b80e9368e0da773
Mariam-Hemdan/ICS3U-Unit-5-02-Python
/passing_by_value.py
788
3.96875
4
#!/usr/bin/env python3 # Created by : Mariam Hemdan # Created on : November 2019 # This function calculates the area of a triangle def calculate_area(base, height): # calculate area # process area = base * height / 2 # output print("The area is {0} cm²".format(area)) def main(): # this fu...
8580727b0b797597f0d07853b2a7cfdd40e80080
Shaper-cyber/python_1373
/les4/les4task2.py
183
3.515625
4
my_list = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] new_list = [el for i, el in enumerate(my_list) if my_list[i] > my_list[i - 1] and i != 0] print(my_list) print(new_list)
daaa1ca3c591d9945871d9a8f811c940be5b371d
Shaper-cyber/python_1373
/les8/les8task5.py
1,987
4
4
'''Тему ооп 8 не понял''' class Storage: def __init__(self, count=0, all_cost=0): self.count = count self.all_cost = all_cost def accept(self): pass class OfficeEquip: count = 0 all_cost = 0 class Printer(OfficeEquip): def __init__(self, name: str, count: int, printing...
d08d06ef7496f4a24761372ae50c267ad7d20d55
Shaper-cyber/python_1373
/les7/les7task1.py
871
3.625
4
class Matrix: def __init__(self, matrix): self.matrix = matrix def __str__(self): return '\n'.join(' '.join([str(itm) for itm in line]) for line in self.matrix) # len(self.matrix) == len(other.matrix) and def __add__(self, other): try: if len(self.matrix) == len(ot...
082a493615261f6d90fe0ee504d4f9f9fd439d97
flykiller24/amis
/km-82/Starov_Denys/workshop2/homework/task1.py
1,232
3.984375
4
stud_list = [ { 'name': 'Bob', 'age': 18, 'marks': { 'Math': 87, 'English': 95 } }, { 'name': 'Boba', 'age': 21, 'marks': { 'Python': 78, 'Math': 89 } } ] maxAge = 0 def max_age_f(stud_list, len_stud_list, max_age): global maxAge if len(stud...
14b7065d2363b18ece570775c30407d8a6170c6a
moonseokho85/TIL
/A.I/12_Python/3_argsort.py
449
4.15625
4
# np.sort(x)[::-1] : 정렬을 한 후 mirror view 생성 import numpy as np x = np.array([4, 2, 6, 5, 1, 3, 0]) x_reverse_1 = np.sort(x)[::-1] # mirror view print('x_reverse_1: ', x_reverse_1) # x[np.argsort(-x)] : np.argsort() 로 index를 받아서 indexing 해오기 x = np.array([4, 2, 6, 5, 1, 3, 0]) print('np.argsort(-x): ', np.argsort(-...
2e2ec9946a04129b21465a0e1a79fc0c01e2c25a
moonseokho85/TIL
/Algorithm/bj_9498.py
391
3.828125
4
# 백준 알고리즘 9498번 # 입력받은 점수의 학점을 출력해주는 프로그램 # 입력: 시험 점수 # 출력: 시험 성적 # input n = input() # convert string to int point = int(n) # if phrase if 90 <= point <= 100: print('A') elif 80 <= point <= 89: print('B') elif 70 <= point <= 79: print('C') elif 60 <= point <= 69: print('D') else: print('F')
5fd993dc0e0ffb9d2f05d7bee8999833ae941d39
moonseokho85/TIL
/A.I/12_Python/2_sort.py
342
3.765625
4
# 1차원 배열 정렬 import numpy as np x = np.array([4, 2, 6, 5, 1, 3, 0]) sorted_x = np.sort(x) print('sorted_x: ', sorted_x) # 원래 배열은 그대로, 정렬 결과 복사본 반환 x = np.array([4, 2, 6, 5, 1, 3, 0]) print(np.sort(x)) print(x) # 배열 자체를 정렬 x = np.array([4, 2, 6, 5, 1, 3, 0]) x.sort() print(x)
0cd8bf2487bb6f9667a04d9c79c1d9b25e6118fc
moonseokho85/TIL
/A.I/10_Keras/keras03_test.py
1,022
3.53125
4
import numpy as np # 데이터를 train과 test set으로 나눕니다. x_train = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) y_train = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) x_test = np.array([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) y_test = np.array([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) # 데이터 확인 # print(x.shape) # print(y.shape) ...
602a1e5c8a0ffd470fde7c7fc3d8cfc871b60074
recepdagli/urlshortener-flask
/db.py
603
3.5
4
import sqlite3 def createdb(): conn = sqlite3.connect('example.db') c = conn.cursor () c.execute('''CREATE TABLE links (link text, redirect_url text)''') c.execute("INSERT INTO links VALUES ('asdfgh','https://www.google.com')") conn.commit() conn.close() def getdata(): with sq...
4135034cb4a6d104a8ad45cdafd901d48085ab1f
Ketan-Kulkarni2791/Rolling-Dice
/dice.py
1,734
3.515625
4
from tkinter import * from PIL import ImageTk, Image import itertools import random background_color = "#0D865D" root = Tk() root.geometry("960x720") root.configure(bg=background_color) root.title("Let's try out your Luck!") first_image_path = '1.png' second_image_path = '2.png' first_dice_image = Im...
42f648fb63ebbcaacc4f7903675136dbcfa1ab67
TianqiWang1/data_mining_project
/mini_hash/example.py
3,480
3.515625
4
import random import re from itertools import combinations def mapper(key, value): # key: None # value: one line of input file # -------------------------------------------------------------------------- # Define the number of hash functions. numHashes = 975 # Record the maximum shingle ID. ...
ac2d074f9035c2b4f0ac1a02195571feedcedc7b
JMatthysen/GantrySimPy
/AxisShapes.py
321
3.765625
4
""" simple shapes used to represent a gantry axis """ class Rectangle: def __init__(self, depth, width, height): self.depth = depth # x axis self.width = width # y axis self.height = height # z axis class Circle: def __init__(self, radius): self.radius = radius...
1f6b3a5068e01df6a1c0856e019a4faf4e1df33c
smc002/Python-Learn
/reference
436
4.25
4
#!/usr/bin/python # Filename: reference print('Simple Assignment') shoplist = ['apple', 'mango', 'carrot', 'banana'] mylist = shoplist # mylist is another name pointing to the same object! del shoplist[0] print('shoplist is', shoplist) print('mylist is', mylist) # in both list, 'apple' is removed print('Copy by ma...
0082aa62be12274fe9468d15a190ca7cae000604
metiscoderclass/python-2-maak-een-woordspel-naar-keuze-RyanJakePaulFan
/hangman.py
878
3.625
4
import random naam = input("Hallo wat is je naam? ") print("Hallo " + naam, "welkom bij galgje!") list = [' banaan', 'soep', 'woord', 'coderclass', 'issam', 'codercrackers', 'huis', 'boom', 'midas', 'baggerbusters', 'python', 'html', 'css', 'javascript'] woord = random.choice(list) print (woord) countfouten = + 1 ge...
cf9b78afb00be0ce05bf52bbb04b92dfde1b55d4
jokercell-lab/science_search
/primechker.py
568
3.875
4
def prime_ck2(y): is_prime = True for n in range(2,y-1): if y % n == 0: is_prime = False if is_prime: print("Prime!!!") else: print("Not Prime!!!") # def check_prime(x): # check = True # for i in range(2,x+1):f # if x/i == 1: # check = Fal...
c7df807ff719bd4a7064c37496c65a4ec88d57ec
Lakshmi1098/Hackerankquestions-
/Pairs.py
969
4.0625
4
You will be given an array of integers and a target value. Determine the number of pairs of array elements that have a difference equal to a target value. For example, given an array of [1, 2, 3, 4] and a target value of 1, we have three values meeting the condition: 2-1=1,3-2=1 ,4-3=1. Sample Input 5 2 1 5 3 4 2 ...
9984acc8fb463e3d34afba27a177dab4c445c00b
RohanSadnani/Data-Visualization
/Drop_Entries.py
497
3.78125
4
import pandas as pd import numpy as np from pandas import Series,DataFrame cars= Series (['Alpheon','Hyundai','Kia','SsangYong'],index=['a','b','c','d']) print(cars) cars= cars.drop('a') print(cars) #dataframes cars_df = DataFrame(np.arange(12).reshape(4,3), index=['Alpheon','Hyundai','Kia','SsangYong...
bf0bfd7e7b535deec4476fb5834ae14db59fcc9e
ZJmitch/Booleans
/Problem 2.py
370
3.859375
4
#Justin Mitchell #3/7/2021 #Problem 2, user input for sum def findSum(fS): x = int(input("Input first integer:")) y = int(input("Input second integer:")) if (x >= 10 ** 10) or (y >= 10 ** 10) or (x + y >= 10 ** 10): print("Overflow!") else: print("Sum of the two in...
6bd8557bc6558b7d445a36dda4997bf82b84b2bc
sfroid/dolst
/utilities/filesearchutilities.py
1,646
3.515625
4
""" Utility functions for searching and finding files { sfroid : 2014 } """ import os import sys import fnmatch def get_root_dir_path(): """ Get the root directory path of the repo assuming that this file is in the utilties folder. """ currdir = os.path.dirname(os.path.abspath(__file__)) ...
3c69762c267dff313f8d094dbe988435d53d1607
ophwsjtu18/ohw
/students/QinZijian/Final/create_maze.py
5,848
3.796875
4
import random import numpy as np from matplotlib import pyplot as plt import matplotlib.cm as cm import csv ''' num_rows = int(input("Rows: ")) # number of rows num_cols = int(input("Columns: ")) # number of columns # The array M is going to hold the array information for each cell. # The first four coordinates tell...
684be547254336defd757a09499142dc6e4433a3
PallabPandaOwn/Total_PythonConcept_Codes
/class_Demo/ConstAndSelf.py
649
3.6875
4
class Computer(): classinfo = "test class" def __init__(self): self.name = 'Pallab' self.age = 30 def compare(self, others): if c1.age == c2.age: print("Age are same") else: print("Age are different") @classmethod def getClassInfo(...
cb04d4a9f623eed235c115787e121f5bf475554f
PallabPandaOwn/Total_PythonConcept_Codes
/ArraySorting.py
333
3.765625
4
import array as arr myarr=arr.array('i',[3,1,23,17,90,4,67,89]) def arrsort(x): first_num=x[0] newarr = arr.array('i',[len(x)]) for i in x: if i <= first_num: first_num = i newarr.append(first_num) #return newarr for i in newarr: print(i) arr...
2c15b5780548b0163ebcc443e3459c8ad7048264
PallabPandaOwn/Total_PythonConcept_Codes
/ListToFunction/lengthName.py
177
3.953125
4
names = ['pallab', 'bidya','Ravi'] def GetLength(names): for name in names: if len(name) >= 5: print('Name :{}'.format(name)) GetLength(names)
21555770a324f49860c71368638b8caa252d5d85
Habii4425/Slumparen
/dagensövning.py
847
3.625
4
klader = [ "Jeansbyxor med vit t-shirt, Svart hoody och bumber jacka.", "Svarta byxor med vithoody och Peak jacka.", "Tygbyxor med tygtröja och klassik jacka." ] t-shirt = [ "svart hoody", "vit tröja med bumber jacka", "" ] skor = [ "Vita", "Svarta", "Röda" ] Ha...
c36c399ba3d39a375627a27caec88e04d22e534e
clvnkhr/Text-Flappy-Bird
/flap.py
6,216
3.609375
4
#flap.py #Calvin Khor #First game ever! #learned how to use curses, sort with basic lambda function key import copy as cp import time, math, random, curses def newCol(): #make the next column that will appear #height should be the height of the game screen newColumn = ['*' for _ in range(height)] x = random...
e780a28fdd89a90180d6f136d5b677fb3d62ba3c
AidanZap/CIS434-Group12
/button.py
1,169
3.53125
4
import pygame class button: text = "Button Text" color = (150,150,150) text_color = (0,0,0) x = 0 y = 0 w = 10 h = 10 hidden = False hover = False def __init__(self, gs, text,x,y,w,h,color,text_color): self.color = color self.text = text self.x = ...
640d9f5e259c44d3444d5613b24698ed9662f5df
ritesh-1227/basic_py_scripts
/ass1_atm.py
2,079
3.75
4
u = [123, 456, 789] p = ['abc','def','abc'] amount = [5000,2000,3000] while(True): while(True): user = input('Enter the username: ') passw = input('Enter the password: ') login = 0 ##for i in range(3): ## if u[i] == int(user) and p[i] == passw: ## ...
eb2ce50afc53e1a464a8c8d53519e57432350391
papaniivanderpuye/password-generator-api-sql-experiment
/account_generator.py
5,284
4.4375
4
import random import sqlite3 import string import re import requests from typing import List """ File Name: account_generator.py Written By: Papa Nii Vanderpuye Date: 14th August 2018 """ """ This is my implementation of the required coding section of the technical interview. I have described some...
ed188b0c3c3c683f015c498109831aad4e91578e
BokyungChoi/2019_1_GH_Quest
/BK_Quest9.py
15,576
3.578125
4
#!/usr/bin/env python # coding: utf-8 # ### Deep learning # ### -Softmax classification과 CNN # In[1]: import tensorflow as tf import random from tensorflow.examples.tutorials.mnist import input_data import matplotlib.pyplot as plt # In[2]: # size:(28*28*1) = 펼치면 784차원의 벡터 # 흰색 배경에 검은색으로 적힌 0~9의 숫자 mnist = inp...
9e4eaaaa9abc622397a32a16788b963b23ab0166
maricspe000/Encryptor-Decryptor
/main.py
2,318
3.5625
4
import cryptography choice = input("Key from file,typed, generated(or decrypt): ") from cryptography.fernet import Fernet if choice == "generated": x = input("Message to Encrypt: ") key = Fernet.generate_key() file = open('key.key', 'wb') file.write(key) # The key is type bytes still file.close() from cry...
3eaadebb8592e5ebacc59f2d0b99aed03f0d4812
FransGabro/Dungoncrawler
/Dungoncrawler/Map.py
2,936
3.75
4
from random import randint, choice import os from new_room import Room class Map: def __init__(self, width, height): self.width = width self.height = height self.walls = [] self.start = (0, 0) self.end = (width-1, height-1) self.player = (0, 0) # WIP - Check i...
91b149ac8f16f788e985b65265a479384d1e2d44
ravenusmc/trail
/merchant.py
2,644
4
4
from valid import * #I created this merchant class to help solve some problems that I was having wih the store file. #So far, it seems to help solve my problems as well as to increase my understanding of OOP. The methods #in this file may be long but they got the job done and help me solve my issue! class Merchant()...
161aaf35de8a136a6cdce33d2ae79668178b594f
ravenusmc/trail
/main.py
5,164
4.28125
4
from valid import * from humanClass import * from wagon import Wagon from store import * #This is the title screen of the game and introduces the user to it. This will also be the main menu of #the game. def main(): print("\033c") print("{ The Oregon Trail }") print(" --------------------...
99f0b286c317d79651159771737a3cb24d06f66f
keyaria/SI206
/HW6/HW6a.py
890
3.53125
4
from urllib.request import urlopen from bs4 import BeautifulSoup import ssl import re # Ignore SSL certificate errors ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE url = input('Enter - ') html = urlopen(url, context=ctx).read() counter = 0 sum_lst = 0 # html.parser is th...
ee8b3ace84ee4cf1ba0b1c9da5f12ba2c6da6651
hiimbex/DiscreteMathematics
/bex_warner_discrete_hw1.py
1,414
3.890625
4
# Problem to solve: # Let R be the relation defined as follows: # R = {(m, n) ∈ Z × Z|0.5 ≤ |m/n| ≤ 1} # Write a Python function which takes an integer argument m and returns # a list consisting of exactly those integers n such that (m, n) ∈ R. isNotFinished = True print "This program will return to you the potential n...
3fc1a8c285a6ea0b857aa501d886b9a43f0ad922
hiimbex/DiscreteMathematics
/4digitcontaining7.py
220
3.546875
4
#How many 4 digit numbers contain a 7? def fourDigitNumsContainSeven (): count = 0 for x in range(1000, 9999): if "7" in str(x): count += 1 return count print fourDigitNumsContainSeven()
6fc7d166b357e4c0ae406866dce8c53ecc45a113
jaoist/pycc
/Dictionaries/6-6.py
612
4.34375
4
# Poll friends favorite languages. Create list of names. # If name does not have favorite language, # print a message saying that they should take the poll. favorite_languages = { 'jen' : 'python', 'sarah' : 'ruby', 'edward' : 'c', 'phil' : 'python', } friend_list = ['jackson', 'desmond', 'ruthe...
98faa0d157a5ace892219a8096c8512f0c593da8
jaoist/pycc
/Dictionaries/6-12.py
868
4.46875
4
# Cities dictionary. A dict inside of a dict. Extended formatting. cities = { 'amsterdam':{ 'country': 'netherlands', 'population': 851573, 'fact': 'is below sea level.', }, 'hiroshima':{ 'country': 'japan', 'population': 1196274, 'fact': 'is one of two c...
ef1b6c9fb161d854a8acfa0bb041d7248dc3d089
jaoist/pycc
/Classes/9-1.py
566
3.875
4
class Restaurant(): """Model of a restaurant that has two methods.""" def __init__(self, name, cuisine_type): self.name = name self.cuisine_type = cuisine_type def describe_restaurant(self): print(self.name.capitalize() + " serves " + self.cuisine_type.title()) def open_restau...
5e413837d54186013eba754f0355183aba30c3c9
jaoist/pycc
/Classes/9-3.py
1,088
4
4
class User(): """Create a profile for a user.""" def __init__(self, first_name, last_name, age, gender, location, occupation): self.first_name = first_name self.last_name = last_name self.age = age self.gender = gender self.location = location self.occupation...
28c36e03a454146535cbb08274f7c21997d6a15a
jaoist/pycc
/Dictionaries/6-2.py
302
3.6875
4
favNums = { 'ken':[12,24,66], 'jackson':[34,890,7], 'tim':[44444,8609834,90923409], 'harrison':[1,2,3,4], 'peanut':[42,0.07], } for name, numbers in favNums.items(): print(name.title() + " likes these numbers:") for number in numbers: print(" # " + str(number))
77fbea39c08d07080c7c5e6b7ed93047fd8db154
cordell-charles/Battleships
/test_battleships.py
19,768
3.78125
4
import pytest from battleships import * # Ship representation - (row, column, horizontal, length, hits) # Fleet - The fleet consists of 10 ships. The fleet is made up of 4 different types of ships, each of different size as follows: One battleship (4 squares), Two cruisers (3 squares), Three destroyers (2 squar...