blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d8a61ab2ca640b9bd50066cc4189688d05c533b8
raymondluk1995/UNSW-course-backup
/COMP9021/Assignment/Assignment_1_Question_3.py
2,347
3.8125
4
import sys word_to_value = {'a': 2, 'b': 5, 'c': 4, 'd': 4, 'e': 1, 'f': 6, \ 'g': 5, 'h': 5, 'i': 1, 'j': 7, 'k': 6, 'l': 3, \ 'm': 5, 'n': 2, 'o': 3, 'p': 5, 'q': 7, 'r': 2, \ 's': 1, 't': 2, 'u': 4, 'v': 6, 'w': 6, 'x': 7, \ 'y': 5, 'z': 7} def l...
ae6a9e001de26e09992008490f0f4c9d4920ed1b
SilviaCabello/firstPython
/loan.py
279
3.921875
4
money_owed = float(input("How much money do you owe, in dollars?\n")) apr = float(input("What is the annual percentage rate?\n")) payment = float (input("What will your monthly payment be, in dollars?\n")) months = int(input("How many months do you want to see resulst for?\n"))
51dfa3f8040b9ad4c472f4ef192bd1e0af9d109d
jmorenov/CRIP
/test.py
2,516
3.578125
4
# -*- coding: utf-8 -*- """ Criptografía. Práctica 2. Cifrado de Flujo @author: Javier Moreno <jmorenov@correo.ugr.es> Archivo de prueba de los ejercicios mostrando ejemplos y comprobaciones. """ import cifrado_flujo as cf #################### # # Ejercicio 1 # #################### print("Ejercicio 1") if cf.testG...
f9e56006e09780a4a7663f2588cdaa4e26feff7e
denyadenya77/beetroot_units
/unit_2/lesson_11/presentation/1.1.py
2,990
3.578125
4
# Создать классы с методами __str__, __repr__ и собственными методами классов, построить правильную иерархию классов. # Перечень классов: Студент, Преподаватель, Персона, Зав. кафедрой. class Person: def __init__(self, name, age, p_number): self.name = name self.age = age self.p_number = p...
f90733bef923ec6c5b3e87be67cf0b2c311b0ccf
alirezanorouzi/Hypertension
/ImportantFeature.py
2,418
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jun 3 13:16:25 2021 @author: alireza """ # linear regression feature importance from sklearn.datasets import make_regression from sklearn.linear_model import LinearRegression from matplotlib import pyplot import pandas as pd from sklearn.linear_model ...
7b1acc9ee7d7bf5c4195b71d26261b0fbe1e98e9
dm36/interview-practice
/leetcode/sum_bst.py
771
3.8125
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 findTarget(self, root, k): """ :type root: TreeNode :type k: int :rtype: bool ...
2652831d077e7da2982e2ee2b1b89c34716d4be2
marcmatias/challenges-and-studies
/Edabit/python/Xs and Os, Nobody Knows.py
283
3.75
4
''' Xs and Os, Nobody Knows Create a function that takes a string, checks if it has the same number of "x"s and "o"s and returns either True or False. ''' def XO(txt): return txt.lower().count("x") == txt.lower().count("o") print(XO("ooXXm"))
7df289288122b4cadedca51d48bf69994622b3fa
errinmarie/FeedBack
/Documents/BACKEND/week2/2.3-python/2.3-python/activities/1_intro_to_python.py
1,863
4.4375
4
# HINT 1: Lines starting with '#' are comments & ignored # HINT 2: Only do one challenge at a time! Save and test after each challenge. # Challenge 1: # 1. Write Python code here to print 'Hello World!' # 2. Save this file # 3. Run it it in a terminal # Challenge 2: # Write more print statements, to print out your f...
916f8e56365ee4551231be7b9cdd435a59d76a18
imsubhamsingh/Project-Euler
/1.py
129
3.5
4
def compute(): ans= sum(x for x in range(1000) if x%3==0 or x%5==0) return str(ans) if __name__=="__main__": print(compute())
187ea161feb6ac5a80caf35e3b107f8ef56cedf4
klknet/geeks4geeks
/algorithm/graph/connectivity_of_graph.py
1,062
4.09375
4
""" Check if a graph is strongly connected. """ from algorithm.graph.graph import DirectedGraph def strongly_connected(graph): if not is_connected(graph): return False if not is_connected(reverse_graph(graph)): return False return True def reverse_graph(graph): re = DirectedGraph() ...
2b6575f4fcd87f41380f53fc6de5af64b519b54b
SandyUndefined/Python-tutorials
/Algorithm/Amazon.py
460
3.734375
4
''' Given an array nums you need to find sum of the k elements such that it's maximum Input : [80,-50,90,100] k = 2 Output : 190 ''' def maxi(arr, k): new = 0 for i in range(k): new += arr[i] curr_sum = new for i in range(k, len(arr)): curr_sum += arr[i] - arr[i - k] new =...
0826e441760e163e17f0d3a69961540334f79e2b
nischalshrestha/automatic_wat_discovery
/Notebooks/py/cshields/introduction-to-naive-bayesian-classifier/introduction-to-naive-bayesian-classifier.py
11,255
4.03125
4
#!/usr/bin/env python # coding: utf-8 # This notebook introduces Python, data analytics, and an online platform to practice them - Kaggle! We will go over the basics of data storage, manipulation, and visualization with Python. Then we will implement a statisical learning model to develop a classification predictor. T...
d79ea7fadea3a1f69b3334d2a487fb5c17b37172
1902february04cloud/grep-emurray8
/palindrome.py
221
3.96875
4
#!/usr/bin/env python3 def main(): with open('cities.txt') as f: for line in f: line = line.strip() reverse = line[::-1] if line.lower() == reverse.lower(): print(line) if __name__ == '__main__': main()
810c89d83aeab5f914ca02f4a56a90e8688e865d
simtb/coding-puzzles
/daily_coding_challenges/challenges/invert_binary_tree.py
1,093
4.125
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Google. Invert a binary tree. For example, given the following tree: a / \ b c / \ / d e f should become: a / \ c b \ / \ f e d """ from typing import List class BinaryTreeNode: def __init__(se...
2b1a5ac26a95e6b980c24137ba6360f28e3077c7
AndyFlower/zixin
/python/pyfiles/range.py
467
3.671875
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 2 10:48:45 2020 @author: sangliping """ range1 = range(4) # 只指定stop为4,start默认为0,step默认为1 range2 = range(5,8) # start=5 stop=8 step默认为1 range3 = range(3,20,4) # start=3 stop=20 step = 4 range4 =range(20,0,-3) # step也可以为负数 print(range1,range2,range3,range4) print(range4...
be2cfd9e87f54b23f2197911f4cd2e341ae87e53
ricwtk/result-ai-a1-202104
/players/Group14Player1/player.py
7,754
3.578125
4
# Node class for each position on the maze class Node(): def __init__(self, parent=None, state=None): self.ID = None self.parent = parent self.state = state self.expansionsequence = -1 self.children = [] self.actions = [] self.removed = False self...
71c4bb6afa50aa2662b5672778c6438102135141
crystal30/DataStructure
/PycharmProjects/leetcode/MySort/88.py
2,061
3.84375
4
class Solution: def merge(self, nums1, m: int, nums2, n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ if m == 0: nums1[:] = nums2 elif m>0 and n>0: if nums2[0] >= nums1[m-1]: nums1[-n:] = nums2 ...
ec35049cadedde8476b6dba65412a8bfade3d61c
liujiang9/python0421
/dmeo/day6/code/demo_02字符串.py
1,538
4.21875
4
# string1 = "hello" # string2 = string1 # string3 = "hello" # print(id(string1),id(string2),id(string3)) # lst1 = [1,2,3] # lst2 = lst1 # lst3 = [1,2,3] # print(id(lst1),id(lst2),id(lst3)) # string = "hello world" # #获取 e # print(string[1]) # #获取d # print(string[-1]) num_str = "0123456789" # 1. 截取从 2 ~ 5 位置 的字符串 # ...
ff15c9337ce438b7eb573698f109729061e8a7a1
rajeevdodda/Codeforces
/CF-A/1401-1500/CF1459-D2-A.py
450
3.53125
4
# https://codeforces.com/problemset/problem/1459/A for _ in range(int(input())): n = int(input()) red = input() blue = input() red_count = blue_count = 0 for i in range(n): if red[i] > blue[i]: red_count += 1 elif red[i] < blue[i]: blue_count += 1 if red...
662f428366b6a8713dd89bf3fadea9f707bd452f
thran/the_code
/primes.py
1,191
3.640625
4
from fractions import Fraction from functools import reduce from math import sqrt from collections import defaultdict from utils import memoize @memoize def factorization(n): found_primes = defaultdict(lambda: 0) while n > 1: found = False for i in primes(): if n % i == 0: ...
a01f526481d48cc0864823d0dcd912a23d35ec15
andreacalegari98/Games
/reversi.py
6,952
4.34375
4
#!/usr/bin/env python #python2 program that simulates a game of reversi import random, time #globals p1, p2 = "X", "O" #characters for each player gameCounter = 0 def draw_board(board): '''This function takes in an 8x8 array and prints it to stdout.''' print " 0 1 2 3 4 5 6 7" row = 0 for i in ra...
5fac735dca1a2b05de5c176d0967777e968ecf62
mtyylx/BasicAlgorithms
/binary_search.py
710
3.9375
4
# Basic Binary Search # 返回与target最相近的较小元素的index def find_closest(a, target): if a is None or not isinstance(a, list) or len(a) == 0: return -1 left = 0 right = len(a) - 1 while left <= right: mid = left + (right - left) // 2 if target > a[mid]: left = mid + 1 ...
5b570168559708075d967909b9d7130ac454da75
emil45/computer-science-algorithms
/algorithmic-questions/majority_element.py
553
4.15625
4
from collections import defaultdict def majority_element(l): """ Given an array of size n, find the majority element. The majority element is the element that appears more than floor(n/2) times. You may assume that the array is non-empty and the majority element always exist in the array. """ ...
0172d82b7d7c9f99f21bcf27653cc202dc10d12f
asishraz/banka_sir_notes
/ch_1/39.py
343
3.828125
4
#wap to enter the values of u(object vision) & v(image vision) and print the value of f(focal length) using the formula: # 1/f = (1/u) + (1/v) u = int(input("enter the object vision: ")) v = int(input("enter the image vision: ")) f = (u*v) / (v+u) ''' (v+u)/uv = 1/f => uv/f = v+u = > f(v+u) = uv ''' print("enter ...
921a1b18cc4037c23c02d9479a3d42f7d9680431
rosu123/X-Serv-13.6-Calculadora
/calculadora.py
883
3.921875
4
#!/usr/bin/python3 import sys from sys import argv def sum(numero1, numero2): return numero1 + numero2 def res(numero1, numero2): return numero1 - numero2 def mult(numero1, numero2): return numero1 * numero2 def div(numero1, numero2): try: return numero1 / numero2 except ZeroDivisi...
c726d9c805a5e9514555057f43ffaf95da24b407
hoholyin/CS50x
/pset6/caesar.py
1,223
3.90625
4
import cs50 import sys def main(): if len(sys.argv)==2: print("Plaintext:", end="") t=cs50.get_string() key=int(sys.argv[1]) if key>26: while True: key=key-26 if key<=26: break elif key<0: while True...
141ab074958f0de76afe3775a26c89654045ce40
clovisleoncio/problemsolve
/hackerrank/arrays-and-sorting/countingsort4/countingsort4.py
337
3.5
4
#!/usr/bin/env python inputSize = int(raw_input()); lists = [[] for x in xrange(100)]; for k in xrange(inputSize): lineSplit = raw_input().split(); position = int(lineSplit[0]) if k < inputSize / 2: text = '-'; else: text = lineSplit[1]; lists[position].append(text); print ' '.join(' '.join(a for a in x...
a319f26502ea5c93ce34e90aa51da4e62e97c9d1
kapoor-rakshit/pyfiddle
/xlsx_works.py
4,273
3.6875
4
# REFERENCE : https://openpyxl.readthedocs.io/en/stable/tutorial.html from openpyxl import Workbook, load_workbook # A workbook is always created with at least one worksheet. #---------------------------------------------------------- wb = Workbook() # get the current sheet #---------------------- ws1 = wb...
dd6b75a3030b4de6de74c2d55561d2187d8606cc
gothandy/PythonPlayground
/PythonPlayground/Functions.py
452
3.625
4
def A(): print('A') def B(): print('B') def C(): print('C') i = 'b' # Using Eval f = { 'a': 'A()', 'b': 'B()' } eval(f[i]) # Classic if if i == 'a': A() elif i == 'b': B() # Short circuit. def sc(x): (x == 'a' and A()) or (x == 'b' and B()) sc(i) # Lambda l = lambda x: (x == 'a' and A()) ...
9bce51764b98275bd4de9e7207e37f6b6da7619c
Thairam/Projeto-de-Extensao
/4º - 03.05.2019/1171.py
214
3.5
4
n = int(input()) valores = [0] * 2001 for i in range(n): x = int(input()) valores[x] += 1 for i in range(len(valores)): if valores[i] != 0: print('{} aparece {} vez(es)'.format(i, valores[i]))
8cf6efdf152baa2d5c8344ca51b7dc23b3cdb823
rtroshynski/one-python-project-a-day
/2019-06-25-Python_Counter.py
416
3.875
4
# Python 3.7 # https://book.pythontips.com/en/latest/collections.html from collections import Counter colours = ( ('Yasoob', 'Yellow'), ('Ali', 'Blue'), ('Arham', 'Green'), ('Ali', 'Black'), ('Yasoob', 'Red'), ('Ahmed', 'Silver'), ) favs = Counter(name for name, colour in colours) print(favs) ...
8551c0ad8451a287ac2541090db06bb0f6d76355
zxmeng/LeetCode
/string/13.py
1,069
3.671875
4
def romanToInt(self, s): """ :type s: str :rtype: int """ roman = {"I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000} re = 0 i = 0 while i < len(s): if i == len(s) - 1: re += roman[s[i]] elif...
161b3cda39d21eaf5f4252796225375a636691b3
murongziying/python
/case/random_number.py
662
4.0625
4
#! /usr/bin/python3 # author:linuxc # date:2018.5.27 # application:random number import random # 用random.randint(0,9)方法获取0-9的随机数 answer = random.randint(0,9) guess = int(input("Please guess the number i want in my heart:")) if guess == answer: print("You got the right answer for the first time!") else: if guess...
226a4c70f6ba33c790df0265b12831fbf263f664
mc811mc/cracking-python-bootcamp
/text_based_fantasy_game.py
8,306
3.859375
4
import string gender = str(input("""What is your gender? Enter "m" for male and "f" for female. """)) name = str(input("What is your name? ")) name = string.capwords(name) gender = gender.lower() timeframe = int(input("What year is it in your world? ")) if gender == "m": partner_name = str(input("What is the nam...
f84c9766c545de93df3e0fdf82c433b107f00e6f
garg-saurav/numpy-neural-net
/layers.py
16,040
4.0625
4
'''This file contains the implementations of the layers required by your neural network For each layer you need to implement the forward and backward pass. You can add helper functions if you need, or have extra variables in the init function Each layer is of the form - class Layer(): def __init__(args): ...
07c79e067cbd44cef14b21ad9115f28d64890155
brianhardner/COSC
/ELIZABETH/Project2.2.py
5,594
3.640625
4
import csv, math # i dont use these lists, they just help me remember what columns go to which data elements passengerid = [] #0 Skip this when reading data in survived = [] #1 Keep 0 pclass = [] #2 Keep? 1 pname = [] #3 Skip sex = [] #4 Keep 2 age = [] #5 Keep 3 sibsp = [] #6 Skip parents=...
d0a3baf38b0a24e487cd44dd43049e6880286eca
programming-653501/GovzichAV
/5.1.6.py
3,014
3.53125
4
import random def parse_int(string): while 1: try: string = int(string) while not string: print('Value should not be 0! Try again:') string = int(input()) except ValueError: print('Value should be integer! Try again:') ...
917c9e4dfa11fb8af08b3eb0b9dca305ee66e5d4
shiannn/Phys4009-Numerical-Analysis-Kakix
/5-3.py
598
3.5
4
import math class Vector3D(object): def __init__(self, x,y,z): self.x = x self.y = y self.z = z def r(self): return (self.x**2+self.y**2+self.z**2)**(1/2) def theta(self): r = (self.x**2+self.y**2+self.z**2)**(1/2) return math.acos(self.z/r) def phi(se...
73a9510202a319958c9284519566bd39a523af6d
jyash28/Python-practice
/chapter2/find.py
74
3.8125
4
string="she is beautiful and she is good dancer" print(string.find ("is"))
e5a28fb83cfdfcbd624bef2680d9983218ac0f8f
testcg/python
/code_all/day08/exercise06.py
1,468
4.21875
4
""" 练习3:创建函数,根据课程阶段计算课程名称. number = input("请输入课程阶段数:") if number == "1": print("Python语言核心编程") elif number == "2": print("Python高级软件技术") elif number == "3": print("Web全栈") elif number == "4": print("网络爬虫") elif number == "5": print("数据分析、人工智能") """ # def...
eaa8e660990473233f7ff13f3b560c9cf5d1a5c8
GdDev00/PythonWorkbook
/Part Four/99.py
820
3.765625
4
from numberConverter import hex2int, int2hex def convertDecToN(num, newBase): result="" n = num r = n%newBase result = int2hex(r)+ result n=n//newBase while n>0: r = n%newBase result = int2hex(r)+result n=n//newBase return result def convertNtoDec(num, oldBase): ...
36fee93fc758d78f0bddd2c58a7710932fe563d2
hgminh95/bank-diary
/bank_diary/common/syntax.py
2,551
3.5
4
import re class Tokenizer: TOKEN_REGEXS = '|'.join([ '[A-Za-z0-9]+', ',', '=' ]) def tokenize(self, line): return re.findall(self.TOKEN_REGEXS, line) class Parser: def parse_line(self, *tokens): self.tokens = tokens self.pos = 0 try: ...
2cf07a25bde5070688dc707427e002164d76642e
mmaysami/azure-functions-python
/Templates/FuncApp-Http-Py-OptionC/ToolsC1/toolsC1.py
305
3.546875
4
import time def sum1(a, b): a = float(a) b = float(b) return a+b def sub1(a, b): a = float(a) b = float(b) return a-b def pow1(a, b): start = time.time() a = float(a) b = float(b) return a**b def div1(a, b): a = float(a) b = float(b) return a//b
09432329d149728d2c96a05ed179e3a1fbbe0024
zouyuanrenren/Leetcode
/src/Problems/Minimum_Path_Sum.py
1,108
3.671875
4
''' Created on 12 Jan 2015 @author: Yuan ''' ''' A typical dynamic programming problem. Let us use MIN[i][j] to represent the minimal path sum from grid[0][0] to grid[i][j] then MIN[i][j] = min(MIN[i-1][j], MIN[i][j-1])+grid[i][j]. Consider the first row and column of grid[i][j] as corner cases. Two options for optim...
70bb92154fd072a5255d796df723854204538d65
cwjshen/dailycodingproblems
/python/24-lock-binary-tree.py
4,463
4.40625
4
# This problem was asked by Google. # Implement locking in a binary tree. A binary tree node can be locked or unlocked only if # all of its descendants or ancestors are not locked. # Design a binary tree node class with the following methods: # is_locked(), which returns whether the node is locked # lock(), which a...
a6881ecf4b1394ca4501718271ce01c7bb334474
BJT55/Code
/Test1/test1.py
3,222
3.765625
4
# s ='Hello, %s' % 'world' # print(s) # s = 'Hi, %s, you have $%d.' % ('Michael', 1000000) # print(s) # s = 'growth rate: %d%%' % 7 # print(s) # s = 'hello, {0}, 恭喜你成绩提高了 {1}%'.format('晓红',12.31) # print(s) # r = 2.5 # s = 3.14*r**2 # print(f'radius {r} is {s:.2f}') # s1 = 72 # s2 = 85 # r = (85-...
0e4fd6f7dbff0b15ef6ae5a14cbb90b4b9483d08
kirubah18/guvi
/codekata/findgcd.py
136
3.609375
4
def gcd(nu1,nu2): if(nu2==0): return nu1 else: return gcd(nu2,nu1%nu2) nu1,nu2=map(int,input().split()) print(gcd(nu1,nu2))
7a1bc38d0b12c2d68ab685885f691fab8efd5bfe
Murfa/practice
/productivity_tool.py
2,079
3.8125
4
import time from datetime import datetime as dt #now we dont have to do datetime.datetime #if we only did import datetime as dt, then it would be dt.datetime #so dt.now() is the same as dt.datetime.now() hosts_temp='hosts' #using the r allows us to escape escape characters hosts_path=r'/home/fitzgej/Practice Py/produc...
7a7a51725f5f45fb174080ad6a4b6471020deb5c
rowantahseen/Problem-Solving
/leetCode_Medium/229_MajorityElementII.py
1,660
3.6875
4
''' **This solution aimes to be general and without mathematical calculations yet in O(1) Space, O(n) Time** According to a mathematical proof the (n/3) will give us 2 majority votes, but what happens if you faced n/2,n/4, n/5, n/6...n/k, don't know the mathematical proof of the number of candidates you will need e...
1ac70563cd94640d0db59a6c0a88b11f59d921aa
Katarzyna-Bak/Coding-exercises
/Find Maximum and Minimum Values of a List.py
891
3.890625
4
""" Your task is to make two functions, max and min (maximum and minimum in PHP and Python, maxi and mini in Julia) that take a(n) array/vector of integers list as input and outputs, respectively, the largest and lowest number in that array/vector. #Examples maximun([4,6,2,1,9,63,-134,566]) returns 566 minimu...
5f8d93a01c0f26bbb2a15bdfd28d10014ad7631c
AdamZhouSE/pythonHomework
/Code/CodeRecords/2909/60767/249747.py
649
3.59375
4
def getAppeartimes(target,string): cnt = 0 for i in range(0,len(string)-len(target)+1): #print() if(string[i:i+len(target)]==target): cnt += 1 return cnt def getNumOfDifferentLetters(s): temp = set(s) return len(temp) s = input() #print("s is",s) maxLetters = int(input...
084ab89f55b25eca8ac0f4118ea42d3927daf908
Sophietje/rosalind
/problem1.py
350
3.8125
4
# Problem 1 : Counting DNA Nucleotides def count(input): countA = input.count("A") countC = input.count("C") countG = input.count("G") countT = input.count("T") print(str(countA)+" "+str(countC)+" "+str(countG)+" "+str(countT)) if __name__ == "__main__": f = open("data/rosalind_dna_1_dataset....
d2959ad8f7d2f7242d3e4eaa0b0cc0af6a75e01b
fabricio24530/ListaPythonBrasil
/EstruturaDeRepeticao33.py
692
3.953125
4
'''O Departamento Estadual de Meteorologia lhe contratou para desenvolver um programa que leia as um conjunto indeterminado de temperaturas, e informe ao final a menor e a maior temperaturas informadas, bem como a média das temperaturas''' quantidade = int(input('Informe a quantidade de temperaturas:')) lista = [] fo...
c0e21fe70e58b263ab1548a9d5db9c92574ce5a0
PsychoLeo/Club_Informatique
/8-BinomeNewton/test.py
710
3.609375
4
import pprint def trianglePascal(N): """ Retourne une liste 2D du triangle de Pascal contenant N lignes """ triangle = [[1]] for indice_ligne in range(1,N): previous_line = triangle[-1] new_line = [] for indice in range(len(previous_line)+1) : if indic...
48e624a86bbccea8e828c42ecd2e38f86b067bd1
skraymond/adventofcode
/2017/day01/progy.py
1,014
3.53125
4
import sys import pdb import argparse def main_two(args): with open(args.filename) as file_open: data = file_open.readlines() count = 0 data = data[0].strip() half = len(data) / 2 def next(num): return (num + half) % len(data) for i in range(len(data)/2): if ...
cab8e2c12611efb800d1bf40a7c3b32acdedeed2
siddhantjayakumar/Algorithms-Project
/Chapter 2/Heapsort.py
946
4.1875
4
''' Heapsort Implementation ''' #Start with the heapify function that 'fixes' a max-heap from index of root def heapify(heap,root,end): left = 2*root + 1 right = left + 1 largest = root #Find the largest of the root, left and right, if not #at the end of the array if left <= end and heap[left] > heap[root]:...
cc7e9f78b40f9d6b9df54434407c571bf031ef78
Eugen00/LPTHW
/ex4.py
659
3.6875
4
cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_a_car average_passenger_per_car = passengers / cars_driven print "There are", cars, "cars available." print "There are only", drivers, "drivers available." print...
7b4fadce0cb724354be1806b68ef74b3753cf217
advecchia/hackerrank
/30-days-of-code/Day 6/solution.py
844
3.921875
4
MINIMUM_T_NUMBER = 1 MAXIMUM_T_NUMBER = 10 SMALLER_STRING = 2 GREATER_STRING = 10000 def validate_test_case_number(test_case_number): if MINIMUM_T_NUMBER > test_case_number > MAXIMUM_T_NUMBER: raise Exception('Invalid test case number.') def validate_string(input_string): if SMALLER_STRING > len(inp...
e87922d2dc1d5386350bc21129004548dd0f4bb7
AishaDhiya/python
/greatest no.py
300
4.15625
4
print(" the greatest noamong three is") a = int(input("enter first number =")) b = int(input("enter second number =")) c= int(input("enter third number =")) if a>b and a>c: print(a,"is the largest number") elif b>c: print(b,"is the largest number") else: print(c,"is the largest number")
0b3313a6e4bc835241e33911e8e3d727792341d8
anvetsu/anviz
/fractals/mandelbrot.py
1,937
4
4
""" mandelbrot.py - Implement the Mandelbrot set in Python using matplotlib & numpy, by reusing code from the Julia set. """ import matplotlib.pyplot as plt import numpy as np def mandelbrot_set(width, height, zoom=1, x_off=0, y_off=0, niter=256): """ A mandelbrot set of geometry (width x height) ...
9620be0f4649db5790a15dc08358f130885d6d68
jcmattasox/deal-cards
/cards 1.1.py
1,998
3.78125
4
#cards V1.1 # JC Matteson # testing functions and random by dealing cards # to be fixed on future version, cards can repeat (fixed) # to be fixed cant deal all 52 cards import random used = [] heartL=[] spadeL=[] clubL=[] diamondL=[] def card(): x = (random.randint(1,13)) ...
b394618c58fb169b4cddedc05ca7707a54d572de
SaumilP/Pyprogs
/rolling_dice/dice.py
322
4.125
4
#!/usr/bin/python import random min = 1 max = 6 roll_again = "yes" while roll_again == "yes" or roll_again == "y": print("Rolling the dices...") num1 = random.randint(min,max) num2 = random.randint(min,max) print("Values: {0} {1}".format(num1, num2)) roll_again = raw_input("Roll the dice again ? "...
8727183b9c9fa2f8f8bf49d31f23894e2c7a7fcd
santhosh-kumar/AlgorithmsAndDataStructures
/python/test/unit/problems/math/test_palindrome_number.py
991
3.78125
4
""" Unit Test for palindrome_number """ from unittest import TestCase from problems.math.palindrome_number import PalindromeNumber class TestPalindromeNumber(TestCase): """ Unit test for PalindromeNumber """ def test_solve(self): """Test solve Args: self: TestPalindromeN...
e8ced5ea5b698f5c9f196fb139ad142c3106161a
robgoyal/RedditWordCount
/main.py
1,523
3.6875
4
# Name: main.py # Author: Robin Goyal # Last-Modified: March 7, 2018 # Purpose: Calculate the frequency of words in reddit post(s) from helpers import * def get_post(url): """ (str) -> praw.Reddit.Submission Returns an instance of the Submission object from reddits API which contains information ...
a31bf1a0b7ecc5c28ce6817c5a12f6e05ef9ff5e
woohyun212/Data_Science_and_AI_introductory_Coding_Solution
/chapter9/ex_4.py
153
3.5625
4
a = input('a = ') b = input('b = ') for i in range(len(a)): print(a[i]+b[i], end='') print() for i in range(len(a)): print(a[i]+b[-i-1], end='')
fafbdd67f7d18640c6eb08c37ed05c2d90a41ef1
mbaeumer/fiftyseven
/part7/ex43/v1/input_util.py
288
3.828125
4
#!/usr/bin/python def get_string_value(question): value = '' while len(value) == 0: value = input(question) return value def get_yes_no_answer(question): answers = ['y', 'n'] answer = '' while answer not in answers: answer = input(question) return answer == 'y'
8bb3c283d154ef6217aeb238ef520f38cd71c9d0
dyedefRa/python_bastan_sona_sadik_turan
/18_Python_Veri_Analizi_Numpy/03_numpy-indexing.py
1,221
3.53125
4
import numpy as np numbers = np.array([0,5,10,15,20,25,50,75]) result = numbers[5] # output 25 result = numbers[-1] # output 75 result = numbers[0:3] # output [ 0 5 10] result = numbers[:3] # output [ 0 5 10] result = numbers[3:] # output [15 20 25 50 75] result = numbers[::] # output [ 0 5...
cf0fdb7753b7d94a4314c64200fa49655a96e1fe
Manash-git/Python-Programming
/mixed/reverse_num.py
180
3.71875
4
def reverse_num(n): result = 0 while n>0: last_digit = n%10 result = result*10 + last_digit n= n//10 return result print(reverse_num(153))
957e9e33c1d519ba15f3ec470ca52588dc6c7606
mariandocarmo/JogoResilia
/jogo-do-ouro-resilia-py.py
7,885
4.28125
4
def linha (): print ("="*60) def espaco (): print (" ") titulo = "Bem vindos ao jogo do ouro!" linha () print ("Bem vindos ao jogo do ouro!".center(60)) linha () nome = input("Qual o seu nome? ") idade = int(input("Quantos anos você tem? ")) if idade <= 9: print("O jogo só é permitido para maiores de...
45128ccb0e26422c3cf8fe55d11edd5dbce62b19
deepak368/luminarpython
/flowcontrolls/Disitionmaking/sorting3num.py
507
4.15625
4
num1=int(input("enter the 1num")) num2=int(input("enter the 2num")) num3=int(input("enter the 3num")) if ((num1>num2)&(num1>num3)): if(num2>num3): print(num1 ,num2,num3) else: print(num1 ,num3,num2) elif ((num2>num1) & (num2>num3)): if(num1>num3): print(num2, num1, num3) else: ...
e3af73a4a171ec6cf7109a4d72b040a193aab19b
fraware/A-Comparative-Study-on-Graph-Convolutional-Networks
/models/sparse_help_funcs.py
1,385
3.921875
4
"""Help functions for working with sparse matrices""" import numpy as np import scipy.sparse as sp def matrix2tuple(matrix, tol =1e-4): """Turns a matrix into its three-tuple representation as needed for 'tf.sparse.SparseTensor'. Args: matrix - matrix in form of numpy array Returns: indices, value...
51a84b43b6def3af8dc824a3b5c595f0037ebbe7
kami71539/Python-programs-4
/Program 13 Guess Game using If Else.py
433
4.15625
4
secret_word="Power" print("What is it that you seek ?") guess=input("I seek ") guess_limit=3 guess_count=0 out_of_guesses=False while guess!=secret_word and not out_of_guesses: if guess_count<guess_limit: print("No,Guess again.") guess=input("") guess_count=guess_count+1 else:...
a480e5b6f0826b03c1454620ca491770763161c4
mauney/DS-Unit-3-Sprint-1-Software-Engineering
/SC/acme_report.py
1,644
3.65625
4
#!/usr/bin/env python from random import randint, sample, uniform from acme import Product # Useful to use with random.sample to generate names ADJECTIVES = ['Awesome', 'Shiny', 'Impressive', 'Portable', 'Improved'] NOUNS = ['Anvil', 'Catapult', 'Disguise', 'Mousetrap', '???'] def generate_products(num_products=30)...
af89321304a7a1d13941206db31c1c0659b86550
Mushinako/River-Crossing
/river_crossing.py
8,114
3.6875
4
#!/usr/bin/env python3 import math import json from dataclasses import dataclass from itertools import combinations from typing import Tuple, List, Generator, Dict CONFIG_PATH = "config.json" SOLUTION_PATH = "solution.json" @dataclass class Horse: """Data of each horse at each instant Properties: id...
5adddabbaf0bf579bbfcef3e54242846f66bc721
jahnavi95/DP_Practice_Problems
/matrix.py
2,287
3.78125
4
def print_spiral_order(mat): top = left = 0 btm = len(mat) - 1 right = len(mat[0]) - 1 while True: if left > right: break for i in range(left, right + 1): print(mat[top][i]) top = top + 1 if top > btm: break for i in range(...
d54fb1f92e52d1226ebed5ce4a507947c9ee742b
siyun-koh/Sandbox
/password_checker.py
356
4.34375
4
passwordMinLength = 8 password = input("Please enter a password of minimum {} characters: ".format(passwordMinLength)) while len(password) < passwordMinLength: print("Your password is too short. Please enter a new one.") password = input("Please enter a password of minimum {} characters: ".format(passwordMinLe...
dd36b3efe5c4d0c03c7feb42b5c73d421d8c48c3
AngelSassin/Project-Euler
/28.py
453
3.796875
4
# returns the sum of the diagonals of the square spiral made from the # specified number. PRECONDITION: num is odd def sumDiagonalsSpiral(num): iterations = (num-1)/2 diagonals = [1] for i in range(0,iterations): difference = (i+1)*2 for j in range(0,4): diagonals.append(diagon...
ffe4a11b00ffdb26548cd87620316de8616f63db
jbro321/Python_Basic_Enthusiastic
/Python_Basic_Enthusiastic/Chapter_08/P_08_3_3.py
154
3.875
4
# Enthusiastic_Python_Basic #P_08_3_3 def main(): for i in range(2, 100): if i % 2 != 0 and i % 3 != 0: print(i, end=' ') main()
5205c3a6aa44e9473b0c8da43a9979fe37120d35
decayedteeth/python-learning-process
/爬虫代码/第三课.py
2,324
3.5625
4
from bs4 import BeautifulSoup file=open("作业/总文件.html","rb") html=file.read().decode("utf-8") bs=BeautifulSoup(html,"html.parser") # print(bs.head) # print(type(bs.head) # 1.tag 标签及其内容:拿到它所找到的第一个内容 # print(bs.title.string) # print(type(bs.title.string)) # 2.NavigableString 标签里的内容(字符串) # print(bs.a....
417514bdaf9d21b233d1fbad77e518ca965fdd0a
Vovanuch/python-basics-1
/adaptive_python_cource/18.Squirrels_and_nuts/18.squirrels_and_nuts.py
413
3.578125
4
''' Squirrels and nuts - 1 N squirrels found K nuts and decided to divide them equally. Determine how many nuts each squirrel will get. Input data format There are two positive numbers N and K, each of them is not greater than 10000. Sample Input: 3 14 Sample Output: 4 ''' try: n, k = int(input().strip()...
87579ed7777e4b26319ab4c93eea4647e2478188
Anshul-GH/hackerrank
/Solutions/42.Lists-KeyOperations.py
1,192
3.828125
4
# https://www.hackerrank.com/challenges/python-lists/problem # Key operations on lists: ''' insert i e: Insert integer at position . print: Print the list. remove e: Delete the first occurrence of integer . append e: Insert integer at the end of the list. sort: Sort the list. pop: Pop the last element from the list. ...
681788ffe7672458e8d334316aa87936746352b1
jichunl/CSE415
/Assignment1/a1.py
1,323
3.578125
4
# CSE 415 Winter 2019 # Assignment 1 # Jichun Li 1531264 # Part A # 1 def five_x_cubed_plus_1(x): return 5 * (x ** 3) + 1 #2 def pair_off(ary): result = [] for i in range(0, int(len(ary) / 2 * 2), 2): result.append([ary[i], ary[i + 1]]) if (int (len(ary) % 2) == 1): result.append([ar...
b43700f6b801a4cadf03a3a7a7751bf6031f73d6
phamhailongg/C4T9
/minihack1/Part 3/ss3.py
520
4
4
# Viết chương trình cho người dùng nhập vào một tháng trong năm và in ra số ngày của tháng này m = int(input("Month? ")) if m <= 7 : if m % 2 == 0 : print("This month has 30 days") elif m == 1 : print("This month has 31 days") else : print("This month has 31 days") else : if...
51b5914a8b9c1d1a9c5e8cc47b11b0903d5825b8
KhanyiMM/Pre-bootcamp-python
/Task 3.py
185
3.625
4
def sixty_five(x,y): if x + y == 65 or x == 65 or y == 65: return True else: return False print(sixty_five(65,3)) print(sixty_five(60,5)) print(sixty_five(20,3))
86af59493ad5cc5d80a6634fd715301743ec62ce
madjabal/abstract-algebra-polynomial
/polynomial.py
2,338
3.859375
4
# Rough Draft of Polynomial Object for the purposes of studying and manipulating field polynomials class Polynomial: coefficients_d = {} coefficients_l = [] highest_degree = 0 field = 0 def __init__(self, coefficients, field): # Checks for input type and edits the corresponding attribut...
90fed6a1ce920b594384afb9a5d7bb08403967c7
dgiampapa/TaxiFareWebsite
/app.py
1,992
3.59375
4
import streamlit as st import datetime import requests ''' # TaxiFareModel front ''' #st.markdown(''' #Remember that there are several ways to output content into your web page... #Either as with the title by just creating a string (or an f-string). Or as with this paragraph using the `st.` functions #''') #''' ## He...
176cfe0d38b1afe9b68280043cf66cab5bda7af1
uadson/api_flask_iniciantes
/application.py
2,793
4
4
"""Construção de uma API CRUD para gerenciar barramentos de motores AA. Disponível em: https://ichi.pro/pt/desenvolvimento-de-api-com-flask-para-iniciantes-178216365709514 Obs.: fundamental utilizar uma ferramente de teste como Postman As informações necessárias para coleta serão: Number Plate Manufacturer Model...
6ff4ebb284f6baf12ec8ec7730378da02277858b
eflaherty/Projects
/python/practice/range_xrange_collections.py
1,135
3.734375
4
# range vs xrange for generating ranges from 1-1000 def geese(): goose=[] for i in range(1000): goose.append(i+1) for i in range(1000): goose.remove(i+1) def light(): lights=[] for i in xrange(1000): lights.append(i+1) for i in xrange(1000): lights.remove(i+1) #...
2283fc4bbed3be6adfcf3bb912513aa7be9154c1
AngelValAngelov/Python-Advanced-Exercises
/Lists as Stacks and Queues - Lab_student/02. Matching Brackets.py
339
3.75
4
numbers = input() stack_open_brackets = [] for i in range(len(numbers)): if numbers[i] == "(": index = numbers[i] stack_open_brackets.append(i) if numbers[i] == ")": index = i start_index = stack_open_brackets.pop() print(numbers[start_index: index + 1]) ...
7b6639968e92cde78b2f8786bdcedb7657675050
f1amingo/leetcode-python
/贪心算法 Greedy/860. 柠檬水找零.py
1,041
3.734375
4
from typing import List class Solution: def lemonadeChange(self, bills: List[int]) -> bool: five, ten = 0, 0 for bill in bills: if bill == 5: five += 1 elif bill == 10: if five == 0: return False ...
f42ae7fb55c1571558c828ef5a73663aa750e389
ianahernandez/master-python
/03-funciones/funciones.py
717
4
4
#======================================================= #=============== FUNCIONES ============================= #======================================================= """ Son fragmentos de codigo que se puede ajecutar múltiples veces. Puede recibir y devolver información para comunicarse con el proceso principal. "...
cb91a387b88abebb16b7293f40b9849b320575a8
MrSameerKhan/Machine_Learning
/practice/second_max_min.py
4,507
3.96875
4
my_list = [1,2,3,4,5] def second_large_number (): first_largest = my_list[0] second_largest = None for elem in range(1, len(my_list)): if my_list[elem] > first_largest: first_largest = my_list[elem] print(first_largest, second_largest) def second(): data = [-11, 20, 8, 30...
1509b856118479d924f05653b63ec7664e0a81c5
rivet9658/Rivet9658-Python-University-Works
/Python練習5/python練習5-例題4.py
271
3.625
4
#練習5-例題4 def totalAndmean(): total=0 for i in num: total=total+i return total def main(): for j in range(1,11): x=eval(input("put number:")) num.append(x) t=totalAndmean() print("sum=",t,"mean=",t/10) num=[] main()
faaeb6bebec620558b2ace0c95f19e434fb0f21b
pythonlove143/python_codes_Intor_to_computer_science
/sudoku_udacity.py
2,979
4.28125
4
#THREE GOLD STARS # Sudoku [http://en.wikipedia.org/wiki/Sudoku] # is a logic puzzle where a game # is defined by a partially filled # 9 x 9 square of digits where each square # contains one of the digits 1,2,3,4,5,6,7,8,9. # For this question we will generalize # and simplify the game. # Define a procedure, check_su...
a961be830502762f1f29a6115f51c62f0588940e
Adarsh1193/Python-Udemy-Course
/Object Oriented Programming/Funtion vs OOP.py
534
4.0625
4
""" def abc(): name = input('Enter the name') age = input('Enter the age') print(name) print(age) abc() """ class Student: def __init__(self, name, age): self.name = name self.age = age def get_data(self, name, age): self.name = name self.age = a...
5a1cf80647b467a02066225c17a4dfd683c981b4
SMony-L/Cracking-the-coding-interview
/Interview Questions/Linked List/palindrome.py
1,861
3.90625
4
class ListNode: def __init__(self, val = 0, next = None): self.val = val self.next = next class Solution: def __init__(self): self.head = None def insertNode(self,data): newNode = ListNode(data) newNode.next = self.head self.head = newNode def print...
9539a661cb196b0a15ae792d6e944f0a8c632442
kjwilsondev/leetcode
/max_subarray.py
1,272
3.78125
4
# Given an array of integers, find maximum length subarray having given sum. # For example, # Arr = [5,6,-5,5,3,5,3,-2,0] # sum = 8 # Output: # [-5,5,3,5] # Two loops def two_loops(arr, num): # instantiate old solution is [] final_solution = [] # iterate through array with index i for i in range(0, l...
40eff0e807a83375ec673eb60a696d261f21567a
awarbler/awarbler.github.io
/cse210/week5/hide/game/director.py
2,324
3.984375
4
from game.console import Console from game.seeker import Seeker from game.hider import Hider class Director: """A code template for a person who directs the game. The responsibility of this class of objects is to control the sequence of play. Stereotype: Controller Attributes: co...
6bc779a8139dce7284052b50b60a5e3c1b1009f0
jream-network/learn-python
/ch1/console-1.py
293
3.9375
4
#name = raw_input("Whats your name?\n") #print "Hello {0}".format(name) while True: try: age = int(raw_input("Whats your age?")) print "In 10 years you will be {0}".format(age + 10) except ValueError: print "Error: You must enter a digit" continue
5def1c6867133f89907f587871ac3a056157a3d3
zhlinh/leetcode
/0054.Spiral Matrix/solution.py
1,162
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-02-22 Last_modify: 2016-02-22 ****************************************** ''' ''' Given a matrix of m x n elements (m rows, ...