blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ed878f5c85a164124b98a12df55e0d462592b4dd
marco-c/gecko-dev-wordified
/third_party/python/rsa/rsa/prime.py
4,222
3.53125
4
# - * - coding : utf - 8 - * - # # Copyright 2011 Sybren A . St vel < sybren stuvel . eu > # # Licensed under the Apache License Version 2 . 0 ( the " License " ) ; # you may not use this file except in compliance with the License . # You may obtain a copy of the License at # # http : / / www . apache . org / licenses ...
0e86fc33e75f4301bf4d52192b434c25cda7ad80
hackingmath/challenges
/LeetCode/star.py
655
3.625
4
from itertools import combinations def lowest(a,b): if a == 0 or b == 0: return True if a / b not in [1,-1]: print(a,b) return False return True def align(arr): pairs = 0 for pair in combinations(arr,2): x,y = pair[0][0]-pair[1][0],pair[0][1]-pair[1][1]...
13cd737b8f9a3ec99760e9e3dd5aa54e29e56764
ebyau/guessing-game
/assignment.py
1,880
3.890625
4
import random def play_mind_game(): first_list = list(range(10)) random.shuffle(first_list) digits = (first_list[:3]) print(digits) lives = 5 while True: entry = input("hello there! please any 3 digit number") present = [] c = 0 lives -= 1 ...
3d249105e59c988599324efca69b1dd98550c8c5
Brice-76/ATP13
/Ex2.py
4,524
3.859375
4
from Ex1 import Node class BinaryTree : def __init__(self,root): self.__root=root def get_root(self): return self.__root def is_root(self,node): if self.__root == node : return True else : return False def size(self,node): if node == ...
4b492c9902354b4371a1ee168543f1438cda4f3e
logansdmi/spikeinterface
/spikeinterface/core/default_folders.py
2,096
3.640625
4
""" 'global_tmp_folder' is a variable that is generated or can be set manually. It is useful when we do extractor.save(name='name'). """ import tempfile from pathlib import Path ######################################## global temp_folder global temp_folder_set base = Path(tempfile.gettempdir()) / 'spikeinterface_ca...
ea815b7a6e6aad69da00092c48c48fa7451ee32a
citlali-trigos-raczkowski/introduction-to-computer-science
/6.0002/1-space-cows-transportation/ps1b.py
1,851
4.1875
4
########################### # 6.0002 Problem Set 1b: Space Change # Name: Citlali Trigos # Collaborators: none # Date: 6/12/20 #================================ # Part B: Golden Eggs #================================ # Problem 1 def dp_make_weight(egg_weights, target_weight): """ Find number of e...
fec727642786580aabe819885b6f39ae7ce0a6ad
yangyuebfsu/ds_study
/leetcode_practice/1299.py
637
3.953125
4
*** 1299. Replace Elements with Greatest Element on Right Side Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. Example 1: Input: arr = [17,18,5,4,6,1] Output: [18...
fc1ce82c733f668d03dcf98c65d1a62202f07f93
simyy/leetcode
/binary-tree-inorder-traversal.py
877
3.953125
4
# -*- coding: utf-8 -*- # https://leetcode.com/problems/binary-tree-inorder-traversal/ # 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 inorderTraversal(self, root): ...
b870496805ba1603bbdc2de2ef27f8693f915591
webclinic017/dyno
/src/strategies/random_trader.py
3,666
3.640625
4
import numpy as np import pandas as pd import Quandl # Necessary for obtaining financial data easily from backtest import Strategy, Portfolio class RandomForecastingStrategy(Strategy): """Derives from Strategy to produce a set of signals that are randomly generated long/shorts. Clearly a nonsensical str...
2aec4b785ee783cb24eec47483895334f3fceca2
jimmyjwu/chest_X-ray_diagnosis
/model/net.py
7,630
3.5
4
"""Defines the neural network, losss function and metrics""" import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torchvision from sklearn.metrics import roc_auc_score class DenseNet169(nn.Module): """ The DenseNet169 model, with the classification layer modified to ou...
9fa9db3f12304c14849dc96d485b45cd3ba77658
1914866205/python
/pythontest/day41数学内置函数.py
634
3.859375
4
""" 数学内置函数 """, 10 # 长度 dic = {'a': 1, 'b': 3} print(len(dic)) a = [{'name': 'xiaoming', 'age': 18, 'gender': 'male'}, {'name': 'xiaohong', 'age': 19, 'gender': 'female'}] # 最大值 print(max(a, key=lambda x: x['age'])) # pow(x,y,z=Nome,/) x为底的y次幂,如果有z,取余 print(pow(3, 2, 4)) # 四舍五入,第二个参数代表小数点后保留几位 print(round(3.141592...
eb30300767e2d0229d38f0d4a5fba27989f670bd
acheney/python-labs
/lab01/trobertson/fancy.py
335
3.96875
4
# fancy.py # Asks the user for their first, last, and nickname, then welcomes the user # # Tyler Robertson # January 4, 2013 def main() : first = input("Enter your first name: ") last = input("Enter your last name: ") nick = input("Enter your nickname: ") print("Welcome back, ",first," \"",nick,"\" ",l...
dc814f401d6b589c35bbc21600e66e041ad97273
Shorokhov-A/repo-algorithms_python
/lesson_3/task_3_5.py
736
4.0625
4
numbers = (5, -5, -18, -10, 0, 5, 12, -3, -11, -19, -7, -3) print(numbers) negative_els = [] for item in numbers: if item < 0: negative_els.append(item) if negative_els: max_negative_el = negative_els[0] for item in negative_els: if item > max_negative_el: max_negative_el = item...
ac9eedd9f99dc895c4a6d6e460926830c7f2604a
gesmith19/mit
/ProblemSet6/ps6recur1.py
459
4.4375
4
def reverseString(aStr): """ Given a string, recursively returns a reversed copy of the string. For example, if the string is 'abc', the function returns 'cba'. The only string operations you are allowed to use are indexing, slicing, and concatenation. aStr: a string returns: a reversed...
60888df318772a1f4ee2fd56764df45aa8d61acb
abespitalny/CodingPuzzles
/Leetcode/reverse_integer.py
504
3.796875
4
def reverse(x: int) -> int: is_negative = False if x < 0: is_negative = True x = -x ans = 0 while x > 0: last_digit = x % 10 x //= 10 ans = (ans * 10) + last_digit if is_negative: ans = -ans # Checks if the answer overflowed the bounds of a 32...
df3c88934a316d3aa6f28970a31ed2475eb9d4de
D-Girouard/mycode
/challenge1.py
241
3.609375
4
#!/usr/bin/env name= input ("STATE YOUR NAME SUCKA:") date= input ("WHAT DAY IS IT SUCKA:") color= input ("WHAT'S YOUR FAVORITE COLOR SUCKA: ") print ("HELLO, " + name + " happy " +date, "SUCKA!!!") print ("ALSO...." + color + " SUCKS!! ")
417ed556bd7460a78f2d238df3770b786bc95a6f
simonava5/Programming-and-Scripting-Assignments
/projecteuler5.py
373
3.609375
4
# Simona Vasiliauskaite # 02/03/2018 # Project Euler 5 # Exercise 5 # What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? i = 1 for x in (range(2, 21)): # all the numbers from 2 to 20 if i % x > 0: # test if the remainder of i is more than 0 for n in range(2, 21): ...
603ad3aa3fa3bbe327341aec70bd20fe9780eb09
HarsimratKM/python
/Assignment 1/versionControl.py
11,752
4
4
#versioncontrol.py # Author: Harsimrat Kaur # Last Modified by: Hrsimrat Kaur #Date last Modified: 23rd May 2013 #Program description: older version of the game #VERSION 0: #This version had only 2 decision level and no story, was built up using the dragon.py import time def displayIntro(): print ('You are stuck...
980168a00cc927abaa31dcf6e436814ed49e4dae
Pebaz/coding-problems
/py/10-11-19.py
1,167
3.90625
4
def show_matrix(matrix): for row in matrix: print(('{:<3}' * len(row)).format(*row)) def create_matrix(length): fill = iter(range(length ** 2 + 1)) return [ [next(fill) for i in range(length)] for i in range(length) ] def rotate_matrix(m): print('Before:') show_matrix(m...
3d5213329f4a1ce202fd13f399bf132cc1b4bae5
wenmengqiang/learn-python-the-hard-way
/ex24.py
899
3.828125
4
#encoding:utf-8 print "Let's practise everything." print 'You\' d need to know \'bout escape with \\ that do \n newlines and \t tabs.' poem =""" \t The lovely world with magic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires an explanation \n\twhere there is none....
04752e57b8035c274f67e4f4d4ef8179251d4bc3
chrislevn/Coding-Challenges
/Orange/KMP/Text_Editor.py
2,039
3.515625
4
def KMP_preprocess(p, prefix): """ Preprocess function for KMP algoritm Args: p (str): pattern string prefix (list): output prefix """ prefix[0] = 0 m = len(p) Len = 0 i = 1 while i < m: if p[i] == p[Len]: Len += 1 ...
b2921283d2ad1ee3329c81dfc14512f7b0808823
kameron-mcadams/Money-Counter
/money_counter.py
631
3.8125
4
pennies = int(input("How many pennies do you have?")) nickels = int(input("How many nickels do you have?")) dimes = int(input("How many dimes do you have?")) quarters = int(input("How many quarters do you have?")) halfDollars = int(input("How many half dollars do you have?")) dollars = int(input("How many dollars do yo...
49e085c948960fce6a0a35acb72c87bb370e2c5a
RubyJing/100DaysStudy
/Day01-15/Day07/tuple_test.py
1,411
3.796875
4
import sys """ 使用元组: 与列表类似,也是一种容器数据类型,可以用一个变量(对象)来存数多个数据 不同点:元组的数据不能被修改 """ # 定义元组 t = ('今天', 7, True, 14.40) print(t) # 获取元组中的元素 print(t[0]) # 今天 print(t[3]) # 14.4 # 遍历元组中的值 for member in t: print(member, end=',') # 今天,7,True,14.4 print() # 重新给元组赋值 # t[0] = '罗云熙' # TypeError: 'tuple' object does not support...
752dca251b3d236b2b7141e7cf5b8d8be465b162
KillToTheReal/Algorithms
/Sorting_algorithms/radix_sort.py
1,154
3.828125
4
def radix_sort(arr, decimal_places=2): counts = [0] * 10 len_arr = len(arr) # sort loop for step in range(decimal_places): temp_arr = [0] * len_arr print("Step",step) for item in arr: last_num = check_number(item, step) counts[last_num] += 1 # compute prefix sum for i in ra...
ccde22affe7f01bff4b8d72e6d759c066b096230
INTO-CPS-Association/mono-camera-robot-tracking
/Code/Models/SquareModels.py
1,744
3.53125
4
class RobotSquare: def __init__(self, square, distance = None, angle = None, id = None): self._square = square self._angle = angle self._distance = distance self._id = id self._corners = None self._center = None self._setup(square) def _setup(self, square...
27533f13e2b008478c40892f4ce47d917a02ec84
Vampirskiy/Algoritms_python
/unit3/Task 2.py
654
4.1875
4
# Task 2 # Во втором массиве сохранить индексы четных элементов первого массива. Например, если дан массив со значениями 8, 3, 15, 6, 4, 2, второй массив надо заполнить значениями 0, 3, 4, 5, (индексация начинается с нуля), т.к. именно в этих позициях первого массива стоят четные числа. A = [8, 3, 15, 6, 4, 2] B = [] ...
ee2a267d0436551970b4bddede6a6296c7f422b8
j-vieira/AlgoritmosED
/python/lista1/exercicio3.py
135
3.65625
4
a = 5 #int print(a) a = 1 or 0 #boolean print(a) a = "a" #char print(a) a = 65/13*4+1 #float print(a) a = "teste" #string print(a)
c3e36b996fe37a864ab6d24f5c9b2f868a287c73
fo5u/basics-of-python
/7_classes_objects.py
1,692
4.21875
4
class PersonalInfo: def __init__(self): self.name = 'Alex' self.age = 25 self.grades = (44, 55, 66) def total(self): return sum(self.grades) / len(self.grades) student = PersonalInfo() print(student.name) print(student.age) print(student.grades) print(student.total()) # Or yo...
8eb9c255d19a7a2afd0e48e8be3e6b0e45c81f5d
RodolpheBeloncle/100-days-Python
/tip-calculator-start.py
832
4.125
4
print("Welcome to the tip Calculator") bill = input("What was the total bill ?: ") billStringToFloat = float(bill) #-------------------------------- amountOfTips = input("What percentage of tips would you like to give ? 10 ,12 or 15 : ") amountOfTipsStringToFloat = int(amountOfTips) #-----------------------------...
4ce1533c8ab87fec1721d0d38c56c2e5bb9dc6d0
disaisoft/python-course
/project3/app.py
247
3.5625
4
from datetime import date from datetime import datetime #obtener la fecha actual. d = date.today() d.strftime("/%d/%m/%y") print(d) # obtener la fecha con el dia, mes, ano y la hora dt=datetime.now() dt.strftime("%A %d/%B/%y %H:%M:%S") print(dt)
864030d847c54e999486b41afe7e9e8f2fc0779c
daniel-reich/ubiquitous-fiesta
/suhHcPgaKdb9YCrve_18.py
276
4.21875
4
def even_or_odd(s): even = sum(int(i) for i in s if int(i) % 2 ==0); odd = sum(int(i) for i in s if int(i) % 2 ==1); if even == odd: return 'Even and Odd are the same'; elif odd > even: return "Odd is greater than Even"; return "Even is greater than Odd";
51dcb075e822e2bd48740ec10f22d9b3e304275e
matheusforlan/TST-P1
/afinidademusical/afinidade.py
404
3.53125
4
#coding:utf-8 def meu_in(elemento,sequencia): for e in sequencia: if e == elemento: return True return False def tem_afinidade(l1, l2): afinidade = 0 for c in range(len(l1)): if meu_in(l1[c],l2): afinidade += 1 if afinidade >= 3: return True return False l1 = ['zeze', 'bruno e marrone', 'joao...
d518d89261e9c4f8277e3521f7bef923d66b7c9b
SmischenkoB/campus_2018_python
/Yurii_Smazhnyi/3/PokerHands.py
4,522
3.671875
4
suits = ("H", "D", "C", "S") cards = ("2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A") categories = ("Straight Flush", "Four of a kind", "Full house", "Flush", "Straight", "Three of a kind", "Two pair", "One Pair", "High card") def is...
3656caba1f6f20699e14a45bf773df9ac80fa25a
Rushin95/LeetCode_Practice
/binary_tree_right_side_view.py
958
3.734375
4
# 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 rightSideView(self, root): """ :type root: TreeNode :rtype: List[int] """ an...
02f70db5315d3417e2e43881d15febf87550bfc4
dheredia19/COMP-SCIENCE
/guess.py
436
3.953125
4
import random mine = random.randint(1,10) print("Guess my number, or not. I don't care...") def goback(): guess = int(input()) if guess == mine: print("Wow, smartypants, you did it. Now go away.") quit() else: print("Wrong! Of course you're wrong. I'm not surprised.") if guess < mine: print("Hint: my n...
41bb47b99b047e4d1d64a4327567a5b2a35db73f
shincap8/holbertonschool-machine_learning
/math/0x04-convolutions_and_pooling/6-pool.py
1,780
3.96875
4
#!/usr/bin/env python3 """Function that performs pooling on images""" import numpy as np def pool(images, kernel_shape, stride, mode='max'): """Performs a convolution on images using multiple kernels Args: images: `numpy.ndarray` with shape (m, h, w) containing multiple grayscale images ...
033885210ef9177f6fa5f3d09d884351478da0e3
AlexisGrolleau/TP13
/Exercice2.py
1,504
3.859375
4
from Exercice1 import * class BinaryTree: def __init__(self,root): self.__root = root def getRoot(self): return self.__root def isRoot(self,Node): if Node == self.__root: return True else: return False def size(self, node): if node is None: ...
3fb9a3a0fe1be1406a7637138a31955bb46ea3ec
mulder974/Escape-Game
/Programme_de_trad.py
2,290
3.84375
4
def decode_alien(): m=input("Saisissez la phrase à traduire: ") dict_alien_fr = { '.':'.', '!':'!', '?':'?', ',':',', '': '', '__': ' ', '/\\' : 'a', ']3': 'b', '(': 'c', '|)': 'd', '[-': 'e', '/=': 'f', '(_,': 'g', '|-|': 'h', '|': 'i', '_T': 'j',...
c54b48c5c6ecd38c87842e7e854874277eab584d
quando110704/DoHongQuan-C4T-HDT-B10
/session7/liSt.py
147
3.671875
4
items = ['com', 'pho', 'chao'] print(items) items.append('coca') print(items) new_items = input("new items: ") items.append(new_items) print(items)
b06fbff99e9c78a18fcdaf07fb9f9126e371f781
Ran1s/mvc-proj
/View.py
990
3.609375
4
class View: def __init__(self): pass # def __init__(self, controller): # self.controller = controller def set_controller(self, controller): self.controller = controller def print_question(self): print(self.current_question.value) def print_unkown_command(self, com...
6617eef3b62b07baf4a4260cbdf62f654ab9e46c
greenfox-zerda-lasers/matheb
/week-03/day-3/08.py
1,293
4.03125
4
# Create a new class called `Person` that has a first_name and a last_name (takes it in it's constructor) # It should have a `greet` method that prints it's full name # Create a `Student` class that is the child class of `Person` # it should have a method to add grades # it should have a `salute` method that prints it...
74af2cc01693f1c3d663aef4432ecaccbef8bc22
muhiqsimui/MatematikaGkAsik
/fibonaci.py
395
4.03125
4
#fibonaci # OLD CODE NOT GOOD TO SLOW def fibonaci(n): a,b = 0,1 while a<n: print(a, end=' ') a,b=b,a+b print() fibonaci(100) # THIS IS BETTER VERY FAST LIKE USAIN BOLTZ I RECOMENDED TO YOU TRUST ME XD USE TO YOUR PROJECT def fibonacci(num): if (num <= 1): return...
0eab7ff439d8d9659f0ff076b44a28d84bb91c4a
faizan2sheikh/PythonPracticeSets
/Sem2Set3/Q4.py
1,932
4.0625
4
class Publication: title:str price:float def __init__(self,title,price): self.title=str(title) self.price=float(price) def get_data(self): self.title=str(input('Enter title: ')) self.price=float(input('Enter price: ')) def put_data(self): pri...
e44a55b280967a49308faaa3127dee8c0107babc
kpranjal2047/Cryptography-Assignment
/Assignment 2/Main.py
6,375
3.671875
4
## Cryptography Assignment 2 ## Implementation of BlockChain ## Created by-- ## Kumar Pranjal - 2018A7PS0163H ## Yash Arora - 2018A4PS0002H ## Abhik Santra - 2018A8PS0612H ## Ayush Singh Chauhan - 2018B4PS0818H import pickle from os.path import exists from Block import Block from Record import Record from User import...
9c7828f5406ee99defc76121cfe922051c947e48
sergiiop/PlatziCodingChallenge
/dia12_next_birthday.py
727
4.25
4
from datetime import datetime, date def calculator(date_birthday): now = date.today() next_date_birth = date(now.year, date_birthday.month, date_birthday.day) if next_date_birth < now: next_date_birth = date( now.year + 1, date_birthday.month, date_birthday.day) missing = next_date...
799502c12d8392b5828d271db9b02c6a614db5bb
JHyuk2/Hyuk2Coding
/SWAG/IM/list1/4831_전기버스.py
588
3.53125
4
''' input value 3 3 10 5 1 3 5 7 9 3 10 5 1 3 7 8 9 5 20 5 4 7 9 14 17 ''' def longest_way(pos, steps): if pos + k >= n: return steps tmp_list = [i+pos for i in range(k, 0, -1)] # 갈 수 있는 모든 거리 for d in tmp_list: if d in station_list: return longest_way(d, steps+1) else: ...
068e9a2c5e7142e77e34d719d6342223b98552c6
MishinK/Django_pool
/d01/ex05/all_in.py
1,381
3.796875
4
#coding=utf8 import sys def get_key(d, val): for k, v in d.items(): if v.lower() == val.lower(): return k def get_val(d, key): for k, v in d.items(): if k.lower() == key.lower(): return v def capital_city(state): states = { "Oregon" : "OR", "Alabama" : "AL", ...
fbfddc5dd86f7b97fca224a17635c08ea7383036
Luxios22/RSA
/RSA.py
2,121
3.828125
4
import random # compute gcd # gcd(a,b)=gcd(b, a%b) def gcd(a, b): if b == 0: return a return gcd(b, a % b) if a % b else b def is_prime(n): """Primality test using 6k+-1 optimization.""" if n <= 3: return n > 1 if n % 2 == 0 or n % 3 == 0: return False i = 5 while i...
8cc701c29f54bc48c53083b5beea3a9daa384cde
Candy-Robot/python
/基本语法学习/类和对象.py
825
3.59375
4
""" class Person(): name = '小甲鱼' def print_name(self): print(self.name) p = Person() p.print_name() class Juzheng(): def setRect(self,length,width): self.length = length self.width = width def getRect(self): print(self.length) print(self.width) def getArea(...
92aeaaa4e24d5cc3c393c44ea7cfe4095eeba18e
AjayKarki/DWIT_Training
/Week2/Day7/Count_chars.py
230
3.75
4
user_input = input("Enter any word") count_dict = dict() for ch in user_input: if ch not in count_dict.keys(): count_dict[ch] = 1 else: count_dict[ch] += 1 print(count_dict) # print(user_input.count('p'))/
2755c642ddf1bb758bd9f81c12b9f65aa14fa00d
JuanluOnieva/pyCDI
/cdi/Analysis.py
3,594
3.59375
4
""" This script contains the necessary functions to deal with the data, obtain data frame and show some graphics """ import matplotlib.pyplot as plt from pyspark.sql import DataFrame from pyspark.sql.utils import AnalysisException from py4j.protocol import Py4JError import pandas as pb def get_data_frame_count_type_...
a3e0df83439768b6b7e81c02170bb1e94e7cbf33
NIAN-EVEN/SUSTC-CSE5018-AOA
/genetic_algorithm.py
6,545
3.5625
4
import copy from local_search import * import numpy as np ''' 单独存储一个list记录每一代最好的个体,每一代结束后都进行一遍localsearch 群体的iterative local search, 就是演化算法 ''' def selections(num, combinations): seletedGroup = [] # 轮盘赌方法 sum = 0 scores = [] total = 0 newCombination = [] for combi in combinations: s...
b16199e31669a439c25278df234a8310dfc0dba9
saltafossi/lego_dimensions_protocol
/checksum/verify_nfc_checksums.py
3,186
3.671875
4
#------------------------------------------------------------------------------- # Name: module2 # Purpose: # # Author: User # # Created: 23/11/2015 # Copyright: (c) User 2015 # Licence: <your licence> #------------------------------------------------------------------------------- import os def...
6f07bcca69bafd2a27fcfca940c3dfedd796479e
bandofcs/boilerplate-arithmetic-formatter
/arithmetic_arranger.py
5,491
3.890625
4
import re #Enable checking by printing to console DEBUG= False def arithmetic_arranger(problems, count=None): #Variables definition #To be printed out firstrow=list() secondrow=list() thirdrow=list() forthrow=list() #Length of each operand firstlen=0 secondlen=0 thirdlen=0 m...
7bf551528806430c66326b578d95fd96dfee6189
Camille-Arsac/python
/dog/dog.py
418
3.515625
4
class Dog: def __init__(self, name, age, owner, trick): self.name = name self.age = age self.owner = owner self.trick = trick def learn(self, trick): self.trick.append(trick) def same_trick(self, dog): same_tricks = [] for trick in self.trick: ...
4d28d079222049a3f52650423ec9e93ab6e8bd5c
Bhargavi0326/Python-Strings
/print sorted list.py
74
3.609375
4
S=input() li=S.split() A=sorted(li) for i in A: print(i,end=" ")
dfa70c585b7dd60f8076cd5656bec1efeb9485f4
jyu197/comp_sci_101
/apt7/GreenIndexes.py
307
3.625
4
''' Created on Nov 4, 2015 @author: Jonathan ''' def green(pixels): greens = [] for pixel in pixels: values = pixel.split(",") if int(values[1]) > int(values[0]) + int(values[2]): greens.append(pixels.index(pixel)) return greens if __name__ == '__main__': pass
26b27dd776d9f454418913dba250757e73fa0925
sarahkittyy/Functional2
/interpreter/clean.py
398
3.515625
4
import re def removeSpaces(line): depth = False ret = "" for char in line: if char in ['"', "'"]: depth = not depth if depth: ret += char elif not depth and re.match('\\s', char) == None: ret += char return ret def clean(lines): cleaned = [] for line in lines: line = removeSpaces(line) line =...
2bb99930cd03e5deee78aca5029d7ac6342a6dc2
quzeyang/quzheyang
/rpsls.py
1,392
3.953125
4
#coding:gbk """ һСĿRock-paper-scissors-lizard-Spock ߣ ڣ2019/11/20 """ import random # 0 - ʯͷ # 1 - ʷ # 2 - ֽ # 3 - # 4 - # ΪϷҪõԶ庯 def name_to_number(name): if name=="ʯͷ": return 0 if name=="ʷ": return 1 if name=="": return 2 if name=="": return 3 if name=="": return 4...
fff327735a9d699d9bc2769d9d51e00107c07d00
manishbalyan/python
/function.py
134
3.71875
4
def square(number): sqr_num = number **2 return sqr_num input_num = 5 output_num = square(input_num) print output_num
2f49c988d058480c409d3a3ca6a37bc5f99e8b74
rafaelperazzo/programacao-web
/moodledata/vpl_data/63/usersdata/245/31962/submittedfiles/swamee.py
240
3.609375
4
# -*- coding: utf-8 -*- import math f=float(input('Digite o valor de f:')) l=float(input('Digite o valor de l:')) q=float(input('Digite o valor de q:')) dh=float(input('Digite o valor de Delta h:')) v=float(input('Digite o valor de teta:'))
24509cba69187ad590ce53c9cd6f9df859366b13
bakaInc/AppliedPythonAtom
/homeworks/homework_01/hw1_det.py
940
3.71875
4
#!/usr/bin/env python # coding: utf-8 ''' Метод, считающий детерминант входной матрицы, если это возможно, если невозможно, то возвращается None Гарантируется, что в матрице float :param list_of_lists: список списков - исходная матрица :return: значение определителя или None ''' def calculate_determinant(list_of_lis...
d59def2d5703464933f43543c8e881b618b97a44
MinaPecheux/Advent-Of-Code
/2015/Python/day9.py
2,881
3.671875
4
### ============================================= ### [ ADVENT OF CODE ] (https://adventofcode.com) ### 2015 - Mina Pêcheux: Python version ### --------------------------------------------- ### Day 9: All in a Single Night ### ============================================= from networkx import Graph, all_simple_paths #...
6b0498f1a6db6f514f48dd510439998135d98478
gomtinQQ/algorithm-python
/codeUp/codeUpBasic/1581.py
584
3.546875
4
''' 1581 : (함수 작성+포인터) swap 함수 만들기 (Call by Reference) 함수명 : myswap 매개 변수(parameter) : 정수형 포인터 변수 변수 2개(매개변수를 반드시 int∗로 사용) 반환 형(return type) : 없음(void) 함수 내용 : 첫 번째 포인터가 가리키는 변수의 값이 두 번째 포인터가 가리키는 변수의 값보다 클 경우 두 값을 서로 바꾼다. ''' def myswap(a, b): tmp = 0 if(a > b): tmp = a a = b b = tmp ...
8ba58f7b06f559d5c0129b021e54d8af65e0cb19
umyuu/Sample
/src/Python3/Q74082/list_rotate.py
647
3.9375
4
# -*- coding: utf-8 -*- from collections import deque def main(): n = int(input()) # ずらす個数 code = [1, 2, 3, 4] items = deque(code) print(items) items.rotate(n * -1) print(items) # dequeからlistに戻す code = list(items) print(code) def test(): n = int(input()) # ずらす個数 code = [1...
6b3683b6b1666261f589bd5180f2941e0203c566
Catalin-David/Expenses
/Expense.py
3,211
3.796875
4
class Expense: def __init__(self, day= 1, amount=0, tip=""): ''' Function initializes a new Expense params: day (default:1) - day of the expense (integer between 1-30) amount (default:0) - amount that is paid (integer) tip - type of expense/object that was pu...
df8d860662fe2981ab9c5a3f2a6d1fd83609a742
Jon-117/py.projects
/prime numbers.py
289
3.765625
4
high_n=float(input("prime numbers up to...")) num = 0 while True: num+=1 ''' numcheck=num % range(0,(high_n+1.0)) if numcheck.is_integer(): print(num) ''' print(num) ''' i=0 while True: False i+= 1 if i == ((i/i) and (i/1)) : print(i) '''
50c5ecb8740866a06db06ee7931e0a365f9dd26a
mlech456/pyp-w1-gw-language-detector
/language_detector/main.py
730
3.953125
4
# -*- coding: utf-8 -*- """This is the entry point of the program.""" from languages import LANGUAGES def detect_language(text, languages=LANGUAGES): stats = {} #Creating a dynamic counter for language in languages: name = language['name'] stats[name] = 0 fo...
f633fae18296eba731f7153ac4f823c8c57aa80c
kaw19/python
/notebooks/1_Basic/pedra_papel_tesoura.py
2,023
3.8125
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 13 22:16:26 2019 @author: kaw """ import random # Mostra instruções print("Regras do jogo Pedra, papel e tesoura: \n" + "Pedra X Papel -> Papel vence\n" + "Pedra X Tesoura -> Pedra vence\n" + "Papel X Tesoura -> Tesoura vence\n") while Tru...
23816b7f972b2a249beff3c4b9335ad7088ad711
CppChan/Leetcode
/medium/mediumCode/c/sumo_logic/putandget.py
771
3.765625
4
class Solution(object): dic = {} def __init__(self, name, year, location): self.dic[(name,year)] = location def put(self, name, year, location): self.dic[(name,year)] = location def getyear(self, name, year): if (name, year) not in self.dic: closest,itemlist,res = f...
5d641e0bc03aef8011f601d248bb557e4cd8d45c
stewSquared/project-euler
/p037.py
870
3.640625
4
from math import sqrt from itertools import count, islice def primesUntil(n): composite = [False for _ in range(n)] for m in range(2, int(sqrt(n))): if not composite[m]: for i in range(m**2, n, m): composite[i] = True return [i for (i, m) in enumerate(composite) if (not ...
d99e2e27d661525743a8611a9fd2dc061acc2d53
silkyg/python-practice
/Assignment_2_Decision_Control/Check_year_is_leapyear.py
278
4.3125
4
#Program to check whether the year is a leap year or not year=int(input("Enter a valid year :")) if year%4==0 : print("%d is a Leap year"%year ) elif year % 400 == 0 and year % 100 != 0: print("%d is a Leap year" % year) else : print("%d is a not a Leap year"%year )
52c917a8c59b119bb4ca3b2617371b2f242dd17c
captain-crumbs/websniff
/websniff.py
357
3.703125
4
import urllib import argparse parser = argparse.ArgumentParser() parser.add_argument("url", help="The URL of the site to be image sniffed") args = parser.parse_args() print args.url # We get a file-like object at the specified url f = urllib.urlopen(args.url); # Read from the object and store the contents of the page ...
d81c068a0f3fdf07017ba919ad5094de9357d52a
darwin-nam/python-algorithm
/codeup/6070.py
273
4.25
4
month = input() month = int(month) if(month==1 or month==2 or month==12) : print("winter") elif(3<=month and month<6) : print("spring") elif(6<=month and month<9) : print("summer") elif(9<=month and month<12) : print("fall") else : print("input a number between 1 to 12")
abaac9afe461023d1ad515e3f3a0b3aaccc2cc74
dbsgh9932/TIL
/variable/03_variable_ex1.py
427
3.6875
4
name='홍길동' no=2016001 year=4 grade='A' average=93.5 level=10 print('성명 :',name) print('학번 : '+str(no)) print('학년 : '+str(year)) print('학점 :',grade) print('평균 : '+str(average)) # 포맷코드 사용 (%표시는 %%(그 자체를 표기)) print('성명 : %s'%name) print('학번 : %d'%no) print('학년 : %d'%year) print('학점 : %c'%grade) print('평균 : %.1f'%average...
bfbd51a9400a8ac12f3beea0960d653d09b70034
woodjb/ISAT252
/Hangman.py
607
3.921875
4
import random answerlist = ["python","benton","computer","class","javascript","JMU","ISAT",] random.shuffle(answerlist) answer = list(answerlist[0]) display = [] display.extend(answer) for i in range(len(display)): display[i] = "_" print("The topic is: 252\n") print (' '.join(display)) print () count = 0 w...
565ac8f2f1e65ec380daa250befa95ca6faa2a18
krikavap/python-kurz
/dedictvi.py
635
3.75
4
""" dedictvi.py algoritmus pro rozdělení majetku mezi libovolný počet potomků každý dostane stejnou částku + zůstane nerozdělený zbytek vstup: částka k rozdělení, počet potomků výstup: částka na jednoho potomka a výše nerozděleného zbytku """ castka = int(input("Zadej částku, která se bude rozdělovat: ")) potomci = ...
bbaded358226faa82713c0d5c7cb22cf51b34e36
srikanthpragada/PYTHON_29_OCT_2020
/demo/oop/isinstance_demo.py
155
3.65625
4
def add(n1, n2): if isinstance(n1, str): return int(n1) + int(n2) else: return n1 + n2 print(add(10, 20)) print(add("10", "20"))
039f1824df824286e318d58bd3ddf87243d72313
Aasthaengg/IBMdataset
/Python_codes/p02801/s823636358.py
143
3.734375
4
C = input() # 文字列と数値の変換 # ord('文字') / chr(数値) で変換できる ord_s = ord(C) chr_s = chr(ord_s + 1) print(chr_s)
7774254b9037273f5152349776869c0800468b87
kylemaa/Hackerrank
/LeetCode/top-k-frequence-elements.py
656
3.59375
4
import collections import heapq class Solution: def topKelements(self, nums, k): count = collections.defaultdict(int) for n in nums: count[n] += 1 heap = [] for key, v in count.items(): # heap push method heapq.heappush(heap, (v, key)) ...
b205116bf47669f70b54b28f582bfa35689542a4
JargonKnight/Intro-To-Graphics
/Final Project - Part A/0.1/level1.py
9,567
3.625
4
'''Author: Jesse Higgins Last Modified By: Jesse Higgins Date Last Modified: July 25th 2013 Program Description: Leapy is a fun little frogger game with unique levels and requires you to collect all the objects in that level in order to move on to the next. version 0.1...
cd001f45018cc03f10be76c316bb02aaa6d44899
csse120-201830/16-Exam2
/src/problem4.py
10,473
3.65625
4
""" Exam 2, problem 4. Authors: David Mutchler, Dave Fisher, Matt Boutell, Amanda Stouder, their colleagues and PUT_YOUR_NAME_HERE. April 2018. """ # TODO: 1. PUT YOUR NAME IN THE ABOVE LINE. import time import testing_helper def main(): """ Calls the TEST functions in this module. """ # ----...
4c1aa3500a1b7b27dcff8c5227bf07422226cc17
mrfaiz/distributed-system-ws20-21
/lab3/server/historires.py
802
3.515625
4
from threading import Lock from data import Data from utility import currrent_time_secs class Histories: def __init__(self): self.lock = Lock() self.history_list: [Data] = [] self.latest_history_entry_time = currrent_time_secs() ## Global static variable, common for all history objects ...
fa515d7e16764d27c37778c3a53c9f61da80d7cb
gusLopezC/Python-Curso
/21.decoradores.py
589
3.625
4
#decorador es una funcion que recibe una una #funciones y crea una funcion #A recibe como parametro B para poder crear C def decorado(valido): def fundecorado(func):#AyB def nueva_funcion(*args,**kwargs):#C print("Vamos a ejecutar la funcion") resultado = func(*args,**kwargs) ...
23c36e451cc88339364fa405d97f1b42fe0438c9
ljseok/PrimeNumebrAlgorithm
/ImprovePrimeNumebr.py
355
3.59375
4
import math def is_prime_number(x): # 소수 판별 함수 정의 for i in range(2,int(math.sqrt(x))+1): # 2부터 x의 제곱근 까지 모든 수를 확인한다 if x % i == 0: # 해당수로 나누어 떨어진다면 return False # 소수가 아님 return True # 소수 print(is_prime_number(4)) print(is_prime_number(17))
3918481af5f3142ef9b4b1658d731d5a5f082883
thomas-marcoux/assignments
/AI/red_planet/source/planet.py
642
3.625
4
import math import point class Planet(point.Point): def __init__(self, name, dist, mass, angle, vel): self.name = name self.mass = mass self.vel = vel super().__init__(dist, angle) def rotate(self, time): self.angle += self.vel * time self.setCartesianCoord() ...
bb66d3d91efca0c70547d9326c2a43f58df3a38b
ariprasathsakthivel/DataStructures
/Strings/CharacterReplace.py
1,086
3.921875
4
''' @Author: Ariprasath @Date: 2021-09-11 19:19:30 @Last Modified by: Ariprasath @Last Modified time: 2021-09-11 19:40:00 @Title : Replace a charater into $ ''' class Error(Exception): def __init__(self,message): super().__init__(self.message) class EmptyStringError(Error): def __init__(self): ...
001402f83d8943c13741c39eac07fe6a5fbb4420
nalssee/SICP
/eceval/syntax.py
312
3.703125
4
def is_self_evaluating(exp): """number, string, booleans """ return \ isinstance(exp, int) or isinstance(exp, float) \ or (isinstance(exp, str) and len(exp) >= 2 and exp[0] == '"' and exp[-1] == '"') \ or exp == 'true' or exp == 'false' def text_of_quotation(exp): pass
ebe673e043cdc5e9bc368ec9b75fe98f35631c3b
markuspettbor/fysproj
/numtools.py
3,503
3.75
4
import numpy as np # This is our code #some usefull things def integrate(func, t, teacher_is_strict = True): ''' Function for integration. Assumes func is a function that evaluates a numpy array of x-values. If teacher_is_strict is True, the midpoint method is used. If not, the built-in numpy trap...
bf597158843338a7d6ed6a71a83fcfac5e1f24f6
jmvazquezl/programacion
/Prácticas Phyton/P4/P4E5 - IMPORTE Y DIGA SI EL CAJERO LE PUEDE SACAR EL DINERO.py
1,128
3.53125
4
# JOSE MANUEL - P4E5 - IMPORTE EN EUROS Y DIGA SI EL CAJERO AUTOMATICO LE PUEDE # DAR DICHO IMPORTE UTILIZANDO EL MISMO BILLETE Y EL MÁS GRANDE importe = int(input("Introduce el importe que quieres sacar: ")) if (importe % 500 == 0): cantidad = importe // 500 print('', importe, 'el cajero te devuelve', cantid...
15433013a66e68e4d70586002e92e3aa865e1e20
mbartido/RNGSimulator
/minion.py
398
3.640625
4
# Minion class class minion: health = 0 name = "" def __init__(self, health, name): self.health = health self.name = name def __str__(self): return "(Name: " + str(self.name) + ", Health: " + str(self.health) + ")" def isDead(self): if (self.health == ...
52881a0fc55f4245088f4ce2578715ebe51063e8
wuxu1019/leetcode_sophia
/hard/heap/test_23_Merge_k_Sorted_Lists.py
906
4
4
""" Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2->3->4->4->5->6 """ # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self...
4f5db4f11fa3b70da64aee5b03653208b93a37d4
Ftoma123/100daysprograming
/day24.py
907
4.3125
4
#copy dictionary using copy() dict1 = { 'brand':'Ford', 'model':'Mustang', 'year':1934 } new_dict = dict1.copy() print(new_dict) #copy dictionary using dict() new_dict1 = dict(dict1) print(new_dict1) #Nested Dictionaries family_dict = { 'child1':{ 'name':'Noura', 'year':2000 }, ...
7dbb990d12c86424a130417b922782f4584916a8
leticiamchd/Curso-Em-Video---Python
/Desafio015.py
184
3.71875
4
dias = int(input('Quantos dias de aluguel do carro ? ')) km = float(input('Quantos km percorridos no total ? ')) print('O valor total do aluguel foi de R${}'.format(dias*60+km*0.15))
a4395b57140bbbc8355cae894bf8eef91f7ba94d
KaioPlandel/Estudos-Python-3
/livro/ex3.36.py
167
3.75
4
#crie uma função que abrevie o dia da semana mostrando apenas os 3 primeiras letras def abreviacao(st): return st[0:3].upper() print(abreviacao('terça feira'))
3c3d3401b92f68e8b58b5e09948ca25873a43a03
thehitmanranjan/Handwritten-Digit-Recognition
/Handwritten Digit Recognition.py
10,066
3.796875
4
#!/usr/bin/env python # coding: utf-8 # In[8]: import numpy as np import matplotlib.pyplot as plt #conda install -c conda-forge tensorflow #conda install -c anaconda keras or conda install -c anaconda keras or nothing from tensorflow import keras from keras.datasets.mnist import load_data # # 1. Load the Data...
121c6e3fae13a965fde294dcf69bac29da82df2e
Sinlawat/Laland
/BMI.py
1,544
3.65625
4
import math from tkinter import * def description(x): if x > 30: return "อ้วนมาก" elif x > 25 and x <= 30: return "อ้วน" elif x > 23 and x <= 25: return "น้ำหนักเกิน" elif x > 18.6 and x <= 23: return "ปกติ" elif x < 18.5: return "ผอมเกินไป" def LeftClickCal...
85733ff859a3d9b52996d023910d4c9cbcf9c823
lvoinescu/python-daily-training
/custom_alphabetical_order/main.py
2,532
4.21875
4
# Given a list of words, and an arbitrary alphabetical order, verify that the words # are in order of the alphabetical order. # # Example: # # Input: # words = ["abcd", "efgh"], order="zyxwvutsrqponmlkjihgfedcba" # # Output: False # # Explanation: 'e' comes before 'a' so 'efgh' should come before 'abcd' # # Example 2: ...
3aa6fcc0e32e26f1e3af55bb6d19a54fc6e80e30
9a24f0/USTH
/ML/lab1/petrol.py
1,033
3.59375
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn import metrics dataset = pd.read_csv("data/petrol_consumption.csv") print(dataset) X = dataset[['Petrol_tax', 'Aver...
12527b261943cc4df52b8c59398ccf26e3c58fea
Aludeku/Python-course-backup
/lista exercícios/PythonTeste/desafio090.py
479
3.84375
4
aluno = {} aluno['nome'] = str(input('Nome: ')) aluno['media'] = float(input(f'Média de {aluno["nome"]}: ')) if aluno['media'] >= 7: aluno['status'] = 'aprovado' elif 5 <= aluno['media'] <= 7: aluno['status'] = 'recuperação' else: aluno['status'] = 'reprovado' print('-=' * 20) print(f' -O nome é igual a {a...