blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
85689ba651f7a647634f864967c0df6ab5236a9c
potato16/pythonl
/python101/python101.py
375
3.578125
4
print("Hello Azinomoto") #This is something boring and we do it all day age = 24 name ='idonottellyou' print('{0} was {1} years old when he wrote this book'.format(name,age)) print('Why did you ask it, go away!'.format(name)) print('{0:3.3f}'.format(222222.0/3)) print('{0:*^22}'.format('thao'),end='||') print('{chieu} ...
fc2cb25e42595b8139707b837532e9fc30332f87
lewtwelf/SpartaPythonNotes
/codingChallange.py
1,891
3.8125
4
""" sumlist = [] for i in range(0,1000): if i % 3 == 0 or i % 5 == 0: sumlist.append(i) print(sum(sumlist)) def fibaRecurs(first, second): if second > 4000000: return first + second + fibaRecurs(first, second) def fibo(x): print(x, " ", end="") if x > 10: return x else...
1962bff441dfff94a9f40f68503f29e24815eca4
jacobbjo/AI_A4
/trash/Sheep_backup.py
4,975
4.09375
4
import numpy as np import matplotlib.pyplot as plt from importJSON import Map # Global variables defining the sheep behavior #SHEEP_R = 0.7 # The space the sheep wants between them SPACE_MULT = 3 SPACE_R = 0.7 RANGE_R = 3 * SPACE_R BUMP_h = 0.2 # Value from the paper. Used in the bump function A = 5 B = 5 C = abs(A-...
39a09545365aea8c01d72dc92bddef9e9b0a1290
RobRoseKnows/Project-Euler
/Problem 001-100/Problem 01-10/Problem1.py
2,038
4.375
4
#!~/anaconda2/bin/python # If we list all the natural numbers below 10 that are multiples of 3 or 5, # we get 3, 5, 6 and 9. The sum of these multiples is 23. # # Find the sum of all the multiples of 3 or 5 below N. # # Input Format # # First line contains T that denotes the number of test cases. This is # followed...
f9eded943ee01fe07f87a13ebf88fb1201fe3f9e
paul0920/leetcode
/question_leetcode/131_1.py
706
3.59375
4
def partition(s): """ :type s: str :rtype: List[List[str]] """ res = [] dfs(s, 0, [], res) return res def dfs(s, index, path, res): if index == len(s): res.append(list(path)) return for i in range(index + 1, len(s) + 1): sub_string = s[index: i] ...
32f1f3841ae8e6365774f1e1b6e3ce4f3ab0cebd
hammond756/uvadlc_practicals_2018
/assignment_1/code/modules.py
5,411
3.75
4
""" This module implements various modules of the network. You should fill in code into indicated sections. """ import numpy as np def exp_normalize_batch(x): b = x.max(axis=1)[:, None] y = np.exp(x - b) return y / y.sum(axis=1)[:, None] class LinearModule(object): """ Linear module. Applies a linear...
00ad7c52e5e72b5f38474f381a2e2f677f557039
tlima1011/Python
/retangulo.py
398
3.703125
4
from math import sqrt, pow base: float; altura: float base = float(input('Base do retangulo: ')) #4.0 altura = float(input('Altura do retangulo: ')) #5.0 area = base * altura perimetro = 2 * (base + altura) diagonal = sqrt(pow(base, 2) + pow(altura, 2)) print(f'AREA = {area:.4f}') #20.0000 print(f'PERIM...
e4f79a1870563c2e4f02995c749082db8fb4e117
greenbean1/thinkful
/chi_squared.py
1,494
3.59375
4
import pandas as pd from scipy import stats import collections import matplotlib.pyplot as plt # Load the reduced version of the Lending Club Dataset loansData = pd.read_csv('https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv') # Clean Data: Delete rows with null values loansData.dropna(inplace=True) ...
b7a6173153be52920ffd8383456da76935454c0e
doubleZ0108/IDEA-Lab-Summer-Camp
/src/util/find_classes.py
469
3.796875
4
""" 找到之前的数据是对几类对象进行分类 """ import os max = 0 save_name = "" os.chdir("../data/img") for filename in os.listdir(os.getcwd()): (name, appidx) = os.path.splitext(filename) if appidx == ".txt": with open(filename, "r") as file: line = file.readline() num = int(line[0]) ...
c9c4600a233fe8acda8ad94b1949735ab7532959
elLui/python_tools_and_practice_v3.8
/python_3.8/display_inventory_project.py
779
3.9375
4
# inventory.py """Fantasy Game Inventory""" stuff = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12} def display_inventory(inventory): print("inventory: \n") item_total = 0 for k, v in inventory.items(): print(str(v) + ' ' + k) item_total += v print('Total number of ...
c14b764a3ea115112b347021d4ef66f7fc43c19a
pzfrenchy/SortingMethods
/InsertionSort/InsertionSort/InsertionSort.py
508
3.90625
4
list = [3,2,5,8,4] for i in range(1, len(list)): currentValue = list[i] #copy current value to temp location while i > 0 and list[i-1] > currentValue: #check if index greater than 0 and preceeding value greater than current list[i] = list[i-1] #shift higher va...
84dd9fb90572c96309cf464c4a29380a80c9240c
devopshndz/curso-python-web
/Python sin Fronteras/Python/Ejercicios/10- Funcion par o impar.py
585
4.03125
4
# escribir una funcion que diga si un numero es par o impar # utilizaremos el operador de modulo % que indica el resto de una division: 10 Mod 2=0 def es_Par(num): return num % 2 == 0 # retornamos la operacion de que el numero que demos %(mod) 2 sea igual a 0 # esto efectua la division entre...
202f5faeab5277ec04a5c973792c02e5193865db
KonstantinSKY/LeetCode
/1337_The_K_Weakest_Rows_in_a_Matrix.py
1,039
3.5
4
"""1337. The K Weakest Rows in a Matrix https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/ """ import time from typing import List class Solution: def kWeakestRows1(self, mat: List[List[int]], k: int) -> List[int]: n = sorted([(mat[i], i) for i in range(len(mat))]) return [n[i][1] for ...
7247adf12a40bbcdf3c81d9d3cb5eead76986f17
purcellconsult/python_intro_juniper
/06_functional_programming.py
9,318
4.46875
4
import math import functools from random import randint ################################################ # Functional programming and comprehensions # ----------------------------------------- # Functional programming is a popular paradigm in # coding. Functional programming aspects of python # was inspired from Lisp ...
b0be3e66a4c8835288598de3a0515e9aa269b77d
jzachem/num2words
/num2words.py
3,153
3.578125
4
import sys class num_convert: output = "" ones_dict = {"0": "zero", "1":"one", "2": "two", "3": "three", "4": "four", "5": "five", "6": "six", "7": "seven", "8": "eight", "9": "nine", "10": "ten", "11": "eleven", "12": "twelve", "13": "thirteen", "14": "fourteen","15": "fifteen", "16": "sixteen", "17":...
cbe17c9bac56ffe4aee581baca885262f40d3fb1
xjr7670/corePython
/6-12a.py
1,228
3.875
4
#!/usr/bin/env python #-*- coding:utf-8 -*- def findchr(string, char): l1 = len(string) l2 = len(char) t = False for i in range(0, l2): for j in range(0, l1): # 两次循环历遍,只是为了寻找第一个相同的字符 while char[i] == string[j]: # 如果发现有相同的字符,则开始逐个比较 k = j ...
92711fd8c910e4ea4a731d2cf7a74240e65141a3
mandarspringboard/notes
/Python_notes/yield_and_return_difference.py
1,489
4.15625
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 17 16:44:50 2020 @author: Gokhale """ def wrapper_return(n): return countdown(n) def wrapper_yield(n): yield countdown(n) def countdown(n): while n > 0: yield n n -=1 if __name__ =='__main__': # wrapper_...
fc9a166508b02a9006723d3bb683f035648567c6
ankhuve/gammalPython
/mastermind.py
2,782
3.75
4
import random allcolors = ["yellow","blue","red","green","orange","black","white"] colors = ["yellow","blue","red","green","orange","black","white"] # Lista med användbara färger def randColorlist(colors): # Funktion för att skapa slumpad colorlist i = 0 # Skapa räknare colorlist = [] # Skapa tom lista ...
a38fa2df9e7ac0215e5d06cf9fe37fa0707f6335
bingheimr/edX-Projects
/edX Midterm - Problem 5.py
955
3.890625
4
""" Write a Python function that returns a list of keys in aDict that map to integer values that are unique (i.e. values appear exactly once in aDict). The list of keys you return should be sorted in increasing order. (If aDict does not contain any unique values, you should return an empty list.) This functio...
6abd7fa34f0c407078c64d4f688acca753945b4b
rafaelperazzo/programacao-web
/moodledata/vpl_data/3/usersdata/106/426/submittedfiles/ex2.py
263
4
4
# -*- coding: utf-8 -*- from __future__ import division #entrada a = input ('Digite um valor para a:') #processamento if a>=0: b= (a**0.5) print (' a raíz quadrada de a será: %.2f' %b) if a<0: b= (a**2) print (' o quadrado de a sera: %.2f' %b)
6d00961dd3e125cc9bb531cbfbc1a63076ce4cde
TheRealCubeAD/BANDO
/BWM/BWM_2018_2/Konfetti9.py
5,669
3.75
4
import time # - - - - - Programminterne Moduswahl - - - - - # Abfragemodus: #modus = "quadrat" modus = "quadrat_schnell" #modus = "rechteck" #modus = "rechteck_schnell" # Ausgabemodus: modus_a = "farbe" #modus_a = "zahl" # Beginn des Programms print() print("- - - - - Programmstart - - - - -") print() print() ...
d51bbfbcd5c0e0b5305d656c1252762256a3d598
stdg3/python3M
/course1/loops.py
222
4.09375
4
# Infinitive loop: while True: userInput = input("Please input positive number: ") if float(userInput) > 0: print("Your number is: %s" %userInput) break else: print("%s is wrong nnumber." %userinput) continue
f8008491066541b5c1a753066d43f40499b2de71
IsaSchin/exercises_python
/0.11.py
115
4.0625
4
print ("Exercício 11") num = int(input("Digite um número: ")) for x in range(num +1): print (x) print ("fim")
e2af54b476a4c730d9da49b408ef7674c5ea71a1
ameerfaisal89/BayesianNetworks
/graph.py
5,939
3.734375
4
''' Created on Apr 19, 2015 @author: jorge Creates classes DirectedGraph and UndirectedGraph and private classes _Vertex and _Edge that users should not need to use by name ''' import functools @functools.total_ordering class _Vertex(object): ''' A Vertex in a graph. End users should not create their own Ve...
3a0b2fde590cf37ed79bd2eb62187142be877b1a
ChristinaDeLonghi/100DaysofCodeChallenge
/While Loops.py
895
4.3125
4
#code that continually repeats until a certain condition is no longer met import sys MASTER_PASSWORD = 'opensesame' #caps for variables that should not change throughout running the code. Better to put it at the top set of variables than only in the while loop itself. password = input("Please enter your password: ") ...
d628a1a935b3f49c2273da42e40ea3172b18614a
bj0/aoc
/aoc/2018/d25_2.py
526
3.578125
4
import networkx as netx def get_data(): with open("d25.txt", "r") as f: data = f.read().rstrip() return [tuple(map(int, line.split(","))) for line in data.splitlines()] def mandist(s, t): return sum(abs(x - y) for x, y in zip(s, t)) def part1(points): g = netx.Graph() for point in poi...
e92935cf2203570c05f5d351b73694ee6d137d40
aegglin/leetcode
/python/valid_parentheses.py
919
3.984375
4
# Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', # determine if the input string is valid. # # An input string is valid if: # Open brackets must be closed by the same type of brackets. # Open brackets must be closed in the correct order. def isValid(self, s: str) -> bool: ...
ff225c1c021de4a11a950f741e1f4effb29769c6
NeelJVerma/Daily_Coding_Problem
/Class_Scheduler/main.py
775
3.765625
4
""" Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required. """ def scheduler(l): l = sorted(l, key=lambda x: x[1]) queue = [] rooms = 1 queue.append(l[0]) for i in range(1, len(l)): while queue and queue[0][1...
c8121089138a40ad043406819004d2d8c4f339bd
ProkRoman/python
/lesson 1.6.py
217
3.875
4
day1 = int(input("сколько км в первый день: ")) max = int(input("лучший результат в км: ")) days = 1 while day1 < max: day1 = day1 * 1.1 days = days + 1 print(days)
9b7d64ecc8fe6905286a35bc23ca240e8a5f9806
antonmeschede/Conversor-XLSX
/EXCEL-CSV.py
861
4.09375
4
import pandas as pd # another file reading the file, showing the columnbs and the user selects to see the results print('*' * 25) print('Conversor de XLSX para CSV') print('*' * 25) print('') # escolha = str(input('Olá, seja bem-vindo ao conversor! O que você deseja converter? ') file = input('Local do Arquivo...
6e6de276de8f1333202046a69aefaa5a4e989798
OlyaIvanovs/python_playground
/oop/wizcoin.py
563
3.53125
4
class Wizcoin: def __init__(self, galleons, sickles, knuts): """Create a new WizCoin object with galleons, sickles and knuts.""" self.galleons = galleons self.sickles = sickles self.knuts = knuts def value(self): """The value in knuts of all coins in the WizCoin object."...
3230ceea034e4fb08bf0cfca6794c932f1a62699
Catering-Company/Capstone-project-2
/Part2/us_coin_calculator.py
2,718
4.53125
5
# CODE FOR COIN CALCULATOR, PROVIDED THAT THE CURRENCY IS SET TO DOLLARS. # -------------------------------------------------- # General_functions contains functions that are used throughout multiple parts of the program. from general_functions import us_coins, us_coins_dict, get_cent_amount, floor_calc # -----------...
23d8fae62a6fc51c05a30be01e52252ede1a4a55
santina/Master_Thesis_UBC
/PubMed_100_Random_Papers/Python_Code/Sanity/check_empty_lines.py
1,191
3.609375
4
import argparse def getEmptyLines(filename, outfile): empty_lines = list() with open(filename) as f, open(outfile, 'w') as out: for lineNum, line in enumerate(f): # 0 base for lineNum if line.strip(): continue else: empty_lines.append(lineNum) for l in empty_lines: out.write(str(l) + '\n') p...
2b9189775f83ffabd762141ad24c3391f825167c
smugokey/python-Problems
/Exercise 9.2.py
1,146
4.09375
4
# In 1939, Ernest Vincent Wright published a 50,000 word novel called Gadsby that0 # does not contain the letter “e.” Since “e” is the most common letter in English, that’s # not easy to do. # In fact, it is difficult to construct a solitary thought without using that most common # symbol. It is slow going at first...
e2c6b187ddaea09ea04accca60024e46387ceffe
CyanD/YNU
/Python_Code/FunctionSet.py
454
4.1875
4
"""this is a function,to display all the item in a list the_list: the list you want to display indent: decide whether to intent level: intent size """ def print_lol(the_list,indent=False,level=0): for each_item in the_list: if isinstance(each_item,list): print_lol(each_item,indent,level+1) ...
d746edc50ec7fa5151309cb56bc12dd11f26a200
amaurya9/Python_code
/Compare_File.py
1,331
3.609375
4
import argparse import filecmp def compareFile(i,o): if i!=None and o!=None: #fd = open(args.i) #fd1=open(args.o) #if sum(1 for line in fd if line.rstrip()) == sum(1 for line in fd1 if line.rstrip()): fd = open(i) fd1 = open(o) if len(fd.readlines())!=len(fd1...
01134ef0d96afa7117dc561642a3f9ffae13aad1
FabioRomeiro/FATEC_codes
/1SEM/Algoritimos/Python/Lista de Exercicios String/7.py
546
3.6875
4
frase = input("Digite uma frase:").lower() numEspacosEmBranco = 0 numVogais=0 numA = 0 numE = 0 numI= 0 numO = 0 numU = 0 for i in frase: if i == ' ': numEspacosEmBranco += 1 if i in ['a','e','i','o','u']: numVogais += 1 if i == 'a': numA += 1 if i == 'e': numE += 1 if i == 'i': ...
81406eae0381117c2038322e68ddcf4236186474
vinodekbote/Cracking-the-Coding-Interview
/permutation_string.py
1,111
4.1875
4
__author__ = 'rakesh' ''' the idea is to create a recursion tree of the string and it will print out all the different combination ''' ''' A[current], A[start] = A[start], A[current] this type of item assignment is not supported for string. All int values can be swapped like this ''' ''' python does not support strin...
dcdcfce858ba71394a31df4468b454825235f276
mohmilki/IF1311-10220013
/main-operasilogikadanboolean.py
1,179
4.09375
4
#latihan logika dan komparasi #membuat gabungan area rentang dari angka # +++++++++3-------------10++++++++++++ inputUser = float(input("masukkan angka yang bernilai\nkurang dari 3\n atau\n lebih besar dari 10\n:")) # +++++++++3----------- # memeriksa angka kurang dari 3 isKurangDari = (inputUser < 3) ...
4ebcb86766deb4e08a69dfa0118e306ed12fb2ac
yahua/LearnPython
/sorted.py
197
3.546875
4
#coding:gbk l = [36, 33, 56, 9] # 默认从小到大 print sorted(l) # 倒序 def reversed_cmp(x, y): if x>y: return -1 elif x<y: return 1 else: return 0 print sorted(l, reversed_cmp)
1ab9cac91b0ec6db3416bb73e9363c84bb8af925
rupeshpatil/python
/algo/bin.py
409
3.890625
4
def binarySearch(item, itemlist): first = 0 last = len(itemlist) -1 found = False while first <= last and not found: middle = (first + last) //2 if itemlist[middle] == item: found = True elif itemlist[middle] < item: first = middle + 1 else: ...
e5dbe56dc4d3ac51497ad138808cc8cb4bf7ce7b
Genionest/My_python
/Zprogram3/Fibonacci.py
232
3.546875
4
#斐波那契数列,非递归正解算法 print("请输入一个数:") n = int(input()) Fib = [] for i in range(0,n): Fib.append(0) if i < 2: Fib[i] = 1 else: Fib[i] = Fib[i-1] + Fib[i-2] print(Fib)
52b912b4c42c4ea0db40ccf7e6c817200ad6f05f
Tulip2MF/100_Days_Challenge
/Love Calculator.py
662
3.921875
4
name1 = input("Write your name: ").lower() name2 = input("Write other person's name: ").lower() joinedName = name1 + name2 def loveCounter(countParameter): count1 = 0 for i in countParameter: count1 += joinedName.count(i) return count1 trueCount = loveCounter("true") loveCount = loveCounter("lov...
332a98d412af583a929955fe203e61ca4260cf2e
ricarcon/programming_exercises
/2020/week11.py
1,621
4.09375
4
def max_duffel_bag_value(tuples, num): temp = [] #first we'll take a look at which single cake has the highest value if we took just one type of cake for entry in tuples: weight, value = entry count = int(num/weight) temp.append((weight, count * value)) ...
d83ec512d170b13ff48b03ff326b32292a4acc4d
AMendoza04/Numerico
/Taller1/punto1b.py
931
3.5625
4
#11 -1b- 7 - 13 - 2 - 4 o 5 - 6 - 15 import math def horner(p, n, x, ans): y = p[0] d = 0 for i in range( 1 , n ): d = y + x * d y = x * y + p[i] ans.append(y) ans.append(d) def evalp(p, n, x): s = 0 for i in range(n): s = s + p[i] * x**(n - i - 1) return s def ...
92d8d793f018764bfcfec63a12c31cb6f83328a1
tarrade/proj_DL_models_and_pipelines_with_GCP
/src/model_mnists_skripts/tf_lazy_lowlevel.py
8,802
3.59375
4
""" Basic ideas frm https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/neural_network_raw.py - update using tf.data - update session """ import tensorflow as tf import numpy as np from src.constants import NUM_EPOCHS, BATCH_SIZE, LEARNING_RATE ###################################...
d435123b428818b73dba5ecc56f6b049084f2993
iamaaditya/Project-Euler
/018.py
1,260
3.625
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 09 00:58:43 2014 @author: aaditya prakash """ import utilities import math import time import numpy as np problem_number = '018' problem_statement = """ Find the maximum total from top to bottom of the triangle below: Problem 67, related """ def MaximumTopBottom(strMat...
f08d10047a3da1f95324156752ef78eb5df52395
mineai/evolf
/servicecommon/persistor/local/pickle/pickle_persistor.py
1,596
3.53125
4
import pickle from framework.interfaces.persistence.persistence import Persistence class PicklePersistor(Persistence): def __init__(self, file, base_file_name=".", folder=""): """ This constructor initializes the name of the file to persist at what path. :param base_file_name: N...
c4ffc231d97246d898292bb662e6e9160c2c0e4a
rafaelperazzo/programacao-web
/moodledata/vpl_data/61/usersdata/232/27281/submittedfiles/poligono.py
161
4.03125
4
# -*- coding: utf-8 -*- n=int(input('Digite o número de lados do polígono: ') nd=(n*(n-3))/2 print('O valor do número de diagonais do polígono é: %.1d' %nd)
00749418b5992e7111442681a4ae85dbca7bc577
q2806060/python-note
/day04/day04/exercise/right_align2.py
967
3.890625
4
# 输入三行文字,让这三行文字依次以 20个字符的宽度右对齐 # 输出 # 如: # 请输入第1行: hello world! # 请输入第2行: abcd # 请输入第3行: a # 输出结果为: # hello world! # abcd # a # 做完上面的题后再思考: # 能否以最长字符串的长度进行右对齐显示(左侧填充空格) s1 = input("请输入第1行: ") s2 = input("请输入第2行: ") s3 =...
dac6216046b0f60e61b11259f72a0e5e4f53e539
almogboaron/IntroToCsCourseExtended
/deriv_intergral.py
685
3.9375
4
import math def diff(f, h=0.001): """ Returns the derivative of a one parameter real valued function f. When h is not specified, default value h=0.001 is used """ return (lambda x: (f(x+h)-f(x))/h) def integral(f, h=0.001): """ definite integral of f between a, b """ ...
b25c07d1417e8727ed89b1cb7d56e495f9f6b249
Asperas13/leetcode
/problems/48.py
682
3.78125
4
class Solution: def rotate(self, matrix): """ Do not return anything, modify matrix in-place instead. """ i = 0 dim = len(matrix) while i < dim: offset = 0 while i + offset < dim: matrix[i + offset][i], matrix[i][i + offset] = m...
0db81e1bcbd379ad932e8948450d120730f725ec
Icedomain/LeetCode
/src/Python/885.螺旋矩阵-iii.py
671
3.609375
4
# # @lc app=leetcode.cn id=885 lang=python3 # # [885] 螺旋矩阵 III # class Solution: def spiralMatrixIII(self, R: int, C: int, r0: int, c0: int) -> List[List[int]]: mat, d = [[r0,c0]], 0 x , y = r0 ,c0 while len(mat) < R * C: # s代表方向 d 代表走的距离 for s in (1,-1): ...
cf8c33d6fec23546fc1c676076dcc29596c496b2
bug-thiago/Exercicio-4
/Exercicio04/Questao6.py
226
3.75
4
u = input("Digite um nome de usuário e a sua respectiva senha (não podem ser iguais):\nUsername: ") p = input("Senha: ") while u == p: u = input("Erro: os valores não podem ser iguais.\nUsername: ") p = input("Senha: ")
a3eb55eb4af858431ac24de39bccc4e9ec918b3d
MichelMuemboIlunga/Python-From-Zero-To-Hero-For-Beginners
/1.Data Structure and Objects/1_variable.py
1,090
4.53125
5
# variable and data type (string, integer, float, arithmetic) # declaring variable variable = "I am a variable" # display the variable value in the console print(variable) # display the data type of the variable print(type(variable)) print("-------------- Done -------------------") # variable containing string da...
59f7439bfb4410ef9c1052ab8111b8fc07193568
kaneLittle2020/QUEUE
/main.py
874
3.953125
4
class Queue: def __init__ (self, capacity): self.internalArray = [None] * capacity self.start = 0 self.end = capacity - 1 self.size = 0 def add (self, item): if (self.end != (len(self.array) - 1)): temp = self.end + 1 else: temp = 0 if (self.array[temp] == None): se...
217fd627aff637b66736c8bb77e6ab6a15af25bf
Dekuben/pyEx
/pythonExercises/ex19.py
567
3.625
4
def CheeseAndCrackers(cheeseCount, boxesOfCrackers): print "You have %d cheeses!" % cheeseCount print "You have %d boxes of crackers!\n" % boxesOfCrackers print "I can just give the function numbers directly:" CheeseAndCrackers(20,30) print "OR, I can use variables:" amountOfCheese = 10 amountOfCrackers =...
0ba15f4a1e9826eb0c703742f000a72f6a6a441f
tommyconner96/Computer-Architecture
/class_notes.py
3,562
4.0625
4
import sys PRINT_WORLD = 1 HALT = 2 PRINT_NUM = 3 SAVE = 4 PRINT_REGISTER = 5 ADD = 6 PUSH = 7 POP = 8 CALL = 9 RET = 10 memory = [0] * 256 # LOAD A PROGRAM INTO MEMORY def load_program(): if len(sys.argv) != 2: pri...
2831a6b6772ac448a4715e94b68700f01b9410b2
echrisinger/Blind-75
/solutions/insert.py
1,122
3.578125
4
class Solution: def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]: res = [] new_s, new_e = newInterval inserted = False for inter in intervals: s, e = inter if (new_s <= s <= new_e) or\ (new_s <= e ...
b3bcddcb48a595086ae2f62091b6c48d4c295580
jufei/BtsShell
/bts_infomodel/ute_common_converter/to_list.py
2,511
3.609375
4
# -*- coding: utf-8 -*- """Module contains converters to list of specified types. :author: Pawel Chomicki :contact: pawel.chomicki@nsn.com """ from .base import BaseConverter from .exception import ConvertError class ToTypeList(BaseConverter): """Class tries to convert current list to list of specified type. ...
a7a08f61f6670cb915cd68a50245aabf185e4584
FACaeres/WikiProg
/estruturas-condicionais/exercicio04.py
142
4.34375
4
numero = int(input("Digite um numero: ")) if (numero % 7 == 0) or (numero % 3 == 0): print("Divisivel") else: print("Nao divisivel")
c1232a4384d18fa0fac2117425bd31e880424758
scnu-sloth/hsctf-2020-freshmen
/MISC-onePiece/src/game.py
1,469
3.734375
4
#!/usr/bin/env python3 import random import time import sys from map import * from secret import flag ''' NOTHING = 0 WALL = 1 BOMB = 2 PIECE = 3 PERSON = 4 HOLE = 5 ''' def randint(start, end): m = end - start + 1 return random.getrandbits(16) % m + start actions = ['u', 'd', 'l', 'r', '_'] seed = int(time....
5c1f50aff1ef5ef4925479878d54f8c87d60d4d3
ajwalsh08/randombracket
/ncaab.py
841
3.859375
4
# Import a random number generator. import random # Bring in the favorites and their chances of winning as a dictionary. with open('chances.txt') as f: favorites = dict(line.strip().split(",") for line in f) # Create a function that chooses winners using random numbers generation. def losers(d): lst = list() ...
dde1f8cec0c99fb30adbfe256ffddc02adb06cfe
nikk7007/Python
/Exercícios-do-Curso-Em-Video/01-50/034.py
244
3.890625
4
salario = int(input('Qual o seu salario? R$')) if salario <= 1250: salarioAumento = salario + (salario * (15 / 100)) else: salarioAumento = salario + (salario * (10 / 100)) print('Novo Salario: R${}'.format(salarioAumento))
3f422169871604625c12159db983a85f440ffc2a
tcltsh/leetcode
/leetcode/src/5.py
949
3.671875
4
class Solution(object): def judge(self, idx, step, s): front = idx + step tail = idx find = False ret = "" while True: if front >= len(s) \ or tail < 0 \ or s[front] != s[tail]: break find =...
1a797ca30a497773e72829c3e7c37a8b7450b6f2
Volkoff/firstPython
/listspractice.py
261
3.828125
4
list = ["Dog", "Cat", "Boop", None, None] print(list) tuple = ("Dog", "Cat", "Boop", None, None) print(tuple) set = {"Dog", "Cat", "Boop", None, None} print(set) dictionary = { 1:None } print(dictionary) iphone13 = "iphone13" iphone13+="pro" print(iphone13)
795202fc16a3df6a7088cb5e96b78a20eb0374dd
kermitnirmit/Advent-of-Code-2020
/day_21/solution.py
1,921
3.59375
4
from collections import defaultdict f = open("input.txt").read().strip().split("\n") lines = [] for rec in f: a,b = rec.split(" (") b = b.strip("()").split(", ") b[0] = b[0][len("contains") + 1:] lines.append((a.split(" "), b)) allergenmap = defaultdict(list) ingmap = defaultdict(set) # for every ing...
086f8f96ec5e2f19f12a7451526371b46640f2bf
zenwattage/csc1102018
/functiondeftest.py
137
3.59375
4
def test(age, amount, rate): loop_count = age while loop_count < age: age += age year += 1 print(test(5,10,20))
9e91aada659d4fa73b2b28e0f4bdf5f63766d250
a-falcone/puzzles
/adventofcode/2019/09a.py
7,862
3.65625
4
#!/usr/bin/env python3 """ --- Day 9: Sensor Boost --- You've just said goodbye to the rebooted rover and left Mars when you receive a faint distress signal coming from the asteroid belt. It must be the Ceres monitoring station! In order to lock on to the signal, you'll need to boost your sensors. The Elves send up t...
34a03b688bb9775159237239b26469833c2e5376
BurnFaithful/KW
/Programming_Practice/Python/Base/Bigdata_day1002/LOOP06.py
209
3.734375
4
# 팩토리얼 factorial = 1 x = int(input("팩토리얼 구할 수 : ")) for i in range(x, 0, -1): if i == 1: print(f"{i}=", end='') else: print(f"{i}*", end='') factorial *= i print(factorial)
92b17e8306cc02da2d01e7602d65153950288915
Azurick05/Ejercicios_Nate_Academy
/Encontrar_numero/Numero_mayor_sin_usar_max.py
279
4.0625
4
""" Ejercicio 17) Crear un programa que encuentre el numero más grande de una lista (sin usar la función max). """ numeros = [1, 2, 3, 4, 5, 6, 7, 8, 70, 10, 13, 15, 16, 17, 20, 30] mayor = 0 for entero in numeros: if entero > mayor: mayor = entero print(mayor)
ceedaf8f03d605da04cd0ef28d14b7528768dbf6
MeitarEitan/Devops0803
/8.py
344
3.8125
4
myFile = open("newFile.txt", "r") allLines = myFile.readlines() for line in allLines: print(line, end='') myOtherFile=open("newFile.txt","a") myOtherFile.write("\nthis is the last line") myOtherFile.close() myFile.close() inputUser = input("Enter your name:") myNewFile=open("names.txt","w") myNewFile.write(inputU...
4182f904ffed8003eee92fc460ffa05de07c5141
lsom11/coding-challenges
/leetcode/May LeetCoding Challenge/Implement Trie (Prefix Tree).py
1,479
4.125
4
class TrieNode: def __init__(self,char): self.char = char self.isWord =False self.children = {} class Trie: def __init__(self): """ Initialize your data structure here. """ self.root = TrieNode("*") def insert(self, word: str) -> None: ...
7d2c06dd6baab97e61b1518ed9207721c75fa27b
TejasD10/python
/data_structures/misc/LCS.py
1,821
3.890625
4
import unittest def longest_subsequence(s1, s2): """ Determine the longest common subsequence in the strings s1 and s2 :param s1: String :param s2: String :return: A Tuple of the length and the longest common subsequence. """ # If one of the string is none, there is no common subsequence, ...
879c929183f98e70da6526822733576695d04f8c
baaanan01/practice3-4
/21_6.py
301
3.671875
4
import turtle def tree(forward_len=200, minim_len=5): turtle.forward(forward_len) if forward_len > minim_len: turtle.left(45) tree(0.6*forward_len, minim_len) turtle.right(90) tree(0.6*forward_len, minim_len) turtle.left(45) turtle.back(forward_len)
b6dafc74a6b08f9a403c648f034ffd58e33f82cd
funfun313/strings
/string1.py
150
3.609375
4
def tripleend(s): l = len(s) w=s[l-2:] return w+w+w print(tripleend("hello")) print(tripleend("hi")) print(tripleend("goodbye"))
17ab37243715033d028b421b0345fac86be7b59d
DovzhenkoVit/main_academy_homework
/homework_6.py
1,509
3.796875
4
sort_dict = {} def register_sort(*name): def wrapper(func): for sort_type in name: sort_dict[sort_type] = func def inner(*args, **kwargs): return func(*args, **kwargs) return inner return wrapper def sort(sort_type, *key): def wrapper(func): def i...
d0eadcbb12bb50d9bdbffdb96a8175be3cf9f325
minjekang/Python_Study
/Python/Rand.py
941
3.78125
4
from random import * # print(random()) # print(random() * 10) # 0.0 ~ 10.0 # print(int (random() * 10)) # 0 ~ 10 # print(int (random() * 10)) # print(int (random() * 10)) # print(int (random() * 10 + 1)) # 1 ~ 10 # print(int (random() * 10 + 1)) # 1 ~ 10 # print(int (random() * 10 + 1)) # 1 ~ 10 # print(int (random...
b39c658b6f043df0003b4f96173b0239a765ca52
itwbaer/advent-of-code
/day4.py
2,918
4.5
4
""" A new system policy has been put in place that requires all accounts to use a passphrase instead of simply a password. A passphrase consists of a series of words (lowercase letters) separated by spaces. To ensure security, a valid passphrase must contain no duplicate words. aa bb cc dd ee is valid. aa bb cc dd aa...
df37b3db6a4102090fcc8ea0b604dcbb99a63a78
avqzx/CS3_Git
/student_gui.py
7,014
4.03125
4
import tkinter as tk from student import Student from student import StudentListUtilities class StudentGui: DEFAULT_NAME = "" DEFAULT_GRADE = 9 DEFAULT_ADDRESS = "123 Main St, 456" DEFAULT_PHONE = "123 456 7890" def __init__(self): """Constructor for a GUI for Student.""" self._ro...
f39789e37a4cf4d0d5f994e6f1f2ae08b8c02a9e
cybelewang/leetcode-python
/code204CountPrimes.py
709
3.859375
4
""" 204 Count Primes Count the number of prime numbers less than a non-negative number, n. """ # https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes # 1 is not a prime number class Solution: def countPrimes(self, n): """ :type n: int :rtype: int """ if n < 2: ...
05c0fe1817d05ae9eec396618fbbca586f2fde19
lucienbertin19/python_exercise
/exercise.py
959
4.3125
4
''' To design and implement a Python application that prints all numbers between 1 and 100 with the square value in the allotted time specified. • Create a Python application that will loop between 1 and 100 for i in range(1, 101): print(i) • The numbers are to be printed out alongside their squared val...
a0e5ebee6c667189cb226d3721083edbfc39ba67
graevskiy/mit_6.0001
/PSet1/ps1a.py
700
3.5
4
#! python3 import sys if len(sys.argv) != 4: sys.exit('parameters to provide annual_salary portion_saved total_cost') try: annual_salary = int(sys.argv[1]) portion_saved = float(sys.argv[2]) total_cost = int(sys.argv[3]) except: sys.exit('one of your parameters is of incorrect types') assert por...
7e52bd4e65afb2eec143b049a0118f9d44a9a311
ojhermann-ucd/comp10280
/p18p5.py
359
3.953125
4
""" Pseudocode take user input count each occurance of "xyz" count each occurance of ".xyz" take the difference print the results """ stringInput = input("Please enter what you would like: ") def xyzCheck(s): xyzCount= 0 xyzCount += s.count("xyz") xyzCount -= s.count(".xyz") return xyzCount print("There are "...
3764a2cda74f66ebc8cebddc04fea0866e9ffc3b
mdbasoglu/Phyton-Applications
/Tek mi cift mi.py
164
3.6875
4
nummer=int(input('Schreiben Sie bitte Ihre Nummer!')) if nummer % 2==0: print('Cif Sayidir') # yada print(f'{nummer} cift sayidir') else: print('tek sayidir')
a6715dcf3acb15423af8a7a1ec145259777a7a54
msuzun/GlobalAIHubPythonCourse
/Homeworks/HW3.py
489
3.984375
4
#question 3 loginUsernamePassword={"admin":"admin", "root":"1234567", "login":"qwerty"} print(loginUsernamePassword.keys()) username=input("Kullanıcı adinizi giriniz") password=input("Parolanızı giriniz") if username in loginUsernamePassword.keys(): if loginUserna...
b3d108d971309d26b88949c0de3eff7c836e4287
pabloares/misc-python-exercises
/cesar-short.py
354
3.875
4
string = input("Introduce una frase: ") shift = int(input("Numero entre 1 y 25 para cifrar: ")) newstring = "" for i in string: n = ord(i) if n >= 65 and n <= 90: newstring += chr(((n-65+shift) % 26) + 65) elif n >= 97 and n <= 122: newstring += chr(((n-97+shift) % 26) + 97) else: ...
88a31567cdc0b9ddfebc0a7916bea48e4bac1255
duwenzhen/leetcode
/833find.py
806
3.5
4
from typing import List class Solution: def findReplaceString(self, S: str, indexes: List[int], sources: List[str], targets: List[str]) -> str: nl = [] for i, v in enumerate(indexes): nl.append((v, sources[i], targets[i])) nl = sorted(nl, key=lambda x: x[0], reverse=True) ...
590463ad832f16841bcdd9647d73520383e2a61f
joostrijneveld/Euler-Project
/Python/problem63.py
309
3.640625
4
import math def diglen(n): return len(str(n)) def main(): count = 0 for i in range(100): for j in range(100): n = pow(i,j) if diglen(n) == j: print "j = " + str(j) + " LEN= " + str(diglen(n)) + "Result: " + str(pow(i,j)) count = count + 1 print count if __name__ == "__main__": main()
9b716865be1e87a83017b9ff60f378276c433036
huangwenzi/mingyue
/main/control/image.py
2,171
3.734375
4
# 系统模块 # 三方模块 import pygame # 项目模块 # 窗口 class Image(): # 初始化 # parent : 父级窗口 # path : 图像资源地址 # name : 资源名 # tmp_type : 图像类型 # postion : 坐标 def __init__(self, parent, path, name, tmp_type, postion): self.parent = parent # 父级窗口 self.image_list = [] # 子级窗口列表 sel...
b3696040510322e2785026d3c9d6afcdef5582e3
bellcliff/algorithm
/sorting/quick.py
1,561
3.546875
4
# encoding: utf-8 import sys import os testpath = os.path.dirname(os.path.realpath(__file__)) + "/test" if not testpath in sys.path: sys.path.append(testpath) from TestStuf import TestStuf class QuickSorting(TestStuf): ''' from [[http://zh.wikipedia.org/wiki/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F]] function qu...
211d6ce07287364d6800a059625419ac93e88e12
sohaib-93/SOIS_Assingment
/Embedded_Linux/Part_A/prog3.py
769
4.53125
5
# !/usr/bin/python3 # Python Assignment # Program 3: Implement a python code to find the distance between two points.(Euclidian distance) # Formula for Euclidian distance, Distance = sqrt((x2-x1)^2 + (y2-y1)^2) def edist(x1,y1,x2,y2): dist1 = (x2-x1)**2 + (y2-y1)**2 dist = dist1**0.5 return dist x1 = float(input("...
568d2e1865bc08f62a448e6b4f720a9a1ec7435f
oclather/learn_python
/getImage/learn_class.py
3,226
4.21875
4
#coding=utf-8 #这里学习类、继承、多态 #学习完:获取对象信息。 接下来是:面向对象高级编程 class Student(object): #这是一个类:1、类的名称一般都大写;2、括号中是这个类的继承类,如果没有继承,则写object def __init__(self, name, sex, score): #这里可以理解为模板参数,将这一类中所有共有的参数都直接写进来。创建实例时必须要携带这些参数。self是本身就有的,不用传参数 self.__name = name #__代表这个参数是私有的。不能从外部访问 self.score2 = score #我们从外部设定内部参数值的时候,实际...
8ecf2bbb1b21bb514c0d5be41ffb3cbcdabad29a
chuliuT/Python3_Review
/Python3命名空间和作用域.py
1,025
3.890625
4
# var1 是全局名称 var1 = 5 def some_func(): # var2 是局部名称 var2 = 6 def some_inner_func(): # var3 是内嵌的局部名称 var3 = 7 g_count = 0 # 全局作用域 def outer(): o_count = 1 # 闭包函数外的函数中 def inner(): i_count = 2 # 局部作用域 import builtins print(dir(builtins)) total = 0 #...
ab951b913e3f0adc872f65e695e8047f90c4d5a7
RickXie747/UNSW-18S1-COMP9021-
/Lab4/Q4.py
872
3.65625
4
def print_square(*L): if not L: raise square_exception('No Input!') for i in range(len(L[0])): if len(L[0]) != len(L[0][i]): raise square_exception(f'Wrong Input!') for j in range(len(L[0][i])): print(L[0][i][j], end = ' ') print() def is_magic_square(*...
aad2ea8c3d79e0e3f80dc50d43cf554be2a99061
Donsworkout/boj_algorithm_python
/divide_conquer/boj_1992.py
680
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Feb 8 18:12:18 2019 @author: donsdev """ def quad(size,x,y): if size == 1: print(arr[y][x],end='') return same = True for i in range(y,y+size): for j in range(x,x+size): if arr[i][j] != arr[y][x]: ...
58e4180b26ee33f6e0f696b68a0743adc9df8457
maynkjain/CSE544-Probability-and-Statistics-Assignment
/A1/nba.py
4,314
3.828125
4
import numpy def games(): """ This function performs 7 games and calculate the wins of each team based on the win probabilities. The win probabilities for both the teams are equal (=0.5). args: None return: - [eventA_Occured, eventBA_Occured] where, eventA_Occured: LAC is 3-1 ...
b03699a211be656dd5f8faf3c236caae9194d57b
rajat19/Hackerrank
/Tutorials/30-Days-of-Code/30-review-loop.py
359
3.8125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT def printc(s): for i in range(0, len(s), 2): print(s[i], end='') print(" ", end='') for i in range(1, len(s), 2): print(s[i], end='') print() if __name__ == "__main__": t = int(input()) while t>0: s = ...
9d1a59167e53da032a25672c070f6a649d7ba9ff
Sohamraje137/Python-Learning
/Python_codes/ex03.py
214
4.28125
4
# inpu1=input("Please enter a test string\n") # if len(inpu1) <3: # print("\nShort") # else: # print("Okay") num=input("Please enter a number"); num1=int(num) if num1%2 == 0: print("Even") else: print("Odd")
6ce1e834e9b90fa13766bf881d4602b0fdb1c5a1
CharuTamar/SIG-PYTHON
/MODULE3/M3_4.py
135
3.71875
4
print("CHARU TAMAR 1803010065") sum=0 for i in range(0,11): if i%2==0: sum+=i print("Sum of even numbers from 0 to 10 is:",sum)