blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5c3678aa0497ab0e117ce37102264cb667a13a26
hanzhg/aoc2020
/day1b.py
382
3.59375
4
def main(): with open('input.txt') as f: lines = [line.rstrip() for line in f] result = 0 for line in lines: for line1 in lines: value1 = 2020 - (int(line) + int(line1)) if str(value1) in lines: result = int(line) * int(line1) * value1 ...
2584d7f13ace7722c952ed40e0afa3a3c30eeebe
wilbertgeng/LintCode_exercise
/DP&Memorization/724.py
895
3.515625
4
""" 724. Minimum Partition """ class Solution: """ @param nums: the given array @return: the minimum difference between their sums """ def findMin(self, nums): # write your code here ### target = sum(nums) // 2 n = len(nums) dp = [[False] * (targ...
51b8415553ad64d14e63a55652436820fc3e1e40
brown9804/Python_DiversosAlgortimos
/AgregarLineasTXT.py
681
3.703125
4
#Python3 # Permite ejemplificar como agregar lineas de texto a un archivo extension .txt #Agregando lineas a un archivo de texto archivo = open("Himno.txt", "w") archivo.write("¡Noble patria!, tu hermosa bandera\n") archivo.write("expresión de tu vida nos da;\n") archivo.write("bajo el límpido azul de tu cielo\n"...
ddb29ec69b25ce0d5bd1981d4102fa2f2cd134ea
Gyczero/Leetcode_practice
/动态规划和贪心/Easy/leetcode_70.py
469
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019-09-14 18:19 # @Author : Frenkie # @Site : # @File : leetcode_70.py # @Software: PyCharm class Solution: def climbStairs(self, n: int) -> int: """ clib(n) = clib(n-1) + clib(n-2) :param n: :return: """ ...
08de1d23eaddeaac19bf707aba6e2088bfe184e2
ikamilov/AlgorithmsQuestions
/AlgorithmDesignManual/increment.py
109
3.828125
4
y = 8 if y == 0: print("1") else: if y % 2 == 1: x = 2 * (y / 2) print(x) else: y = y + 1 print(y)
2f1804a2de2a5b7b3a9eec6c49d343ad50132e4e
JakubTesarek/projecteuler
/src/problem_005.py
292
3.765625
4
#!/usr/bin/env python """https://projecteuler.net/problem=5""" if __name__ == '__main__': primes = [] result = 1 for x in range(1, 21): for prime in primes: if x % prime == 0: x /= prime primes.append(x) # not really primes, we use number 1 too result *= x print(result)
7ae09408fa4cc36227c45f48042969e8d30bd86f
appltini/clever-bee
/kalman.py
1,040
3.59375
4
# Import python libraries import cv2, numpy as np class Kalman(object): """Kalman Filter class keeps track of the estimated state of the system and the variance or uncertainty of the estimate. Predict and Correct methods implement the functionality Reference: https://en.wikipedia.org/wiki/Kalman_filte...
364ad89c54a3e0020e1b61647e807305742e8268
Copenbacon/code-katas
/katas/test_triangle.py
823
3.546875
4
import pytest from triangle import is_triangle TRIANGLE_TABLE = [ [1, 2, 2, True], [7, 2, 2, False], [1, 2, 3, False], [1, 3, 2, False], [3, 1, 2, False], [5, 1, 2, False], [1, 2, 5, False], [2, 5, 1, False], [4, 2, 3, True], [5, 1, 5, True], [2, 2, 2, True], [-1, 2, 3, False], [1, -2, 3, False], [1, 2, ...
0fab9deff0b6a3e034c9872a748c8710370ee1ab
elidinkelspiel/GoalTrak
/Old_Versions/v.0.0.3.py
3,567
3.796875
4
#####GoalTrak version v. 0.0.3 (alpha version 3)##### ###March 28th, 2014### #By Eli Dinkelspiel# #This version's functionality: #1) Can add names to a list database of Students #2) Recognizes if name is already in list #3) Refreshes listbox upon adding new name #4) Quit button #5) I started documenting cause I'm co...
c232ca500a07d2ddb5bd9dacbced209f7e593698
Sntsh176/LeetCode_Apr_Problems
/subarray_sum_equal.py
1,901
3.9375
4
""" Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Note: The length of the array is in range [1, 20,000]. The range of numbers in the array is [-1000, 1000] and the range of the integer k is ...
0636a2cb9e1e293e0f04103923bdd1d80eb720ee
MoMoLT/KeySim
/dist/资源/createFile.py
2,579
3.546875
4
def writeKeyName(fileName='KeyName.txt'): with open(fileName, 'w') as f: # 写入鼠标键 mouseName = ('左键', '右键', '中键') for i in mouseName: f.write(i+'\n') # 写入字符键 for i in range(65, 91): ch = chr(i) f.write(ch+'\n') # 写入数字键 for i i...
93e25bbb15fd058a4ded801a8206b7fbe8eab4ed
qmnguyenw/python_py4e
/geeksforgeeks/python/medium/23_13.py
1,599
4.25
4
stdev() method in Python statistics module Statistics module in Python provides a function known as **stdev()** , which can be used to calculate the standard deviation. stdev() function only calculates standard deviation from a sample of data, rather than an entire population. To calculate standard deviati...
ce7c6e856cf572673562d0d35406ebb49404fc0a
huanhuancao/Python-programming-exercises
/github_100_python_questions/11.py
186
3.671875
4
# -*-coding:utf-8-*- value = [] nums = [num for num in raw_input().split(',')] for num in nums: n = int(num, 2) if n % 5 == 0: value.append(num) print(','.join(value))
467c27b5014ad09a8fd1d645e1584ca3ea2e18ec
evaristofm/curso-de-python
/PythonExerciocios/ex004.py
357
3.8125
4
algo = input('Digite algo: ') print('Seu tipo primitivo é {}'.format(type(algo))) print('É um número? {}'.format(algo.isnumeric())) print('É uma letra? {}'.format(algo.isalpha())) print('Tem letras e números? {}'.format(algo.isalnum())) print('Está em maiúsculo? {}'.format(algo.isupper())) print(('Está em minúsculo? {...
bf20e59e54dba56847f37b9c38913dbff1d431e5
shahbaz-pycread/Python_Notes
/list/lists.py
6,547
4.625
5
print( """ A list is a collection which is ordered and changeable. It allows duplicate members. In Python, lists are written with Square Brackets. ---------------------------------------------- """ ) football_countries = ["Argentina","Brazil","Germany","Spain","Italy","France"] # Print the type prin...
26e4dddea51c477b6fbc636bfdebf8fe27a06733
logantillman/cs365
/hw7/frequency.py
862
4.03125
4
# Author: Logan Tillman import sys # Reading in the file name file = sys.argv[1] # Reading the data from the file with open(file, 'r') as f: data = f.read() # Splitting the words into a list splitData = data.split() # Creating the dictionary to hold our information wordDict = {} # Populating the dictionary fo...
37e1793c33b6bce48451dce00f5b3c0b628266d2
Celmad/learning-python-with-vim
/039-builtin-libraries.py
196
3.78125
4
import random for i in range(3): print(random.random()) print(random.randint(10, 20)) members = ['Manuel', 'Elias', 'Jose Luis', 'Antonio'] leader = random.choice(members) print(leader)
819f6f6246c99bc7e296e81825840829074892e9
sumanmukherjee03/practice-and-katas
/python/grokking-coking-interview/sliding-window/avg-subarr-size-k/main.py
2,210
3.78125
4
def describe(): desc = """ Problem : Given an array, find the average of all subarrays of K contiguous elements in it. Ex : Given Array: [1, 3, 2, 6, -1, 4, 1, 8, 2], K=5 Output: [2.2, 2.8, 2.4, 3.6, 2.8] """ print(desc) # Time complexity = O(n^2) def brute_force_find_averages_of_subarrays(K, ar...
6e848cdacf2855debfa5adb7ee6164758a53f8e7
susoooo/IFCT06092019C3
/Riker/python/08.py
232
3.609375
4
# 1-Escriba un programa que pida dos números enteros y que calcule su división, escribiendo si la división es exacta o no. n1 = int(input("n1? ")) n2 = int(input("n2? ")) if (n1%n2 == 0): print("yes") else: print("no")
eea5eee7082d42273340511727ebd1cfe9a95e27
medishettyabhishek/Abhishek
/Abhishek/Section 9/Section 9-1/find and replace.py
131
3.859375
4
import re string = ("hello my name is John") pattern = r"John" newstring = re.sub(pattern , "abhishek",string) print(newstring)
ba08a92fa65af167884cf5fd766c6833d2d72f30
lilac/mini-nn
/src/network.py
3,689
3.625
4
import numpy as np def sigmoid(x): return 1.0 / (1 + np.exp(-x)) def derivatives(x, y, z): """ Given the loss function C(x, y) = (f(x, w, b) - y)^2 f(x, w, b) = sigmoid(g(x, w, b)) g(x, w, b) = wx + b the partial derivatives d.C / d.b = 2(f(x, w, b) - y) * (d.f(x, w, b) / d.b) and it's...
066282e51de275bba77fc48a871cd77625a34a27
rayankikavitha/InterviewPrep
/PRAMP/draw_H_recursively.py
1,024
4.1875
4
import math import Graphics def drawLine(x1, y1, x2, y2): # draws line, assume implementation available point1 = Graphics.point Graphics.Line(point1, point2) def drawHTree(x, y, length, depth): # recursion base case if depth == 0: return x0 = x - length / 2 x1 = x + length / 2 ...
1765a4c0fdc25bd38a12656f98c8387e2f0e6a04
metodiev/PythonOverview
/age_notificator_2.py
597
4.125
4
#If age is 5 go to Kindergarten #Ages 6 through 17 goes to grades 1 through 12 #if age is grater then 17 say go to college #Try to complete with 10 or less lines #Ask for the age age = eval(input("Enter age: ")) #Handle if age < 5 if age < 5 : print("Too Young for School") #Special output just for age 5 elif ag...
3d7e3d7042d93cec14ecc34baf6c766496d140a5
jcperdomo/182finalproject
/state.py
3,159
3.53125
4
from copy import deepcopy import cards class State(object): """Docstring for State. """ def __init__(self, playedCards, whosTurn, topCard=None, lastPlayed=None, finished=[]): """Initialization for State. :playedCards: list of card count dictionaries representing how many of ...
ccc82a2ea33fc6da2e5d070845e7de9199c13826
erenerdo/algorithms
/Data Structures/HashMap.py
4,915
4.03125
4
# Eren Erdogan # YCharts Coding Challenge # Setting up the Linked List Class to be used in the Hash Map for # seperate chaining implementation # Linked List Node Class class LListNode: def __init__ (self, key, value, nextNode): self.key = key self.value = value self.nextNode = nextNode # Lined List Cl...
785fdb1b44e5a9e89b8c8a58d622c4e37da641cc
dwdii/py-sandbox
/src/utillib/unionfind.py
2,026
3.984375
4
# # Author: Daniel Dittenhafer # # Created: May 21, 2019 # # Description: Coursera Algorithms # __author__ = 'Daniel Dittenhafer' import random """ Union-Find Data Structure """ class union_find: class entry: def __init__(self, id): self.rank = 0 self.parent = None ...
9b467fe9aefb0dab880a0877c494d5a6e7e97905
kimmyoo/python_leetcode
/A_ENUMERATION/contains_duplicate_ii/solution.py
1,408
3.65625
4
""" Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k. """ class Solution(object): def containsNearbyDuplicate(self, nums, k): """ :type nums: List[int] ...
ce6f839b522c4713e5537261427befa879ead1b0
Osama-Khan/bscs-na
/Mid/Q2.py
472
3.65625
4
# Write python code to find the solution of given set of equations using # Seidel Method with initial conditions x, y, z = 1, 1, 1 [for 10 iterations only] def f1(y, z): return (-4*y + z + 32)/28 def f2(x, z): return (-2*x - 4*z + 35)/17 def f3(x, y): return (-x - 3*y + 24)/10 x, y, z = 1, 1, 1 print("k", "x", "y",...
883c2c3ac11c439d47be84f927fa282f8aa5dd18
igormcoelho/goat-in-door-challenge
/goat.py
1,636
3.875
4
#!/usr/bin/python3 import random import statistics # simulate game turns=1000000 print("running ", turns) player1_static_wins=0 player2_dyn_wins=0 for i in range(turns): goat = random.randint(1,3) ##print("goat on ", goat) selected = play1_bet = play2_bet = random.randint(1,3) # same bet for both pla...
235f877dbd294deb6e9927b62181682a8435a5ff
VfromNN1909/ArtezioHomeTasks
/Lesson VI/Iterators and Generators/hw6.3.py
986
3.578125
4
# импортируем json,дабы красиво вывести словарь import json # для генерации значений # если ввести значение < количество ключей + 1(27) # то вместо недостающих значений будет None # если ввести больше,то лишние значения будут игнорироваться limit = int(input('Введите лимит: ')) # генерируем ключи - буквы от a до z ke...
1de339b2152f1a0bda7a0fa52ec300234adcbee0
himanshus97/Linear_Regression_py
/linear_reg.py
1,142
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 1 19:30:30 2018 @author: himanshu """ import numpy as np import matplotlib.pyplot as plt import pandas as pd #importing the data dataset = pd.read_csv("sample_data.csv") #add your data here X=dataset.iloc[:,:-1].values #make changes here as accor...
a3b16f747683a27637453da9da8bfd8555648e14
boboriska/PythonMIIGAIK
/Task_4/Task_4.py
1,502
3.734375
4
# Задача 1 «Длина отрезка» (1 балл) m = input('Введите число: ').split(" ") m[0] = int(m[0]) m[1] = int(m[1]) m[2] = int(m[2]) m[3] = int(m[3]) def distance(x1, y1, x2, y2): return ((x2 - x1)**2 + (y2-y1)**2)**0.5 print(distance(m[0],m[1],m[2],m[3])) # Задача 3 (1 балл) stroka = input('Введите строку: ') print(''....
ce2690ee101b5fa749519fbe04b528bf95ee3e47
heshengbang/pylearn
/100examples/1.py
167
3.84375
4
#!/usr/bin/python count =0 for a in range(1,5): for b in range(1,5): for c in range(1,5): if (a!=b and b!=c and a!=c): print a,b,c count+=1 print count
c52488cea975fde4e1264bf1f9796325dda9783f
linguang-up/python_code
/day1/passwd.py
381
3.953125
4
#!/usr/bin/env python # Author:Lin Guang name = input("name:") age = input("age:") salary = input("salary:") # info = '''------------information %s ------------ # NAME:%s # AGE:%s # salary:%s # ''' % (name,name,age,salary) info = '''------------information {_name} ------------ NAME:{_name} AGE:{_age} salary:{_sala...
e741a4968936eab9cfc48d1b07cf3a113639e9e9
OWEN-JUN/python_study
/day1/tri_ex.py
272
3.84375
4
def drawdiamond(num): for i in range(1, num + 1): print(" " * (num - i),"*" * (2 * i - 1)) for i in range(num - 1, 0, -1): print(" " * (num - i),"*" * (2 *i -1)) diamond = int(input("만들어질 다이아몬드 줄수>>")) drawdiamond(diamond)
fa4062ca2eb80c11819d607cff84dafd8b31dc9e
sadrayan/connected-vehicle-iot
/src/Servo.py
828
3.546875
4
import Adafruit_PCA9685 class Servo: def __init__(self): self.angleMin=18 self.angleMax=162 self.pwm = Adafruit_PCA9685.PCA9685() self.pwm.set_pwm_freq(50) # Set the cycle frequency of PWM #Convert the input angle to the value of pca9685 def map(self,value,...
3f8e0269c489ef326443abc8df82174eed309d8f
pedrohcf3141/CursoEmVideoPython
/CursoEmVideoExercicios/Desafio023.py
459
3.859375
4
# Desafio 23 nro = input('Informe um numero ') nro = '0000'+nro print(' o numero tem {} Unidades '.format(nro[-1])) print(' o numero tem {} Dezenas'.format(nro[-2])) print(' o numero tem {} Centenas '.format(nro[-3])) print(' o numero tem {} Milhares '.format(nro[-4])) nro = int(nro) print('Unidades {}'.format(nro%...
f1f926a47452bbd548c08433ac470f5720a827d6
qtvspa/offer
/LeetCode/increasing_number.py
903
3.703125
4
# 单调递增的数字 # https://leetcode-cn.com/problems/monotone-increasing-digits/ # 思路:见注释 def monotone_increasing_digits(n: int) -> int: list_n = list(str(n)) r = len(list_n) - 1 res = [] # 从右往左遍历 while r - 1 >= 0: # 如果当前元素大于或等于前一个元素,则将当前元素加入res if list_n[r] >= list_n[r - 1]: ...
de57334bcbb07150146941ee80d780f07a6f10d5
Leahxuliu/Data-Structure-And-Algorithm
/Python/贪心/区间问题/56. Merge Intervals.py
894
3.703125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @Time : 2020/05/25 ''' Method - greedy Steps: 1. sort intervals based on interval[0] 2. append intervals[0] into res 3. traverse intervals[1:] (start, end) 4. compare start with res[-1][1] if start <= res[-1][1], res[-1][1] = max(end, res[-1][1]) ...
9baa38f9cf403a3789da6e5089462a440e1f58ef
Un-knownCoder/Python-Repository
/Exercises/perfetto.py
664
3.8125
4
# Per stabilire se un numero e' perfetto bisogna # calcolare se e' dato dalla somma dei suoi divisori class Perfetto: def calculate(self, num): P = Perfetto() value = p.getDivisori(num) out = 0 for i in range(0, len(value)): out += value[i] if(out ==...
d68ff9fec6be7beb4b001ea1d9ce0cb3d1af57ea
Brian-Mascitello/UCB-Third-Party-Classes
/Udacity-Intro-To-Computer-Science/Lesson 12/Lesson 12 - Quizzes/Product List.py
506
4.21875
4
# Define a procedure, product_list, # that takes as input a list of numbers, # and returns a number that is # the result of multiplying all # those numbers together. def product_list(list_of_numbers): product = 1 for number in list_of_numbers: product = product * number return product # print pr...
81fbdba5a8723fef6fdaec04d7da14984b2eaefa
daniel-reich/ubiquitous-fiesta
/ygeGjszQEdEXE8R8d_4.py
815
3.546875
4
from copy import deepcopy class Move: dirn = {'up': (-1, 0), 'down': (1, 0), 'left': (0, -1), 'right': (0, 1)} def __init__(self, mat): self.height = len(mat) self.width = len(mat[0]) for r, c in [(r,c) for r in range(self.height) for c in range(self.width)]: if mat[r][c] == 1: break ...
c3a063f96474b634ba373dc46e45dce59ad28b8c
allegit/cs50w
/openFile.py
766
3.71875
4
"""openFile.py Reads a file containing scores then prints the data as-is, sorts and prints and then reverses and prints """ scores = [] # Array to hold scores names = [] # Array to hold names result_f = open('results.txt') for line in result_f: (name,score) = line.split() scores.append(float(score)) name...
8320aabb883c1ef1fc8205039bdeeaa8653b7a8f
LesterAGarciaA97/OnlineCourses
/08. Coursera/20. Data visualization with Python/Module 1/Week 01/Program/PythonDataV/task2.py
552
3.765625
4
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns #Create the dataframe using the json file... df = pd.read_json (r'./rain.json') plt.figure(figsize=(17,5)) plt.plot( df['Month'], df['Temperature'], label='Temperature') plt.show() #Plot rainfall plt.figure(figsize=(17,5)) plt.plot( df['Month'...
b82e7ae66d5160d03d67c3bd8ef6a0c5d2408118
TheAutomationWizard/learnPython
/pythonUdemyCourse/Interview_Questions/LogicMonitor/string_based.py
1,353
3.75
4
def get_first_non_repetitive_Case_sensitive(input): position_holder = 0 unique_flag = False for character in input: position_holder += 1 sub_position_holder = 0 for other_char in input.lower(): sub_position_holder += 1 if position_holder == sub_position_holder...
7c35f6e372f479d2d5a5dd1f2e90fedf030afda0
indo-seattle/python
/Sandesh/Week3_0324-0330/CollectionDataTypes/10_CountEachStatefromList.py
458
4.03125
4
#Write a Python program that takes mylist = ["WA", "CA", "NY", “IL”, “WA”, “CA”, “WA”] and print how many times each state appeared in the list. mylist = ["WA", "CA", "NY", "IL", "WA", "CA", "WA"] for x in mylist: print(mylist.count(x),x) print("WA is", mylist.count("WA"), "in the list") print("CA is", mylist.count...
83c38ad389ac23abb0ee84ce31e45675c7e007ff
Pegasids/Introduction-to-the-Foundations-of-Computation-I
/Lab Assignments/Lab 12/Lab 12.py
1,397
3.65625
4
from wordplay import * import os import random s = "" all_pron = all_homophones() all_anag = all_anagrams() inv = invert_dict(all_homophones()) count = 0 txtfile = str(input("File name: ")) while True: if os.path.isfile(txtfile): fin = open(txtfile, 'r') break else: print("File DNE.") ...
f1b9ad5eb0054536bbe4f1a6badaca082711c675
annasochavan777/Python-Assignment
/Assignment-3/Assignment3_5.py
1,241
4.25
4
################################################################################################## # Write a program which accept N numbers from user and store it into List. Return addition of all # prime numbers from that List. Main python file accepts N numbers from user and pass each # number to ChkPrime() function ...
c8f9261b705be99057e3b9dd382cdb5c1db6b628
fzelkhamouri/Regression_NN
/NN2.py
2,865
3.78125
4
import numpy as np class Neural_Network(object): def __init__(self): # Parametters self.inputSize = 2 self.outputSize = 1 self.hiddenSize = 3 # Weights self.W1 = np.random.randn(self.inputSize, self.hiddenSize) # (2x3) weight matrix size p...
f00a03b511b3337e9eb3d2d4895d9e48a5540e89
aa-arora/Data_Structure_Algorithms_Utility
/integer_square_root.py
333
3.96875
4
def binary_search_square_root(target): low = 0 high = target while low <= high: mid = (low + high) // 2 square_num = mid ** 2 if square_num > target: high = mid - 1 elif square_num <= target: low = mid + 1 return low - 1 print(binary_search_squar...
529f85257c2e7c61f517ab276e020ea0117cfb97
MEng-Alejandro-Nieto/Python-3-Udemy-Course
/10 TEST 1.py
2,825
4.71875
5
# write a brief description of all the following object types and data structures we have learned about: # Number: number can be of two different types, integers such as (1, 13, 300) or float such as (1.2, 35.159, 0,004) # Strings: this is basically text that can be indexing or sliced # List: a list is a colect...
87e9dc0937a256f39dc4ee51335452adbc20ba35
arifaulakh/Project-Euler
/10-Summation-of-Primes/main.py
269
3.671875
4
def primes(n): primes = [] sieve = [True] * (n + 1) for p in range(2, n + 1): if sieve[p]: primes.append(p) for i in range(p * p, n + 1, p): sieve[i] = False return primes P = primes(2000000) print(sum(P))
fcb3030677d9919b1d74de6adc239fde2aba0be6
trgreenman88/CS_21
/greenman_futval.py
869
3.78125
4
# Trent Greenman # CS 21, Fall 2018 # Program: futval.py (Modification #4) def main(): print("This program calculates the future value") print("of a 10-year investment.") # Get inputs for yearly amount, interest rate, number of years for the # investment, number of times compounded, and set the total a...
a0b99e48935984eb5c6f2d08f99f58adf26b4694
rodrigohuila/python_scripts
/MyScripts/splitPdf.py
2,524
3.671875
4
#! python3 #! /usr/bin/python3 import os import PyPDF2 from tkinter import filedialog as FileDialog from tkinter import messagebox as MessageBox from os import system from os.path import basename path = r"D:/Users/victo/Downloads/" path2 = r"D:/Users/victo/Desktop/RenamePDF/" contentAll = '' def clear(): # BORRAR ...
042dd4d4dbe40949fbd577771d29161342565944
Sharvari07/Functional-programming-in-python
/practice problems/last element of list.py
463
3.703125
4
import random ls = [random.randint(0,20) for i in range(10)] print (ls) l = len(ls) ''' for x in range(l): if x == l-1: print("last number is:", ls[x]) ''' ''' last = [print("Last no is:",ls[x]) for x in range(l) if x==(l-1)] def find_last(list, index): if index == len(list) - 1: return ...
8b93e1e66783a2348b65a465094cdd0e8daa0bf9
BarberAlec/Common-Interview-Questions
/code/mostFreqInt.py
405
3.65625
4
def mostFreqInt(my_list): d = dict() for val in my_list: key = str(val) if key in d: d[str(val)] += 1 else: d[str(val)] = 1 max_val = -1 max_key = None for key,freq in d.items(): if freq>max_val: max_val = freq max_key =...
a5c1513e205100031be9a2327067929f87a7429b
xidaodi/AILearn
/pandas_test.py
258
3.71875
4
import numpy as np import pandas as pd # create a pandas dataframe arr=np.array([["Zhang",30,100], ["Chang",100,100], ["Huang",30,60]] ) df=pd.DataFrame(arr,index=[1,2,3],columns=["name","math","english"]) print(df)
b6cd7a9b0c9c6b6fb12b25de83844936bc09b736
chloe-wong/pythonchallenges
/A214.py
1,308
3.703125
4
#exercise1 dictionary = {} sentence = input() b = sentence.lower() a = b.replace(" ","") for x in range(len(a)): if a[x] in dictionary: dictionary[a[x]] = dictionary[a[x]]+1 else: dictionary[a[x]] = 1 dictionaryitems = list(dictionary.items()) dictionaryitems.sort() for y in range(len(dictionar...
280e584e3820bcf8802d26926b200f79612e231a
xshen1122/Python-practice-1
/lambda_p1.py
384
3.828125
4
# lambda_p1.py # coding: utf-8 ''' format lambda x: x*x 匿名函数有个限制, 就是只能有一个表达式,不用写return,返回值就是该表达式的结果。 ''' print map(lambda x: x*x, [1,4,5,7,9]) ''' Python对匿名函数的支持有限,只有一些简单的情况下可以使用匿名函数。 ''' def build(x,y): return lambda: x*x + y*y print build(5,7)()
fe006f5dbb34fe5eb0a42b6ebc4e074b528dec00
huangketsudou/leetcode_python
/List Node/postorder.py
625
3.65625
4
""" # Definition for a Node. class Node: def __init__(self, val=None, children=None): self.val = val self.children = children """ class Solution: def postorder(self, root: 'Node') -> List[int]: from collections import deque if not root: return [] stack = deque() s...
8c434d869f2fec10c6eeb4e1089455fc91920024
Jownao/Provas-Laboratorio-e-Introducao-a-progamacao
/provas de prog/LABORATORIO/Prova3/Docente.py
611
3.53125
4
import Funcionario as fu class docente(fu.funcionario): def __init__(self): super().__init__() self.disciplina = '' self.salario = 0.0 self.titulacao = '' def cadastrar(self): super().cadastrar() print('Dados do Docente'.center(50, '-')) ...
538d2022fc0bc46e92c0c3881a4e604e56ad1eed
tonydo2020/CPSC_Security
/final_version.py
3,798
3.53125
4
import random D = [('F', 'P', 'Z'), ('G', 'Q'), ('I', 'S'), ('J', 'T'), ('A', 'K', 'U'), ('B', 'L', 'V'), ('C', 'M', 'W'), ('D', 'N', 'X'), ('E', 'O', 'Y'), ] symbol_list = ['!', '@', '#', '$', '%'] def getString(): user_string = input("Enter in your string") re...
ed62f625098ef8ddc379da6983c9cf5f507d7b6c
onlykevinpan/Summer-Lecture-for-Teacher-With-Python
/Linkedlist & Tree/LinkedList.py
1,699
3.8125
4
class Node: #一個節點含兩個數值及下一個節點所在位置 def __init__(self): self.coeff = None self.power = None self.next = None class LinkedList: def __init__(self): self.head = None #插入節點時即依照次方做排序 def addNode(self, coeff, power): curr = self.head if curr is None: n =...
329ec125b3b8acd9eb527bbf42b198fc21c33ecf
venkatr21/python_coding
/codeforces1.py
195
3.59375
4
n=int(input()) counter=0 if n>9: n=n-9 counter+=1 while n>=20: n=n-20 counter+=1 if n%2: print(counter) else: print(n//2-1) else: print(n)
4bd7d6a90e3fbae7e711145bf2622621b94c43df
Aluriak/rollin-function
/rollin.py
688
3.5
4
def somme_chiffre(nb:int) -> int: return sum(map(int, str(nb).replace('-', '').replace('.', ''))) def rollin(annee) -> int: """Calcule le nombre de Rollin pour l'année donnée >>> rollin(2005) 3 >>> rollin(1922) 5 >>> rollin(0) 0 """ nb = ((-52 * annee) + (sum(map(int, str(anne...
8e16aebf403570874b7c817c1c79ca1a900cd46e
vale314/Seminario-Algoritmia
/Actividad 9/grafo.py
832
3.703125
4
import pprint grafo = dict() #{} while True: print('1 Crear Conexión') print('2 Mostrar Grafo') print('0 Salir') op = input(': ') if op == '1': origen= input('origen: ').upper() destino = input('Destino: ').upper() peso = int(input('Peso: ')) if origen in grafo: ...
8e062b298f4bb2175a534bd0f69ea4948a78afbf
lxmii/SWE2018
/rle.py
861
3.5625
4
def rle_encoder(txt): """ RLE encoder modetager en streng og returner en streng med så gentagne bogstaver bilver erstattet med bogstavet og antallet af gentagelser "bbbkkk" bliver "b3k3" """ c = txt[0] i = 1 res = [] for x in txt[1:]: if x == c: ...
0538ed593bd1d7b21099d8c27b6d5785aded085e
stunningspectacle/code_practice
/python/python_cookbook/c04_iterator_generator.py
2,501
3.53125
4
#!/usr/bin/python3 from unittest import TestCase, main def do_iter(): items = [1, 2, 3, 4] it = iter(items) print(it) try: while True: a = next(it) print(a) except StopIteration: pass def do_reversed(): class CountDown: def __init__(self, start...
f7539ed431d2efed86248b43bbf319a52c58e5a4
Jeysi2004/GRUPO-5
/PAR O IMPAR 1.py
200
3.859375
4
def verificarNumero(numero): if numero%2==0: print ("El número es par") else: print ("El número es impar") n1=int(input("Ingrese un número: ")) verificarNumero(n1)
4ed86cc5c076a5afc15d7fedf5502a31c1e26fad
vfaldasz/practice
/arrays_and_strings.py
5,145
4.09375
4
def is_unique(string): """1.1 Implement an algorithm to determine if a string has all unique characters.""" unique = [] for char in string: if char in unique: return False else: unique.append(char) return True string = "asdifF" print (is_unique(string)) def is_un...
058bd3191b3b92636e1c30815a101ca226a937b1
zzy1120716/my-nine-chapter
/ch02/related/0141-sqrtx.py
1,715
4.0625
4
""" 141. x的平方根 实现 int sqrt(int x) 函数,计算并返回 x 的平方根。 样例 sqrt(3) = 1 sqrt(4) = 2 sqrt(5) = 2 sqrt(10) = 3 挑战 O(log(x)) """ import math # 二分法 class Solution: """ @param x: An integer @return: The sqrt of x """ def sqrt(self, x): # write your code here start, end = 0, x whi...
e99ebb2b5c9bb51f31070f70f8720ed8186b127a
garytryan/dp2
/knapsack/recursive/problem.py
404
3.90625
4
# Given items with a weight and profit. # Put the items in the knapsack to get the maximum profit. # The knapsack a weight capacity. # You can only take at most 1 of each item. # Example: # Capacity: 3 # Given the following items. # profit: [1, 2, 3] # weight: [2, 1, 2] # The maximum profit is: 5 (using items at index...
caa2faecb9d4cae55544b064c3842176bbdf04fe
Geeky-har/Python-Files
/oop.py
547
4.09375
4
class Student: no_of_keys = 3 # class variable, will shared by all the objects, objects cannot change this pass harsh = Student() # object created aditya = Student() # object created harsh.marks = 89 harsh.thappad = 2 harsh.kisses = 99 aditya.marks = 70 aditya.thappad = 10 aditya.kisses = 6 ...
1a5c97ef69cf56caba71e9653c42eb2013453b3d
sirajmuneer123/anand_python_problems
/2_chapter/reverse.py
188
3.875
4
def reverse(num): length=len(num) i=0 temp=[] while length!=0: temp.append(num[length-1]) length=length-1 return temp f=reverse([1,2,3,4,5,6,7]) print "revere is =%s" %f
9eb7dcc3c3f72492aae0c9fee3bbe0e62fb78d0d
philippegirard/square-weebly-parser
/orderParser.py
4,907
3.578125
4
import pandas import csv from dataclasses import LineOrder df = pandas.read_csv('splitting-11-13.csv') print(list(df.columns)) lineOrderList = [] for index, row in df.iterrows(): # print(row[0], row[1]) orderNum = row['OrderNum'] date = row['Date'] firstName = row['Shipping First Name'] lastName...
3445b472f3db7716fd7c3a20e6dcb8af2542a66e
jonjelinek/euler-python
/problems/4.py
1,818
4.25
4
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. import sys sys.setrecursionlimit(100000) import time largest_pal = { 'pal': 0, 'n1': 0, 'n2': 0...
ed926906171a42e2a7dd009817389b18c77647af
noamRoditi/Logic
/code/propositions/tautology.py
5,043
3.640625
4
""" (c) This file is part of the course Mathematical Logic through Programming by Gonczarowski and Nisan. File name: code/propositions/tautology.py """ from propositions.syntax import * from propositions.proofs import * from propositions.deduction import * from propositions.semantics import * from proposit...
de43611d9e400049a7482e4a0ce0ce84b92a1960
biniama/python-tutorial
/lesson10_classes/student.py
572
4.15625
4
class Student: """Class is like a house blueprint. Then, you can create as many Objects as you want""" def __init__(self, id, first_name, last_name, department, result): """assigning arguments from outside to self i.e. the Student""" self.id = id self.first_name = first_name ...
393e1bbea31f9ae2e3dd805d4785cbcf8ffbdde6
owenhu99/pizza-parlour-api
/src/drink.py
1,755
4.03125
4
from src.food_item import FoodItem class Drink(FoodItem): 'Drinks and their relevant data are defined here' def get_price(self): """Returns the drink price and reads price from data file if price is not initialized""" if self.price is None: return self.data['drink'][self.it...
e7be76a71ffa4d5a7712da7487f4eee57a089f9c
Ramyhemdan2018/100-Days-of-Python
/BMI calculator.py
654
4.25
4
weight = float(input("What is your weight? ")) shbr = float(input("enter your hight with shbr: ")) shbr_to_meter = (shbr * 11.592) /100 print("your hight with metres is: ", shbr_to_meter) height = float(input("What is your hight? ")) bmi = round(weight / height ** 2) if bmi < 18.5: print(f"Your bmi is {bmi...
ce0427c83935136181994cc94dd36a9974604ab2
alannesta/algo4
/src/python/data_structure/stack/150_eval_RPN.py
1,212
3.96875
4
""" 150. Evaluate Reverse Polish Notation https://leetcode.com/problems/evaluate-reverse-polish-notation/ Input: tokens = ["2","1","+","3","*"] Output: 9 Explanation: ((2 + 1) * 3) = 9 Input: tokens = ["4","13","5","/","+"] Output: 6 Explanation: (4 + (13 / 5)) = 6 """ from typing import List import math class Solu...
b0f60a95e1dc12fb08eacccf42b24df7f060555d
vip7265/ProgrammingStudy
/leetcode/sjw_trapping_rain_water.py
1,538
3.9375
4
""" Problem URL: https://leetcode.com/problems/trapping-rain-water/ """ from typing import List class Solution: def trap(self, height: List[int]) -> int: # return self.bruteForce(height) # O(n^2), 2460ms return self.dynamicProgramming(height) # O(n), 60ms def bruteForce(self, height): ...
08178fdac1b3d2e973e9f2ee62834a25287fe202
vkjangid/python
/loop4.py
432
4.03125
4
'''a=input('enter any number') a=int(a) for i in range(1,a+1): b=0 while b<i: print("*",end='') b+=1 print()''' '''a=1 b=input('enter any number') b=int(b) while a<=b: for i in range(a): print("*",end='') print() a+=1''' a=input('enter any number') a=int(a) for ...
b46fee95748992d068ccca081fde99257d1fa29d
xcgoner/gluon-exp
/docs/tutorials/classification/dive_deep_imagenet.py
11,100
3.578125
4
"""5. Train Your Own Model on ImageNet ========================================== ``ImageNet`` is the most well-known dataset for image classification. Since it was published, most of the research that advances the state-of-the-art of image classification was based on this dataset. Although there are a lot of availab...
fd53e562b00bb22268cedc8e6074f2a5cf72bbec
edu-athensoft/stem1401python_student
/py200325_python1/py200501/homework/stem1401_python_homework_11_max.py
134
3.859375
4
""" Homework 11: Print out a matrix by 3x4 """ matrix = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4] ] print(matrix)
a37fbdd53f26fcc7b312c3a776c212b5b4832fe5
Aleksandra1101/k
/create.py
9,837
3.6875
4
import numpy as np import matplotlib.pyplot as plt def f(x_point): x1 = x_point[0] # х координата x2 = x_point[1] # у координата print('x1 ->', x1) print('x2 ->', x2) # функция Розенброка: fx = 100.0 * (x1 ** 2.0 - x2) ** 2.0 + (x1 - 1) ** 2.0 print('f(x) =', fx, '\n') return fx x0 =...
707007dd4a1b8a9a939f2666033bdefa3030fb7b
JonathanKutsch/Python-Schoolwork
/Quizzes/Quiz6/main.py
1,051
3.78125
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: Jonathan Kutsch # Section: 514 # Assignment: Quiz 6 - Plotting # Date: 15 November 20...
ebe79e6a70789e7431270c1c6112995aee8e4d6b
damminhtien/python-concurrent
/21_status_thread.py
1,021
4.1875
4
"""Event instances are similar to a “sticky” flag that allows threads to wait for something to happen. Initially, an event is set to 0. If the event is unset and a thread waits on the event, it will block (i.e., go to sleep) until the event gets set. A thread that sets the event will wake up all of the threads that hap...
5ba833b9ed3f202560cf8a867952e4c0934a3ee5
yoderw/math121
/hw/hw7/remainder.py
281
3.6875
4
def remainder(n, d): if n == 0: return 0 if n < 0: if n + d > 0: return d + n else: return remainder(n + d, d) if n > 0: if n + d < 0: return d - n else: return remainder(n - d, d)
05297c055934945412ad77d5226361dd4978bd64
gen0v/Extruder_Corrector
/extrudorcorrector.py
777
3.6875
4
def main(): print("ExtruderCorrector v0.1") print("Measure 120mm of filament of the edge of your extruder and mark it") print("Let the extruder run for 100mm") print("Now measure the remaining filament of the edge to the mark") old_steps = float(input("Please enter the STEPS/MM of your printer : "))...
a40c323df9a720e12c07a6e0be9c6b9cc0393340
NirvanSinghania/Bomberman-Game
/persons.py
1,234
3.75
4
from game_board import board class Person: def __init__(self, x, y): self.x = x self.y = y self.alive = 1 def clear(self): """ Fill air in place of Person's position""" board.change_grid(self.x, self.y, 0) """ Movement functions for the Person """ def move_ri...
f56da44cc89b1f282d82a3dd09b59ba8d23c79d7
peterept/mazes-for-programmers
/Chapter-01/gridy.py
2,902
3.640625
4
#!/usr/bin/env python3 class GridCell: def __init__(self, grid: "Grid", x: int, y: int): self.grid = grid self.x = x self.y = y self.links = [] @property def n(self): return self.grid[self.x, self.y - 1] @property def s(self): return self.grid[self....
7d09a94fa31919e40a83b9164093d16203b591cf
Bacon911/git-lookup
/po.py
453
4.09375
4
x = input("Введите первое число:") print("Ваше первое число:" + x) y = input("Введите второе число:") print("Ваше второе число:" + y) x = float(x) y = float(y) a = x + y b = x - y c = x * y d = x / y print ("Результат суммы чисел:", a) print ("Результат отнимания чисел:", b) print ("Результат умножения чисел:", c) #te...
8b9546839f48cd3ae52848433a2822baef6f03c7
nikhil-shukla/GitDemo
/pythonProject/List (Ordered collection of Objects)/ListDemo4.py
247
4.15625
4
list1=[12,89,58,66,52,0,3,6,8] print(list1) list1.reverse() #reverse order print(list1) list1.sort() #sorting print(list1) #lists of list myList=[10,9,20,["Nikhil","Python","Selenium"]] print(myList) print(myList[3][::-1]) #access using indexing
9e5e1602bb68f13a461c93a6585e348290abcc34
yilak1/machine_learning_study
/effective_python/study1.py
1,002
3.5
4
''' effective python1 ''' import os from urllib.parse import parse_qs # python3 bytes and str def to_str(bytes_or_str): if isinstance(bytes_or_str, bytes): value = bytes_or_str.decode('utf-8') else: value = bytes_or_str return value #Instance of str def to_bytes(bytes_or_str): if isin...
1daf8888f6f499a0968f4119fb638bc442c7defb
entrekid/BOJ
/bronze/2739/2739.py
84
3.765625
4
num = int(input()) for i in range(9): print(num, "*", i + 1, "=", num *(i + 1))
62885b72bf14633859217d592b35bf703f0ccd1b
hellokayas/Codewars-Solutions
/human_read.py
501
3.546875
4
IN_SECONDS = (('year', 31536000), ('day', 86400), ('hour', 3600), ('minute', 60), ('second', 1)) def format_duration(seconds): if not seconds: return 'now' times = [] words = 0 for name, num in IN_SECONDS: q, seconds = divmod(seconds, num) if q: times....
acdc04bb0e71b9ad27515b7a3029f7f38179285a
thanhluan208/Ex1
/Hello.py
109
3.78125
4
print("Hello world") n = input("what your name") b = input("birthday") # print("Hi", n, end =" ") print (b)
9edf024a83f21bf4e00c8f2287cce12cefac1c38
kashyapa/interview-prep
/revise-daily/epi/revise-daily/6_greedy_algorithms/1_compute_optimum_task_assignment.py
594
3.734375
4
from collections import deque from collections import namedtuple PairedTasks = namedtuple('PairedTasks', ('task_1', 'task_2')) def compute_task_assignment(task_durations: list): durations = deque(sorted(task_durations)) total_time = 0 while durations: total_time = max(total_time, durations.pople...
369847af02af13ded9ba0d768187188f072a44fc
tush922/PythonAssignments
/Assignment4_5.py
827
3.546875
4
from functools import * def chkprime(num): for i in range(2, num//2): if (num % i) == 0: return False; break else: return True; def createlist(): size = int(input("Number of elements:")) nolist = list(); for i in range(size): print("I...