blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5f0e99461a268874a31f97da98f754bba2a2d9ff
peaisge/NN_digit
/predict.py
542
3.59375
4
import numpy as np from sigmoid import sigmoid def predict(Theta, X): # Takes as input a number of instances and the network learned variables # Returns a vector of the predicted labels for each one of the instances # Useful values m = X.shape[0] num_layers = len(Theta) + 1 p = np.zeros((...
c39d3eb3bc32fd08299399b87df61ffcb1ca54d3
Parkhyunseo/PS
/baekjoon/algo_1652.py
582
3.546875
4
N = int(input()) room = [] for i in range(N): room.append(list(input())) horizontal = 0 vertical = 0 for i in range(N): count = 0 for j in range(N): if room[j][i] == 'X': count = 0 else: count += 1 if count == 2: horizontal += 1 for...
ce25717acb4a7f3a43386d75dd0c883d78490b31
gjmingsg/Code
/leetcode/Remove Duplicates from Sorted List.py
933
3.828125
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def show(self): t = self st = '' while t!=None: st = st + '%d->' %t.val t = t.next print st class Solution: # @param head, a ListN...
a4afcd31bd0b346a88fa467ecb8ba9efee9c3eb8
Blacky91/info175_JuanContreras
/cen-pol.py
296
3.609375
4
if __name__== "__main__": cenit = "cenit" polar = "polar" cad = raw_input("Palabra a encriptar: ") for i in range(len(cad)): if cad[i] in polar: print cenit[polar.find(cad[i])] elif cad[i] in cenit: print polar[cenit.find(cad[i])]
ad0c7d5c30fe2f1b68a93c63859431fc7ba38deb
vivek3141/RandomProblems
/Python Projects/Lib cataloging.py
2,834
3.90625
4
#Project 2 : Library Book Stocking System #A library is in the process of updating its system and cataloguing all the books. The following #coding scheme is followed. Code is a 5 digit number. #Code starts with 1 – Magazine #Code starts with 2 – Fiction #Code starts with 3 – Non Fiction #Code starts with 4 – Referenc...
29fb5c6c721aa8b830e96a4e63fbf65583e87d36
tpracser/PracserTamas-GF-cuccok
/week-03/day-1/07a.py
140
3.9375
4
g1 = 123 g2 = 345 # tell if g1 is bigger than g2 if g1 > g2: print("g1 is bigger than g2") else: print("g1 is not bigger than g2")
55453b6cefa879cc7a3db4731152640ad3b1fe8c
bradmdesign/PY4E-UoM
/Course 4 - Databases/emaildb.py
1,146
3.6875
4
import sqlite3 conn = sqlite3.connect('emaildb.sqlite') cur = conn.cursor() cur.execute('DROP TABLE IF EXISTS Counts') cur.execute('CREATE TABLE Counts (email TEXT, count INTEGER)') fname = input('Enter File Name: ') if (len(fname)<1): fname = 'mbox-short.txt' fh = open(fname) for line in fh: if not line....
d585e16b37eee153b4ff110de015d65968843426
Loran425/2018AdventOfCode
/Day_2/Part_1.py
570
3.5
4
from collections import Counter def main(): twos = 0 threes = 0 with open("./input.txt", mode="r") as input: for line in input: c = Counter(line) two = three = False for char in c: if not two and c[char] == 2: two = True ...
32b4865ac119135149bbd940f4388ccef6b1d907
sandblue/Advent_of_code_2020
/05/adven2020_5.py
3,786
3.609375
4
import sys import math def find_highest_seat_id(path): file = open(path) highest_id = 0 for line in file: current_line_value = int(find_id(str(line))) if(int(highest_id) < int(current_line_value)): highest_id = int(current_line_value) file.close() print(highest_id) ...
fafbd90ea020b9ed84e0d585bb0d400516060f19
Chen-Yiyang/CompetitiveProgramming
/Lesson1/01_01_Fibonacci_DP.py
351
4.21875
4
# Fibonacci using Recursion # by Yiyang 17_01_18 fiboValues = {1:1, 2:1} def _Fibonacci(N): if N in fiboValues: return fiboValues[N] else: fiboValues[N] = _Fibonacci(N-1) + _Fibonacci(N-2) return fiboValues[N] N = int(input("Enter an integer: ")) for i in range(1, N+1+1): pri...
27ee889ee5ee7065c11f401ae0f3f21920227239
sweetysweets/Algorithm-Python
/microsoft/4.py
587
3.8125
4
class Node: def __init__(self,v): self.val = v self.next = None def set_next(self,next): self.next = next def get_length(node): if node is None: return 0 p = node q = node while p.next is not None and q.next is not None and q.next.next is not None: p ...
2a85119097060a6b215c3fee2a5555320a4b3983
Shimon-W/bioprojekt
/Sequence.py
9,698
3.875
4
"""This module contains classes that represent sequences of a 4x4 tile.""" import random class Sequence(list): """ Represents a DNA sequence. Enhances String class with useful methods for sequences. """ def get_part(self, part): """ Get specific numbered part of sequence. ...
570d3e92d657ade7c8b7a2c3c9ad09d3b35f1f1e
TonyXia2001/ICS3UI
/ICS3UI/palindrome.py
579
4.125
4
''' Tony(Tanglin) Xia 4/9/2018 Palindrome take an input, detect whether it's a palindrome, return True or False ''' def isPalindrome(userInput): tempList = list(userInput) for i in range(len(tempList)): tempList[i] = tempList[i].upper() if tempList == tempList[::-1]: return True else: return False userI...
0b4d29ea0d9ff9758dfce1d8f8369df88511090a
daks001/py102
/5/Lab5b_a.py
835
4.1875
4
# By submitting this assignment, I agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Name: DAKSHIKA SRIVASTAVA # Section: 532 # Assignment: LAB 5b ACTIVITY a # Date: 26 SEPTEMBER 2019 print("This p...
555273eccb98de31ee19693fe50a9e36ab056cce
bvick/RubikPhotoSolve
/Rcube.py
19,468
3.875
4
''' Created on Oct 30, 2017 @author: bob vick These are structures and functions for managing a Rubik's Cube. A cube is an object of class Rcube. Terminology: side - one of the 6 faces of a cube. facet - one of the 54 (9 for each side) surfaces. (Lars Petrus calls them "stickers") corner - one of the 8 corner piece...
3540775dc510153940e19820363c10cd2ecf653a
ajinkyamukherjee98/ElGamal
/ElGamal.py
680
3.5
4
import math import keyword class elGamal(): print("*************************** Simple Program for EL-GAMAL Algorithm ***************************") print("Enter the value for q :") q = int(input()) #print("You have chosen "+str(q)) p = (2*q) + 1 print("The value of P is "+ str(p)) ...
f3d3fba96abb6f7dea148106ab357bbff418a4ae
priyankasomani9/basicpython
/Assignment3/basic3.5_primeNumberInRange.py
170
3.625
4
for number in range(1,10000): count=0 for i in range(1, number + 1): if number % i == 0: count+=1 if count==2: print(number)
944c2896f7305b1c6848b13b2aec8f8c882071fb
silverstorm9/Test_keepass
/main.py
6,818
3.546875
4
import sqlite3 import os import getpass def add_entry(mem_conn,mem_cursor): username = input('Enter a username : ') if username == None: return password = ask_password() if password == None: return query = """INSERT INTO keepass (username,password) VALUES ('{}','{}')""".format(use...
26a4b92aac33d0389c01f554cc7b7e8ce48079cd
akhileshcheguisthebestintheworld/pythonrooom
/crazy.py
850
3.953125
4
input("What is your favorite basketball team?") if answer == "the warriors": input("Good, who is your favorite player on the Warriors?") if answer == "stephen curry": input("Is he the best player currently in basketball?") if answer == "yes": input("I agree with you.") else: input("I do not agree with yo...
6f24ac8a11118f09ffbae16c64d5a918f4ec0abf
namhai923/Daily-Problem
/simple-calculator/simple-calculator.py
1,206
3.53125
4
def eval(expression): result = '' operations = [] post_fix = [] for x in range(0,len(expression)): if expression[x].isdigit(): post_fix.append(expression[x]) elif expression[x] == ')': while(operations[len(operations)-1] != '('): post_fix....
9aced73d77b96ae0387427f8b8397cd20ed3d929
bhchen-0914/PythonCourse
/pattern_json/class8.py
662
4.15625
4
""" group分组 """ import re s = "<t>this is a webpage 's title<t> " r1 = re.search('<t>.*<t>', s) print(r1.group()) r2 = re.search('<t>(.*)<t>', s) # ()内表示一个分组 print(r2.group(0)) # 0是默认取值,会默认匹配完整的正则表达式结果 print(r2.group(1)) s2 = s = "<t>this is a webpage 's title<t>this is other webpage 's title<t>" r3 = re.search('...
472f167f1e5cdf04fa259d74052426982a3ff38c
elchigi/electiva4
/ejercicio1.py
332
3.90625
4
num = input("Ingrese el numero a calcular") divisor = 0 contador = 0 Arreglo= [] print("divisores:") if num % 2 == 0: iterar = num / 2 else: iterar = (num - 1) / 2 for i in range(1, int(iterar) + 1): if num % i == 0: Arreglo.append(i) contador = contador + 1 if contador == 10: break pr...
3c3c9e894535daef8d264951dfc3d00be08b79cf
bestyoucanbe/joyprpr0831urbanplanner2
/city.py
873
4.5
4
# Instructions # In the previous Urban Planner exercise, you practiced defining custom types to represent buildings. Now you need to create a type to represent your city. Here are the requirements for the class. You define the properties and methods. # Name of the city. # The mayor of the city. # Year the city was est...
fbc76072d74262691b48377ded955f02cd30a314
ITNika/advent-of-code-2019
/test_intcode_computer.py
1,455
3.71875
4
import unittest import IntcodeComputer class TestIntcodeComputer(unittest.TestCase): def test_initialize_memory(self): f = open("test_initialize_memory.txt", "w+") f.write("2,2,3,0,99") f.close() expected = [2, 2, 3, 0, 99] intcode_computer = IntcodeComputer.Int...
5617e7bc11f2393322ef152551c56343c75170e9
dunitian/BaseCode
/javascript/1.ES6/var.py
6,143
3.78125
4
# if 1 < 2: # b = 1 # print(b) # --------------------------------- # age = 20 # def test(): # global age # print(age) # test() # --------------------------------- # --------------------------------- # def show(a, b, *args, c): # print(a, b, args, c) # # # 1 2 (4, 5, 6) 3 # show(1, 2, 4, 5, 6, c=3) # ---...
9f426b0d4313f9e441edd441de42855c9d87e1aa
PaulAlexInc/100DaysOfCode
/projects/Day12_project/main.py
2,608
4.375
4
#Number Guessing Game Objectives: # Include an ASCII art logo. # Allow the player to submit a guess for a number between 1 and 100. # Check user's guess against actual answer. Print "Too high." or "Too low." depending on the user's answer. # If they got the answer correct, show the actual answer to the player. # Trac...
884ca98ee233d7b3745805a747a469aa639ea4b0
Janoti/CodeWars-Python
/DataStructures.py
469
3.9375
4
############ LISTS my_list = [1, 2, 3, 4, 5] mix_list = ["A", "B", 1, 2, True, False] a = mix_list[0:2] ## -- SLICE Print A , B print(a) print("\n") nestlist = [1,2,3,[4,5,6],7,8] # 4 , 5 and 6 is inside another list nlist = nestlist[3] print(nlist) # access a index inside the another list nlist2 = nestlist[3][0] pr...
db9a56507bd59c724e3edc5481cbeda6bf313f06
rjmarshall17/miscellaneous
/matching_parens.py
985
4.125
4
#!/usr/bin/env python3 import sys MATCHING_PARENTHESES = { '}': '{', ')': '(', ']': '[', } # This is apparently O(N^2) time complexity but O(N) for space def matchingParentheses(string_in): parentheses = [] for character in string_in: if character in MATCHING_PARENTHESES.values(): ...
1b6ca4e89dd7d1082eb7d9aba899748ff51c8421
Pasquale-Silv/Bit4id_course
/Course_Bit4id/SecondDay/es2_numParioDisp.py
153
4.03125
4
num = int(input("Inserisci un numero: ")) if(num % 2 == 0): print("Il numero", num, " è pari") else: print("Il numero", num, " è dispari!")
1ba4db7e969421cc138c5e2283dd1a44a50d0e98
zaynesember/CompPhys
/Calculus/integrals.py
1,375
3.765625
4
import numpy as np def simpson(f, a, b, n): """Approximates the definite integral of f from a to b by the composite Simpson's rule, using n subintervals. From http://en.wikipedia.org/wiki/Simpson's_rule """ h = (b - a) / n i = np.arange(0,n) s = f(a) + f(b) s += 4 * np.sum( f( a ...
37fd4a3792eff4a2be3c6d3943302294c89fdb0f
SimonStarling/kyh-practice
/Övning51.py
2,681
3.984375
4
# 51.1 Skriv om funktionen add_as_def som lambda, och lagra i en variabel ''' add_as_lambda = lambda a,b:a+b print(add_as_lambda(2,4)) ''' # 51.2 Skriv om obj som en funktion "upper" ''' # Med lambda obj = lambda s: s.upper() print(obj("sträng")) #Som funktion def obj(s): s = s.upper() return s x = "hej dett...
be4122d91c51b8b2fd483427161efc4153465e4a
SamuelFlo/Beatchess-Proyecto
/Beatchess/ChessTest.py
508
3.59375
4
import chess from AlphaBetaPruning import ABPruningAI import time def main(): AI = ABPruningAI() turn = 1 board = chess.Board() while True: print(f"Turn {turn}") print(board) move = input("Type your move: ") board.push(chess.Move.from_uci(move)) print(board) ...
fdae063a2e0d6d401105907918cd8812c49882f4
iggsilva07/Projet-test
/exercicio/ex03.py
777
3.90625
4
campionato = ('','Palmeiras', 'Flamengo', 'Internacional', 'Grêmio', 'São Paulo', 'Atlético Mineiro', 'Atlético Paranaense', 'Cruzeiro', 'Botafogo', 'Santos', 'Bahia', 'Fluminense', 'Corinthians', 'Chapecoense', 'Ceará', 'Vasco da Gama', 'América Mineiro', 'Sport', 'Vitória', 'P...
a4442c8cc1fb02f88aa15912c9f7a1de5487be94
nahaza/pythonTraining
/ua/univer/HW01/Ch02ProgTrain08.py
480
3.84375
4
# charge for food, tip, tax tipRate = 0.18 taxFromSalesRate = 0.07 chargeForFood = float(input("Enter charge for the food, UAH: ")) tipAmount: float = chargeForFood * tipRate taxFromSales: float = chargeForFood * taxFromSalesRate totalAmountInReceipt: float = chargeForFood + tipAmount + taxFromSales print("Tip, UAH:",...
6578a8dd8971b10709263f769e0205047e6f713f
Haruka0522/AtCoder
/ABC/ABC054-A.py
333
3.890625
4
alice,bob = map(int,input().split()) if(bob == 1 or alice == 1): if(bob == 1 and alice == 1): print("Draw") elif(bob == 1): print("Bob") else: print("Alice") else: if(bob < alice): print("Alice") elif(alice < bob): print("Bob") else: ...
29a2f552127e7d115fb54906bb2b6165565375ca
H4wking/alab2
/task1.py
1,498
3.671875
4
import math def distance(a, b): return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) def construct(p): px = sorted(p, key=lambda x: x[0]) py = sorted(p, key=lambda x: x[1]) return px, py def closest_pair(p): px, py = construct(p) p0, p1 = closest_pair_rec(px, py) return distance(p...
a9cd12af22f786b27027aed683f4b95c0352f361
shreyas008/PokerApp
/poker_new.py
11,551
3.515625
4
from tkinter import * from PIL import ImageTk, Image import string def table(window): C = Canvas(window, bg="black", height=500, width=1050 ,bd = 0,borderwidth = 0, highlightthickness=0, relief='ridge') C.pack(side = "top") C.create_oval(40,40,1000,460,fill= "green",width = 10, outline = "brown") P = L...
959f1d82108da99b094e4fd508c3d535121bfc8a
anlancx/leraning
/4-2.py
91
3.6875
4
items3 = [] for x in 'ABC': for y in '12': items3.append(x + y) print(items3)
bebadc8b0746716b27e43fb8c96d1bccc2a9b6ca
cavid-aliyev/HackerRank
/collectionDeque.py
476
3.828125
4
# Collection deque -> https://www.hackerrank.com/challenges/py-collections-deque/problem from collections import deque d = deque() n = int(input()) for i in range(n): l = input().split() command = l[0] if len(l) > 1: e = l[1] if command == "append": d.append(e) elif comm...
367360115f83c25a757d9a4c009c2f459f9c98ce
Aasthaengg/IBMdataset
/Python_codes/p03477/s896259088.py
129
3.640625
4
a,b,c,d=map(int,input().split()) ab=a+b cd=c+d if ab>cd: print("Left") elif ab<cd: print("Right") else: print("Balanced")
0446d6787bda9c1d3ece1a6fe1193109278b03db
tomboo/exercism
/python/sum-of-multiples/sum_of_multiples.py
495
4.4375
4
''' Write a program that, given a number, can find the sum of all the multiples of particular numbers up to but not including that number. ''' def sum_of_multiples(limit, numbers=None): if not numbers: numbers = [3, 5] multiples = set() for m in numbers: if m: for i in range(m...
9173582ad9a299dcb37244e111beeb9e33e1ed86
jiangshen95/UbuntuLeetCode
/LongestPalindrome.py
421
3.71875
4
class Solution: def longestPalindrome(self, s): """ :type s: str :rtype: int """ m = [0] * 128 odd = 0 for c in s: m[ord(c)] += 1 for n in m: if n % 2: odd += 1 return len(s) - odd + (odd > 0) if __name...
8323c9a67f6cd2402b902f8f341d89f7ab3ecec7
sabya14/cs_with_python
/dictonaries/frequency_queries.py
1,271
3.875
4
""" Problem Statement - https://www.hackerrank.com/challenges/frequency-queries/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps """ class FrequencyQueries: state = None def __init__(self): self.state = {} def operation(self, operati...
2a9ebc9ac1ce049bf2f75fb774af86169b6c40f6
AbelHristodor/CurrentWeatherApp
/main.py
1,855
3.734375
4
import json,requests ## -------------------------------- Getting data from the city.list.json file and getting the choosen's city id --------------------------------------------------- city_list_json = open("city.list.json", "r", encoding = "utf-8") data = json.load(city_list_json) # Get all the city's names city_na...
1c8fadfdcb180afae8fce56af637be35f2a5bff8
JoaquinCollazoRuiz/Conceptos-Python
/2TipoDatos.py
485
3.875
4
# coding=utf-8 #Strings print("Hello world") #Integer print(10) #Float print(12.9) #Boolean True False #List(Array) [10,20,30,40,50] ['Uno','Dos','Tres'] [1,'Dos',True, 9.8] #Se pueden combinar distintos tipos de datos en una lista [] #Tuples, la diferencia con la lista es que este no se puede modificar (10,20,30)...
6cb2e1b5b6afdc56c834bfd91ba1f99cd89854e3
yujuenianbei/python-test
/string.py
163
3.890625
4
#!/usr/bin/python3 formate = "hello ,%s! %s enough for ya?" value = ('world','hot') print (formate %value) form = "pi is %.3f" from math import pi print(form %pi)
447125b82e6df5af828d560ced099354965eab2f
mjcarter95/MSc-University-of-Liverpool
/Machine Learning and Bioinspired Optimisation/K-Arm Bandit Problem/k-arm_bandit.py
2,609
3.59375
4
import numpy as np import matplotlib.pyplot as plt # Colours for plots colours = ['g', 'r', 'b'] # Paramters k = 10 # The number of bandits in the problem exploration_rates = [0, 0.01, 0.1] ## IF YOU ADD MORE VALUES, ADJUST COLOURS ABOVE ## runs = 2000 # The number of times to run the problem steps = 1000 # The num...
f2b87bd979456dd283ddf655bb932567f7fa1140
dimpozd13/pythonHomeWork
/3/func.py
1,227
3.625
4
def plusMinus(a, b): if a > 0 and b > 0: print(a + b) elif a < 0 and b < 0: print(a - b) else: print(0) def twoMax(a, b, c): list = [a, b, c] a1 = max(list) list.remove(a1) a2 = max(list) print(a1, a2) def two(list, bl): if bl == False: newList = [...
12745481e04d75ba328c22df8946bdeb430105c2
silverflow/python_study
/contains.py
563
3.625
4
class Boundaries: def __init__(self, width, height) -> None: self.width = width self.height = height def __contains__(self, coord): x, y = coord return 0 <= x < self.width and 0 <= y < self.height class Grid: def __init__(self, width, height) -> None: self.width = ...
894215c08575f5b7c3c764f8bc2d88999ee25aba
isemona/codingchallenges
/3-LongestWord.py
423
4.125
4
# https://www.coderbyte.com/information/Longest%20Word # Difficulty - Easy # Implemented enumerate def LongestWord(sen): i = 0 longestWord = '' for j, ch in enumerate(sen): if not ch.isalpha(): i = j + 1 if len(longestWord) < (j-i+1): longestWord = ...
d9e56551141876c9142cdcb4c69a0ecb2363bcbc
dbms-ops/hello-Python
/1-PythonLearning/3-Python-基础知识/5-循环.py
1,524
4.15625
4
#!/data1/Python2.7/bin/python2.7 # -*-coding:utf-8-*- # date: 2020-1-16 16:57 # user: Administrator # description: 循环表达式 While 和 for # # 循环:while and for # while 表达式: # 语句1 # 语句2 # 如果表达式为真执行允许语句1,执行完成,计算表达式的值; # 否则执行语句2 # # def while_sum_help(): """ add i from 1 to 99 :return: return the sum from 1 t...
44541ae7e12f2a124ea6405cb470cb80f691c14d
diana134/afs
/Code/utilities.py
3,500
3.828125
4
"""Some useful functions used by several things""" import re, datetime def optionalFieldIsGood(mine, theirs): """check if optional field theirs matches with mine""" if (theirs is None or theirs == "" or theirs == mine): return True else: return False def requiredFi...
8e9b395522fa5204efa7d1f96dd3fce07c841169
alexkie007/offer
/others/随机概率生成数字.py
2,737
3.5
4
""" rand3()可以随机等概率生成1,2,3 请使用rand3()构造rand7()可以随机等概率生成1,2,3,4,5,6,7 """ """ 解题思路: rand3可以随机生成1,2,3;rand7可以随机生成1,2,3,4,5,6,7。 rand3并不能直接产生4,5,6,7,所以直接用rand3去实现函数rand7似乎不太好入手。 如果反过来呢?给你rand7,让你实现rand3,这个好实现吗? int Rand3(){ int x = ~(1<<31); // max int while(x > 3) x = Rand7(); return x; } 述计算说明Rand3是...
5ec0c725e241b00e6f7f58021ee0fa67f8cac7e4
Ashi12218604/Python
/regexp/regexp_21_greedy.py
621
4
4
/* Greedy Search Description You’re given the following html code: <html> <head> <title> My amazing webpage </title> </head> <body> Welcome to my webpage! </body> </html> Write a greedy regular expression that matches the entire code. Execution Time Limit 10 seconds */ import re import ast, sys string = ...
a6c187a0ea878ff6a798f8f7f61ab1e8f1c6d9d0
Nanofication/TWC-Naive-Bayes
/TWCNB.py
9,327
3.703125
4
""" Implementing Transformed Weighted Complement Naive Bayes for classifying sentence. Following research paper: Tackling the Poor Assumptions of Naive Bayes Text Classifiers By: Jason D. M. Rennie Lawrence Shih Jaime Teevan David R. Karger """ import math import nltk from nltk.stem.lancaster import LancasterStem...
41da165268912569b241978eeddecfcb0dd29586
xiangyang0906/python_lianxi
/zuoye5/字典的推导式01.py
324
4.28125
4
# 语法;{表达式1:表达式2 for .... in .....} dict01 = {"a": 10, "b": 20} new_dict01 = {} for key, value in dict01.items(): new_dict01[key] = value print(new_dict01) new_dict02 = {key: value for key, value in dict01.items()} print(new_dict02) dic01 = {k: v for k, v in zip(list("ABC"), list("123"))} print(dic01)
fa2b58b559b104fe2c84abf98383c8724e09ef08
Samana19/PythonProjectOne
/PythonLabThree/Prob3.py
258
3.625
4
'''Write a function called showNumbers that takes a parameter called limit.It should print all the numbers between 0 and limit with a label to identify the even and odd numbers. For example, if the limit is 3, it should print:0 EVEN1 ODD2 EVEN'''
d5fff4279e24a670cbf597f2a3741e0561eaeb75
rogerssantos/PythonProgramming
/Learning/Lesson 5.py
1,240
3.859375
4
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> numbers = [20, 50, 29, 87, 45] >>> numbers[2] 29 >>> numbers[2] = 43 >>> numbers [20, 50, 43, 87, 45] >>> numbers + [47, 33, 99] [20, 50, 43, 87, 45, 47, 33...
cdc340410d1a9bacadcc6b90c92865b455685a10
Nicholas-O-Atkins/Projects
/Courses/CS2004(Intro to OS)/A5/BestfitDynamic.py
7,309
4.3125
4
""" Author: Nicholas Atkins Due Date: 3/4/2018 Purpose: To demonstrate the best fit algorithm with dynamic partitioned memory Problems: There are a lot of if and else statements making this very hard to understand just by reading the code, I hope the comments spread throughout the code will help understand the thought ...
ea7120d2e9c435e1fc3527024b1828c231ba47d7
andrhahn/pi-spy
/client/src/example/utils.py
2,385
3.53125
4
import io import os def copy_file_to_stream(input_file_name): """Copies a file fto a stream""" input_file = open(input_file_name, 'rb') stream = io.BytesIO() l = input_file.read(1024) while l: stream.write(l) l = input_file.read(1024) stream_size = stream.tell() stre...
f99c94a3adccac346bf853a83f1724e900d3b56e
ericbgarnick/AOC
/y2019/saved/day10/day10.py
5,324
3.578125
4
import math import sys from fractions import Fraction from functools import partial from typing import Tuple, Set, List Point = Tuple[int, int] ASTEROID = '#' def day10_part1(puzzle_data: List[List[str]]) -> Tuple[Point, int]: max_x = len(puzzle_data[0]) max_y = len(puzzle_data) best_num_visible = 0 ...
6f73f1c16a277efa0941e96a29ad9a79f35fa00c
zlw241/CodeEval
/Medium/reverse_groups.py
677
3.875
4
def reverse_intervals(string): rm_semicolon = string.split(";") num_list = [int(i) for i in rm_semicolon[0].split(',')] interval = int(rm_semicolon[1]) remainder = len(num_list)%interval separated = [list(reversed(num_list[i:i+interval])) for i in range(0,len(num_list), interval)] if remaind...
75ccacf88d81abe84a956be18fa2654da2683e50
LauraBrogan/2021-Computational-Thinking-with-Algorithms-Project
/mergesort.py
1,459
4.5
4
#CTA Project 2021 #Merge Sort #Resourse used:https://runestone.academy/runestone/books/published/pythonds/SortSearch/TheMergeSort.html def mergesort(array): #print is used in testing to see the breakdown of sorting process print("Splitting ",array) #This recursive algorithm splits the list in half if l...
dc1c74fff3044a9e75988b6b9cedb42c280e37bb
314H/competitive-programming
/marathon-codes/Maratonas/U_._R_._I/1. iniciante/iniciante-1176.py
549
3.71875
4
# 1145 - Fibonacci em Vetor # Exemplo de Entrada # 3 # 0 # 4 # 2 # Exemplo de Saída # Fib(0) = 0 # Fib(4) = 3 # Fib(2) = 1 vetor_fibonacci = {} vetor_fibonacci[0] = 0 vetor_fibonacci[1] = 1 def fib_top_down(f): if(f in vetor_fibonacci): return vetor_fibonacci[f] else: vetor_fibonacci[f] = fib_top_down(...
811be7f9fecd5b70949cbe776c3171c9dd73f931
meetrainier/ManojMath
/Diff_eqn/compute_fourier.py
344
3.703125
4
#Inro: Shows how to compute a fourier series import math #B =float(input("Input B=")) import sympy as sy from sympy import fourier_series, pi, cos, sin from sympy.abc import t from sympy.functions.special.delta_functions import Heaviside T = sy.symbols('T') s = fourier_series(Heaviside(t) - Heaviside(t-1/4), (t, 0, 1)...
6578a2ecbdd0b7e4d31409e38f8bde4ca74b6d48
TheGingerNinjaC/Cigar_Party_Python
/CigarParty.py
1,480
4.5625
5
''' Author: Chane van der Berg Date: 13/05/2018 When squirrels get together for a party, they like to smoke cigars. A squirrel party is successful when there were between 40 (inclusive) and 60 (inclusive) cigars, unless it is weekend when there is no upper limit on the number of cigars. Write a function cigar_party()...
de70918cd86e8bd4df2c7451f6f1f1deb697c97d
andrei011011/google-code-sample
/google-code-sample/python/src/video_playlist.py
1,197
3.921875
4
"""A video playlist class.""" class Playlist: """A class used to represent a Playlist.""" def __init__(self, playlist_title: str): self._title = playlist_title self._videos = [] @property def title(self) -> str: """Returns the title of a Playlist.""" return self._titl...
7e678783284f82bd4e867babbf3ebe6253a3538f
abiudmelaku/Inventory-System
/Customer.py
1,822
3.703125
4
class Customer: def __init__(self): self.__baughtItems = [] self.__bill = 0 def get_cart(self): return self.__baughtItems def get_bill(self): return f"Your current bill is ${round(self.__bill , 2)}"; def add_to_cart(self , item): self.__baughtItems.append(item) ...
7b5bc20898ec1359e6fb279118e70fe44307cab2
sydoky/Python
/python class 7/ClassThing.py
5,194
3.796875
4
class Coin: def __init__(self, denomination, year, mintage, material, origin, grade, grade_level, price): self.denomination = denomination self.year = year self.mintage = mintage self.material = material self.origin = origin self.grade = grade self.gra...
9ea595c378ed6b9165f09fd6ad4450eefa76416b
Minari766/study_python
/Paiza/Rank_D/paizad043_天気の表示.py
198
3.703125
4
# coding: utf-8 # 自分の得意な言語で # Let's チャレンジ!! n = int(input()) if n <= 30: print("sunny") elif 31 <= n <= 70: print("cloudy") elif n >= 71: print("rainy")
cf8fb1afb069690f9e2d946ab0b5d24330327e5d
tfeLdnaH/Python
/sintaxerrorbug.py
400
3.921875
4
'''tuna = int(input("What´s your favorite number?\n")) print(tuna)''' while True: try: number = int(input("Whats ur fav. number?\n")) print(18/number) break except ValueError: print("Make sure and enter a number") except ZeroDivisionError: print("Dont pick z...
638d12c564a0399e5811e31352531f4cd023f438
vandrade88/python-challenge
/PyBank/main.py
2,157
3.71875
4
import os import csv # import file pybank_csv = os.path.join("/Users/valerie/Desktop/DA_VA/homework/3_Python/python-challenge/PyBank/Resources/budget_data.csv") pybank_text = os.path.join("/Users/valerie/Desktop/DA_VA/homework/3_Python/python-challenge/PyBank/Analysis/financial_analysis.txt") # open and read csv file...
709b504aa33e086f76b46da717ea0e122828de3a
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/10-Supervised_Learning_with_scikit-learn/e24_regression_with_categorical_features.py
889
3.671875
4
""" Regression with categorical features Having created the dummy variables from the 'Region' feature, you can build regression models as you did before. Here, you'll use ridge regression to perform 5-fold cross-validation. The feature array X and target variable array y have been pre-loaded. """ import pandas as pd i...
f7a3a0e610c04456b4f2001189107fa800d3e1f2
KirutoChan/Leonhard
/leo6.py
184
3.625
4
def sum_square(n): sum_square = 0 s = 0 for i in range(1, n + 1): sum_square = sum_square + i**2 s = s + i result = s ** 2 - sum_square return result print (sum_square(100))
dbacb229768b0a0e8fe24ff1f16164b0d08837a5
SuperPipp/PinkProgrammingPython
/Python/counting,user.py
124
3.921875
4
s = int(input("Pick a starting number:\n")) e = int(input("Pick an ending number:\n")) for i in range(s, e +1): print(i)
d967dd1c05a94ffac4fb29fe7b4b701ba7c2d8af
HugoHugo/pythonplusplus
/pythonplusplus.py
11,682
3.71875
4
import ast,sys #Global variables #Sturcture to store the datatypes for variables since the AST does not do this #may not be an appropriate solution when we start working on functions varTypeStore = {} #used for indentation for structures such as if, for, while, and functions indentationLevel = 0 #used for tracking l...
3adddf52fba857a193adf802ad5eab9817eb564b
lizzzcai/leetcode
/python/array/0049_Group_Anagrams.py
1,872
3.84375
4
''' 07/04/2020 49. Group Anagrams - Medium Tag: Hash Table, String Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat","tan"], ["bat"] ] Note: All inputs will be in lowercase. The order of your output does not ...
98beb56f0d0cd99b056b60e2001647e42f7e80fa
rgcosta7/Introduction-Python
/Lab 2.6.1.11.py
387
3.9375
4
''' Event end time calculator Name: Raul Costa Date: 18/10/2021 Version: 1.0 ''' # Ask user for starting time and duration hour = int(input("Starting time (hours): ")) mins = int(input("Starting time (minutes): ")) dura = int(input("Event duration (minutes): ")) # Calculate the finishing time mins = (mins + dura) hou...
46e3effa9e4ca654da089dad798d933e08fce4c7
abhigupta4/Competitive-Coding
/Data Structures and ALgorithms/producer_consumer.py
855
3.890625
4
""" Solving producer-consumer problem using semaphores - Solved by mahdavipanah """ import threading # Buffer size N = 10 # Buffer init buf = [0] * N fill_count = threading.Semaphore(0) empty_count = threading.Semaphore(N) def produce(): print("One item produced!") return 1 def producer(): front = ...
92c835d9f359fa90ac10bc4a6100f8296d3c66b9
webclinic017/valuation_course
/valuation_undergraduate-spring_2021/session10A_quiz/non_cash_income_growth_perp.py
2,033
3.796875
4
# Session 10A post-class test problem 2 # This is the growth of income the firm makes from non-cash equity. # http://people.stern.nyu.edu/adamodar/pdfiles/eqnotes/postclass/session10Atest.pdf def non_cash_income_growth_prep( net_income, book_value, interest_income, cash_balance, capital_expendi...
505033f029807229981f0daad0b62966943509a8
mustafashakeel/learning
/python/MyScripts/expanded.py
173
3.671875
4
item = 0.70 rate = 1.05 tax = item * rate total = item + tax print( 'Item:\t' , '%.20f' % item ) print( 'Tax:\t' , '%.20f' % tax ) print( 'Total:\t' , '%.20f' % total )
442a350d085d19d92590a7e0d768d56bea7f7514
lkrych/cprogramming
/kAndr/ch_1/freq_histogram.py
774
3.890625
4
import re ALPHA = "abcdefghijklmnopqrstuvwxyz" ALPHA_COUNT = {} ALPHA_RE = re.compile('([A-z]+)') user_input = input("Type in your input and then press enter to print histogram: ") split_input = list(user_input) for char in split_input: if ALPHA_RE.match(char): lower_char = char.lower() if lower_char in ALPHA...
f7cdaf4e28241acc28e42cb40d18f89cf9f89802
ghostrider77/competitive-programming-skills
/Python/04_straight-flush.py
1,013
3.65625
4
import sys from collections import namedtuple Card = namedtuple('Card', ['suit', 'rank']) def read_cards(line): cards = [] for s in line.split(): suit = s[-1] rank = convert_rank(s[:-1]) cards.append(Card(suit, rank)) return cards def convert_rank(rank): if rank == 'A': ...
d5c52aa585b5b42ae6a7ad3c883b61faa85be800
mrmoore6/Module-8
/Test/test_assign_average.py
831
3.5625
4
import unittest from more_fun_with_collections import assign_average class MyTestCase(unittest.TestCase): def test_average_A(self): self.assertEqual("You entered A", assign_average.switch_average('A')) def test_average_B(self): self.assertEqual("You entered B", assign_average.switch_average('B...
5bb29e31c340ee1983a8aaeecd28cfe10351680f
moonlimb/scheme_to_js_translator
/xml_to_js/helper/decorate.py
711
3.828125
4
# file containing decorator / helper functions # Q: Use decorators/wrapper function to add curly braces? def make_fcn(fn): def wrapper(): return fn() + "()" return wrapper def add_parens(fn): def wrapper(): return "(" + fn() + ")" return wrapper def add_curly_braces(content): def wrapper(): return "{" + ...
9ac572962c2126f62acd1e3cc576596ff719e950
erichan1/CS1
/lab2/lab2a.py
4,500
3.921875
4
'''Module for part a of lab2 of CS1. Various functions depending on the problems.''' # B.1 def complement(str): '''Takes in string with only letters A,C,T, and G. returns DNA complement in the form of a string.''' str2 = '' for i in range(len(str)): if str[i] == 'A': str2 += 'T' ...
9a79a08235f147724935867104de4cd4562f6c98
staceysara/PythongProgramming
/Project1130/Project1130.py
4,347
3.53125
4
import numpy as np from matplotlib import pyplot as plt #data = np.array([[1,2,3],[4,5,6],[7,8,9]]) #print(data+2)#[[3 4 5][6 7 8][9 10 11]] #print(data-2)#[[-1 0 1][2 3 4][5 6 7]] #print(data*data)#[[1 4 9][16 25 36][49 64 81]]#not a matrix multiplication #print(data.dot(data))#[[30 36 42][66 81 96][102 126 150]] #...
de94608a24be509d4bc2d1dd693959a860d35b1a
zamirzulpuhar/zamir-
/2 неделя/какое число больше.py
128
3.8125
4
a = int(input()) b = int(input()) if a - b > 0: print(1) elif b - a > 0: print(2) elif a - b == 0: print(0)
be3fee2096ed71483a7a74e3339b656068a34d73
MinaMeh/TransformToLD
/plot.py
2,056
3.59375
4
""" =============================== Legend using pre-defined labels =============================== Defining legend labels with plots. """ import numpy as np import matplotlib.pyplot as plt def plot_with_x(x, x_label, extract, preprocess, mapping, convert, total, title, legend_pos='upper right'): # Make some f...
5e960931ce2ec64a75c45facf245f80f08617ce6
mikhailburyachenko/lesson2
/age.py
346
3.9375
4
age=int(input("Введите Ваш возраст ")) def age_condition(age): if age < 7: return "Иди в сад" elif age < 18: return "Иди в школу" elif age < 24: return "Иди в Вуз" else: return "Иди работать" what_to_do=age_condition(age) print(what_to_do)
33bfa681e884a69bb51b1a7453de7537da033a37
Pascal-tgn/gb-python-basics
/lesson_1/task-01.py
478
3.90625
4
my_int = 1 my_float = 2.0 my_str = "Hello!" my_bool = True print(my_int) print(my_str) in_str_1 = input("Введите строку: ") print("Вы ввели", in_str_1) in_str_2 = input("Введите ещё строку: ") print("Вы ввели", in_str_2) in_int = input("Введите число: ") print("Все строки вместе:", in_str_1, in_str_2) print("А э...
6fbf8077730e3ea743fa97cd5347d7831a28faf8
Sharayu1071/Daily-Coding-DS-ALGO-Practice
/Leetcode/Python/reverseInteger.py
377
3.84375
4
#Problem link : https://leetcode.com/problems/reverse-integer/ def reverse(x): s = str(abs(x)) ans = int (s[::-1]) if (ans > (pow(2,31)-1) or ans < pow(2,-31)): return 0 elif (x >= 0): return ans return ans - 2*ans num = int(input()) print(reverse(num)) #Example test case # Inp...
48ee5556951e1b26bcce2b9871026e648e312a9f
daniel-reich/ubiquitous-fiesta
/pEozhEet5c8aFJdso_0.py
210
3.53125
4
def all_about_strings(txt): return [ len(txt), txt[0], txt[-1], txt[(len(txt)-1)//2:(len(txt)+2)//2], "@ index {}".format(txt.index(txt[1], 2)) if txt[1] in txt[2:] else "not found" ]
105bc4ad31e5116e9f7365391f75de21afb46928
rafaelperazzo/programacao-web
/moodledata/vpl_data/24/usersdata/87/11092/submittedfiles/av1_m3.py
229
3.734375
4
# -*- coding: utf-8 -*- from __future__ import division import math m = input("Digite valor de m: ") i=2 while i<m: if i%2==0: pi=3+(4/(i*(i+1)*(i+2)) if i%2>0: pi=3-(4/(i*(i+1)*(i+2)) i=i+1 print(i)
5ddb6c3b40b79c8d188017c67ceefbb1a925ee15
stammareddi/Fire-Maze
/Static/BFS.py
1,479
3.75
4
""" BFS add start position into queue with distance 1 while queue isn't empty - Pop of element - check if they match if so return distance - set array of directions moves = [up, down , right, left ] - Traverse directions for loop - if value == 0 and in bounds add not in visited add to queue with prev di...
e0a60dcb2299aa6a20f9ad7e1e445826f1e078e0
mnshkumar931/python-program
/inheritance.py
811
3.703125
4
class Animal(): type='pet' def __init__(self,dog,cat): print('parent cons called') self.dog=dog self.cat=cat def speak(self): print(self.dog +" dog bark") print(self.cat +" cat meow") def info(self,name,age): print(f'{name} {age}') # x=...
5c45b7a9c162b74e2f8a5a06b7bbed80e8a82bd4
dfki-ric/pytransform3d
/examples/plots/plot_rotate_cylinder.py
1,414
3.734375
4
""" =============== Rotate Cylinder =============== In this example, we apply a constant torque (tau) to a cylinder at its center of gravity and plot it at several steps during the acceleration. """ import numpy as np import matplotlib.pyplot as plt from pytransform3d.rotations import matrix_from_compact_axis_angle fr...
66ac79532b9cbf43a35b840f1e6fc3b2506741bf
sendurr/spring-grading
/submission - lab5/set2/KAYLA S REVELLE_9396_assignsubmission_file_Lab 5/Lab 5/Lab5Q3.py
183
3.8125
4
def checkprime(n): Number= True for x in range(2,n-1): if n%x==0: Number=False if Number: print(True) else: print(False) print (checkprime(3)) print (checkprime(255))
ab8a42f95b840f1b92735b5a9a42c6976bad5127
Francisco8NGY/PythonPractice
/conjuntos.py
311
4.15625
4
#Lenguaje de programacion python # uso de conjuntos conjunto1 = set # declaracion de un conjnto vacio type(conjunto1) # vizualizar el tipo de dato de una variable conjunto2 = (10, "Colima, 12.45") if 10 in conjunto2: print("Este elemento si se encuentra") else: print("Este elemento no se encuntra")
800abedc9165ef65e701cafe5d79eb343645f517
alexharvey/coursera
/python/exercises/exercise3.py
217
3.78125
4
__author__ = 'alex' hrs = raw_input("Enter Hours:") h = float(hrs) rate = raw_input("Enter Rate:") r = float(rate) if hrs > 40: total = (40 * r) + ((h - 40) * (1.5 * r)) else: total = (r * h) print(total)