blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
1bd1eee00210e861a7f4cc329e6298d978cf8ce4
lvrbanec/100DaysOfCode_Python
/Project08. Beginner, Blind bid decision/main.py
1,094
4.15625
4
# 03.02.21, Frollo # level: Beginner # project: Create a blind bid program from replit import clear from art import logo print(logo) # add a new bidder function bidder_info = [] # could be also saved as {name1: amount1, name2: amount2} def add_bidder_info(val_name, val_bid): new_bidder = {"name": val_name, "bid"...
07453d6cd3191a976c28147f7a4095e4c0bff300
AFishyOcean/py_unit_two
/age.py
161
3.84375
4
age =int(input('How old are you?')) old_age = (100 - age) year_of_age = (2021 + old_age) print('You will be 100 years old in', old_age, 'years in', year_of_age)
93798cd63ba8a244e6ef6039368b4ab053fd5816
alexnhan/CrackingTheCodingInterview
/Chapter1/rotateMatrix.py
429
4.03125
4
#!/usr/bin/python # Question 1.7 # ith row becomes N-1-ith column def rotateMatrix(mat,N): # create an empty matrix to hold rotated matrix newMat=[] for i in range(N): newMat.append(range(N)) # size newMat the same as mat for i in range(N): for j in range(N): newMat[j][N-1-i]=mat[i][j] return newMat if _...
71d2f68bb1c4866381b5bd1350e10ddff84b1200
Shirados9/MaschineLearningSS20
/src/explore/dictonaries/explore_dicts.py
203
3.515625
4
thisdict = { "brand": "Ford", "model": "Mustang", "year" : 1964 } print(type(thisdict.values())) print(thisdict.values()) values = thisdict.values() for x in thisdict.values(): print(x)
b5567628bd4f086980f68d366562471c6831ccfa
demar01/python
/Chapter_PyBites/180_Group_names_by_country/names.py
903
3.578125
4
from collections import defaultdict data = """last_name,first_name,country_code Watsham,Husain,ID Harrold,Alphonso,BR Apdell,Margo,CN Tomblings,Deerdre,RU Wasielewski,Sula,ID Jeffry,Rudolph,TD Brenston,Luke,SE Parrett,Ines,CN Braunle,Kermit,PL Halbard,Davie,CN""" def group_names_by_country(data: str = data) -> defaul...
f4fa3ecc341adce4c0e2c88f49537319eac38f6a
lreimer/fast-fibonacci
/src/test/polyglot/fibonacci.py
487
4.03125
4
print('Fibonacci in Python on GraalVM!') n = 42 def fibonacci(n): if n == 1: return 1 elif n == 2: return 1 else: return fibonacci(n-1) + fibonacci(n-2) def fibonacci_iter(n): if n == 1: return 1 elif n == 2: return 1 else: a = 1 b = 1 ...
624e6f5faeda1783ad359b70a85b31cf0aea2cd1
pintuiitbhi/Codechef
/JulyLongChallenge2018/NSA.py
2,640
3.75
4
T = int(input()) def partition(arr,low,high): i = ( low-1 ) # index of smaller element pivot = arr[high] # pivot for j in range(low , high): # If current element is smaller than or # equal to pivot if arr[j] <= pivot: # increment index of smaller elemen...
771329aa614d4765f709dea7a00095edaca4ed3f
appupratik/ADV_Python
/02-Assignment.py
2,718
3.59375
4
#Question 1 #The SHIELD is a secretive organization entrusted with the task of guarding the world against any disaster. Their arch nemesis is the organization called HYDRA. Unfortunately some members from HYDRA had infiltrated into the SHIELD camp. SHIELD needed to find out all these infiltrators to ensure that it was ...
9364772e75a94ec85ce7cec7869dd9029b82086c
TheThornBirds/pythonworker
/bases/tuple.py
695
4.34375
4
classmates = ('刘刘', '晨晨', 'charles') #tuple和list类似,但是tuple一旦初始化就不能修改 print(classmates) t = () #定义一个空的tuple t = (1,) #定义只有一个元素的tuple必须加一个逗号,消除歧义 print(t) t = ('a', 'b', ['A', 'B']) #"可变"的tuple,这里变得不是tuple的元素,而是list的元素。 t[2][0] = 'x' t[2][1] = 'y' print(t) #练习:用索引取出下面list的指定元素: # -*- coding: utf-8 -*- L = [ ...
1e68153a0856330398eb698c211b4ca5ea4d3b4f
akashvshroff/Puzzles_Challenges
/k_goodness_string.py
1,059
3.5625
4
def min_ops(n, k, s): """ Charles defines the goodness score of a string as the number of indices i such that Si≠SN−i+1 where 1≤i≤N/2 (1-indexed). For example, the string CABABC has a goodness score of 2 since S2≠S5 and S3≠S4. Charles gave Ada a string S of length N, consisting of uppercase letters...
6bd01ced108b9ea56ff11bcfd4bbcef37cab1dad
renanreyc/linguagem_python
/algoritmos/AeC/questao08.py
336
4.15625
4
#Python num = int(input("Informe um número inteiro: ")) while num < 0: num = int(input("Número inválido. Digite um número maior ou igual a 0: ")) #Função def fatorial(num): fatorial = 1 for i in range(num, 0, -1): fatorial *= i return fatorial print(f"\nO valor do fatorial de {num} é:",fatori...
3dd33013cb8c044e85b0a031a49cf34382cfc419
pondycrane/algorithms
/om_api/deck_of_cards/deck_of_cards.py
2,899
3.828125
4
import abc import collections import random import unittest class Card: def __init__(self, number, color, suit, folded=False): self.number = number self.color = color self.suit = suit self.folded = folded def fold(self): self.fold = not self.fold def __str__(self):...
b75a0ddb353a3f00bab4fb9f512e5c887b95c3fe
Henri-J-Norden/solve-system
/solve_system.py
3,784
3.53125
4
from fractions import Fraction def _div(l, divider, new=False): if new: ln = [] for i in range(len(l)): if new: ln.append(Fraction(l[i], divider)) else: l[i] = Fraction(l[i], divider) if new: return ln def _sub(l, lSub): for i in range(len(l)): ...
ae962928e6300ebf3fec6cb8626a18407e5e7a9a
kstulgys/coding-challenges
/leetcode/125/index.py
315
3.78125
4
import re def isPalindrome(s): s = re.sub(r'[\W_]', "", s).lower() left = 0 right = len(s) - 1 while left < right: if s[left] != s[right]: return False left += 1 right -= 1 return True test = 'A man, a plan, a canal: Panama' print(isPalindrome(test))
71409e651ae833aebbaa68b87be04a1ecc06c9a0
joseph-mutu/JianZhiOfferCodePics
/数组中重复的数字.py
1,031
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019-09-14 09:22:11 # @Author : mutudeh (josephmathone@gmail.com) # @Link : ${link} # @Version : $Id$ import os class Solution: # 利用额外的散列表寻找重复出现的数字 # def duplicate(self,numbers,duplication): # if not numbers: # return False # dupli_dic = {} # f...
005895eb599215870ff2432641ebaa7d5280941a
bigearsenal/test
/04_data_structures/task_4_2.py
356
3.53125
4
""" Задание 4.2 Преобразовать строку MAC из формата XXXX:XXXX:XXXX в формат XXXX.XXXX.XXXX Ограничение: Все задания надо выполнять используя только пройденные темы. MAC = 'AAAA:BBBB:CCCC'""" MAC = 'AAAA:BBBB:CCCC' print(MAC.replace(':', '.'))
b646db5680c422573657a009925c0820f8354c2f
Toofifty/project-euler
/python/006.py
606
3.734375
4
""" The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 - 385 = 264...
3896b2da8c8a8abc22fa82d977d982b1b8df81c1
luzlyherrera/Ejercicios-de-repaso
/Ejercicio92.py
3,919
3.84375
4
#Funcion que llena el arreglo con números aleatorios #Funcion que crea una copia original del arreglo #Funcion que muestra en pantalla en arreglo #Funcion de ordena por burbuja #Funcion de ordenar por seleccion #Funcion de ordenar por insercion #Funcion de ordenar por quirk-sort #Funcion que muestra un menú de ...
c4264cce2eb267cec68c407d485aaba71b49e1c8
smileyoung1993/pystudy
/mymod.py
430
3.609375
4
# mymod.ex # 내가 정의한 모듈 pi =3.14 def add(a,b): return a + b def subtract(a,b): return a - b def multiply(a,b): return a * b def divide(a,b): return a / b def main(): print("mymod testcode") print("add", add(10,20)) print("subtract", subtract(20,10)) if __name__ == "__main__": main...
04a08f5e12b72e5f4309a3f3490d9f1845ea456a
henrylin2008/Coding_Problems
/LeetCode/Easy/28_strStr.py
1,144
4.0625
4
# 28. Implement strStr() # Link: https://leetcode.com/problems/implement-strstr/ # # Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. # # Example 1: # # Input: haystack = "hello", needle = "ll" # Output: 2 # Example 2: # # Input: haystack = "aaaaa", needle = "bba"...
745f93b4d4320a2163222bb8837fb7d2ede15118
shourya192007/A-dance-of-python
/pandas_tutorial/1.Basics.py
818
4.25
4
import pandas as pd # creating a data frame titanic_data = pd.DataFrame( { "name":["Preyansh","Prerit","Doreamon"], "age":[11,11,24], "type":["Human","Human","Robo Cat"], "century":["21st","21st","22nd"], "specialPower":["coding","coding","gadgets"] } ) # print(titanic...
8877d866fe371f416f24cf323c96184371f746b3
dwildmark/aoc_2018
/06/code.py
2,589
3.828125
4
from collections import defaultdict import sys def parse_input_to_list(): output = [] with open("input.txt", "r") as file: for i, line in enumerate(file): x, y = line.split(", ") output.append(dict(x = int(x), y = int(y))) return output def manhattan_dist(point_a, point_b)...
2ceaf8371f5effa82ecd5e89c8f1ff0c5743da23
Minkov/python-advanced-2020-01
/comprehensions/2_vowels.py
132
4.15625
4
vowels = {'a', 'o', 'u', 'e', 'i'} text = input() result = [ch for ch in text if ch.lower() not in vowels] print(''.join(result))
7cc0ee3f5f318961ace74c111edc90d4227a5023
babichevko/proga_babichev_2021
/звёзды.py
220
3.578125
4
import turtle as t t.speed(5) def z(n): b=(n-2)*180/n a=180-b/3 for i in range(n): t.forward(100) t.left(a) z(5) t.penup() t.backward(150) t.pendown() z(11)
cce5d4db3ca6cd1079de84673613f86ba7faafc7
segmond/pythonThingz
/err_day_countdown/countdown.py
1,538
3.765625
4
#!/usr/bin/python import Tkinter as tk import time from datetime import datetime, timedelta ''' Count down to bed time, then count down to wake up time ''' class Countdown: def __init__(self): # create root/main window self.root = tk.Tk() self.time_str = tk.StringVar() label_font =...
ff2a343b4c550f6a78eb5ff343d39a847ff70f8a
mcauleyc/CA4015_Assignment_1
/Book/_build/jupyter_execute/clustering.py
17,666
3.90625
4
#!/usr/bin/env python # coding: utf-8 # # Cluster Analysis # # Cluster analysis or clustering is the task of grouping a set of objects in such a way that objects in the same group are more similar to each other than to those in other groups. # In[1]: import numpy as np import pandas as pd import statsmodels.api as...
a24522be5f97badb956590dccdec0731a0a69024
kapppa-joe/leetcode-practice
/daily/20201025-stone-game-IV.py
959
3.5
4
from functools import lru_cache from math import sqrt class Solution: def winnerSquareGame(self, n: int) -> bool: square_nums = [i * i for i in range(int(sqrt(n)), 0, -1)] @lru_cache(None) def can_win(i: int) -> bool: if i in square_nums: return True ...
77bebfd73388d0fc3e432a2784e5ef99c5e6aa4a
jsgiant/SDE-sheet-python
/1_find_the_duplicate.py
695
3.71875
4
# Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. def findTheDuplicate(nums): nums_len = len(nums) if nums_len > 1: # Find the intersection point of the two runners. slow = nums[0] fast = nums[nums[0]] while True: ...
0e5ef84ad4b36150a414456450533759c4ba6de5
jinglepp/python_cookbook
/07函数/07.07匿名函数捕获变量值.py
1,506
4.03125
4
# coding:utf-8 # 问题 # 你用lambda定义了一个匿名函数,并想在定义时捕获到某些变量的值。 # 解决方案 # 先看下下面代码的效果: x = 10 a = lambda y: x + y x = 20 b = lambda y: x + y print(a(10)) # 30 print(b(10)) # 30 # 这其中的奥妙在于lambda表达式中的x是一个自由变量, 在运行时绑定值,而不是定义时就绑定, # 这跟函数的默认值参数定义是不同的。因此,在调用这个lambda表达式的时候,x的值是执行时的值。例如: x = 15 print(a(10)) # 25 x = 3 print(a(10)...
3738d1ca4910d62feebe0e7f3cebfc94404c49cd
bljessica/machine-learning-practices
/studying-practices/gradient-descent.py
1,692
3.71875
4
import matplotlib.pyplot as plt import random #训练集 x_data = [1.0, 2.0, 3.0] y_data = [2.0, 4.0, 6.0] w = 1.0 #初始权重猜测 def forward(x): return x * w #梯度下降代价函数 def cost(xs, ys): cost = 0 for x, y in zip(x_data, y_data): cost += (forward(x) - y) ** 2 return cost / len(xs) #随机梯...
9655650d39dfc18d50e83de8adc24f75dcf34c76
wahello/physics
/backend/data/random_student.py
1,500
3.65625
4
from openpyxl import Workbook import random import string # 姓名 学校 年级 学号 专业 电话号码 电子邮箱 账号状态 major = ['物理','化学','英语','计算机','经管','人文','环境','土木','机械','设计'] mail = ['163','162'] status = [True,False] def random_phone(): head = ['139','188','185','136','155','135','158','151','152','153'] s = '0123456789' ret...
eeb9669ee0c15a5d7d4412b77e8011a4af4c0316
lionheartStark/sword_towards_offer
/leetcode/py36/最短无序连续子数组N581.py
714
3.625
4
from typing import List from typing import List class Solution: def my_findUnsortedSubarray(self, nums: List[int]) -> int: stack = [] n = len(nums) shixu = [] minx = float('INF') maxy = 0 for i in range(n): if stack == [] or nums[i] >= stack[-1][0]: ...
8ab66ebc8be0b313943cb9f2889c8400ec053581
saldanaj/CS325-Algorithms
/HW1/JoaquinSaldana_Question4FinalSubmission/mergesort.py
2,565
3.953125
4
#!/usr/bin/python # Student: Joaquin Saldana # Assignment: Homework 1 / Merge Sort program import string import io # Citation: the code for the merge_sort and the sort functions was borrowed from the # following site https://pythonandr.com/2015/07/05/the-merge-sort-python-code/ def merge(array1, array2): ...
f2efc4243b1b305b43cbd1fb583a8e5a0e684249
Oscar883/AprendiendoPython
/Conversiones.py
646
4.09375
4
#Declaramos variable str, con cadena de numeros. numero = "1234" #Se MUESTRA el tipo de variable , # type = da un dato type, no un str(<class 'str'>). print(type(numero)) #Convertimos la cadena a int. numero=int(numero) #Se MUESTRA como el tipo ha cambiado, #aunque se usa la misma variable (<class 'int'>). pri...
ca433b1c89660a13dfd6b81777e9e0297728a6f4
Esirn/Learning_Coding
/SUM(1!~20!).py
146
3.609375
4
a=1 b=0 print("SUM(1!~20!)\n=0",end='') for i in range(1,21): a *= i; b += a; print("+{0}".format(a),end='') print("\n={0}".format(b))
16bee523d94e83d6181822e0522a44083740dc02
webclinic017/Financial_Machine_Learning
/old_stuff/fixed_window_labeling.py
8,670
3.6875
4
""" Name :fixed_window_labeling.py in Project: Financial_ML Author : Simon Leiner Date : 19.05.2021 Description: sheet contains the functions for computing the triple barrier method """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from datetime import datetime, timedelta import matplotlib....
ca7a0210475b5004ed5a2b1b06516d480592bba3
marwin-ko/dsp
/python/q8_parsing.py
751
4.21875
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
ceb9d87770312344b359564481355bd9b4c9d4aa
statsmodels/statsmodels
/statsmodels/stats/contingency_tables.py
44,247
3.546875
4
""" Methods for analyzing two-way contingency tables (i.e. frequency tables for observations that are cross-classified with respect to two categorical variables). The main classes are: * Table : implements methods that can be applied to any two-way contingency table. * SquareTable : implements methods that can...
32719f446dd7a95bbe88ac400788876377462b36
merimus/coding-bootcamp
/euler/merimus/35/35.py
1,471
3.90625
4
import math class GenPrime(object): def __init__(self): self.primes = [2, 3, 5, 7] def Primes(self): for p in self.primes: yield p while True: yield self.GenPrime() def IsPrime(self, n): cuttoff = math.sqrt(n) for p in self.primes: ...
569a527462bbfbdd06b23a2a18f309fd728ba545
tamily-duoy/pyfile
/2017-5/DS/eightde/select_sortde.py
345
3.828125
4
#!/usr/bin/python # -*- coding:utf-8 -*- def select_sort(a): # 选择排序 for i in range(0, len(a)): pos = i for j in range(i + 1, len(a)): if a[pos] > a[j]: pos = j a[pos], a[i] = a[i], a[pos] return a if __name__=='__main__': a=[4,3,1,7] c=select_sor...
8a7fba97f2e5895d65f3181d82455883cbe5eeee
zuxinlin/leetcode
/leetcode/204.CountPrimes.py
741
3.828125
4
#! /usr/bin/env python # coding: utf-8 ''' 题目: 统计素数 https://leetcode-cn.com/problems/count-primes/ 主题: hash table & math 解题思路: 1. 利用数组缓存是否素数 ''' class Solution(object): def countPrimes(self, n): """ :type n: int :rtype: int """ no_prime = [False] * n count = 0 ...
925cc5e42f6e746f24bc7e5d6488186e53754097
gavjan/py_data_struct
/trie.py
1,677
3.640625
4
class TrieNode: def __init__(self, char): self.char = char self.is_end = False self.children = {} """ Trie that returns the first 3 suggestions for a given query """ class Trie(object): output = [] def __init__(self): self.root = TrieNode("") def insert(self, word)...
824853a3c83f0d2c46cf43fbe34b86372f85b772
Sgrives/Python-Class
/using_numpy.py
9,806
4.53125
5
# Crash Course in Python # Author: Breanna McBean # Select functions from the NumPy package # May 28, 2019 ############################################## # Using the NumPy Package (especially NumPy Arrays) # importing a package (adding "as np" allows us to shorten what we type in the future) import numpy as ...
c2024f2269216f8e794d010ea11b9d3d2a04fc24
LeslieHor/woof-tile
/lib/src/helpers.py
861
4.03125
4
def join_and_sanitize(list_): """Join a list of items into a single string""" if isinstance(list_, str): return list_ new_list = [] for item in list_: if isinstance(item, str): new_list.append(item) elif isinstance(item, int): new_list.append(str(item)) ...
ec70e4d94a405465763d739bdbf1728e90559075
mtucker91/Intro_to_Python
/past_assignments/Prog Assignment 5 - 2_ Print Even numbers + indexes/even_numbers.py
1,037
4.0625
4
# This part is to ask the user to input the list items. # It works, don't change or delete. # The way it works is not the scope of this question, we will cover it later #commented this out for testing #list_string = input('Enter list items (all int):\n') list_string = "7 5 6 5 4 9" my_list = [int(elem) for elem in lis...
a8eee36c673c6081ad3c57b84ea9e371bb068c50
zuobing1995/tiantianguoyuan
/第一阶段/day04/exercise/square.py
553
3.921875
4
# 练习: # 输入一个整数代表正方形的宽度,用变量n绑定, # 打印指定宽度的正方形 # 如: # 请输入: 5 # 打印如下: # 1 2 3 4 5 # 1 2 3 4 5 # 1 2 3 4 5 # 1 2 3 4 5 # 1 2 3 4 5 # 如: # 请输入: 3 # 打印如下: # 1 2 3 # 1 2 3 # 1 2 3 n = int(input("请输入: ")) line = 1 # 代表当前行 while line <= n: # print('打印第%d行' % line) i =...
45181810d2d51ed8df8b5a6dc7f61c9d30888b6d
Dragos-n/Composite_design
/01_Python/Submenu.py
562
3.609375
4
class Submenu: """ Class for leaf/submenu """ def __init__(self, name): """" 'Constructor' (init) method for a new leaf/submenu object Input parameter: the name of new class object """ self.name = name def __del__(self): """" Destructor meth...
7768feee6a59b972a085a5fba4bb50053dbcc4d7
mohammedaasem/PythonBasicPrograms
/26_operator_identity.py
166
4.09375
4
# is & is not a=10 if a is 10: print("Equal") else: print("Not Equal") b=5 if b is not a: print("Both are different") else: print("Both are Equal")
d64bbe00e52430cce530be00a42fd62ae17aeed2
Ricky-Hu5918/Python-Lab
/sortedSquares.py
1,191
3.6875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- #Leetcode.num = 977 """ Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number,  also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] """ '''以下两种方式均借助了排序方法,耗时在250ms左右''' ''' #1 def so...
8ebaac53f31fa9bee0a8c5ab169bedf614255483
andyworkingholiday/Operating_System
/Lab02/Safety_Algorithm.py
4,838
3.59375
4
import sys def print_safe_sequence(allocations, needs, availables, sequence): global process_count, instance_count if(len(sequence) == process_count): print("시작", end=" => ") for process_num in sequence: print("process{}".format(process_num), end=" => ") print("종료") else...
cb5163b3b2e95e5dd417ab5cc51b4031e4665e7a
BreakZhu/nltk_start
/start05/class5_7.py
1,067
3.671875
4
# -*- coding: utf-8 -*- import nltk # 如何确定一个词的分类 """ 形态学线索 ness 是一个后缀,与形容词结合产生一个名词,如 happy→happiness,ill→illness。因此,如果我们遇到的一个 以-ness 结尾的词,很可能是一个名词。同样的,-ment 是与一些动词结合产生一个名词的后缀,如 govern→government 和 establish→establishment一个动词的现在分词以-ing 结尾,表示正在进行的还没有结束的行动(如:falling,eating) 的意思。-ing 后缀也出现在从动词派生的名词中,如:the...
623f6218b656df8ef6480ea17321355fc2a53e16
TomGardoni/ExamPython
/Eval v3.py
744
3.5
4
from colorama import init init() from colorama import Fore, Back, Style print("Bienvenue dans motus sans ami") essais=4 chances=4 l=6*[0] for i in range(len(l)): l[i]=6*[0] l[0][0]=1 print(l) list = ["castor","cinema","cypres","citron","camion","webcam","ajoute","aligne","bronze","brutal"] motadeviner = lis...
2296eaff433b8cf81cc7207108640b12ddc39ce3
NishiMaliya/Analyzer
/analyzer.py
1,035
3.5
4
import argparse import requests from lxml import html def parse(link: str) -> str: """Function for extracting path to element""" page = requests.get(link) root = html.fromstring(page.text) tree = root.getroottree() element_path = root.xpath("//div[@id='page-wrapper']//a[contains(@class,'btn-succe...
d5eb5285fe5cc8b8fbb666fd9fe536dd8f45ad53
gschen/sctu-ds-2020
/1906101052-曾倩/day0310.py/test01.py
853
3.953125
4
class Student(object): def __init__(self,name,age,score): self.name=name self.age=age self.score=score def personInfo(self): print(("name:%s,age:%s,score:%s")%(self.name, self.age,self.score)) yi=Student("张三",20,'语文:92,数学:90,英语:90') yi.personInfo() class Student(): def __...
bdc4696c30161f6f07776d66f87a649fdd4a02f7
C-SON-TC1028-001-2113/listas-tarea5-A01252527
/assignments/17MenoresANumero/src/exercise.py
263
3.671875
4
def main(): a = int(input('')) aa = int(input('')) aaa = a*aa lista=[] i=1 while i<=aaa: i=i+1 aaaa = int(input('')) if aaaa<10: lista.append(aaaa) print(lista) if __name__=='__main__': main()
5d107f5830efc12296b21b86f84b3616dbcd2512
mwhit74/interpreter
/rbi/inte3.py
4,141
3.984375
4
#Token types # #EOF (end-of-file) token is used to indicate that #there is no more input left for lexical analysis INTEGER, PLUS, MINUS, MULTI, DIV, EOF = ('INTEGER', 'PLUS', 'MINUS', 'MULTI', 'DIV', 'EOF') class Token(object): def __init__(self, type, value): #token...
9cfd285e5d2ce31a169e523d1baff1c21db64581
maihan040/Python_Random_Scripts
/courseList.py
1,288
4.25
4
#!/usr/bin/python3 # #module name: courseList.py # #purpose: determine the order of courses that need to be taken based on their prerequisites of them. # The courses, along with their prerequisites will be passed a as a dictionary # #date created: 10/03/2019 # #version: 1.0 # #####################################...
6f6e6df2f1784aedbacd777244d0e72fc02ec096
LuisGabrielZamora/python_first_steps
/02_functions/01_my_first_function.py
1,766
4.34375
4
# PRACTICE TITLE: Function Definition # DESCRIPTION: Code structure that enable to execute an specific process # NOTATION: def my_first_function(): # NOTES: # 1. All the code that corresponds to the function has to be with tabulation # 2. To execute the function we have to call it with the same "def" tabulation # Defi...
0f795408aaf68709488def037ec03aa4836df30d
urvib3/ccc-exercises
/herding.py
1,563
3.515625
4
def onespace(x,y,z): if(x+2 == y): return True elif(x+2 == z): return True elif(y+2 == x): return True elif(y+2 == z): return True elif(z+2 == x): return True elif(z+2 == y): return True def maxmoves(nums): nums.sort() firstgap = n...
65492a228dd46eed5bafc725dae2bdb07fb2baaf
nuno-21902803/pw-python
/pw-python-03/exercicio_3/main.py
667
3.6875
4
import os def pede_pasta(): while True: try: nome = input("Introduza o caminho para pasta: ") if os.path.isdir(nome): return os.path.realpath(nome) except IOError: print("Pasta não existente") def calcula_tamanho_pasta(pasta): if os.path.i...
e32e0355e5083c19e78c6648192bb82e8d3ab6fe
bainco/bainco.github.io
/course-files/tutorials/tutorial05/warmup/b_while_termination_condition.py
511
4.03125
4
import time ''' A few things to note here: 1. A counter is initialized before the while loop begins. 2. The counter is updated each time the code block within the while loop executes. 3. If counter is less than 5, the block executes, otherwise, the while loop terminates. 4. The condition ...
e62f2c08aa364a46e29d6bbf702281c4fe70122c
perfect-song/LeetCode
/剑指66/二维数组查找.py
391
3.609375
4
# -*- coding:utf-8 -*- class Solution: # array 二维列表 def Find(self, target, array): m, n = len(array), 0 m -= 1 while (m >= 0 and n < len(array[0])): if array[m][n] == target: return True elif array[m][n] > target: m -= 1 ...
de2696aff3a6fd645c769228e2aee6db27aa8de2
L200180034/praktikum-ASD
/MODUL 5/No 1.py
1,033
3.5
4
class Mahasiswa(object): def __init__(self,nama,nim,kota,us): self.nama = nama self.nim = nim self.kotaTinggal = kota self.uangSaku = us class MhsTIF (Mahasiswa): def katakanPy(self): print('Python is cool.') listan = [MhsTIF ('Vara',34,'Surakarta',...
d570bcea6b0fd5ad4447c90973c2776e5a9eddfe
IriW/rock_paper_scissors_v2
/main.py
980
3.96875
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) ___...
baacbb690b743547203ce29e62012c8db4801a14
Keegan-Ross/it-python
/Rock, Paper, Scissors.py
1,471
4.09375
4
import random from banner import banner banner("ROCK, PAPER, SCISSORS", "Keegan Ross") print("We are going to play a game of Rock, Paper, Scissors. The first to win two times out of 3 rounds is the winner.") cpu_score = 0 player_score = 0 while player_score < 2 and cpu_score < 2: print(f"SCORE: Player: {player_sc...
9d02a0916fd49a09cbf01475d04730514eda231d
sadieh0ugh/12-balls-problem
/balls.py
2,043
3.640625
4
import random balls =[1,1,1,1,1,1,1,1,1,1,1] place = random.randint(0,11) num02 = (random.randint(0,1))*2 balls.insert((place),(num02)) print(balls) ball_label=[["ball 1","normal"],["ball 2","normal"],["ball 3","normal"],["ball 4","normal"],["ball 5","normal"],["ball 6","normal"], ["ball 7","nor...
dc7ac81da2551298e74f1a073ec101c7963eb28a
super-penguin/Data_Projects
/Test_Perceptual_Phenomenon/stroop.py
5,308
3.53125
4
# -*- coding: utf-8 -*- """ P1: Test a Perceptual Phenomenon Stroop data analysis and visualization in python 04/20/16 """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy import stats ########################################################################## ## 1. Read stroop dataset ...
13e77f023c93620347735b3d00537b911f7cf1e5
kns94/algorithms_practice
/powerofthree.py
613
3.625
4
import sys class Solution(object): def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ if n == 0: return False if n == 1: return True if n < 0: return False if (ma...
b57bab273d091434ed43a76c04a3a8c3fcbedb62
boknowswiki/mytraning
/lintcode/python/0085_insert_node_in_a_binary_search_tree.py
1,722
4.40625
4
#!/usr/bin/python -t # iteration way """ Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param: root: The root of the binary search tree. @param: node: insert this node into the binary search ...
0496105f3d578bf727c4e1ebc01d6f94fadd73e8
jmvazquezl/programacion
/Prácticas Phyton/P5/P5E11 - PROGRAMA QUE PIDA UN NÚMERO E IMPRIMA SUS DIVISORES.py
249
3.828125
4
# JOSE MANUEL - P5E11 - PROGRAMA QUE PIDA UN NÚMERO E IMPRIMA SUS DIVISORES num = int(input('Dame un número: ')) print('Los divisores de', num, 'son', end=': ') for i in range(num): i = i + 1 if (num % i == 0): print(i, '', end='')
533b524df2134a52a702cfa92c58a8825505ca74
dubian98/Cursos-Python
/100 ejercicios/ejercicio10.py
195
3.65625
4
def sum_pos_divisor(num): sum=0 for i in range(1,num): if num%i == 0: sum+=i if sum==num: n=True else: n=False return n sum_pos_sivisor(28)
b67c2c6499f38c88511594c1c7aae8d813ea84b8
ansoncoding/CTCI
/Python/01_Strings_Arrays/IsPermutation.py
1,427
4
4
#1.2 is one string a permutation of another string? def is_permutation(str1, str2): if len(str1) != len(str2): return False counts = {} for i in range(0, len(str1)): if str1[i] not in counts: counts[str1[i]] = 1 #print(counts) else: counts[str1[i]...
789ae00a7540e9d1894b966d11a0f1e0e4065f41
rAndrewNichol/random
/Python/hackerrank/stats2.py
639
3.515625
4
# Weighted Mean N = int(input()) values = input().split() weights = input().split() weighted_values = [] for i in range(N): values[i] = int(values[i]) weights[i] = int(weights[i]) weighted_values.append(values[i]*weights[i]) weighted_mean = round(sum(weighted_values)/sum(weights),1) print(we...
cfd7b1f6ec51e586c0e58bcd37c2361b8ab95379
FarzamHejaziK/DyLoc
/KNNCNN/Indoor/MakeADPgrid.py
5,281
3.578125
4
import numpy as np # Define x and y grid size. Must match xnum and ynum in "Train.py" xnum = 18 ynum = 55 # Function calculates class of each ADP based on the loc data # Inputs: raw validation data (ADP, location), and size of (x,y) grid # t - handles name of location dataset. Can be removed if name of location colu...
692073825a339d2aa4b412bd4a18c61a873919b6
dannyhollman/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_models/test_rectangle.py
3,157
3.5
4
#!/usr/bin/python3 """unittest for Rectangle""" import unittest import pep8 from models.rectangle import Rectangle class TestRectangle(unittest.TestCase): """class to test Rectangle""" def test_pep8(self): """tests PEP8 format""" pep8style = pep8.StyleGuide(quiet=True) result = pep8sty...
507ca68d0a97543a429dc3d53116a52d79d7ad24
sindhu819/Array-2
/Problem-31.py
731
4.09375
4
# Finding minimum and maximum element in an array # time complexity =O(N) #space complexity =O(1) # Approach : we compare two elements in an array then find the max and min element between and simultaneously update the max and min values. def min_max(nums): min_num=nums[0] max_num=nums[0] n=len(nums) ...
728d75b7e5c2e70da464a8c8d5645a5fd77dd319
ndjenkins85/Code
/Frisbee Golf/Hole.py
1,140
3.5
4
from Utilities import show_pic from Wind import * class Hole: def __init__(self): self.zones = [] self.starting_position = (0.0, 0.0) self.goal_position = (0.0, 0.0) self.goal_zone = [] self.name = "" self.number = 0 self.par = 0 self.wind = Wind() ...
aae67bc984f347a23394cba0dd74c8dd272c57c0
yukijuki/Statistics
/test.py
95
3.609375
4
arr = [2,4,6,7,8] sum = 0 i = 0 while(i < 5): sum = sum + arr[i] i = i+1 print(sum)
0c793c93c551048e0fbd38abbed63122d8958c8a
Jribbit/GenCyber-2016
/hex64.py
1,269
3.953125
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 21 09:08:22 2016 Cryptopals Set 1 Challenge 1 This program converts a hexadecimal string into base64. """ # -*- coding: utf-8 -*- """ Created on Tue Jul 19 12:54:08 2016 @author: student """ def hex64(string): """ Converts hex string to binary string """ num =...
a5e9f3cb25c2bcc948f24db3ae277676d2170d40
RaduMatees/Python
/Algorithms/ghicire.py
414
3.796875
4
"""Ghicirea unui numar generat aleator intre 1 si 1000""" from random import randint numar = randint(1,1000) ghici = int(input("Introduceti un numar intreg ")) contor = 1 while ghici != numar: if ghici > numar: print("Numarul tau este mai mare ") else: print("Numarul tau este mai mic ") ghici = int(input("I...
f7e17cda5e487615c7ab9c88a5e2796feb8f0d5d
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/sum-of-multiples/4b069fd846384561ad59a168d2253577.py
219
3.734375
4
def sum_of_multiples(value, bases = None): if bases is None: bases = [3, 5] while 0 in bases: bases.remove(0) return sum(set([i * b for b in bases for i in range(1, round(value / b) + 1) if i * b < value]))
41a869c8e930a3cf526a9760ca2197619b948f01
Monisha1892/Practice_Problems
/car game.py
2,381
4.34375
4
print("""Welcome to the car game. Type commands to start and stop the car. List of commands will be available when you type help. Enjoy the game.""") command = input(">") while command != 'quit': if command == 'help': print("""start - to start the car stop - to stop the car quit - to exit...
8a883ac2bafa871568cba967278310730742b04e
OliverMD/TPOP
/theory/hw1.py
898
3.5625
4
def gcd(a,b): #gdc(int,int) -> int #Recursive implementation of GCD if a > b: c = a a = b b = c def internal(a,b): if a % b == 0: return b return internal(b,a%b) return internal(a,b) def altGcd(a,b): #altGcd(int,int) -> int #A more literal...
3fcdc9d71501c9d51166795ac3227d4ce3dd737e
jeremiedecock/snippets
/python/opencv/opencv_2/drawing_functions/drawing_functions.py
2,737
3.96875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2015 Jérémie DECOCK (http://www.jdhp.org) """ OpenCV - Drawing functions: draw lines, circles, rectangles, ellipses and text Required: opencv library (Debian: aptitude install python-opencv) See: https://opencv-python-tutroals.readthedocs.org/en/latest/p...
71b18e371270cdc1b998b86dad6146f71f942194
randiaz95/nysom
/utils.py
911
3.6875
4
import os def create_directory(root, folder): if folder is str: path = os.path.join(root, folder) if not os.path.exists(path): os.mkdir(path) return path elif folder is list: path = os.path.join(root, *folder) if not os.path.exists(path): ...
359e01605ec43e181ec70e4389a79192696a4b19
Researching-Algorithms-For-Us/4.Implementation
/source/python/시각.py
535
3.890625
4
#source code ''' 21:08~21:17 정수 N입력 00:00:00 ~ N:59:59초 3이하나라도 포함되는 모든 경우의수를 작성하시오 ''' def set_input(): clock = int(input()) #roads.append(0) return clock def main(): clock = set_input() count = 0 for hour in range(clock+1): for minute in range(60): for second in range(60):...
108c4caded59a4d9b5be66f627dd9f07cdb4cdeb
sikendershahid91/SoftwareDesign
/assign3/src/fibonacci_iterative.py
259
3.875
4
from functools import reduce def fibonacci_iterative(number): if number < 0: raise ValueError("Negative number!") return reduce( lambda previous, index: [previous[1], sum(previous)], range(number + 1), [1, 0]) [1]
c54de7736befcbf4569c8a1758b452a1ba3001de
croot95/BMGT404_FInal
/analyze_cuisines.py
1,927
3.96875
4
#!/usr/bin/python import pandas as pd #create dataframe column names col_names = ['Cuisine' , 'Avg Sentiment','Avg Rating','Restaraunts','Ratings'] #choose the file with the data file_path = "/Users/christopherroot 1/Desktop/cuisines.csv" df = pd.read_csv(file_path, header = None, names = col_names) #find mean an...
d0b45a622ed42d3074ae0e469e165bf603d01721
brityboy/python-workshop
/day2/src/substring.py
1,078
4.125
4
from collections import defaultdict def substring_old(words, substrings): ''' INPUT: list, list OUTPUT: list Given two lists of strings, return the list of strings from the second list that are a substring of a string in the first list. The strings in the substrings list are all 3 characters...
7739a1d442d28c210c44b22fb841f25ab9d31efc
dehvCurtis/NSA_Py3_COMP3321
/Lesson_02/lesson02_sec4_ex2.py
164
3.65625
4
def all_the_snacks(snack, spacer): print((snack + spacer) * num) num = 42 spacer = '! ' my_snack = input('Pick a snack > ') all_the_snacks(my_snack, spacer)
5c19ce06f65e92b4c5642e75fbe2581b29e99423
geeks121/TriangularArbitrage-1
/Events.py
488
3.5625
4
from abc import ABCMeta, abstractmethod from threading import Timer, Thread import time import queue class HelloEvent(Thread): def __init__(self, string_arg): self.string_arg = string_arg Thread.__init__(self) def run(self): print('hello world!') time.sleep(3) print(sel...
2ab80870c38bee607444dfafe88ff926fe192ede
tejapenugonda/pythonIcp2
/Source/FIRST.py
257
3.875
4
n = int(input("How many numbers do you have? ")) s = 0 obs = list(map(int, input().split())) if len(obs) != n: print("Did not enter "+str(n)+" values") else: for i in range(0,len(obs)): s = s+obs[i] avg = s / float(n) print (avg)
b73de30be801bfc88bad65a118ebf93ba4cd1e11
MrAaaah/fractals_basics
/sierpinski_triangle.py
1,549
3.5
4
# -*- coding: utf-8 -*- # noinspection PyPackageRequirements from PIL import Image, ImageDraw from datetime import datetime # each vertices is represented by a tupple (x, y) # define some params WIDTH = HEIGHT = 800 ITERATIONS = 7 # vertices of the sierpinski triangle A = (400, 68) B = (10, 760) C = (790, 760) BACKG...
c447c31b37e3085dc5d9a0c6243aa37a0706ffc0
siyam04/python_problems_solutions
/Siyam Solved/Problem Set -1/Solutions - 1/8.py
132
3.78125
4
print("Enter 1st String:") a = str(input()) print("Enter 2nd String:") b = str(input()) print("the two strings are", a, 'and', b)
33033fee63afe069bddc05b9f0f09a082fb3722a
ClaraKim2002/cs110-connect-four
/connect_four.py
3,045
3.78125
4
import pygame import sys import ai class Board(): def __init__(self): self.spots = [None]*7 for col in xrange(0, 7): self.spots[col] = [None]*6 def get_spot_status(self, col, row): return self.spots[col][row] def add_piece(self, col, player): """ Ad...
f83e3c398374ff243c036ea0b0cef5e5104cbc67
supriyashahane/TIC-TAC-TOE-game
/tic-tac-toe.py
21,826
3.671875
4
import os import random #os.system("clear") class Board(): def __init__(self): self.blocks = [" ", " ", " ", " ", " ", " ", " ", " ", " "] def display(self): print("\t\t\t\t ===============") print ("\t\t\t\t || %s | %s | %s ||" %(self.blocks[0], self.blocks[1], self.blocks[2])) ...
ae19f46702080a4b284b9c4ee7fa6875d3aa8278
askiefer/practice-code-challenges
/sentence_reversal.py
408
4.125
4
def sentence_reversal(strg): # remove the whitespace before and after the string strg = strg.strip() # split the string on each space lst = strg.split(' ') new_lst = [] for word in lst: if word == '': continue new_lst.insert(0, word) return ' '.join(new_lst) if __name__ == '__main__': print(sentence_re...
793ac06bd2f228e546ef40ff13bad8b6c7099c11
keshav304/DSC-SIST-CP-QUESTIONS
/DAY-5/ClosestNumbers.py
523
3.578125
4
# Closest Numbers: https://www.hackerrank.com/challenges/closest-numbers # Complete the closestNumbers function below. def closestNumbers(arr): arr.sort() result = min([arr[i]-arr[i-1] for i in range(1,len(arr))]) print(arr) print(result) summ=[] for i in range(1,len(arr)): if (arr[i]-ar...
67a7b667f16e9f55d85a07adf4337ba8fa5f40bc
MYMSSENDOG/leetcodes
/111. Minimum Depth of Binary Tree.py
670
3.71875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None from tree_node_lib import * class Solution: def minDepth(self, root: TreeNode) -> int: def helper(root): if not root: ...
1f40c8a2f302fd2158bf4714e649089544e810b0
tinsleyzzz/Field_Control_Score
/Field Control Cutton.py
3,046
3.6875
4
from tkinter import Tk, W, E from tkinter.ttk import Frame, Button, Label, Style from tkinter.ttk import Entry #from tkinter import * #from tkinter import ttk #class Frame: #frame = Frame(self, relief=RAISED, borderwidth=1) #frame.pack(fill=BOTH, expand=1) class Calculator(Frame): def __init__(self, paren...