blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fbfc196014d53c3dc2311df8081fc955fe13e671
heysushil/numpy-array-coding
/16.logistic_distribution.py
1,211
3.609375
4
# Logistic Distribution ''' Logistic Distribution using Numpy array with matplotlib and seaborn by hey sushil: 1. ye growth ko show karne ke liye use hota hai. 2. ye bahot jaruri hai because aage chal ke ye ml aur neural networking me use hoga. 3. ye continuous probability distribution hai 4. isme 2 parameters hote h...
660cf9617bcc506742a35754d91a29bdebb4413c
amelialutz9/CSSI
/FirstPython/numberGame.py
538
3.703125
4
from random import randint def game(): counter=1 comp_num=randint(0,10) print comp_num player_num=int(raw_input("What is your guess? ")) while player_num!=comp_num: if (player_num>comp_num): print "Guess lower" else: print "Guess higher" player_num=in...
94175e12f56e9541f80462c1a570bf3926442741
xinyiDou/assignment1
/XinyiDou3b.py
454
3.671875
4
more ='y' count = 1 amount=0 while more=='y': c=input("Enter count of item "+str(count)+": ") p=input("Enter unit cost for item "+str(count)+": ") amount+=(int(c)*float(p)) more = raw_input("More item (y/n)?"+": ") count+=1 tax= input("Enter sales tax rate (%):") print("Total cost (pretax): "+str(a...
64df1ddffa5d1de844c14ef4068ba0ec751d641c
JuliaChae/ESC180
/lab3/argtest.py
2,027
4.21875
4
# It is best to name your arguments rather than relying on position; # this enables a user to use your program without memorizing # argument order. This is a standard industrial practice. # Below, you see that there are two named arguments that each take # an additional parameter: # --fin <ADDITIONAL-PARAM> --fout <ADD...
189e6fd7362a34f69648223edf1ba8f3df152094
levleonhardt/guias_Programacion1
/prog1/guia3/ej6_3.py
604
3.859375
4
#Ingresar nombres en una lista, luego buscar un nombre y de encontrarlo decir en qué posición está. lista_nombres = [] nombre = input("\nIngresar nombre (0 para finalizar): ") while (nombre != "0"): lista_nombres.append(nombre) nombre = input("\nIngresar nombre (0 para finalizar): ") print("\n ---...
8e98501d5fa19d6b3779bf6905747d8517380f16
sravanneeli/Data-structures-Algorithms
/Sorting_Algorithms/insertion_sort.py
539
4.34375
4
""" Insertion Sort: Worst Time Complexity : O(n^2) Best Time Complexity : O(n) Average Time Complexity : O(n^2) """ def insertion_sort(a): arr = a n = len(arr) for i in range(1, n): x = arr[i] j = i - 1 while j > -1 and arr[j][1] < x[1]: arr[j + 1] ...
f7969b0f3d78a3d6eb321b5c7943db907e60dfc3
aayush-srivastava/LeetCode-Problems
/21. Merge Two Srted Arrays.py
542
3.5625
4
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: l3 = ListNode prev = l3 while l1 != None and l2 != None: if l1.val <= l2.val: prev.next = l1 l1 = l1.next elif l1.val >= l2.val: prev.next = ...
d9209a8d9012dabf938c9b342c2c88a70c51e701
jmlassen/cs450
/NeuralNetwork/neural_network.py
8,882
3.609375
4
import matplotlib.pyplot as plt from sklearn.metrics import accuracy_score from NeuralNetwork.neuron import Neuron from NeuralNetwork.utilities import * DEFAULT_LEARNING_RATE = 0.1 DEFAULT_VALIDATION_PERCENTAGE = 0.2 DEFAULT_EPOCHS = 500 class NeuralNetwork: """Object to hold a neural network. """ def...
55bbf28d14a40cb72e3ef17112a633153c5505c6
rahulp0/pythonIndustrialTrain
/guessTheNum.py
444
3.8125
4
import sys import random print("Guess the number MC") #upp=int(input("Enter poss upp bnd")) #r=random.randint(1,upp) #guess=input("Guess?") corrr=[] guesses=[] for k in range (1,10): corrr.append(random.randint(1,10)) guess=int(input("Guess: ")) guesses.append(guess) if guess==corrr[-1]: print("Congrats! u got i...
a2455c9f09a9294f84e1b117f55fc13c83af43b2
Keyon19/lab-08-for-loops
/party.py
213
4.03125
4
userinput = input("Let's party! How long till the party? (Give me a number.)") if (userinput, 1): print("Party Now!!!") else: for i in range(userinput, 1, 1): print(i) print("Party Time!")
2a77d329bc68459c890db55de6f563f444b4d443
iurii-milovanov/pymlclass
/machine-learning-ex2/costFunctionReg.py
725
3.515625
4
# COSTFUNCTIONREG Compute cost and gradient for logistic regression with regularization # J = COSTFUNCTIONREG(theta, X, y, lambda) computes the cost of using # theta as the parameter for regularized logistic regression and the # gradient of the cost w.r.t. to the parameters. import numpy as np from sigmoid i...
139b50438df9356c06323e43615220b2bf1f82e8
IkramMOPHS/Y11Python
/whileloopchallenges01.py
173
4.0625
4
#Ikram Munye #whileloopchallenges01 total = 0 while total <= 50: num = int(input("Please enter a number: ")) total = total + num print("The total is now" ,total)
26dc03c7dc821580a4bb8cdc33d92ff6171f4a57
sina1680/python
/modules/level.py
3,968
3.703125
4
"""This module contains map and relative locations of items for a room /level""" from modules.bag import Bag def highest_display_priority(contents): """Given a list of locatables this function will return the one with the highest priority""" max_priority = None for locatable in contents: if max...
91254c6936c8dd44a3fbca7804c0a5025912e54e
jhn--/sample-python-scripts
/python3/thinkcs-python3/7.26.4-words_length_5.py
286
4.1875
4
''' Count how many words in a list have length 5. ''' listofwords = ["happy", "win", "lose", "rojak", "lovely"] def words_length_5(listofwords): total = 0 for i in listofwords: if len(i) == 5: total += 1 return total print(words_length_5(listofwords))
ef444d35893522ed48778a0f2fc4363e231025e7
d0xa/Pong-Game
/Ball.py
678
3.921875
4
class Ball: def __init__(): ballPosition = []; #Figure out ball position for X,Y ballSize = 2; ballXSpeed = 1.0; ballYSpeed = 1.0; def __init__(size,xSpeed,ySpeed): ballPosition = [] ballSize = size; ballXSpeed = type(float)xSpeed; ballYSpeed = type(float)ySpeed; def __init__(size): ballPosition =...
3c0316b149ce9842150eef661fee1f596b3d180c
suacalis/VeriBilimiPython
/Ornek11_2.py
345
3.578125
4
''' Örnek 11.2: Temel matematiksel küme işlemlerini (birleşim, kesişim, fark ve simetrik fark) gerçekleştiren programı kodlayınız. ''' # Küme elemanları A = {0, 2, 4, 6, 8} B = {1, 2, 3, 4, 5} # Birleşim print("A u B=", A | B) # Kesişim print("A ∩ B=", A & B) #Fark print("A \ B=", A - B) # Simetrik fark print("A ∆ B=",...
da2fd30f420e755cf33563030e79dce79f3e8baf
OleKabigon/test1
/for loop example.py
157
4.25
4
# This is an example of the for loops. total = 0 for price in [15, 10, 13]: total += price # += is the same as total + price in this case print(total)
bccc8a0aa3e8241153ece1116f3431867ab64302
google/or-tools
/examples/python/cover_rectangle_sat.py
4,354
3.515625
4
#!/usr/bin/env python3 # Copyright 2010-2022 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law ...
1199077138e4dc07c2e7814993fd5d50c6c57e1e
Quidge/cs50
/pset6/crack/crack2copyofcrack.py
1,620
3.625
4
from sys import argv from crypt import crypt if len(argv) != 2: print("Usage: python crack.py [HASH]") hashval = argv[1] chset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" setrange = 52 attempt = " " # 5 whitespace chars c1 = 0 c2 = 0 c3 = 0 c4 = 0 c5 = 0 ''' The dance here isn't intuitive. Th...
78212c809819932478d2f1ef8a05f1e456857498
arnawldo/primes
/src/prime_generator.py
1,215
3.96875
4
def prime_numbers(n): """ Given integer, generates prime numbers from 0 to stopping number :param n: stopping number :type n: int :return: list of prime numbers up to n :rtype: list """ # return if input is negative if n < 0: return None primes = [] for i in range(...
93da2919d8b20df6162568712a6eb789948d419c
LiuY-ang/leetCode-Medium
/search.py
797
3.578125
4
class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ if len(nums)==0: return -1 if target>=nums[0]: i=0 while i+1<len(nums) and nums[i]<nums[i+1]: ...
fb94008b187f52ec249e92030202e3ef91639778
riterdba/magicbox
/3.py
515
4.15625
4
#!/usr/bin/python3 # Простейшие арифметические операции. def arithmetic(x,y,z): if z=='+': return x+y elif z=='-': return x-y elif z=='*': return x*y elif z=='/': return x/y else: return print('Неизвестная операция') arif=arithmetic a=int(input('Введите перво...
0a2d07c907fa9ff55af9069e8c2aaa318e5808e2
MitchDziak/crash_course.py
/python_work/chapter_four/buffet.py
248
3.875
4
foods = ('chicken', 'pizza', 'burger', 'gunk', 'roach') print("Original menu:") for food in foods: print(food) foods = ('chicken', 'pizza', 'burger', 'fries', 'salad') print("\nRevised menu:") for food in foods: print(food)
950f7400e99e83bc8821fb4ffb9925aabd81c213
mustafaergan/Python101
/HellWorld/Example5Loops/__init__.py
822
4.21875
4
#LOOPS # while print("** while") count = 0 while (count < 10): print("*****") count = count +1 print(count, " Count") print("** while-else") while count < 5: print(count, " is less than 5") count = count + 1 else: print(count, " is not less than ...
14756311359435ad7e8184f4eca4f55ce026f534
wjma98/project-euler
/factorial_digit_sum.py
409
3.96875
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 5 00:27:39 2021 @author: William """ def get_digits(n): digits = [] while n >= 10: digits.append(n%10) n = n // 10 digits.append(n) reverse_list = digits[::-1] return reverse_list def factorial(n): if n==1: return n ...
9d204dce33c9ef15febfbf61877023d22941f9fb
ssshhh0402/Ssafy_Algorithms
/정리/알고리즘/0828_PriorityQue.py
367
3.71875
4
# from queue import PriorityQueue # # # arr = [(3, 4), (3, 5), (8, 9), (1, 4), (2, 6),(3,7)] # PQ = PriorityQueue() # # # for val in arr: # PQ.put(val) # # # while not PQ.empty(): # print(PQ.get()) from heapq import heappush, heappop Q = [] arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0] for val in arr: heappush(Q,...
cf79bd6d149555da916794b422760745e26d9472
lukemenzies/miscellaneous
/S3FileRenamer_edit.py
3,197
3.96875
4
#!/usr/bin/env python3 """Find and remove characters from directories and files that pose difficulty in Amazon S3. See https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html for a list of characters. This will generate a double pipe-delimited file for review. Default behavior is to only generat...
52f3fc195278c1e22774f89915d8fca40c51868f
N-biswas000/python-projects
/task.py
883
4.125
4
# # Sorting a numeric list---> # l=[13,1,25,40,130,135,55,57,90] # def bubble_sort(x): # for i in range(len(l)): # for j in range(len(l)-1-i): # if l[j] > l[j+1]: # l[j],l[j+1]=l[j+1],l[j] # return x # print(bubble_sort(l)) # remove the last object from a list in python----...
079e0c5d5255a8d64fb7a7d4b3cc06e08e430feb
brandonrobson/Learning
/Python/testingmatplot.py
356
3.9375
4
import matplotlib.pyplot as plt def ball_trajectory(x): location = 10*x - 5*(x**2) return(location) xs = [x/100 for x in list(range(201))] ys = [ball_trajectory(x) for x in xs] plt.plot(xs,ys) plt.title('The Trajectory of a Thrown Ball') plt.xlabel('Horizontal Position of Ball') plt.ylabel('Vertical Position of Bal...
d09fb7580c3ccb5c3b6618f90d0e4b959a2e7d43
yujinHan97/Algorithm_Study
/핸드폰 번호 가리기.py
465
3.53125
4
''' 알고리즘: 1. phone_number의 길이에 대하여, 앞에는 모두 *로 출력 2. 뒤의 4글자는 그대로 출력 ''' def solution(phone_number): answer = '' for i in range(len(phone_number)): if i < len(phone_number) - 4: answer += '*' else: answer += phone_number[i] return answer ...
7668d1c824748ddb578d6d640e61ee5923cba255
GiliScharf/my_first_programs
/from_file_to_tuple.py
977
3.984375
4
def takefirst(elem): return elem[0] #this function gets a nested list and returns a nested tuple def list_to_tuples(MY_LIST): for i in range(len(MY_LIST)): MY_LIST[i]=tuple(MY_LIST[i]) my_tuple=tuple(MY_LIST) return(my_tuple) #this function gets a name of a file whith students' name and grades a...
ca2e7ca918b5059cdaf406185ed7f1dd937c274b
AANICK007/STEPPING_IN_PYTHON_WORLD
/programme_10.py
511
4.09375
4
# This is a programme to study identity operators in python # Identity operators are used to compare that are two variables pointing to a same memory location or not x = 5 ; y = 5 ; print ( id ( x ) ) ; print ( id ( y ) ) ; print ( x is y ) ; print ( x is not y ) ; y = 6 ; print ( id ( x ) ) ; print ( id ( y ) ) ...
2632bc708d4edb9746877bf112e829662df8ccfa
cljuiza/curso-Python
/dia2.py
2,680
4.03125
4
# base=input("Ingrese la base en cm del rectángulo: ") # altura=input("Ingrese la altura en cm del rectángulo :") # area=int(base)*int(altura) # print("El área del rectángulo es " + str(area) +" cm^2") # def saludar(): # print("Estamos dentro de la funcion ") # print("segunto print") # print("tercer print") # ...
ded0535d70ae0b5eb11ad98e23510d735f1691c2
huangeyou007/SampleCodeRecommend
/project/FuncVerbClassifier.py
964
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ ----------------------------------------- @Author: Lv Gang @Email: 1547554745@qq.com @Created: 2021/04/15 ------------------------------------------ @Modify: 2021/04/15 ------------------------------------------ @Description: """ from funcverbnet.sentence_classifier imp...
7b9baedd8329c1b69f4d75d1fea7d9959848f279
Zixi-L/Python-Assignments-
/HW(G).py
1,910
3.734375
4
import csv from collections import defaultdict largestPopulation = 0 state_largestPopulation = '' with open ('States.txt') as file: text = csv.reader(file, delimiter = ' ') states = defaultdict(dict) for line in text: state, region, population = line states[region][state] = int(popu...
1ed684b347c64efa77608a32afa468087be35576
jack-fjh/RF_project
/read_csv.py
513
3.65625
4
import csv #读取csv文件 def csv_read(): with open('./data/data.csv') as f: reader=csv.reader(f,delimiter=';') for line in reader: print(line) #写入文件 def write_csv(): with open('./data/write_csv_res.csv','w',newline='') as f: write_res=csv.writer(f) #写入多行 write_res...
2c239578ac74283b07cffb764af47ef112ee28e9
jenntang1/holbertonschool-higher_level_programming
/0x06-python-classes/102-square.py
2,227
4.46875
4
#!/usr/bin/python3 """ 9. Compare 2 squares """ class Square(object): """ Creating a class called Square that defines a square. """ def __init__(self, size=0): """ Using the __init__ method. Args: size: private instance attribute for the class """ self.size = size ...
b9d76f239a4fc2912792dabf6d7331bee03b9a2e
Alishirinova/python_lesson
/lesson12_2.py
1,153
3.671875
4
import random import string def generate_string(min_limit=20, max_limit=500): len_str = random.randint(min_limit, max_limit) res_str = ''.join([random.choice(string.ascii_lowercase) for _ in range(len_str)]) return res_str def insert_spaces(some_str): go_jump = True total_index = 0 some_list...
4a1aea0f9db7d8d696899a008f24cd63a321d706
Vaisakhj/PROTHON-01
/Text formatter.py
430
4.0625
4
if __name__ == '__main__': print("Enter the sentence:") Text = input() print("1.All Caps\n 2.Smallcaps\n 3.Title case\n 4.Start Case\n") print("Enter the option:") n = int(input()) if n==1: print(Text.upper()) elif n==2: print(Text.lower()) elif n==3: p...
678537541ea3ad0d2645b874a2f6bf7343d7a1dd
macluiggy/Python-Crash-Course-2nd-edition-Chapter-1-11-solutions
/CHAPTER 7/EXAMPLES EXERCICES/cities.py
248
3.6875
4
prompt = "\nPor favor ingrese el nombre de una ciudad que haya visitado:" prompt += "\n(Ingrese 'quit' cuando haya acabado)" while True: city = input(prompt) if city == 'quit': break else: print(f"Me gustaria ir a la ciudad {city.title()}")
17ada564d351c8e19ed7dec265df04473b3bd021
Aasthaengg/IBMdataset
/Python_codes/p03042/s812942440.py
191
3.671875
4
s = input() x = int(s[:2]) y = int(s[2:]) if 1 <= x <= 12 and 1 <= y <= 12: a = "AMBIGUOUS" elif 1 <= x <= 12: a = "MMYY" elif 1 <= y <= 12: a = "YYMM" else: a = "NA" print(a)
6730f8f494a65d06ebd8831d86c307f4c60f9f35
korshunovdv/DFS
/dfs.py
1,119
3.5625
4
def dfs(graph, visited, entrypoint, color): stack = [] stack.append(entrypoint) while stack: vertex = stack.pop() if not visited[vertex]: visited[vertex] = color for next_vertex in graph[vertex]: if not visited[next_vertex]: stack.a...
35b185eb8b57a3c52d31b767378f859556921f65
prgu6170/useful_code_snippets
/reverse_linked_list.py
363
3.9375
4
def reverseList(self, head: ListNode) -> ListNode: prev_node = None curr_node = head if head == None: return None next_node = head.next while next_node: curr_node.next = prev_node prev_node = curr_node curr_node = next_node next_node = curr_node.next curr_...
c8352f33bb3c7f22903e55ca52f83fb36f715d2c
ayr-souza/deposito
/slide3/q02.py
174
3.71875
4
try: v = float(input("Forneça um valor em reais (R$): ")) print("70%c de R$ %.2f é R$ %.2f." % ("%", v, v * 0.7)) except: print("Você não forneceu um valor real.")
f58930f828763cc79e4949320f65c29bc21ea4a7
Arthwin/NeuralNetwork
/2.NeuralNet/_2.NeuralNet.py
2,176
3.875
4
from numpy import exp, array, random, dot class NeuralNetwork(): def __init__(self): #seed the random number generator so it generates the same numbers everytime random.seed(1) #we model a single neuron with 3 input connections and 1 output connection #we assign random wights to a 3...
bc3014e33e8724c57734eae95ad4e25fe68fb832
dnssdet/daily-interview-pro
/014_Number_of_Ways_to_Climb_Stairs/solution.py
251
3.703125
4
cache = [0] * 100 cache[0] = 1 cache[1] = 1 def staircase(n): if n <= 1: return cache[n] else: cache[n] = staircase(n-1) + staircase(n-2) return cache[n] # 1 1 2 3 5 8 print staircase(4) # 5 print staircase(5) # 8
fc80d50637ae17d9a8c21a8c2b61a21b1cc32c7b
rahulbansal16/geeksforgeekspython
/p6.py
517
3.765625
4
# https://www.geeksforgeeks.org/kth-largest-element-in-a-stream/ # Finding the kth largest element in the stream of numbers def getKthLargestFromTheInfiniteStreamOFNumbers(number): if number < heap[0]: return heap[0] if len(heap) == k: heapq.heappop(heap) heapq.heappush(heap, number) ...
ab95a7f46cd16de093ecda606168cc54a3614efd
zopepy/leetcode
/monotonic.py
527
3.78125
4
class Solution: def isMonotonic(self, a): """ :type A: List[int] :rtype: bool """ tpe = None l = len(a) for i in range(1, l): if a[i-1] < a[i]: if not tpe: tpe = "increasing" elif tpe != "increasing": return F...
59431afe5104f5f28bac74292cf3288994ed09d3
satishkumard/Python
/Code/sumrange.py
1,208
4.4375
4
# ---------------------------------------------------------------------------------------------------------------------- # Name: Satish Dandayudhapani # Class: 603-02 Found. Software Dev-Python # File: rangefun2.py # [H2-3] (sumrange.py) Write a program that reads integers start and stop from the user, then calcu...
44d273386e3f37bcf231ff46304082fce385b1a5
savatabachhav/mca-sem2-practicals
/python/18_June_2021/Sum_of_List_Numbers.py
305
3.703125
4
""" Name.: Bachhav Savata B. Class.: MCA-I Roll No.: 03 Subject: Python Programming Program: WAP to calculate sum of all number in list """ total = 0 list1 = [20, 15, 10, 21, 9, 8.11] for ele in range(0, len(list1)): total = total + list1[ele] print("Sum of all elements in given list: ", total)
af9791cf7b9ec883b6bfda82d17ce3e34f9d5d8d
JudeJang7/CSE_231
/CSE_231/Project/Project 2/proj02.py
4,750
4.34375
4
########################################################### # CSE 231 Programming Project 02 # Change-Making Program # # Print stock of coins # Prompt user for purchase price # Prompt user for payment # Calculate change # Pay user in quarters, dimes, nickels, pennies # ######################################...
060a44305e62af31412c7779354fdbae588c7fe9
anu-cybercrime-observatory/spear-phishing-framework
/participant.py
669
3.59375
4
""" A little construct that holds all the data relating to a participant in this experiment. """ class Participant: def __init__(self): self.uid = "" self.anon_id = 0 self.first_name = "" self.full_name = "" self.template = "" def to_string(self): return ...
bf9e8f9219ff03b4a4bb4df49b9bbdcfd9408b8d
bjack205/ME320
/HW2/cs223a/dh.py
2,818
4.03125
4
#!/usr/bin/env python """ dh.py Authors: Toki Migimatsu Lin Shao Elena Galbally Herrero Created: December 2017 """ import numpy as np def rot_x(theta): """ Returns a matrix that rotates vectors by theta radians about the x axis. Args: theta (float): angle to rotate by in radian...
9c14f8111bfe0b8fe26d02d583bd967e36901898
123456thomas/python_learn
/pythonsup/py04.py
911
3.796875
4
# 4,windows下使用跨平台模块 multiprocessing # 编写多进程应用程序 # 结合getpid getppid()方法编码验证父子进程id from multiprocessing import Process import os def Fun2(j): print("pid21 %s,pid12 %s" % (os.getpid(), os.getppid())) print(j) def Fun1(i,num): print("pid12 %s,pid1 %s"%(os.getpid(),os.getppid())) num+=2 print(i,"num %s...
459d45cf76e5c70be2eaad136e91a4c262448fb9
JB0925/Bites
/Bite_286.py
931
3.75
4
from typing import Dict from string import ascii_letters, digits def decompress(string: str, table: Dict[str, str]) -> str: if string == '' or table == {}: return string chars = ascii_letters + ' ' + digits string = list(string) i = 0 while i != len(string): try: if t...
dc7f10ac667dcc78454abc9b3c3328d6d9b91553
miotomato/Coursera_Genomic_Data_Science_Specialization
/Genomic_Algorithms/Algorithm1_Naive_Exact.py
3,531
3.90625
4
#!/usr/bin/env python """ File: Algorithm1_naive_exact.py Author: Shengyuan Wang Date: Mar 30, 2020 Description: Coursera_Genomic_Algorithm_quiz1 """ import matplotlib.pyplot as plt def naive(p, t): occurrences = [] for i in range(len(t) - len(p) + 1): # loop over alignments...
4355f043cd9a9040683931b5653990e2d30bf0ca
akash9182/Project-Euler-Python-challenge
/Euler/prob_3.py
824
3.703125
4
def prime(n): l = [] for i in xrange(n): if (n % (i+1) == 0): l.append(i+1) trial = n/(i+1) if (len(l) > 5): break # if (type(trial) == int): # n = n / (i+1) # print l return l # def largest_prime(l): # L = [] # for i in xrange(len(l)): # if (len(prime(l[i])) == 2 ): # L.append(l[i])...
8f835e7f4a983554d4c75758eecc1e4a34c47826
YuanZheCSYZ/algorithm
/math/29 Divide Two Integers.py
1,755
3.59375
4
# https://leetcode.com/problems/divide-two-integers/ class Solution: """ Runtime: 28 ms, faster than 92.31% of Python3 online submissions for Divide Two Integers. Memory Usage: 14.2 MB, less than 57.12% of Python3 online submissions for Divide Two Integers. """ def divide(self, dividend: int, divis...
04db3d0975f0e1ccd2383cc3b03c5e1c2e101853
ztalloC/ProjectEuler
/proj_euler/problems/p98.py
3,226
3.5
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 20 07:23:56 2015 @author: mjcosta """ import optparse import itertools from collections import defaultdict from proj_euler.utils.timing import timefunc # Given a comma separated string of quoted words, returns a list of words def parse_word_input(s): return [x.st...
853ba66f47fdb0b624abc7a5e8102d63f9e03c8c
Rafaelbarr/100DaysOfCodeChallenge
/day033/001_password_generator.py
2,736
3.96875
4
# -*- coding: utf-8 -*- # Importing libraries from __future__ import print_function import random def generate_new_pass(new_password, password_list, password_reference, pass_index): password_reference.append(str(raw_input('What\'s your password reference?: '))) pass_length = int(raw_input('Choose the ch...
c1fc63e6fc396c044df3dad50dbe5cace4232463
mickyaero/CFD
/laplace.py
1,898
3.703125
4
from __future__ import print_function #grid size = (m+1, m+1) print("Enter the size of the grid") size = input() #it has to be greater than or equal to 2 grid_pts = [[0 for x in range(size)] for y in range(size)] """ The boundary conditions are the temperature at the upper surface = t1, lower surface = t2, at the ri...
cb56a3fe8b8862a6f5e016add0bfd4a43e2ca5f8
TTopoo/Introduction-to-Data-Science
/数据科学课本资料/例题源程序-学生/2-1.py
758
4.375
4
#例2-1 创建一维数组分别保存学生姓名和考试科目,访问数组元素。 #导入numpy import numpy as np #创建一维数据 names = np.array(['王微', '肖良英', '方绮雯', '刘旭阳','钱易铭']) print(names) subjects = np.array(['Math', 'English', 'Python', 'Chinese','Art', 'Database', 'Physics']) print(subjects) #1. 查看数组的属性 print(names.ndim) #数组维度 print(names.size) #数组元素个数 print(nam...
13b137030b8cd8083e1f15df36751b89fb03d449
c-mac/ctci
/arr-str/__init__.py
659
3.6875
4
from collections import defaultdict def all_unique_dict(s): d = defaultdict(int) for c in s: if d[c] == 1: return False d[c] += 1 return True def all_unique(s): for i, c in enumerate(s): for j in range(i + 1, len(s)): r = s[j] if c == r: ...
f8b9cfde248370d6053edb497f05d3e2e7b1c54e
Sem8/js-mock-interview-code-challenges
/Lambda_CS_TL_algorithms/merge_sort.py
3,830
3.734375
4
# Merge sort: Divide up the array in halves and keep dividing till each element in the array is a single element. Then merge each # element in a sorted fashion. '''Pseudocode: 1. Make a merge helper function which takes in 2 arrays (leftArr and rightArr) as inputs. 2. Have pointer indexes for each of the two arrays i...
0af4420a5ca970669786dc1a7a9a0c62cd5f76a7
commoncode/menus
/menus/fakers.py
1,008
3.703125
4
from random import sample WORDS = ( 'admirable', 'alluring', 'appealing', 'attractive', 'beauteous', 'charming', 'classy', 'cosmetic', 'cute', 'dazzling', 'delightful', 'divine', 'elegant', 'enticing', 'excellent', 'exquisite', 'eyebrows', 'eyes',...
6fc07f1ca5c9c04508d74a1031e42e6b01f75b11
klepple/learningPython
/soft_assign.py
2,267
4.28125
4
#This program contains a list, for and while loops, and functions #I will be creating a list of cats and playing around with it my_cats = ["Nina", "Bozo", "Midnight"] #A list of cats size = len(my_cats) #Original size of my list of cats print "Hello! I'd like you to meet my cats:" def print_cats(): #Function that pr...
1797157389867e963e0234984671ebd693f3ff18
nolleh/leetcode
/leetcode75/level1/70.climbing-stairs.py
933
3.625
4
class Solution: nums = [] def climbStairs(self, n: int) -> int: if len(self.nums) == 0: self.nums = [0] * n # 1 or 2 step # 1. former answer plus 1 to as prefix, postfix # 1, 2, 3, 5, 8 # n = 4 # plus 1 to former. # 1 + 1 + 1 + 1 # 1...
4ecbe8460df418b3bfe391e095985569597d0196
chicory-gyj/JustDoDo
/pre_test/enumerate.py
237
3.96875
4
#!/usr/bin/python g=['chicory','fabius','pagge'] t=enumerate(g) #print list(t) for index,string in list(t): if 'chicory' in string: print t print list(t) g[index]='[gyj]' print g print list(t)
e02d283cb3cdba354cdeeb6373480836ddce81d1
hillarychristines/71180386_GRUP__A
/Contact_Name.py
2,103
3.984375
4
tuple_kontak = ( "Hillary Christine", "Asri Meliana", "Annabela Ciaobella", "Syahrini Maharaini" ) while True : print(" ********** Menu Pilihan ********** ") print("1. Tambah Kontak") print("2. Hapus Kontak") print("3. Update Kontak") print("4. Tampil Kontak") print...
87ba2f0ce15e42daf15768b3fdf23d9be1059814
kchonka/battleship
/main.py
22,337
3.875
4
# Kat Chonka & Denysse Cunza # Main Battleship game file # This file contains the UI display code along with the game logic. import pygame import math from board import Board, Cell from player import Player from AI import AI pygame.init() # Color definition: BLUE = (45, 145, 233) LIGHT_BLUE = (153, 153, 255) BLACK =...
f6c0125018106482debada3362e0072e4ad4f6c5
JakeBroughton/morsedream
/TextToLights.py
1,484
3.859375
4
# Turn text input to morse code light flash on Raspberry Pi import RPi.GPIO as GPIO from time import sleep from morse_functions import * # Sets up LEDs GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) GPIO.setup(17, GPIO.OUT) # Takes in morse character list and required times for characters def LEDs(character_list, ...
ae10370f03eabcd38d29e65c7f65b8a3753cc02c
mdemiral19/Python-By-Example
/Challenge 030.py
95
3.640625
4
'''Challenge 030: Display pi to five decimal places.''' import math print(round((math.pi),5))
e18dbf9dc58eb942753b92d4413513da72493192
brandoneng000/LeetCode
/medium/934.py
2,116
3.65625
4
from typing import List import collections class Solution: def shortestBridge(self, grid: List[List[int]]) -> int: directions = [(1, 0), (0, 1), (-1, 0), (0, -1)] n = len(grid) first_island = set() next_to_water = set() cur_grid = [[float('inf') if grid[i][j] == 0 else -1 for...
970f44e60cbd65c78a692d9bac59326a8cb0c93f
leandawnleandawn/python-exercises
/Chapter 4/exercise-repetition.py
2,106
4.5625
5
# The following is a series of exercises using TurtleWorld. They are meant to be fun, but # they have a point, too. While you are working on them, think about what the point is. # The following sections have solutions to the exercises, so don’t look until you have # finished (or at least tried). # 1. Write a function c...
9aabcbeeb9ed62f73a710d237c7a8c58c088e16b
sebastianbaltser/explore_regex
/test_explore_regex.py
582
3.53125
4
from explore_regex import ExploreRegex import pandas as pd import re #Function to see an output from the explore_pattern method def test_explore_pattern(): # download data path2data = 'https://raw.githubusercontent.com/snorreralund/scraping_seminar/master/english_review_sample.csv' df = pd.read_csv(path2d...
3215504f950c668d65aa588b5d8a581245f7a55c
Garrison-Shoemake/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-write_file.py
400
4.15625
4
#!/usr/bin/python3 """ This function writes a string to a text file, returns character count """ def write_file(filename="", text=""): """ this function calls with and print with a counter variable return the counter variable, function should creat the file if it doesnt exist and overwrites the content if...
053ae7045c7155f95472d73d698b5435d55b776e
aself101/ANN
/ANN Python/matrixMath.py
2,516
4
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 07 18:05:33 2015 @author: Alex Primary matrix math class. Performs math based matrix operations """ import numpy as np class MatrixMath(): # add: Adds two matrixes and produces a third matrix def add(self, matrix_a, matrix_b): # Will hold new matrix...
b18ac2056bfcce9b7971fab66539c31cebecbcbd
ravi089/Algorithms-In-Python
/Array/k_largest_smallest.py
234
3.84375
4
# k-largest/k-smallest element in an array. def k_largest_smallest(arr,k,large): return sorted(arr, reverse=large)[:k] if __name__ == '__main__': arr = [1, 23, 12, 9, 30, 2, 50] print (k_largest_smallest(arr, 2, False))
e26d87d2e5334aa66aa27051308930c51b0b3087
camilapulido/course-material
/exercices/328/solution.py
227
3.734375
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 26 13:15:15 2014 @author: Camila """ def mul(a): import sys o = 1 for i in range (len(a)): if i < len(a): b = o* a[i] o = b print (b)
420d763299f846e159fbec349671f94846adb2b8
jjashinsky/CS241
/checks/check06a.py
1,476
4.0625
4
class Book: def __init__(self): self.title = "" self.author = "" self.publication_year = 0 def prompt_book_info(self): self.title = input("Title: ") self.author = input("Author: ") self.publication_year = input("Publication Year: ") def disp...
8ae394e9f3fd98be2a23b2ac45a08cd1a3436984
BigBossCam/WikipediaSpeedRunDiscordBot
/bot.py
4,103
3.515625
4
import discord, wikipedia, random, os from discord.ext import commands from discord.utils import get DISCORD_TOKEN = os.environ.get('DISCORD_TOKEN') # set prefix to '.' bot = commands.Bot(command_prefix=".") # make sure discord.py is initialized @bot.event async def on_ready(): print("bot ready")...
0ec2880c2f40ef7a85c7aac1100393f343b986de
fabionunesdeparis/Fundamentos-em-python3
/exer104.py
383
3.796875
4
# @Fábio C Nunes - 25.06.20 def leiaInt(txt=''): continua = False while continua == False: print(txt, end='') a = (input()) if not a.isnumeric(): print('\033[31mErro! Digite um número inteiro! \033[m') else: continua = True return a #Main n = leiaInt...
14d06d117da39530972599021543e2e71122dd36
CoderGals/nlp_gals
/BuildVocabularyWordTokenization/1splitIntoTokens2.py
2,142
3.859375
4
import numpy as np import pandas as pd sentence1 = """Albiona Hoti filloi punen si software engineer ne moshen 22.""" token_sequence = str.split(sentence1) # 1 str.split() is a quick-and-dirty tokenizer vocab = sorted(set(token_sequence)) # 2 Your vacabulary lists all the unique tokens (words) that you wa...
df8a2c1a9530e0d81108f6f0116be7d8531fa873
ArnabBasak/PythonRepository
/practice2.py
143
3.984375
4
A = [1,4,-1,3,2] print("The length of the list is",len(A)) for elements in range(len(A)): print(elements,end = ' ') print(A[elements])
b18dfe12b90f425bd0d0035426f626097735b16d
jfernand196/Ejercicios-Python
/area_circulo.py
204
3.921875
4
# Solicitar el valor del radio de un circulo para clacular el area from math import pi r = float(input('escriba el radio del circulo: ')) area = pi*r**2 print('El area del circulo es {}'.format(area))
0700cd1e7c1aff391f1cd80487e1d9395c22e84d
AdamZhouSE/pythonHomework
/Code/CodeRecords/2215/60767/237512.py
182
3.78125
4
arr = input().split(",") result = ''.join(arr[0]) result = result+"/(" for i in range(1,len(arr)-1): result = result+arr[i]+"/" result = result+arr[len(arr)-1]+")" print(result)
f7c2ef1d77bc0979c54fd08194693f92aee0d271
breman27/Ngrams
/text_gen.py
9,642
4.34375
4
"""This program generates random text based on n-grams calculated from sample text. Author: Nathan Sprague and Brett Long Date: 1/20/16 """ import random import string def text_to_list(file_name): """ Converts the provided plain-text file to a list of words. All punctuation will be removed, and all words wi...
3a1eb15ba73e2e917c09bab831e3a959b32e3a31
aniketshelke123/hello-world.io
/type_of_using_function.py
416
3.609375
4
from ast import literal_eval def type_of(itr): for ele in itr: print(type(ele)) lst = ["aniket", 25.55, "vikas", False, 200] tp = (100, True, "sagar", "abhi", 61.26) print("list: ", lst) print("tuple: ", tp) for _ in range(2): lst.append(literal_eval(input("enter elements to enter in a li...
a2e7e21abc804aa0efaf3e54041574093b0c1bc1
digant0705/Algorithm
/LeetCode/Python/263 Ugly Number.py
2,289
4.375
4
# -*- coding: utf-8 -*- ''' Ugly Number =========== Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7. Note that 1 is typically treate...
f87dfa89c364a019f3852def49a1f686f12cef94
rizquadnan/codeForces
/12_wordCapitalization.py
99
3.84375
4
word = list(str(input())) word[0] = word[0].upper() capitalized = ''.join(word) print(capitalized)
23d8fec51a07b9b5a7b5a31bac87392f69b58228
AishwaryaSolanki/Practising-Python
/formattingStringsInPython.py
344
4.28125
4
first_name = input('Enter first name: ') last_name = input('Enter last name: ') output = 'Hello, ' + first_name + ' ' + last_name print(output) output = 'Hello, {} {}'.format(first_name, last_name) print(output) output = 'Hello, {0} {1}'.format(first_name, last_name) print(output) output = f'Hello, {first_name} {la...
c78813229547ef8792eb864a50571385a7fa897f
ishangurung1/python-
/marks.py
821
4.125
4
name=input("enter the name") mark1=int(input("enter the marks of 1 subject")) mark2=int(input("enter the marks of 2subject ")) mark3=int(input("enter the marks of 3 subject")) mark4=int(input("enter the marks of 4 subject")) mark5=int(input("enter the marks of 5 subject")) avg=(mark1+mark2+mark3+mark4+mark5)/5 p...
2b3ef1d71bd074a9db2c3b96e3969668b3270748
b4basitali/PIAIC-Python
/Python String Functions.py
1,932
4.4375
4
x = "My first String" b = ": This is String Functions Practice" print(x.capitalize())# Return a capitalized version of the string. print(x.islower()) # Return True if the string is a lowercase string, False otherwise. print(x.isupper()) # Return True if the string is an uppercase string, False otherwise. print(x.swapca...
662b220140ffac56ac680ed039228b274966ce39
Smaug123/RushHour
/DataStructures.py
12,391
4.0625
4
from enum import Enum class Piece: privileged = False coordinates = [] def __init__(self, coords, is_privileged=False): """ Coordinates are given as eg. [(0,1), (0,2), (0,3)] for a piece which appears on the top row across the second, third and fourth places. is_privileged ...
844cfad725a3dc2e1a197c7cec9598a3521dd279
Seanghor/Bootcamp-2020
/Ex 35.py
1,393
3.625
4
# My Code def dict_shopping(ent): error = 0 l = [] t = [] if len(ent) == 2: # ent = [{}, {}] for dc in ent: # dc = {} for i in dc: # i = key x = dc[i] # dc[i] = value l.append(x) a = l[0]*l[1] + l[2]*l[3] # total =...
dd734a10a528f280eed93c3287e4d4055f38729e
alexshmmy/Python_Algorithms
/024.check_Identity_Matrix.py
819
4.21875
4
# input: a 2D matrix # output: checks if the matrix is identity matrix # complexity: O(n^2) import time import numpy as np # function def checkArray(arr): ''' Checks if a given 2D array is the identity''' # compute the length of the array n = len(arr) # iterate over the array for i in range(n): for j in ra...
12db1760739e3651f0fb745d0ad7c9639e98218a
xiaoming2333ca/Wave-2
/Roots of Quadratic.py
612
3.90625
4
import root_cal print("Quadratic root(s) solver. Please enter the three value a, b, and, c. Separate by [space]") a = int(input("a> ")) b = int(input("b> ")) c = int(input("c> ")) dis = root_cal.disc_quad(a, b, c) if a != 0: if dis > 0: sol1, sol2 = root_cal.root_quad(a, b, c)[0], root_cal.root_quad(a, b, ...
fdd93c82c753fba98b45cbe2b74ab10405360ead
Kcheung42/My_CTCI
/Chapter1/1.1_is-Unique/isUnique.py
442
3.9375
4
#assume 128 ASCII characters def is_Unique(string): if len(string) > 128: return False char_set = [False for _ in range(128)] for char in string: val = ord(char) # ord returns ascii value of char # print "this is val %d" % val if char_set[val]: return False char_set[val] = True return True # if __n...
665fd639ad15c92f4e8df980f943beb0de043984
Aasthaengg/IBMdataset
/Python_codes/p02260/s249727954.py
521
3.578125
4
#coding: UTF-8 import sys import math class Algo: @staticmethod def insertionSort(r, n): count = 0 for i in range(0,n): minj = i for j in range(i,n): if r[j] < r[minj]: minj = j if r[i] != r[minj]: r[i], r[minj] = r[minj], r[i] count += 1 for i ...
4e6edca2619c3035c6ad94d698c4c037d672b2f2
susannah-go/CSCI8920
/problem set 1/problem1-2.py
531
3.828125
4
from hex2Base64 import Hex2Base64 import sys # get hex strings from the user hexString1 = input("Enter a hex string: ") hexString2 = input("Enter a hex string: ") # validate data if len(hexString1) != len(hexString2): sys.exit("Error: strings must have equal length") if not Hex2Base64.is_valid_hex(hexString1) or...