blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b0e7f4a34c5c005ada233f8ab3c0b5b678012c8f
jddelia/think-python
/Section10/duplicates.py
512
4.4375
4
# This program determines whether a word # has duplicate letters. def has_duplicates(word): '''This creates a loop within a loop. For each index, it will loop through the word again, to determine if any word occurs more than once.''' for i in word: count = 0 for n in word: ...
434ae73e69c287b00b4daecbfa570b8c4b86467e
ChanceDurr/DS-Unit-3-Sprint-2-SQL-and-Databases
/module3-nosql-and-document-oriented-databases/mod3.py
1,451
3.828125
4
# QUESTIONS ''' How was working with MongoDB different from working with PostgreSQL? What was easier, and what was harder? I feel as if it will be a lot easier to grab certain things from MongoDB. For example writing db.test.find({'level': 2}) is a lot easier than SELECT * FROM characters WHERE level = 3 Maybe that's ...
39660dba039078019b34732b15ef81138e6a174a
Adriana-Elizabeth-Salgado/PythonProjects-SWISE
/Proyecto2/board.py
3,825
3.6875
4
import blocks import copy class Position: def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return "(x:{0} y:{1})".format(self.x, self.y) def getRight(self): return Pos(self.x + 1, self.y) def getLeft(self): return Pos(self.x - 1, self.y) def getBottom(self): return Pos(self.x, ...
31012856d3c82b9d2cc5247d9b579228a9fcc8e4
VitorinoAssuncao/Coursera_Python
/insertion_sort.py
255
3.953125
4
def insertion_sort(lista): for x in range(1,len(lista)): valor = lista[x] i = x -1 while i >= 0 and valor <= lista[i]: lista[i+1] = lista[i] i -= 1 lista[i+1] = valor return lista
f64e4891872808367e7ec6c66768cc5dd3db61b9
Docbroke/NPTEL-The-Joy-of-Computing-using-Python
/NPTEL-Course-Lecture Programmes/Gambling.py
518
3.921875
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 19 21:06:31 2021 @author: Lakhan Kumawat """ import random import matplotlib.pyplot as plt account=0 x=[] y=[] for i in range(365): x.append(i+1) bet=random.randint(1,10) luck=random.randint(1,10) if bet==luck: account+=900-...
39ad55c45f8294c25bd1257ae621aef97585a800
Docbroke/NPTEL-The-Joy-of-Computing-using-Python
/NPTEL-Course-Lecture Programmes/SameLetterCards.py
998
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 14 09:53:19 2021 @author: Lakhan Kumawat """ import string import random symbols=[] symbols=list(string.ascii_letters) card1=[0]*5 card2=[0]*5 pos1=random.randint(0,4) pos2=random.randint(0,4) #first lets declare same symbol and extract it out samesymbol=...
ad2e04f8ce228e38e8265088e5df1f2afb8445f5
Docbroke/NPTEL-The-Joy-of-Computing-using-Python
/NPTEL-Course-Lecture Programmes/Numpy.py
858
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 27 09:23:18 2021 @author: Lakhan Kumawat """ import numpy as np a=np.array([1,2,3]) #Type array print(type(a)) #shape (row,col) print(a.shape) print(a[0],a[1]) a[1]=6 print(a[1]) b = np.zeros((2,2)) print(b) c = np.ones((2,2)) print...
526034f5ca1fc52347d33ae25e5e170df7170530
Docbroke/NPTEL-The-Joy-of-Computing-using-Python
/Week11/Week 11 Programming Assignment 1.py
924
4.09375
4
# PYTHON program to count ways to write # number as sum of even integers # Initialize mod variable as constant MOD = 1e9 + 7 # Iterative Function to calculate # (x^y)%p in O(log y) def power(x, y, p) : res = 1 # Initialize result x = x % p # Update x if it is more #...
bf134ffdf9b4f32dd7aad2696ae5a5ab12a056c7
Docbroke/NPTEL-The-Joy-of-Computing-using-Python
/NPTEL-Course-Lecture Programmes/Formatting.py
821
3.90625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 16 12:29:23 2021 @author: Lakhan Kumawat def rem(n): return n%8 def convert(li): # Converting integer list to string list s = [str(i) for i in li] # Join list items using join() res = int("".join(s)) r...
d0d38aa31c012c0ec00bf28629fea565d8fa65aa
Docbroke/NPTEL-The-Joy-of-Computing-using-Python
/Online Programming Test Solution/solutions.py
506
4.03125
4
plain_text = input() encrypted_text = input() output = '' for c in plain_text: output+=chr((ord(c)+5-ord('A'))%26 + ord('A')) def removeSpaces(str): str = str.replace(' ','') str = str.replace(',','') return string.lower() def check(output, encrypted_text): # the sorted stri...
4f7d4d8dfe6f4593a08d3cb95ad43ba3e8c5fc22
AmanMuricken/Multiplication-table
/Multiplication table.py
174
4.1875
4
print("this is a programme to generate multiplication table") a=int(input("enter the number for printing out its table:")) for i in range(1,11): print(a,"x",i,"=",a*i)
4d5f48cfb0169015d2d4a3d89c78348211de83fd
findiu/python_test
/day1/if_test.py
402
3.59375
4
import random print("猜数字") i=random.randint(0,100) print(i) ii=int(input("请输入一个数字(0~100):")) while i!=ii: if i > ii: print("你输入得数字小了") ii = int(input("请重新输入一个数字(0~100):")) elif i<ii: print("你输入得数字大了") ii = int(input("请重新输入一个数字(0~100):")) print("恭喜你,答对了")
5222c78af7e2580cdbc71c169d612089eb8b4b0b
rmshaffer/stoq-compiler
/stoqcompiler/unitary/unitary_sequence.py
10,715
3.515625
4
''' Defines the UnitarySequence class. ''' import copy import numpy as np from typing import List from .unitary import Unitary from .unitary_sequence_entry import UnitarySequenceEntry class UnitarySequence: ''' Represents a sequence of unitaries applied to specific qubits in a system. :param dimensi...
8e75f3fde635318277d01bc28340fc8d625c11d6
ocirne/cryptopals
/python/src/cryptopals/set5/challenge40.py
529
3.65625
4
from cryptopals.crypto import RSA, int_to_str from cryptopals.math import invmod, crt plaintext = "trivially" def cube_root(n): cr = int(pow(n, 1 / 3)) while cr ** 3 < n: cr += 1 return cr def rsa_encrypt(pt: str): rsa = RSA() _, n = rsa.public_key() c = rsa.encrypt(pt) return n...
015560bb0f6b99d18b283824e1f735765fd98965
longroad41377/variables
/name.py
147
4
4
#Guy Phillips #10-09-2014 #Exercise 1.1 - Hello World name = input("Enter your name: ") message = "Your name is {0}".format(name) print(message)
5994ebb304753f6835c8b65f1a1504e53d9a8c6d
longroad41377/variables
/fahrenheitconvert.py
161
3.578125
4
fah = float(input("Enter temperature in fahenhiet: ")) centigrade = (fah - 32) * (5 / 9) print("The temperature in centigrade is {0:.2f}".format(centigrade))
07ffbf75b96838f59964bb2d1faf725da2884b91
benhunter/py-stuff
/misc/Queue_hello.py
1,527
3.96875
4
# Testing with threading and queue modules for Thread-based parallelism import threading, queue, time # The worker thread gets jobs off the queue. When the queue is empty, it # assumes there will be no more work and exits. # (Realistically workers will run until terminated.) def worker(): print('Running worker'...
6f0229ea1f2dff3ee5542f573643c81d4153c8d6
benhunter/py-stuff
/misc/filereading.py
313
3.59375
4
file_name = "text.txt" with open(file_name, 'w') as f: for i in range(10): f.write(str(i) + '\n') with open(file_name) as f: # text = f.readlines().rstrip() # text = f.readlines() # print(type(text)) # print() # print(text) # print() print([line.rstrip() for line in f])
f606b1a1a3fee284d2adb9d07dcc3664826d051a
benhunter/py-stuff
/hackerrank/between-two-sets.py
1,096
3.703125
4
#!/bin/python3 # https://www.hackerrank.com/challenges/between-two-sets/ import os # # Complete the getTotalX function below. # def getTotalX(a, b): total = 0 a.sort() b.sort() range_min = max(a) range_max = min(b) for i in range(range_min, range_max + 1): # tempa = a.copy() ...
68721b977739173f4fbef8ee834f06b18e994921
ThamirisMrls/Computer-Science
/connect4gui.py
2,028
4.0625
4
## ## example_grid.py ## ## by Kristina Striegnitz ## ## version 2/10/2010 ## ## Demonstrates how the functions in file grid_display can be used. ## ## Additions to make cool game work by Daniel Dyssegaard Kallick import random from grid_display import run_display def make_grid(): grid = [] for l in range(6): ...
0cdd3534094291c4b56c1ceb8525026fd9ade186
ThamirisMrls/Computer-Science
/board1.py
4,311
3.703125
4
#Yeaaahhhh, everything works. I think. The only thing that doesn't work #entirely is the end. somehow it always manages to inform #the player who has won, and correctly too, but it never really #knows that it is time to stop. well, it does, but not really on #time. When /either/ x or o wins, it decides to give x a b...
be64fc0fd8817c84044ba630e7707505de2c86cc
ThamirisMrls/Computer-Science
/letter_probabilities.py
1,795
4
4
### # letter_probabilities.py # # author: Kristina Striegnitz # # version: 1/27/2010 # ### # If we randomly pick a letter from an English text, how likely is it # that this letter is an "a", a "b", etc.? Given a letter, this # function tells you what that probability is. # From: https://www.cs.hmc.edu/twiki/bin/view/C...
e3bf395892dd6aab81f3a12ca4dcf9ad80298b9f
Dopamineral/planit
/planner.py
5,908
3.515625
4
work_load = 15 #hours study_load = 45 #hours exercise_load = 5 #hours sleep_need = 6.5 #hours days_off = 1 #days semester_duration = 13 #weeks semester_working_days = semester_duration*7 #days class CourseClass: """"default class with attributes""" def __init__(self,classes_per_week,hours_per_class,hours_process...
6163d901d9f0bcdcf16a9004d3a59c84085498f2
Timurdov/Python3.Advanced
/les_8/lab_8a/06-isinstance.py
823
3.640625
4
# -*- coding: utf-8 -*- """ isinstance(obj, cls) проверяет, является ли obj экземпляром класса cls или класса, который является наследником класса cls """ print(isinstance(8, int)) # True print(isinstance('str', int)) # False print(isinstance(True, bool)) # True print(isinstance(True, int)) # True, так ...
82022ceedc594d247c77edc9c269cacdd5425cec
Timurdov/Python3.Advanced
/les_8/lab_8/05-__init__.py
897
4.34375
4
# Начальное состояние объекта следует создавать в # специальном методе-конструкторе __init__, который # вызывается автоматически после создания экземпляра # класса. Его параметры указываются при создании # объекта. # Класс, описывающий человека class Person: # Конструктор def __init__(self, name, ag...
9e56058c401785c8f7cbcdc23331fce8535f518a
xouan/DSA
/python_implement/sort/sort.py
4,568
3.875
4
def bubble_sort(alist): n = len(alist) for i in range(n-1): for j in range(n-1-i): if alist[j+1] < alist[j]: alist[j], alist[j+1] = alist[j+1], alist[j] def select_sort(alist): n = len(alist) for i in range(n): min = i for j in range(i+1, n): ...
1d15d37a1db043f7fa15fd4b5f0131598e422f24
robbiethegeek/acronyms
/scripts/check-acronyms.py
1,913
3.5
4
#!/usr/bin/env python3 """ Script to check for various formatting issues with acronyms file Does a few things, including: 1) Moving any all-lower-case definitions to Title case 2) Moving any all-upper-case strings to Title case 3) Turning smart quotes (e.g. “”‘’) to regular quotes """ import argparse import csv import...
969a6e5934a804963ebd15510f4c21139ae70750
viacheslav-m/codeheap
/eq/numpy_utils/rotation.py
5,123
3.90625
4
#!/usr/bin/env python3 from typing import Dict, List import numpy as np """Rotations - http://planning.cs.uiuc.edu/node102.html - https://en.wikipedia.org/wiki/Rotation_matrix - Use Rodrigues' rotation formula? """ def create_global2camera_rotation_matrix( dtype=np.dtype(np.float32), ) -> np.ndarray: ...
0ea1c662f28d76a4f80f7e18e2ff1747e98cd1ed
sithuaung223/cse530_project2
/databaseSimulation.py
4,623
3.53125
4
""" LAB 02_part_b Scenario: In this lab, please use SimPy to simulate database transaction reading and writing. Your project should randomly generate read and write events that will read or write a set of data for a period of time. The simulation times, number of data blocks, and longest read or w...
6d9e6646f06897bb153246be71824518c0daa113
aapaetsch/Information-Retrieval
/Cmput 397 Project 1/query/testRank.py
758
3.578125
4
from rank import rank def main(): results = {"worst": { "hello": {"tf": 4}, "tiger": {"tf": 8}, "apache": {"tf": 0}}, "medium": { "hello": {"tf": 8}, "tiger": {"tf": 15}, "apache": {"tf": 4}}, "best": { "hello": {"tf": 5}, "tiger": {"tf": 12}, "apache": {"tf": 15}}} query = {"hello": {...
e77e337570b1439243ee3f1ea96dd06d89974a98
Orilow/ca-ex3
/sol.py
2,520
3.640625
4
from collections import defaultdict class Graph: def __init__(self, nodes, edges, distances): self.nodes = nodes self.edges = edges self.distances = distances def dijsktra(graph, initial): uncovered = {initial: 0} path = {} nodes = set(graph.nodes) while nodes: ...
3c11e1e7bd769f096399ce3f22672449b04e37a8
yarkalyba/properties_management
/agent.py
11,915
4.1875
4
from validation import get_valid_input import random class Property: """ Represents a superclass for House and Apartment, the common arguments for both are square footage, number of bedrooms and number of bathrooms """ def __init__(self, square_feet='', beds='', baths='', **kwargs): """ ...
9b6a01c8e0d4c0daed4384134874f57048c40dd6
gamer496/pycon-numtheo
/farey.py
1,043
4.03125
4
def Farey_r(limit, start=(0, 1), stop=(1, 1)): '''recursive definition of a Farey sequence generator''' n, d = start N, D = stop mediant_d = d + D if mediant_d <= limit: mediant = (n + N), mediant_d for pair in Farey_r(limit, start, mediant): yield pair for pair in Farey_r(li...
b484e199cc32c3ceab770040ff1207c735fb2cd1
mateo-lanzillotta/GameDesign2021
/FinalGameFr.py
3,242
3.984375
4
#Mateo Lanzillotta #6/22/2021 #First draft of final project #Historical Quiz game import math, random, sys, time, os #Return to menu def replay(): print("Do you want to return to menu?") level = input() level = level.lower() if "y" in level: return False else: return...
7e609f48fcc1575ef5ae3cafe4c44097e039578b
charliedmiller/coding_challenges
/insert_into_a_binary_search_tree.py
1,173
4.0625
4
# Charlie Miller # Leetcode - 701. Insert into a Binary Search Tree # https://leetcode.com/problems/insert-into-a-binary-search-tree/ """ Recursively check if the current node is larger or smaller than the value Stop when the current node is null (should TreeNode here). In this case return the newly created nod...
3a2e3ab53c10bbeb511a5d6aecd71d4b1c415b11
charliedmiller/coding_challenges
/the_skyline_problem.py
7,450
4.15625
4
# Charlie Miller # Leetcode - 218. The Skyline Problem # https://leetcode.com/problems/the-skyline-problem/ # Written 2020-11-30 """ Use 2 heaps to keep track of the buildings. * 1 min heap to keep track of the right coordinates marking the end of a building * 1 max heap to keep track of the tallest building during o...
cc28062d447977e35a5eb0045e499f84ae6c705b
charliedmiller/coding_challenges
/increasing_order_search_tree.py
1,673
3.921875
4
# Charlie Miller # Leetcode - 897. Increasing Order Search Tree # https://leetcode.com/problems/increasing-order-search-tree/submissions/ # Written 2020-12-03 """ Do an inorder traversal, keeping track of 2 things: The root of the inorder tree The last node of the inorder tree For each node visited, add it as the righ...
d36c87cd708d86e03a74080db0ca0f827b82f053
charliedmiller/coding_challenges
/sequential_digits.py
2,029
3.921875
4
# Charlie Miller # Leetcode - 1291. Sequential Digits # https://leetcode.com/problems/sequential-digits/ """ There are only sequential numbers up to 10^9 There are 9 possible number of digits you can have for each number up to 10^9 [1 - 9], for each there's 10 - (number of digits) seqential numbers. Here, we l...
fca453eb1c6abf4962115d81fba1ac3815aec712
charliedmiller/coding_challenges
/rotate_list.py
1,971
4.0625
4
# Charlie Miller # Leetcode - 61. Rotate List # https://leetcode.com/problems/rotate-list/ """ this operation is equivalent to snapping the list in 2 at some point, then swapping their order. We need 3 locations: The new "last" node after the swap, the new "first" node after the swap, the current last node ...
d9eb26d10d4fc24fbf56b83e098bdfac50100124
charliedmiller/coding_challenges
/longest_substring_with_at_least_k_repeating_characters.py
1,960
3.65625
4
# Charlie Miller # Leetcode - 395. Longest Substring with At Least K Repeating Characters # https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/ # Written 2020-11-26 """ Divide and conquer - get the frequency of each character We know that any char that doesn't make the k minimum can't...
719d825d684af44b72d6fc78f1210b987ba72d67
charliedmiller/coding_challenges
/longest_palindrome.py
1,077
3.765625
4
# Charlie Miller # Leetcode - 409. Longest Palindrome # https://leetcode.com/problems/longest-palindrome/ class Solution: def get_freqs(self,string): freqs = defaultdict(int) for char in string: freqs[char] += 1 return freqs def longes...
7ba88bc12c67c562a49aabd46560cf9d0d1543bd
charliedmiller/coding_challenges
/remove_duplicate_letters.py
3,162
3.71875
4
# Charlie Miller # Leetcode - 316. Remove Duplicate Letters # https://leetcode.com/problems/remove-duplicate-letters/ """ Note:the following algo is correct, but not most efficient. Check out problem for most efficient solution Dynamic program: for each character, choose whether to remove it or not recursively...
211962f6a423b8e6579b584b001215e887f11dae
charliedmiller/coding_challenges
/first_unique_character_in_string.py
1,553
3.734375
4
# Charlie Miller # Leetcode - 387. First Unique Character in a String # https://leetcode.com/problems/first-unique-character-in-a-string/ """ Solved on 4/18/2020 Find the frequencies and first ocurrence (spelled wrong I know lol) for each character in string Iterate over frequencies, do not consider those with...
675058fd9119ae7640c9b6c6bfb5647d58446e97
charliedmiller/coding_challenges
/decode_string.py
2,613
3.890625
4
# Charlie Miller # Leetcode - 394. Decode String # https://leetcode.com/problems/decode-string/ # Written 2020-11-19 """ Iterate over the string. If it's an alpha, just add it Otherwise extract the number. If there's a bracket, extract everything inside. To account for nesting, also keep track of how many open/close ...
1001cfd9f4ccc952cd51e5507fc892e6662cc71a
charliedmiller/coding_challenges
/permutations_ii.py
2,188
4.09375
4
# Charlie Miller # Leetcode - 47. Permutations II # https://leetcode.com/problems/permutations-ii/ # Written 2020-11-12 """ Create the permutation list as if there were no duplicates Put the whole list of permutations in a hash set to remove duplicate sequences convert back to list of lists ---------- How to create a ...
be8da4ca0b138fb2d4710dbad267deb5736d1381
charliedmiller/coding_challenges
/basic_calculator_ii.py
2,535
3.984375
4
# Charlie Miller # Leetcode - 227. Basic Calculator II # https://leetcode.com/problems/basic-calculator-ii/ # Written 2020-11-24 """ parse the string into numbers and operators Calculate * and / in left right order, then + and - to preserve pemdas. To calculate, maintain an accumulator, perform operations on it accord...
8caf1d51780343a2a0fcf8c80312848fa53622d5
charliedmiller/coding_challenges
/repeated_dna_sequences.py
994
3.59375
4
# Charlie Miller # Leetcode - 187. Repeated DNA Sequences # https://leetcode.com/problems/repeated-dna-sequences/ """ maintain a 10 character window for sequences with a queue Add 1 to a dict for each sequence encountered Filter out all sequences that appear less than twice """ class Solution: def find...
850501ab54e20b9c5e74b400bc47c2fb9a72b68a
charliedmiller/coding_challenges
/combination_sum.py
1,564
3.78125
4
# Charlie Miller # Leetcode - 39. Combination Sum # https://leetcode.com/problems/combination-sum/ """ Consider all combinations recursively, if the sum is greater than the target, cut off the recursive path early. Do not consider paths with candidates that come before the current candidate, since they consider...
15a1fc37a817d7024820100d8c1513e922db69cc
charliedmiller/coding_challenges
/flipping_an_image.py
371
3.796875
4
# Charlie Miller # Leetcode - 832. Flipping an Image # https://leetcode.com/problems/flipping-an-image/ # Written 2020-11-10 """ Flip the row, then invert the value in a list comp """ class Solution: def flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]: result = [[px^1...
6e3cdfb4c13f369badf9c4b2f5e06e84e54883a3
charliedmiller/coding_challenges
/mirror_reflection.py
2,994
3.8125
4
# Charlie Miller # Leetcode - 858. Mirror Reflection # https://leetcode.com/problems/mirror-reflection/ # Written 2020-11-17 """ We can imagine the room to actually be a square in a repeating grid. The corners of each square has the sensors. If we project the laser in this grid in a STRAIGHT line, which point will it...
e24852565915a21325061539a583a4217a24f67f
Keviinplz/cc5114-redes-neuronales
/Ejercicio 01/neuron.py
593
4
4
""" Clase Neuron Define una neurona, con 3 parámetros, las cuales son sus pesos y su bias """ class Neuron: def __init__(self, w1, w2, b, lr): self.w1 = w1 self.w2 = w2 self.b = b self.lr = lr def compute(self, x1, x2): return x1 * self.w1 + x2 * self.w2 def...
e97e796b36e2bb1d29e67245f0c0b68e422108f5
VLevski/Programming0-1
/week1/2-If-Elif-Else-Simple-Problems/evenodd.py
146
4.15625
4
n = input("Enter Number: ") n = int(n) parity = n % 2 if parity == 0: print(str(n) + " is even number") else: print(str(n) + " is odd number")
fefb7cd7d93488383ebefe31c0fa10cad43447ef
VLevski/Programming0-1
/week3/1-Baby-Steps/begin_functions.py
607
3.59375
4
def square(a): return a ** 2 def fact(n): start = 1 f = 1 while start <= n: f *= start start += 1 return f def count_elements(a): count = 0 for element in a: count += 1 return count def member(x, xs): is_it = False for element in xs: if x =...
3759deeddc3fd71f3ba13524065f18853d93f795
VLevski/Programming0-1
/week2/4-Three-More-Problems/digits.py
213
3.671875
4
n = input("Enter n: ") n = int(n) numbers = [] start = n while start != 0: numbers = [start % 10] + numbers start //= 10 print(numbers) N = 0 for number in numbers: N = N * 10 + number print(N)
5ae64f80d693d4ad3f58a9f283cd1e3cc5f5f40b
VLevski/Programming0-1
/week3/2-Resolve-with-Functions/first_n_perfect.py
223
3.65625
4
from is_perfect import is_perfect n = input("Enter n: ") n = int(n) start = 6 counter = 0 while True: if is_perfect(start): print(start) counter += 1 if counter == n: break start += 1
a056b9028db7d36c5a02754819beab6882df6e36
VLevski/Programming0-1
/week1/4-While-Loop-Problems/count_to_ten.py
163
3.703125
4
n = 1 N = 10 while n != 0: if n >= 1 and n <= N: print(n) n += 1 elif n == N + 1: print("====") n = -N elif n >= -N and n < 0: print(-n) n += 1
a7bd1e0df20430a629120f5939dc6994065777f2
VLevski/Programming0-1
/week3/2-Resolve-with-Functions/divisors.py
314
3.90625
4
def divisors(n): start = 1 divs = [] while start < n: if n % start == 0: divs += [start] start += 1 return divs def main(): n = input("Enter n: ") n = int(n) for number in divisors(n): print(number) if __name__ == "__main__": main()
e2dec89db421a76fe68c2452bb6036a5e6842692
VLevski/Programming0-1
/week3/2-Resolve-with-Functions/sum_divisors.py
322
3.984375
4
from divisors import divisors def sum_ints(numbers): sum_numbers = 0 for number in numbers: sum_numbers += number return sum_numbers def main(): n = input("Enter n: ") n = int(n) sum_divisors = sum_ints(divisors(n)) print(sum_divisors) if __name__ == "__main__": main() ...
d2c77609553e006244d120dac7289be0cc574ade
fankids/fanPython
/python_crash_course/pccproject/ch07/02_greeter.py
546
4.03125
4
name = input("Please enter your name: ") print("Hello, " + name + "!") print() prompt = "If you tell us who you are, we can personalize the messages you see." prompt += "\nWhat is your first name?" name = input(prompt) print("\nHello, " + name + "!") print() age = input("How old are you? ") print(age) print() # ~ a...
9c4f7795b664f4468273ed7b13a5ca379a3ed7f5
salehsami/100-Days-of-Python
/Day 2 - Understanding Data Types and How to Manipulate Strings/Concatenation.py
218
3.71875
4
num = input("Type a two digit number: ") first = int(num[0]) second = int(num[1]) result = first+second print(result) num = input("Type a two digit number: ") first = int(num[0]) + int(num[1]) print(first)
3b2f7d56e4f3df9bd5907594d7fe0e454fe28d54
salehsami/100-Days-of-Python
/Day 1 - Working with Variables in Python to Manage Data/Band Name Generator.py
250
3.828125
4
print("\t\t\t\tWelcome to the Band Name Generator") city = input("What's name of the city you grew up in?\n") pet = input("What's your pet's name?\n") print(f"Your band name could be {city}-{pet}\n") print("Your band name could be "+ city +" "+ pet)
0d544b19e876801b183d41e418f81f1df3fc84b9
salehsami/100-Days-of-Python
/Day 2 - Understanding Data Types and How to Manipulate Strings/BMI basic.py
161
4
4
# BMI challenge height = input("Enter your height in m: ") weight = input("Enter your weight in kg: ") BMI = int(weight)/float(height)**2 print(int(BMI))
34831fe9e609735f09f1302b72d83e1aff374fe2
hridoymh/OOP-II
/student.py
509
3.71875
4
"""Name: MD. Mehedi Hasan ID: 191-15-2395 """ class student: av_mark = 0 def __init__(self): self.id = input('Enter your ID:') print('Enter your marks') for i in range(0,3): self.av_mark += int(input()) self.av_mark /= 3 def echo(self): print('ID: ',self.id) print('Average...
0d42e585c3ecaf29d58a1dfe4d267afdc34b4340
gtzanetos/gt
/adventure game.py
3,464
4.25
4
print("Welcome to the kitchen") print("Today we will be cooking one of three menu items: burger and fries, brownies or cookies") print('You will go to the grocery store and pick out the food that you need to make the meal') ingredients=['potatoes','burger','buns','lettuce', 'eggs','cocoa','sugar','butter','flour','c...
fdc008257818eac79dfa5a4e6f2846163dbaa03d
liuxining/LeetCodeSolutionWithPython
/p1/ThirdMaximumNumber.py
639
4.125
4
#liuxining #2017年08月03日23:22:39 def thirdMax(nums): ns = set(nums) n = 1; max_val = ns.pop() max2_val = 'null' max3_val = 'null' for val in ns: if(val > max_val): max3_val = max2_val max2_val = max_val max_val = val if(n < 3): ...
8fb6f641c03a32a0991ac9b5095951380a17796b
BZhong7/merge_user_ids
/merge_user_ids.py
2,191
3.890625
4
# Brandon Zhong - Merge User IDs # Main function that calls all other functions in order to merge the two lists together # If there are no objects in existing_users, just merge new user objects within the list # Otherwise merge the lists together, then merge objects together within the new list if needed def merge_u...
3f2eaeca371a1a9d579123a6d4f910b2ae818497
BaamPark/ML_prac
/prac1.py
632
4.03125
4
# def circum(side1, side2): # result = side1*2 + side2*2 # return result # # def area(side1, side2): # result = side1 * side2 # return result # # squ_result = 0 # while(True): # num = int(input("1.둘레, 2.넓이, 3.종료: ")) # if num == 3: # break # else: # print("두 변 길이 입력: ")...
f7e8d6fd95b2841352321d84b22a5cc9dd3311b1
Tyler-Durden-official/Python-projects-collection
/Guess_the_word.py
1,948
3.9375
4
from os import system, name from time import sleep def clear(): # for windows if name == 'nt': _ = system('cls') # for mac and linux(here, os.name is 'posix') else: _ = system('clear') print('Welcome to Guess the word!!\n') print('RULES:\n') print('1.There will be two t...
465af646d81889f40675a1492ee1a424503fc09d
ccyyoyo/my-learning-note
/HW2/merge_sort_06170109.py
1,387
3.6875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: class Solution(object): def merge_sort(self, nums): size = 1 L=0 R=1 newarr=[] R_plus_num = 0 L_plus_num = 0 while size<len(nums): while R<len(nums): for i in range(size*2): ...
874f101af0dcdd6cc4420cf3ac0c122cadf089db
sduffy826/FinchBot
/testFileIO.py
972
3.59375
4
import time def writeFile(fileName): fileHandle = open(fileName,"at") # Append and text file theList = [] someTuple = (123, 456, 1.234) theList.append(someTuple) someTuple2 = (4, 3, "ABC", 3.1) theList.append(someTuple2) for anItem in theList: fileHandle.write(str(anItem)) ...
b37da8c9e08a29c5833f2a670082c846852d4641
anjijava16/Practice-Geeks-For-Geeks
/Strings/Multiply two strings.py
356
4.0625
4
#https://practice.geeksforgeeks.org/problems/multiply-two-strings/1 def multiply(a,b): # code here # return the product string return (str(int(a)*int(b))) #{ # Driver Code Starts #Initial Template for Python 3 if __name__ == "__main__": t=int(input()) for i in range(t): a,b=input().s...
e1280cb2cb7ffc514598e78dfaa70cf3709c78d2
meqmeq/LeetCodeProblems
/twoSum.py
1,383
3.609375
4
def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ # Brute force # it1 = 0 # for num1 in nums: # it2=1 # for num2 in nums[1:(len(nums))]: # if (num1 + num2) == target and it1 != it2: # ...
8b1da2c0ac3ac51563b6a9830217708c814ae13f
shootsoft/practice
/LeetCode/python/001-030/016-3sum-closest/solution.py
1,303
3.609375
4
class Solution: # @return an integer def threeSumClosest(self, num, target): num.sort() #print num length = len(num) minDist = None minSum = None for i in range(length-2): if i > 0 and num[i-1] == num[i]: continue targ...
ce557047241659e66302e2652e0a979ec927e46a
shootsoft/practice
/LeetCode/python/031-060/057-length-of-last-word/last.py
603
3.765625
4
class Solution: # @param s, a string # @return an integer def lengthOfLastWord(self, s): l = len(s) if (l==0) : return 0 pos = l - 1 c = 0 while pos >= 0: if c > 0 and s[pos] == ' ': break elif s[pos] != ' ': ...
ff8ff97cfc4a3b33b4e5da1022dec0533a3cd44e
shootsoft/practice
/LeetCode/python/121-150/148-sort-list/solution.py
1,232
3.90625
4
__author__ = 'yinjun' """ Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param head: The first node of the linked list. @return: You should return the head of the sorted linked list, ...
79b2d5933fa8bf6675bb596909f1cd82d90f8761
shootsoft/practice
/LeetCode/python/common/listnode.py
1,124
3.65625
4
__author__ = 'yinjun' ''' ''' class ListNode: def __init__(self, x): self.val = x self.next = None def toList(self): v = [self.val] c = self.next while c!=None: v.append(c.val) c = c.next def __str__(self): self.toLit() retu...
5d3c4269ab2ac9c2dace580656214ea828e46257
shootsoft/practice
/LeetCode/python/001-030/005-longest-palindromic-substring/solution.py
730
3.5
4
class Solution: # @return a string def longestPalindrome(self, s): l = len(s) if s == None or l == 0: return '' maxLen = 0 result = '' for i in range(l*2-1): left = i/2 right = i/2 if i%2 == 1: right +=1 ...
42b2f96fab4fdcbbd2550be0a340d3382e49c44c
shootsoft/practice
/lintcode/NineChapters/04/wordbreak.py
811
3.5
4
__author__ = 'yinjun' class Solution: # @param s: A string s # @param dict: A dictionary of words dict def wordBreak(self, s, dict): # write your code here if dict == {} : return s == "" maxLength = max([len(k) for k,v in dict.items()]) length = len(s) ca...
f84bddb3bd18eed53274c9c4943e670ad4be71b5
shootsoft/practice
/LeetCode/python/091-120/107-binary-tree-level-order-traversal-ii/solution.py
860
3.703125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param {TreeNode} root # @return {integer[][]} def levelOrderBottom(self, root): result =[] if root == None : ...
fa44302773608d400d414c88e2a9a6a251fc9e7c
shootsoft/practice
/lintcode/NineChapters/04/jump-game-ii.py
1,087
3.546875
4
__author__ = 'yinjun' class Solution: def jump(self, A): if A==None or A == []: return 0 n = len(A) steps = [0 for i in range(n)] start = 0 end = 0 jumps = 0 while end < n-1: jumps += 1 farthest = end for ...
01bb0a690010f275861dd2054327e670bb489352
shootsoft/practice
/LeetCode/python/031-060/049-powx-n/powx.py
1,270
3.75
4
import math class Solution: # @param x, a float # @param n, a integer # @return a float def pow(self, x, n): if n==0: return 1 elif x==1.0: return x elif x==-1.0: if n<0: n*=-1 if n % 2 ==0: return ...
e807a38d83d9203df35b86b3eea311ab71d778e1
shootsoft/practice
/LeetCode/python/001-030/016-3sum-closest/3cloest.py
2,121
3.65625
4
import datetime class Solution: # @return an integer def threeSumClosest(self, nums, target): #starttime = datetime.datetime.now() nums.sort() l = len(nums) m = 0 #r = for x in range(l): if nums[x] >0 and m == 0: m = x mintar...
3c219accd008feba1ce3bc6434deb1fc18cb3b20
victormbarriosb/PowerFlow
/PropiedadesElectricas.py
784
3.625
4
class Potencia: def __init__(self, activa=0, reactiva=0): self.Activa = activa self.Reactiva = reactiva # Test def __add__(self, other): return Potencia(self.Activa + other.Activa, self.Reactiva + other.Reactiva) #def imprimir(self): # print("Activa %.2f, Reactiva %.2f" ...
d85e602547b71e191f8ae009d060aa068c1f4077
robinsamfrancis/Angle_Finder
/Angle Finder/angle finder.py
1,734
3.796875
4
import cv2 import math path= 'angle.jpg' img = cv2.imread(path) pointsList = [] #Creating a points list in which we can store the xy points #Defining a function for the mouse click def mousePoints(events,x,y,flags,params): if events == cv2.EVENT_LBUTTONDOWN: #if we click the left mouse size...
5051644d658d8f0ca7741d8e44e644d0a57c4e17
gfresnais/Lucky_Number_AI
/App/src/pygame_test/app_functions.py
3,010
3.609375
4
# -*- coding: utf-8 -*- """ @author: Gallien FRESNAIS """ import pygame from pygame.locals import * # - Local - # from App.src.pygame_test.app_settings import * # pygame.mixer.init() """ Handles the events from the main pygame program """ def event_handler(): for event in pygame.event.get(): # if the...
78ca47b6b643d4a6e0e4dcc6426203863389ecff
Lineldor/Tensorflow_learning
/CNN/CNN_Timeseries/cnn_2d_to_1d_v1.py
1,973
3.828125
4
from keras.models import Sequential from keras.layers import Convolution2D, Dense, Dropout, Flatten, MaxPooling2D from keras.utils import np_utils import numpy as np # import your data here instead # X - inputs, 10000 samples of 128-dimensional vectors # y - labels, 10000 samples of scalars from the set {0, 1, 2} X =...
15c08c5f47426ac68010ae5b4268fa0dc0d0d9dd
daumie/dominic-motuka-bc17-week-1
/day_2/tests/test_fizz_buzz.py
1,324
3.703125
4
import unittest from day_2.fizz_buzz import fizz_buzz class FizzBuzzClassTest(unittest.TestCase): """docstring for FizzBuzz""" def test_fizz_1(self): self.assertEqual(fizz_buzz(3), 'Fizz', msg='should return `Fizz` for number divisible by 3') def test_fizz_2(self): self.assertEqual(f...
4340fedd7414b94ff4191d5b2537b2b447958ca2
daumie/dominic-motuka-bc17-week-1
/day_4/missing_num.py
662
4.03125
4
"""Module docstring""" def find_missing(arr1, arr2): """compares 2 arrays and returns missing elements""" new_list = [] for element in arr1: if element not in arr2: new_list.append(element) for element in arr2: if element not in arr1: new_list.append(element) ...
dca82c9364f02428cf60ed16c41ff8488a1928b7
daumie/dominic-motuka-bc17-week-1
/day_2/tests/test_car_class.py
4,020
4.0625
4
"""Contains tests for the car class OOP""" import unittest from day_2.car_class import Car class CarClassTest(unittest.TestCase): """docstring for CarClassTest""" def test_car_instance(self): """Test for proper inheritance""" honda = Car('Honda') self.assertIsInstance(honda, Car, msg='...
d26a02a111fc8d79d91a139a4e6e9cf07d374f94
deShodhan/Algos
/w2ga1.py
590
4.40625
4
# Accept three positive integers as input and check if they form the sides of a right triangle. Print YES if they form one, and No if they do not. # The input will have three lines, with one integer on each line. The output should be a single line containing one of these two strings: YES or NO. a=int(input('Enter val...
0041d5db6a013b2dfc608b26fc7268e56f7f2ea4
dylankim97/codewarProblems
/problem1(CREATE_PHONE_NUMBER).py
966
4.375
4
def create_phone_number(n): return "({}{}{}) {}{}{}-{}{}{}{}".format(*n) n = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] answer = create_phone_number(n) print(answer) #format with {} string = "{program} is so {1}".format("great", "good", program = "python") print(string) #real application #------- #Asterisk unpacks ite...
e8770e121967d0a2b8bc938a0b0a6987b7b15d49
Thamaraikannan-R/set
/Remove items from Set.py
95
3.546875
4
list=set([12, 10, 13, 15, 8, 9]) for i in range(0,len(list)): list.pop() print(list)
cc6715c0a1cfc0ad1801971ff8deaacab3f3846c
carlosgomes1/python-tests
/world-1/06-double-triple-and-square-root.py
329
4.34375
4
# Make a program that receives an integer and shows on screen your double, triple and square root. number = int(input('Enter an integer: ')) print(f'The number is {number}') print(f'Double of the number is {number * 2}') print(f'Triple of the number is {number * 3}') print(f'Square root of the number is {number ** (1...
79b9ee0b20a96d717f2c7a352f7583e405532887
carlosgomes1/python-tests
/world-1/03-sum.py
239
4.25
4
# Make a program that receives two user numbers and shows on the screen the sum between them. n1 = int(input('Enter a number: ')) n2 = int(input('Enter another number: ')) sum = n1 + n2 print(f'The sum between {n1} and {n2} is {sum}!')
5096d36ec46cadf1dc1312f69d0a8f28a9b671a6
SolDDAENG/pro1
/pack2/test14.py
1,214
3.734375
4
kor = 100 def abc(): print('난 모듈의 멤버인 함수') class My: kor = 90 def abc(self): print('메소드') def show(self): kor = 77 # 메소드 내에서 kor을 호출하면 클래스 내에서 먼저 찾고 없으면 위에서 찾음. kor = 77을 없애면 위의 kk = 100을 가져온다 print(kor) print(self.kor) self.abc() abc() m = My() m...
922dd71316537a923cf9d5a568bb40dbab675233
SolDDAENG/pro1
/pack2/test16has.py
1,044
3.734375
4
# 클래스의 포함관계로 로또 번호 출력 import random class LottoBall: def __init__(self, num): self.num = num class LottoMachine: def __init__(self): self.ballList = [] for i in range(1, 46): self.ballList.append(LottoBall(i)) # 클래스의 포함 def selectBalls(self): # 섞기 전 출력 ...
9ad1901e3607d8ca5add05e044442af851c1c1ba
enningxie/TensorFlow_1.3
/dataset/reinitializable_iterator.py
1,771
3.765625
4
import tensorflow as tf ''' A reinitializable iterator can be initialized from multiple different Dataset objects. For example, you might have a training input pipeline that uses random perturbations to the input images to improve generalization, and a validation input pipeline that evaluates predictions on unmodifi...
112ded914512c1454d5d4a6262e01858c9bb0e99
jbwincek/bgglChtr
/main_function.py
4,543
3.828125
4
""" ########################################################### # bgglChtr: Main Function # Authors: Thomas Fitzsimmons, J.B. Wincek # # This program is the main controller for the program # bgglChtr. ############################################################ """ import sys import Graph from termcolor ...
7dc4ee6fafb1de341978e8c7d03280b3e6bb4755
lamontu/urllib
/requests_demo.py
952
3.515625
4
# -*- coding: utf-8 -*- import requests URL_IP = 'http://127.0.0.1:8000/ip' URL_GET = 'http://127.0.0.1:8000/get' def use_simple_requests(): response = requests.get(URL_IP) print('>>>>Response Headers:') print(response.headers) print('>>>>Status Code:') print(response.status_code) print...
031d638be957f35688ec014bb46fa59b1ddc6351
divineunited/image_downloader
/image_downloader.py
1,782
3.9375
4
### This function downloads all jpgs from a given website's body into a specified directory on your computer. import os import re import urllib.request def image_list(url): '''This function accepts a URL and returns a list of all the links to the images on that website.''' web_page = urllib.request.urlopen(ur...