blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
85e9489dfed66f81b004aa96c0ee367087c952e6
magladde/Python-CSC-121
/Lesson 13/fly_drone/drone.py
878
4.09375
4
class Drone: def __init__(self): """ constructor creates two instance variables for speed and height """ self.speed = 0.0 self.height = 0.0 def accelerate(self): """ increases the speed of the drone """ self.speed = self.speed + 10.0 def decelerate(self): ...
053339a28c4f433e87e16f20a8cfb1989e2da3c8
magladde/Python-CSC-121
/Lesson 04/M2.py
2,211
4.375
4
# Temperature conversion program (celcius-fahrenheit / Fahrenheit-Celcius) # display program welcome print('This program will convert temperatures (Fahrenheit/Celsius)') print('Enter (F) if starting temperature is Fahrenheit') print('Enter (C) if starting temperature is Celsius') print('Enter (K) if starting temperatu...
0adc3658e2c1c5dd6283f2780dbbd9eeb8df4960
magladde/Python-CSC-121
/Lesson 06/quiz.py
259
3.640625
4
list1 =[[x,y] for x in range(7) if x % 2 == 1 for y in range(4) if y % 2 == 0] print(list1) list1 = [] for x in range(7): if x % 2 == 1: for y in range(4): if y % 2 == 0: list1.append([x,y]) print(list1)
57942b23923dad443865065df46d6ec15b4fc7cb
magladde/Python-CSC-121
/Lesson 04/D3.py
1,269
4.15625
4
# The first-time home buyer tax credit program # program introduction print('This program determines if an individual qualifies for a') print('government First-Time Home Buyer Tax Credit of $8,000.') print('Individuals are available to those that (a) bought a house') print('that cost less than $800,000, (b) had a comb...
2ca3082c5a5eebc402b60f412dc8eb53b1b67d05
magladde/Python-CSC-121
/Lesson 06/password_encryption_decryption.py
1,555
4
4
# Password Encryption/Decryption program # init password_out = '' case_changer = ord('a') - ord('A') encryption_key = (('a', 'm'), ('b', 'h'), ('c', 't'), ('d', 'f'), ('e', 'g'), ('f', 'k'), ('g', 'b'), ('h', 'p'), ('i', 'j'), ('j', 'w'), ('k', 'e'), ('l', 'r'), ('m', 'q'), ('n', 's'), ('o', 'l'), ('p', 'n'), ('q', ...
287ea19369bb3770c1552025133f82276aaeed55
rishabh-live/python-lab-works
/Lab 1/Q8.py
228
4.15625
4
num1 = int(input("Enter Any Number : ")) num2 = int(input("Enter Any Number : ")) num3 = int(input("Enter Any Number : ")) sum = num1+ num2 + num3 average = sum / 3 print(f'Sum of Inputs : {sum} \nAverage of Inputs {average}')
d1f899cd18f8812e1272bbe94feec68723c66ecb
jzerez/computer_vision
/optical_flow.py
4,654
3.5625
4
#!/usr/bin/env python3 import cv2 import pdb import numpy as np import matplotlib.pyplot as plt def get_keypoints(img, fast=None, threshold=100): """ Uses cv2's built in FAST feature detector to find keypoints in an image Parameters: img (np.array): grayscale image to find keypoints in fas...
a6c515a31d529c6631ade06358ccc5e95a1ab326
pk0797/guvi1
/holiday.py
299
3.671875
4
def f(x): return { "monday" : "no", "tuesday" : "no", "wednesday": "no", "thursday" : "no", "friday" : "no", "saturday" : "yes", "sunday" : "yes" }.get(x,"not a valid day") p=raw_input() k=f(p.lower()) print(k)
0f9b4de5dee658586b529413d8d7d78cc8160a40
hahntech/Py-puppy-place
/model.py
1,413
3.8125
4
#!/usr/bin/python3 class Animal: """An animal representation in PuppyPlace system""" def __init__(self, id, date, breed, estimatedAge, notes=[]): self.id = id self.admissionDate = date self.breed = breed self.estimatedAge = estimatedAge for note in notes: se...
a1d572a5f3cd5eb5c5cc68a7832cc8a9db247b08
njuhuxw/VCOCO_det-ICMR2020
/str_test.py
260
3.65625
4
a = "1_2_3_4" b = "1_2" def str_opera(str): str_list = str.split("_") if len(str_list) > 1: str_list.pop(-1) result = "_".join(str_list) print(result) print(str_list) if __name__ == '__main__': str_opera(a) str_opera(b)
27b2318f789f1938179809e4b1deda981a4ff4c7
Lufaja/collections
/m-and-m-dic.py
486
3.515625
4
import random #lijst met M&M kleuren kleuren = ["oranje", "blauw", "groen", "bruin"] #kleuren in de zak stoppen met bepaald aantal def genereerZak(aantal:int): zak = {} for i in range (int(aantal)): kleur = random.choice(kleuren) if kleur in zak: zak[kleur] += 1 else: ...
d5ed1d02f8be4b36b813b25aa1b643081da82ebe
einansgar/error_calculation
/code/functions.py
17,845
4.25
4
""" Contain several mathematical functions. Each provides the following functionality: - __init__(arg, [arg2]) -- construct a new function of this type with the given value(s) - __str__() -- convert the function to algebraic representation - prnt(replacements) -- Return a string with the values inserted (replacements ...
18648faa79b48ce9ee77c37777625276a6d110d0
Obeydapanda/is51Lab4
/californiaCapital.py
1,385
4.28125
4
""" this program allows the user an input of up to 3 attempts to guess "What is the capial of California" answer = "Sacramento" First set maxAttempts = 3, then create a loop to iterate 3 times. Each iteration = +1 counter to maxAttempts. if input = Sacramento, output would be "Correct!" and finish the loop if input ...
38752534f407d67a57dfc04d0eb2ab0c21e2355a
ouyanglei1121/Pytorch
/day01/Demo01/__init__.py
1,554
3.9375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # author: ouyang lei time:2019/7/25 import numpy as np def computer_error_for_line_given_points(b, w, points): totalError = 0 for i in range(0, len(points)): x = points[i, 0] y = points[i, 1] totalError += (y - (w * x + b))**2 return total...
3eaf0469fe713938c50046871b7136a72d9ebdf6
warmestwind/CV_Daily
/Image_processing/convex_hull.py
3,262
4.03125
4
# https://startupnextdoor.com/computing-convex-hull-in-python/ from collections import namedtuple import matplotlib.pyplot as plt import random Point = namedtuple('Point', 'x y') class ConvexHull(object): _points = [] _hull_points = [] def __init__(self): pass def add(self, point): ...
a7e42f47f1abc881719061f04ee2d371ca21945e
warmestwind/CV_Daily
/linear_regression/linear_regression_a.py
1,247
3.5
4
import numpy as np import matplotlib.pyplot as plt import tensorflow as tf learning_rate = 0.1 training_epochs = 5 x_train = np.linspace(-1, 1, 101) y_train = 2 * x_train + np.random.randn(*x_train.shape) * 0.33 file_object=open('x.txt','r') ''' for num in y_train: file_object.write(str(num)) file_object...
48ffd05b12ad7bfa573a9242f01b21034af31e66
salma-shaik/us-crime-analytics
/utilities/economic_api_data_ori_generator.py
1,971
3.625
4
import pandas as pd import os from utilities import df_cleaner # Get the required crime df with info of major agencies crime_major_gov_fips = pd.read_csv( 'C:/Users/sshaik2/projects/criminal_justice/us-crime-analytics/data/crime/Crime_Major_Gov_Fips.csv') # Dropping Govt_level coz it's already present in the merg...
0c7d3068cfcdad05ead2c8524cf1c7c844ccdea0
MozhiJiawei/Huawei_OJ
/OJ_Python/OJ_Python_3.5/character_statistics.py
351
3.65625
4
""" 字符统计(100分) """ str_input = input() c_dict = dict() for c in str_input: if ord(c) < 128: if c in c_dict: c_dict[c] += 1 else: c_dict[c] = 1 c_list = list(c_dict.items()) c_list.sort(key=lambda x: x[0]) c_list.sort(key=lambda x: x[1], reverse=True) for x in c_list: pri...
1b9be011b97be0fc37f4f23299ab9986d3ae197f
MozhiJiawei/Huawei_OJ
/OJ_Python/OJ_Python_2.7/str_match.py
358
3.65625
4
def is_all_char_exist(short_str, long_str): short_str_set = set(short_str) for c in long_str: short_str_set.discard(c) if short_str_set: return "false" else: return "true" if __name__ == "__main__": short_str_in = raw_input() long_str_in = raw_input() print(is_all_c...
8caa869334899fbb606ccdfa524b90a190406994
MozhiJiawei/Huawei_OJ
/OJ_Python/OJ_Python_3.5/str_encrypt.py
1,132
3.890625
4
""" 字符串加解密(100分) """ def encrypt(s): s_ascii = bytearray(s, 'ascii').swapcase() for i, c in enumerate(s_ascii): if chr(c).isalpha(): if c == ord('z') or c == ord('Z'): s_ascii[i] += ord('A') - ord('Z') else: s_ascii[i] += 1 elif chr(c).is...
b637401d3b46fc4edc6cdde510d1ce6ca11eba7a
thisis-nkul/ndlib
/ndlib/nn/layers/linear.py
2,518
3.65625
4
import numpy as np import ndlib.functional as F class Linear: #TODO: implement activations within the layer as to make backprop implem. easier #and THINK: is it really necessary to keep self.A? def __init__(self, input_dim, output_dim, W=0, b=0, activation = 'identity', initialization='HE'): ...
2d5bd461828befb9d6baa7fa6ebf28af7da91a2c
lewie14/strings
/strings2.py
4,893
4.0625
4
poem_title = "spring storm" poem_author = "William Carlos Williams" print("---------------------Title--------------------------------") poem_title_fixed = poem_title.title() print(poem_title) print(poem_title_fixed) print("---------------------Upper--------------------------------") poem_author_fixed = poem_author.upp...
4188605b9ed10a451271fe9c8ab28a7fb45e0988
nmaley/iba_python
/homework_1/3_4.py
771
3.984375
4
# Сформировать одномерный список целых чисел A, используя генератор случайных чисел (диапазон от 0 до 99). Размер списка n ввести с клавиатуры. # Задание 3_вариант_4. Найти значение минимального элемента списка. import random n = int(input('Введите размер списка: \n')) A = [] for i in range(n): A.append(ran...
69fc9cabaa569002af38c5dc966fc39eb0e4e9bc
crisalid/chesstest
/chess.py
2,704
4.09375
4
#!/usr/bin/python # Importing basic libraries to process user input import sys, getopt def coordToPos(x, y): ''' Converting numerical coordinates to board cells ''' r = 'abcdefgh'[x - 1] + str(y) return r def chessPieceMoves(piece, pos, printChessBoard = False): ''' Calculating moves for...
837f48ac163c23384f39142bae405d06bbf9d2b3
treedust/games-puzzles-algorithms
/simple/stile/iter2.py
9,106
3.75
4
# iterative sliding-tile specific algorithm rbh 2016 # under construction from random import shuffle from copy import deepcopy from time import sleep, time from sys import stdin class Tile: """a simple sliding tile class""" def __init__(self): self.state = [] self.history = [] for line in stdin: ...
923db7c14839f56c25a65adffda4583e7d0cfd0d
arovit/Coding-practise
/bit_manipulation10/basechanger.py
641
3.75
4
#!/usr/bin/python class Converter(object): """ Any type to Any type """ def __init__(self, frombase, tobase): self.from_base = frombase self.to_base = tobase def change_base(): pass ## leave the conversion class ToBinary(Converter): """ Convert to Binary """ def __init...
d57647209ad97716b68be27cdefb16f2e66546f1
arovit/Coding-practise
/linkedln/coding1/string_replace.py
534
4.09375
4
#!/usr/bin/python str1 = 'arovitnarul' str2 = 'aro' str3 = 'parularo' def replace_str(main_str, from_str, to_str): index = 0 flen = len(from_str) while index < len(main_str): if main_str[index:index+flen] == from_str: main_str = do_replace(main_str, index, index+flen, to_str) ...
144ad64445a67bb5f4fcb6d06c1c8d3c08ea3361
arovit/Coding-practise
/misc/tic_tac_toe.py
3,846
3.6875
4
#!/usr/bin/python ## Tic Tac Toe - Checker for winning condition # |x |x |o | # |x |x |x | # |o |o |x | class TicTacToe(object): def __init__(self, size): self.boardsize = size self.board = [[0]*(size) for i in range(size)] def winCheck(self): for i in range(self.boardsize): ...
487ef6eaf98e10509ac6ea7aad22a0102d9c4bdf
arovit/Coding-practise
/linkedln/coding1/permutation.py
234
3.859375
4
#!/usr/bin/python def find_permutations(prefix, strn): if not strn: print prefix return for i in range(len(strn)): find_permutations(prefix+strn[i], strn[:i]+strn[i+1:]) find_permutations('', 'abc')
c2c7d52a9e8be746c89734708da93c5959095d81
arovit/Coding-practise
/leetcode/construct-binary-tree-from-preorder-and-inorder-traversal.py
911
3.5
4
class Solution(object): def buildTree(self, preorder, inorder): """ :type preorder: List[int] :type inorder: List[int] :rtype: TreeNode """ root = self.constructTree(preorder, inorder) return root def constructTree(self, preorder, inorder): ...
0d0f3219aa2c7777f94afa4bbdc6459e52378d6e
arovit/Coding-practise
/leetcode/longest_palindrom_subsequence.py
1,054
3.671875
4
#!/usr/bin/python class Solution(object): def longestPalindromeSubseq(self, s): """ :type s: str :rtype: int """ n = len(s) # length of the string if s[::-1] == s: return len(s) lpalin = [ [0 for i in range(n)] for j in range(n)] for i i...
c15040b6dfa21b6ac08c053b4bb201b2af23d878
arovit/Coding-practise
/linkedln/coding1/LCA.py
1,109
4.125
4
#!/usr/bin/python from tree import * def do_inorder(root): if root.left: do_inorder(root.left) print root.data if root.right: do_inorder(root.right) """ There are two ways to finding LCA - one way is 1. when parent pointers are given - calculate the height of both the nodes if both...
6e023befcf7e0615ca630f7e9bd26853c2b36e8c
arovit/Coding-practise
/concurrency/dining_philosophers.py
1,488
3.546875
4
#!/usr/bin/python import time import threading class chopStick(object): def __init__(self, id): self.lock = threading.Lock() self.id = id def _pickUp(self): self.lock.acquire() def _putDown(self): self.lock.release() class Philosopher(threading.Thread): def __init__(...
151ccf4a7f2a987b95facb0068f0d8464a426a11
arovit/Coding-practise
/leetcode/swap-nodes-in-pairs.py
719
3.796875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ a = head pnode = None ...
7a07729eb5d52953c3e22d797230567658e92ab9
arovit/Coding-practise
/google/all_subsets.py
369
3.765625
4
#!/usr/bin/python # Print all subsets of a given set #[1,2] = [1][2][1,2][] def get_all_subsets(slist): if len(slist) == 1: return [slist[0],''] previos_set = get_all_subsets(slist[1:]) new_set = [] for i in previos_set: new_set.append(i+slist[0]) previos_set.extend(new_set) r...
b51f54dad1b75e16f14b44f1572b08d3c829f4f4
arovit/Coding-practise
/leetcode/next-permutation.py
1,328
3.546875
4
#!/usr/bin/python class Solution(object): def nextPermutation(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ num = nums if len(num) < 2: return # Find longest sequest from right ...
c0552b6c7364c2622c129c58642bb48701109ec6
arovit/Coding-practise
/linkedln/coding1/combinations.py
458
3.859375
4
#!/usr/bin/python def combination(elements, k): if k == 1: return [[i] for i in elements] elif k == len(elements): return [elements] else: # first thing is to generate for k-1, elements-1 tmp = combination(elements[:-1], k) result = combination(elements[:-1], k-1) ...
e985b0ec76fb89b228aa82574f9660d73c2f7393
arovit/Coding-practise
/linkedln/coding1/tree.py
739
3.984375
4
#!/usr/bin/python class Node(object): def __init__(self, data): self.data = data self.left = None self.right = None root = Node(100) root.left = Node(50) root.right = Node(150) root.left.left = Node(32) root.left.right = Node(59) root.left.left.left = Node(20) root.left.right.right = N...
8d8a7fcbb7fe29882df158b0b074699218e98b9a
arovit/Coding-practise
/misc/nested_value_checker.py
537
3.71875
4
#!/usr/bin/python mdict = { '1':'a', '2':'b', '3':'c', '4': { '1':'a', '2':{ '1':'a', } } } def print_value(ndict, target): rkeys = [] for i in ndict.keys(): if type(ndict[i]) == dict: keys_target = print_value(ndict[i], target) # this will re...
b9adae6f7b998d6842bb127e5f822cddc5935d48
arovit/Coding-practise
/leetcode/sudoku-solver.py_leetcode
1,808
3.90625
4
#!/usr/bin/python class Solution: # @param board, a 9x9 2D array # Solve the Sudoku by modifying the input board in-place. # Do not return any value. def solveSudoku(self, board): self.solve(board) print board def findUnassigned(self, board): for row in range(9): ...
f8f824944953e2299b38325aaa36a02c278a2283
arovit/Coding-practise
/linkedln/coding1/reverse_words_in_string.py
478
3.5625
4
#!/usr/bin/python class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ slist = s.strip().split(' ') slist = filter(lambda x:x, slist) rlist = self.reverseList(slist) return ' '.join(rlist) def reverseList(se...
e3fdc480c3d212354e56ae42baf37fafc5f308ec
arovit/Coding-practise
/misc/nested_sum.py
1,169
3.953125
4
#!/usr/bin/python #value_list = [1,[2],5] value_list = [1,[2],[[4,[1]],4],5] ####### def depth_sum(value_list): """ Value list depth sum """ return get_all_sum(value_list, 0) def get_all_sum(ele, level): sum = 0 if type(ele) == list: # 1, [2,3] for i in ele: sum += get_all_sum(...
8d7f5d762e48a4b399caa2c5f60787c09b759eb8
arovit/Coding-practise
/leetcode/search-in-rotated-sorted-array-ii.py
1,635
3.765625
4
#!/usr/bin/python class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: bool """ # 00111112 # 20011111 return self.doBinary(nums, 0, len(nums), target) def doBinary(self, nums, start, end,...
32b9f93bcae9f4bfc072eb139bbd31ef1f296c19
arovit/Coding-practise
/trees_graphs/check_balanced_tree.py
615
4.09375
4
#!/usr/bin/python from trees import Node n = Node(10) l1 = n.addleft(2) r1 = n.addright(20) l2 = l1.addleft(13) l3 = l2.addleft(13) lr2 = l3.addright(19) def check_balanced_tree(node): if not node: return 0, True lheight, lbalanced = check_balanced_tree(node.left) rheight, rbalanced = check_bal...
fd5eef45f174ee2576d2c30fc103bf53b9570303
arovit/Coding-practise
/leetcode/longest-common-prefix.py
889
3.65625
4
#!/usr/bin/python class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ cindex = 0 common_pre = "" if len(strs) == 1: return strs[0] while strs: var = "" for i in ra...
12f72d87fcc855e5907bed55494c6fa4afd2232d
arovit/Coding-practise
/linkedln/coding1/array_equal_partition.py
632
3.5
4
#!/usr/bin/python # inp = [1,5,11,1,5,1] # output - [[1,5,5,1],[11,1]] def partition_array(inp): if sum(inp) % 2 == 1: return False result = do_partition([],inp) print result def do_partition(inp1, inp2): if sum(inp1) == sum(inp2): print inp1, inp2 return True else...
5f35c5a32fafa97aff5312ffbfffdcac6d35bc0b
MechAvia/PythonExercise
/drawCesaro.py
639
3.953125
4
""" Created on Tue Mar 22 14:07:04 2016 This program draws the Cesaro torn using recursive programming @author: DJ """ import turtle def draw_ces(size, order, angle, t): if order == 0: t.forward(size) else: draw_ces(size/2.0, order-1, angle, t) t.right(90-angle/2.0) ...
97d8c49948591d6954625bffe34f03a4e28c7b23
JanosLaci/PythonTraining360PyCharm
/feladatok7_datetime.py
587
3.5625
4
# újévi visszaszámláló #\r carriage returnt nem tudja kezelni futtatáskor, de terminálban működik # újabb print while-ból kilépve (indent már nincs!) import time from datetime import datetime new_year = datetime(year=2021, month=1, day=1, hour=0, minute=0, second=0) def countdown_till_2021(no_of_counts): while ...
c1b26c4d32284c1392685921a0b453be620f524c
gitpicard/gasprice
/gasprice.py
1,133
4.15625
4
print("Philip's Gas price Calculator\nMade so that I can split the gas bill with my sister.\n") rows = [ ] users = { } total = 0 cost = 0 # Have the user enter in each row of the sheet one by one. while True: # Ask if there is more data to add. another = input("Add data? (y/n): ") if another.startswith("y") or ano...
07dbd8324f2fd2b01219c2a7e9777425caf5aa80
NightRoadIx/Piton
/inin04.py
1,249
4.3125
4
''' Colecciones de datos en Python (Sets) Existe cuatro tipos de datos en Python: Listas, Tuplas, Sets y Diccionarios ''' # SETS # Un set es una colección de datos no ordenada y no indexada # Se declaran de la siguiente forma: esteSet = {"manzana", "banana", "cereza"} miSetNumeros = {1, 9, 4, 2, 5, 8} ...
bbd1c95185a14a4cdf42d9ec61a6ede5b062e115
NightRoadIx/Piton
/inin33.py
1,674
4.15625
4
''' LIST COMPREHENSION y entrada múltiple de datos ''' # La list comprehension es una manera elegante de generar listas en Python # Además funcionan para ingresar datos de manera múltiple # Supongamos que se dese acrear una lista con los múltiplos de 5 del 1 al 14 multipl = [n*5 for n in range(1,15)]...
500907ba224404f1d1a62763d69ac596a2ca9692
NightRoadIx/Piton
/biseccionCompleto.py
5,959
4.03125
4
# # # # # # # MÓDULOS # # # # # # # # Importar módulo para graficación import matplotlib.pyplot as plt # Importar módulo para el uso de arreglos numéricos import numpy as np # Importar módulo para el uso de matemáticas simbólicas import sympy as sp # # # # # # # OBTENCIÓN DE ECUACIÓN # # # # # # # # D...
b4cac12b4413c3e5c3f155947edc946316507a94
NightRoadIx/Piton
/pooPython.py
1,006
4.0625
4
class MiClase: # # # # # # # ATRIBUTOS # # # # # # # '''x = 5 y = 2.7172 z = "cadenaPI"''' # # # # # # # MÉTODOS # # # # # # # # Constructor def __init__(self, xR = 0, yR = 0.0, zR = ""): self.x = xR self.y = yR self.z = zR # Mostrar "st...
7a95cc6e1474e3158fef1a678f87b9e91e6ecd5a
NightRoadIx/Piton
/RFalsi/rfalsi.py
598
3.515625
4
import sympy as sp import metodo1 as rf # MAIN x = sp.Symbol('x') f = 4 * sp.sin(x) - 3*x sp.pretty_print(f) sp.plotting.plot(f) while True: a = float(input('Ingresa el valor del limite inferior -> ')) b = float(input('Ingresa el valor del limite superior -> ')) if(a < b): break print('V...
68325d7ad14db83158926ee7112ca15ad4da8ac1
rtminerva/hybrid-simulation
/Old Files (Unused)/For Testing Only/tes_again.py
71
3.65625
4
import numpy as np t = np.array([2, 3]) t = np.append(t, [0]*3) print t
a61eef06bce00b82e9205f7ee2dadfcaf1425df3
NDM2021/hello-world
/NorrisMayesCSS225Problem4Unique.py
254
4.0625
4
import math def list(y): return list(y) logically = [1, 3, 3, 3, 6, 2, 3, 5] logically.append(9) print(logically) # Norris Mayes # 3/2/20 # This function takes a list of numbers, return, and add them to the list of new numbers
5c6f3cf18ccf90425e104647a71b3be1f11aff46
NDM2021/hello-world
/NorrisMayesCSS225M4P2.py
255
3.859375
4
greeting = input("Hello, possible pirate! What's the password?") if greeting in ("Arrr!"): input("Go away, pirate.") else: input("Greetings, hater of pirates!") # Norris Mayes # 2/11/20 # This code asks user for password and generate possible answer
a5ae3c38858ee01bd522ed6bdc0cdcf0156225a8
sethgraceb/ML-Week-1-Assignment
/q1_biv.py
741
3.71875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (10.0, 5.0) from sklearn.linear_model import LinearRegression dataf = pd.read_csv("assignment1.csv", comment = '#') X = dataf.iloc[:, 0].values.reshape(-1, 1) Y = dataf.iloc[:, 1].values.reshape(-1, 1) #pri...
ba2a775b6d78d654bfe5cfb74eea57a57cdd94ba
atulpunde/PythonSem4Assignment
/labCourseAsg3.py
2,039
4.375
4
### ATUL RAJARAM PUNDE ### ROLL NO 1655 # Q3 Write a Python class named Circle constructed by a radius # and two methods which will compute the area and the perimeter of a circle from math import pi # we are importing only pi from math module class Circle(object): ''' Method to calculate area of...
583c0cfe1a2ab53ff9992686a86e7c2f3dfac364
atulpunde/PythonSem4Assignment
/labCourseAsg2.py
3,396
4.1875
4
### ATUL RAJARAM PUNDE ### ROLL NO 1655 # Q2 Create a dictionary (in your file) of names and birthdays. # When you run your program it should ask the user to enter # a name, and return the birthday of that person back to them. from datetime import date import re bithdate = {} if __name__ == "__mai...
17063d3b87508fd5aa29a4b8391cb1396953c828
ecgaebler/Practice
/LeetCode/0124.py
1,017
3.859375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def maxPathSum(self, root: TreeNode) -> int: #returns the greatest sum of values possible for a path through a binary tree ...
56ce37bbee77aeac86628a5a96cd226a81f53224
ecgaebler/Practice
/LeetCode/0434.py
548
3.9375
4
def countSegments(s): segments = 0 last_char_was_space = True for char in s: if char == " ": last_char_was_space = True else: if last_char_was_space: last_char_was_space = False segments += 1 return segments #TESTING CODE BELOW TH...
ad7b13477a89bbc3a58309145f0035f143d1afca
ecgaebler/Practice
/AlgoExpert/longest_peak.py
676
3.890625
4
def longestPeak(array): longest_peak = 0 if len(array) < 3: return longest_peak #find peaks peaks = [] for i in range(1, len(array) - 1): if array[i - 1] < array[i] > array[i+1]: peaks.append(i) #determine size of peaks for peak_idx in peaks: peak_length = 1 left_idx, right_idx = peak_idx, peak_id...
57708cbe273c39840a1162e351f0864ac828f0af
ecgaebler/Practice
/AlgoExpert/spiral_traverse.py
667
3.609375
4
def spiralTraverse(matrix): result = [] if not matrix or not matrix[0]: return result startX, endX, startY, endY = 0, len(matrix[0]) - 1, 0, len(matrix) - 1 while startX <= endX and startY <= endY: for x in range(startX, endX + 1): result.append(matrix[startY][x]) for y in range(startY + 1, endY +...
80920cd9a5dbee9aeae25822e0a6dc9466ddc043
ecgaebler/Practice
/LeetCode/0049.py
683
3.828125
4
class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: anagrams = {} for word in strs: key = ''.join(sorted(word)) #alphabetize key to ensure all anagrams will produce the same key if key in anagrams: #check if this anagram already exists ...
ea9ad1ee01f1c95e3f9e477beca84402d7081088
ecgaebler/Practice
/LeetCode/0034.py
1,866
3.59375
4
class Solution: def searchRange(self, nums: List[int], target: int) -> List[int]: if not nums: return [-1, -1] def first_between(array, target, l, r): """ Find the first instance of a value between index l and r. """ l, r = 0, len(array) - 1 w...
de1d36eaa8c99a4429ff11bf7675061f97174d91
ecgaebler/Practice
/LeetCode/0136.py
918
3.921875
4
''' Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. Follow up: Could you implement a solution with a linear runtime complexity and without using extra memory? ''' def singleNumber(nums): for i in range(1, len(nums)): nums[0] ^= nums[i] return...
5b9f735ffba6aa5109af873f34c75f0f47ed614b
ecgaebler/Practice
/AlgoExpert/monotonic_array.py
378
3.9375
4
def isMonotonic(array): if len(array) < 2: return True direction = 0 for i in range(len(array) - 1): if array[i] < array[i+1]: #positive slope if direction == 0: direction = 1 elif direction < 0: return False elif array[i] > array[i+1]: #negative slope if direction == 0: direction = -...
664d319c96b44f9f8625e49ebce082dbbff0c200
ecgaebler/Practice
/LeetCode/0257.py
695
3.890625
4
#Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def binaryTreePaths(root): if not root: return [] def findPaths(node): if not node.right and not node.left: #...
338e3c7de30701898f25d7022e85bac3190b63e7
ecgaebler/Practice
/LeetCode/0003.py
1,089
3.53125
4
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: left, right = 0, 0 #keep two pointers, one at the beginning of the window, one at the end longest = 0 #length of longest string active_chars = set() while right < len(s): if left == right: ...
d463db20b6a9ea4e5e2e1b289e4b58e46f16db47
ecgaebler/Practice
/LeetCode/0374.py
671
3.515625
4
# NOTE: This won't actually run as is. This is just what I submitted on LeetCode. # The guess API is already defined for you. # @param num, your guess # @return -1 if my number is lower, 1 if my number is higher, otherwise return 0 # def guess(num: int) -> int: class Solution: def guessNumber(self, n: int) -> int...
c619ce63fedb4b3cff080d0c9470a93f478b1990
ecgaebler/Practice
/LeetCode/0202.py
647
3.53125
4
class Solution: def isHappy(self, n: int) -> bool: def nextNum(num): """ returns the sum of the squares of the digits in num """ result = 0 while num > 0: result += (num % 10) ** 2 num = num // 10 return result ...
ff17efecae99f578554242b27456afafba49ac47
ronitafter/python
/המשך בעיית ניו זילנד.py
2,096
3.921875
4
#list1 = [[4, 5, 3], [-77, "abc"]] #print(len(list1)) # 2 #print(list1[0]) # [4, 5, 3] #print(list1[1]) # [-77, 'abc'] #print(list1[0][0]) # 4 #print(list1[0][2]) # 3 #inner_list = list1[0] #print(inner_list[2]) #3 #print(list1[0][2][0]) # TypeError: 'int' object is not subscriptable #print(list1[1][1][0]) #...
5c1762fdbdb8f6f1c620edf786885ce39c7e9766
bbenjamin300/oopljpl
/quizzes/Quiz2.py
768
3.765625
4
#!/usr/bin/env python3 """ OOPL JPL: Quiz #2 """ """ ---------------------------------------------------------------------- 1. What is the output of the following? """ from functools import reduce print(reduce(lambda x, y : x + y, [2, 3, 4], 5)) print(reduce(lambda x, y : x - y, [2, 3, 4], 5)) print() print(reduc...
3da036205bdd9e90a6e434f6d002816cbcb74d5a
Mahesh14141/python-random-quote
/mahesh 1.py
426
4
4
""" #print("hello world",end=" ") var1=("hello") var2=45 var3=55.5 var4=() var5="aaa" #print(type(var4)) print(str(var2)+var5 ) """ """ #input() function :- #print("enter a number") #name=input() #print("you enter is" ,name) xyz=input("enter your age") print("your age is ", xyz) """ var1="my name ...
3aadc83041e89144b52175536dbcc5fd071fcd80
zxzerster/algorithms
/DoubleLinkedList.py
3,531
3.875
4
class DoubleLinkedList(object): class Node(object): def __init__(self, val): self._val = val self._prev = None self._next = None def __init__(self): self._head = DoubleLinkedList.Node(None) def insert(self, node): if node is None: return ...
7086d19c54d32aadbb43c30f1a0c267bbb24d16d
PiJoules/Operator-number-system
/main.py
1,494
3.859375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from itertools import product def nos_to_decimal(nos): assert isinstance(nos, str) n = len(nos) result = 0 for i in range(n): c = nos[i] if c == "0": result += i + 1 elif c == "1": result -= i + ...
4315e9545033f6e7a6fe08ed00c25d528b31b8c3
wangbaliang/webkepper
/webkeeper/libs/datetime_helper.py
424
3.734375
4
# -*- coding: utf-8 -*- from datetime import time, datetime def period_time_to_int(time_info): return time_info.hour * 60 + time_info.minute def period_int_to_time(period_time): hour = period_time / 60 minute = period_time % 60 return time(hour=hour, minute=minute) def period_str_to_int(period_st...
6ee2c6dabee5ddaf63a851558aba95932ca31b12
steban1234/Ejercicios-universidad
/07_ciclos_5.py
198
3.625
4
marcas = ['Topcon', 'Sokia', 'Trimble', 'Leica', 'South', 'Nikon', 'Pentax'] for marca in marcas: if marca == 'South': continue print('La UD cuenta con estaciones marca :', marca)
e876c2ee41d420db64c1196ba0533675dc8268e1
steban1234/Ejercicios-universidad
/00.grados_a_decimal.py
727
4.125
4
''' Programa que convierte grados en forma gggmmss (174°09'30" = 1740930) a decimales. ''' print() # Solicito el angulo al usuario angulo = input('Digite un angulo en gggmmss: ') angulo = int(angulo) # Convierto el valor ingresado a un entero angulo = angulo / 10000 # Pongo el punto decimal para separar los grados g...
a4c85beb32ced673c633ea1d00c6ab7515a3e1a6
agerista/HR_Python
/algorithms/warmup/aVeryBigSum.py
397
3.859375
4
def aVeryBigSum(n, ar): """You are given an array of integers of size N. You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large. """ sum = 0 for a in ar: sum += a return sum n = int(raw_input().strip()) ar = map(lon...
f0099b2b6fc9b9ff58eee1ed314daa6494668b58
agerista/HR_Python
/algorithms/search/missing_numbers.py
454
3.59375
4
def missing_numbers(a, b): a.sort() b.sort() i = 0 j = 0 missing = [] while i <= len(a) - 1 and j <= len(b) - 1: if a[i] != b[j]: missing.append(b[j]) j += 1 else: i += 1 j += 1 return " ".join(missing) n = int(raw_input()....
a1d1971654ba0b8f9f8778b1a7746d85e8415a09
agerista/HR_Python
/algorithms/warmup/birthdayCakeCandles.py
585
3.8125
4
def birthdayCakeCandles(n, ar): """Colleen is turning n years old! Therefore, she has n candles of various heights on her cake, and candle i has height heighti. Because the taller candles tower over the shorter ones, Colleen can only blow out the tallest candles. Given the heighti for each individual c...
a9ba1728c18f2795c76bb010e066d24daacb8f4e
JackWiegman/final
/main.py
1,779
3.90625
4
def class_amount(): class_amount = raw_input("How many classes do you have? > ") class_amount_int = int(class_amount) return class_amount_int def class_names_def(): class_names = [] class_name = raw_input("What class is it? > ") return class_name def current_grades_def(): current_grades = [] current_grad...
24ff82f1c8ab16b2068a97988ded92aa091b0253
JiangHuYiXiao/PythonProject
/day05/continue vs break.py
647
4.0625
4
#-*- coding:utf-8 -*- # while 循环语句运行后需要终止时需要使用终止语句,一般使用,continue和break # 1、break用于终止整个循环。 # 2、continue指的是结束这次循环,进入下次循环。 count = 0 while count <=100: print('loop:',count) if count == 5: break # 下面的这个语句不执行,后面也不再运行循环了 count +=1 #result:0,1,2,3,4,5 count1 = 0 while count1 <=100: print('loop:'...
1e64047944e5e453eb5a982a5c9fd06f9c57bf53
JiangHuYiXiao/PythonProject
/Python 入门/day08/浮点数的精度问题.py
499
3.875
4
#-*- coding:utf-8 -*- # python默认是17位的精度,也就是小数点后16位,但是这个精确度越到后面越不准, # 其他语言也存在同样的问题,这个是和浮点数的存储结构有问题。 # 计算高精确度浮点数的办法 # 借助decimal模块的‘getcontext’和‘Decimal’方法 a = 3.14159263513651054608317828332 print(a)#3.1415926351365107 from decimal import * getcontext().prec = 50 #精度为50 b = Decimal(1) /Decimal(3) print(b) print(Decimal(...
63739b81efdfda1961d17a8a3091e2c3923b3f4f
JiangHuYiXiao/PythonProject
/Python 入门/day05/猜年龄小游戏V2.py
843
4
4
#-*- coding:utf-8 -*- # 练习:优化猜年龄小游戏,允许用户猜三次,中间猜对了,直接跳出循环。 # 猜了三次后,再问是否还想玩,如果用户选Y,则再允许猜三次,以此反复。 age = 26 count = 1 while count <=3: guess_age = int(input('请输入你猜的年龄:')) if guess_age == age: print('恭喜你猜中了,可以领走我们的奖品!') break elif guess_age < age: print('请输入更大一点的数据!') elif guess_age...
66bde0098923b360453ad5aa35c9095572b121aa
sagarchoudhary1808/Hackerrank-solution
/Append and Delete.py
841
3.53125
4
#!/bin/python3 import math import os import random import re import sys # Complete the appendAndDelete function below. def appendAndDelete(s, t, k): s=list(s) t=list(t) s_length=len(s) t_length=len(t) if s_length+t_length<=k: return "Yes" same=0 for i in range(0,min(s_length,t_lengt...
07b293e919e6703f03763296479f0f8b025a514a
OlgaUlrich/prework
/PY-Training/10.py
736
3.78125
4
import re def get_size_of_longest_sequence_of_zeros(args): temp = str(format(args, "b")) pattern = '0+' match = re.findall(pattern, temp) match.sort() if len(match)==0: return "0" else: maxN = len(match[len(match)-1]) return maxN print(get_size_of_longest_sequence_of_ze...
76cee7aa0f3d1effe6755b3a8d24d4ac2cc91506
OlgaUlrich/prework
/PY-Training/1.py
339
3.921875
4
def hello_world(y): if len(y) == 0: print(f"Hello Unknown!") else: if y.find(' '): newStr = y.split() for item in newStr: print(f"Hello {item}!") elif y.find(' ') == -1: print(f"Hello {y}!") print('Write your name please: ') x = inp...
ed000c90048866fcb14fc724a96519fe787a4582
em1382/python-programming
/2/c2e7_futval.py
644
4.0625
4
# Programmer: Ellis Madagan # File name: c2e7_futval.py # Date: 9/5/2015 # This program calculates a compound interest rate def main(): print("This program calculates a compound interest rate over 10 years.\n") prin = eval(input("Enter the initial amount: ")) rate = eval(input("Enter the yearly rate: ")) ...
45e59abc5797676981da9050f195eacc4aaa7828
Macchiato0/Py_notes
/address.py
2,546
3.53125
4
@check_street def address_extract(t): #t is a string '........' match=re.search('\d\w+', t) text=re.split("[\s,,,.,?,#,/]", t) if match: x=match.group() #find the digit part in the string as street number if len(x)<6: position=text.index(x) if position<(len(text)-...
48d5d9c57e29ddfd7a0f09f164703be0cfb119f3
Macchiato0/Py_notes
/dict_note.py
981
3.890625
4
scores = {'Loi': 95, 'Bui': 78, 'Dea': 82} #key:value print(scores['Loi']) print(scores['Dea']) # loop through dictionary(i.e. loop keys and get value through key) # %s:string, %d:digit,\t:tab for elem in scores: print('%s\t--->\t%d' % (elem, scores[elem])) # updates value of a key scores['Bui'] = 65 #add an ele...
0199a75523b2e8329346efbd79e99fc323f0f978
MissingNA/spotify_playlist_generator
/create_playlist.py
5,198
3.625
4
""" Step 1: Log Into Youtube Step 2: Grab Liked Videos Step 3: Create a New Playlist Step 4: Search for Song Step 5: Add this song to Spotify playlist """ import json import requests import os from secrets import spotify_user_id, spotify_token import google_auth_oauthlib.flow import googleapiclient.discovery import ...
4fc5508eac0e39d949de6825b234d8a1067c57b4
Hackin7/Programming-Crappy-Solutions
/School Exercises/2. NYJC A Level Computing 2019-2020/Practicals/Practical 1/3.6.py
384
4.28125
4
def factorial(x): #Validation for non-negative integer if x < 0: print("Number input is negative!") exit() #Base case if x == 0:return 1 #Recursion return x * factorial(x-1) print("It's factorial is",\ #Output factorial( #Conversion \ int(input("Ente...
d0906dfacbfb8665e21f2736a7d15dd3b58362a9
Hackin7/Programming-Crappy-Solutions
/School Exercises/2. NYJC A Level Computing 2019-2020/Practicals/Practical 1/All.py
4,420
4.1875
4
###Q1####################################################################### num1 = int(input("Enter num1:")) num2 = int(input("Enter num2:")) operation = input("Select the Operation\n" " + for addition\n" " -for subtraction\n" " X for multiplication\n" ...
4bb530dcff79890b0c50152f1135f8ef92eb0c60
Hackin7/Programming-Crappy-Solutions
/Competitve Programming/Competitions/2021/Global Coding Challenge/2 - Securities Buying.py
880
3.609375
4
def key(a): return a[1] def securitiesBuying(z, security_value): no_of_stocks=0 #participants code here security_value_pairs = [(i+1, int(security_value[i])) for i in range(len(security_value))] s = sorted(security_value_pairs, key=key) money = int(z[0]) for i in range(len(s)): ...
30db88bd6e72b868b9ebd44ade7c95312feee857
Hackin7/Programming-Crappy-Solutions
/School Exercises/2. NYJC A Level Computing 2019-2020/Practicals/Practical 1/Q1.py
1,240
4.34375
4
num1 = int(input("Enter num1:")) num2 = int(input("Enter num2:")) operation = input("Select the Operation\n" " + for addition\n" " -for subtraction\n" " X for multiplication\n" " / for dividing num1 against num2\n" " // for q...
b05c24d55f45313b6ed461a91342a05aeed777f0
Hackin7/Programming-Crappy-Solutions
/School Exercises/2. NYJC A Level Computing 2019-2020/Practicals/Practical 11/Practical11.py
5,485
4.125
4
###Q1############################################################# ###File Input################ def fileInput(): try: filename = input("Enter filename to open: ") f = open(filename) data = f.read() f.close() except: print(f"File {filename} unable to be opened") r...
75120219fa593678b7218e4e45ef736e83818140
Hackin7/Programming-Crappy-Solutions
/School Exercises/2. NYJC A Level Computing 2019-2020/Other School Papers/2020 Mid Year Common Test/YIJC BE2/Q4 Socket Programming/maze.py
1,500
3.640625
4
from random import randint def user(position, direction): if direction == 'U': return [position[0], position[1]-1] elif direction == 'D': return [position[0], position[1]+1] elif direction == 'L': return [position[0]-1, position[1]] elif direction == 'R': retur...