blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
311eaf10018b426662c0b4f694e65b150e7c7f74
stroke-one/CheckiO_Solutions
/home/pawn-brotherhood.py
834
3.859375
4
def safe_pawns(pawns: set) -> int: board = {x: [] for x in range(1, 9)} safes = 0 for pos in pawns: pos_int = split_position(pos) board[pos_int[1]].append(pos_int[0]) for row in range(2, 9): for col in range(1, 9): if col in board[row]: if (col - 1 i...
da1190857891ba038938c4e7bba4cd26dbcc21ac
zabdulmanea/movie_trailer_website
/media.py
555
4.125
4
class Movie(): """ This class provides the structure to store movie information Attributes: title (str): The movie title trailer_youtube_url (str): A link to the movie trailer on youtube poster_image_url (str): A link to the movie poster """ # constructor of Movie class, ca...
abdf72e6d0ccd92df1d6046229e97e72b09e7def
Nitin-Diwakar/100-days-of-code
/day75/2.py
353
3.96875
4
sampleList = [34, 54, 67, 89, 11, 43, 94] print("Original list ", sampleList) element = sampleList.pop(4) print("List After removing element at index 4 ", sampleList) sampleList.insert(2, element) print("List after Adding element at index 2 ", sampleList) sampleList.append(element) print("List after Adding...
4cc8d8b91d7ff1ef46d8362c55ac8f5fc7501b70
Nitin-Diwakar/100-days-of-code
/day44/problem.py
482
3.921875
4
import re p= input("Input your password") x = True while x: if (len(p)<6 or len(p)>12): break elif not re.search("[a-z]",p): break elif not re.search("[0-9]",p): break elif not re.search("[A-Z]",p): break elif not re.search("[$#@]",p): break ...
e578a5360714e36ab813b0d16d7c488e228ff140
Nitin-Diwakar/100-days-of-code
/day73/2.py
353
3.703125
4
def counts(sen): global letter,digit letter = digit = 0 for check in sen: if check.isdigit(): digit+=1 elif check.isalpha(): letter+=1 else: pass return letter,digit sentence = input('>>> ') counts(sentence) print("Letters:",...
c14baeb2ddce50bc2ad1445083a9d717609a0757
Nitin-Diwakar/100-days-of-code
/day61/problem.py
699
3.625
4
class Roman: def __init__(self, num): self.num = num def int_to_roman(self): number = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] symbol = [ "M", "CM", "D", "CD", "C", "XC", "L", "X...
1f358d39f23dae3de4210e3a5cb3f60a81592485
Nitin-Diwakar/100-days-of-code
/da28/main.py
4,061
3.609375
4
from tkinter import * from tkinter import messagebox from random import choice, randint, shuffle import pyperclip import json # ---------------------------- PASSWORD GENERATOR ------------------------------- # #Password Generator Project def generate_password(): letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', ...
b73b09b2466c362a584cada47b9ed0ba2c249d9e
Nitin-Diwakar/100-days-of-code
/day25/main.py
1,431
4.53125
5
# Write a Python GUI program # using tkinter module # to input Miles in Entry widget # that is in text box and convert # to Kilometers Km on button click. import tkinter as tk def main(): window= tk.Tk() window.title("Miles to Kilometers Converter") window.geometry("375x200") # cr...
b9682b063f6004aaf61215f69a958d0bff7b5baf
vietduc1210/ngvietduc1210
/Ex_2.py
446
3.953125
4
prices = { "bananas": 4, "apples": 2, "oranges": 1.5, "pears": 3 } stock = { "bananas": 6, "apples": 0, "oranges": 32, "pears": 15 } for i, j in zip(prices, stock): print(i) print("price : ", prices[i]) print("stock : " , stock[i]) total = 0 for i, j in zip(prices, stock):...
39eea32ec26410b31264abb731e63c41a17f160f
Christasen/CSCI1913_SPRING2018
/project1/project1.py
2,179
3.578125
4
#yanxx630 #Project01 class Random: def __init__(self,seed): self.__seed = seed def next(self): nextseed = (16807 * self.__seed) % (2147483648-1) self.__seed = nextseed return nextseed def choose(self,objects): a = self.next() % len(objects) return objects[a...
88555a8d6b669f603b5baf02652d3ce62df20380
rvause/dotfiles
/bin/mkpy
1,087
3.6875
4
#!/usr/bin/env python import os import sys class ProgramError(Exception): pass def create_dir(path): print('Making dir {}'.format(path)) os.mkdir(path, 0755) def create_init(path): print('Adding __init__.py to {}'.format(path)) open(os.path.join(path, '__init__.py'), 'a').close() def main()...
3d6cab692c8588bf46a2f4f4b96c441141472660
Endie990/pythonweek-assigments
/Assignment_Guessing_game.py
534
4.125
4
#ass 2- guessing game import random guessnum=random.randint(1,9) num= int(input('Guess a number between 1 and 9: ')) while guessnum!='num': if num<guessnum: print('Guess is too low,Try again') num= int(input('Guess a number between 1 and 9: ')) elif ...
3f623f3d19055d66bf34c9b0b1e058fced620393
swetul/AnswerBot
/RelevantQuestionRetrival/setup.py
4,039
3.5625
4
import sqlite3 from sqlite3 import Error import xml.etree.ElementTree as ET import sys sys.path.append("../") # import lxml as etree def create_connection(db_file): """ create a database connection to the SQLite database specified by db_file :param db_file: database file :return: Connection objec...
d874a118f3beef9cfbd004c71f20cbb6c9a5120c
swetul/AnswerBot
/utils/tokenize_text.py
2,536
3.53125
4
from nltk.tokenize import word_tokenize import re def preprocess_question(question): """ This method does the preprocessing of Questions from the Database param: Question - The Question object to be preprocessed return: returns the Question Object """ quest = preprocess_body(question.body...
cd48c39e1acc00d146710ef097c2702df3e603df
stabradi/euler
/sam/euler_7.py
377
3.75
4
primes = [2, 3, 5, 7] def is_prime(num, primes): for p in primes: if not (n % p): return False return True prime_count = 4 n = 7 while True: n += 1 if is_prime(n , primes): #print "prime: {}".format(n) primes.append(n) prime_count += 1 if prime_count...
7b41b5a8a383bd55494bef716e736aecae38a799
stabradi/euler
/sam/euler_4.py
334
3.828125
4
def is_palendrome(n): n_str = str(n) return n_str == n_str[::-1] result = "" largest_product = 0 for x in range(999,99, -1): for y in range(x, 99, -1): if is_palendrome(x*y): if largest_product < x*y: largest_product = x*y result = "{}, {}".format(x, y) ...
29654e832e4e1825a85dc20fa3f8a2800d257f37
whdgmawkd/all_new_rascar
/2nd_assignment_main.py
2,481
3.75
4
######################################################################### # Date: 2018/10/02 # file name: 1st_assignment_main.py # Purpose: this code has been generated for the 4 wheels drive body # moving object to perform the project with ultra sensor # this code is used for the student only #########################...
1608a1f43a358fecf33b0132f0c9e36c5e250390
alexpsimone/salesperson-report
/sales_report.py
2,079
3.875
4
def generate_sales_report(sales_report): """Generate sales report showing total melons each salesperson sold.""" report = open(sales_report) sales_information = {} for line in report: line = line.rstrip() entries = line.split('|') salesperson = entries[0] total_sales ...
8665806d7bee68a3c8ed5c813dca580983254f88
p15060/python
/ergasia9.py
570
3.796875
4
#Π15060 sum=0 print("Πληκτρολογήστε έναν αριθμό...") number=int(input()) number=(number*3)+1 print("Ο αριθμός πολλαπλασιασμένος με 3 και αυξημένος κατά 1: ",number) while number!=0: sum=number%10 number=int(number/10) if number==0 and int(sum/10)!=0: number=sum ...
e52553a913da8472c30b6fea6b177c0bb8d7a906
MiguelOrellanaR/PROGRAMAS_PROYECTOS
/Factorial.py
2,117
4.0625
4
def pedir_numero_menú(): correcto = False num = 0 while (not correcto): try: num = int(input("\n>Ingrese una opción del menú:")) print() correcto = True except ValueError: print("Error, Ingrese un número que corresponda a una opción del menú\n...
6ec6885be58fd0cdf9362b682373a98770be5125
MiguelOrellanaR/PROGRAMAS_PROYECTOS
/Divisores.py
1,666
3.96875
4
def pedir_numero_menú(): correcto = False num = 0 while (not correcto): try: num = int(input("\n>Ingrese una opción del menú:")) print() correcto = True except ValueError: print("Error, Ingrese un número que corresponda a una opción del menú\n"...
f545ae279f4ebd87e5dff3ec85dd258aff264a22
fvilchez/Udacity
/Linear Algebra Refresh/Vectors/Vectors.py
2,852
3.84375
4
##################################### Vector Module ############################################### from math import sqrt, pi, acos from decimal import Decimal, getcontext class Vector(object): def __init__(self, coordinates): try: if not coordinates: raise ValueError ...
1a93f66daa6c45530b984bcd940cd348024c4d40
wkelly1/SchoolCode
/Worksheet 5 recursion/task 2.py
215
3.671875
4
import time def fib(n): if n <=1: return n else: return fib(n-1) + fib(n-2) startTime = time.clock() fib(10) endTime = time.clock() print("Time of completion = ",(endTime - startTime)*1000)
91866a432d9ca728e2452363cc351cc1dbff6d89
wkelly1/SchoolCode
/Homework 6 Object orientated/task 1.py
304
3.5
4
class Member(): def __init__(self, mySurname, myFirstName, myAnnualFee): surname = mySurname firstName = myFirstName annualFee = myAnnualFee def setSurname(self): surname = input("Give me you name brav!") myMember = Member("bob", "james", "£11") setSurname()
2dd33edea8cf006e69846ce26cf5eb4b47e2dbe3
naren-m/programming_practice
/leetcode/add_two_nums.py
1,524
3.8125
4
# Problem: https://leetcode.com/problems/add-two-numbers/description/ # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :typ...
556274d227c8f15620de3eb4dc83ac3887cf48bf
naren-m/programming_practice
/leetcode/1089-Duplicate-Zeros.py
1,393
3.890625
4
# https://leetcode.com/problems/duplicate-zeros/ # https://leetcode.com/explore/learn/card/fun-with-arrays/525/inserting-items-into-an-array/3245/ # Solution: https://leetcode.com/problems/duplicate-zeros/solution/ # Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining ele...
e91bb670d283c102a76f2e5f5129e6203c3b1060
naren-m/programming_practice
/leetcode/CountElements.py
880
3.546875
4
# https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/528/week-1/3289/ class Solution(object): def countElements(self, arr): """ :type arr: List[int] :rtype: int """ if not (1 <= len(arr) <= 1000): return 0 d = dict() for a in...
6e53928d519c34b258315f171a249daf601234f2
naren-m/programming_practice
/leetcode/1.two-sum.py
646
3.53125
4
# # [1] Two Sum # # https://leetcode.com/problems/two-sum/description/ # # Given an array of integers, return indices of the two numbers such that they # add up to a specific target. # # You may assume that each input would have exactly one solution, and you may # not use the same element twice. # # Example: # Given nu...
4e5c4ff082088b93ce96f3ab2dbe573d0225159c
naren-m/programming_practice
/general/divide_and_conquer/list_sum.py
181
3.59375
4
# Problem Grokking algorithms book. Exercise 4.1 def find_sum(l): if len(l) == 0: return 0 return l[0] + find_sum(l[1:]) l = [1, 2, 3, 4, 5] print(find_sum(l))
2c835ba30ce82136917571800052dff4d69c97a3
ArGaL-D/sql.insertions.generator
/modules/info.py
1,246
3.5
4
def db_name(): print(chr(27)+"[1;32m","[+]", chr(27)+"[1;31m","Database name...", chr(27)+"[0m", end="") dbName = input("") return dbName def tb_name(): print(chr(27)+"[1;32m","[+]", chr(27)+"[1;31m","Table name...", chr(27)+"[0m", end="") tb_name = input("") return tb_name def tb_fields(): ...
8c3cb5cad0f597d858c2143ba6fcccef817e219b
iamvidz/073_VidhiMaheriya
/lab1_1.py
2,308
3.5
4
import nltk from nltk.corpus import twitter_samples # sample Twitter dataset from NLTK import matplotlib.pyplot as plt # library for visualization import random # pseudo-random number generator nltk.download("twitter_samples") all_positive_tweets = twitter_samples.strings('positive_tweets.json') all_negative_tweets ...
254d9ce485428c3b7841ce4a693e614df08f9752
AdityaJsr/Bl_week2
/week 2/tuple/unpackTuple.py
430
4.09375
4
""" Title - Write a Python program to unpack a tuple in several variables. Author name - Aditya Kumar Ceation time - ‎‎06 ‎March ‎2021 ‏‎ Modified time - ‎‎‎06 ‎March ‎2021‎ """ #create a tuple tuplex = 4, 8, 3 print(tuplex) var1, var2, var3 = tuplex #unpack a tuple in variables print(var1 + var2 + var3) #the numbe...
ae0540997e2608288680eb7369035627d53004cd
AdityaJsr/Bl_week2
/week 2/basicPython/colorFirstLast.py
372
3.921875
4
""" Title - Write a Python program to display the first and last colors from the following list. Author name - Aditya Kumar Creation time - ‎‎02 ‎March ‎2021 Modified time - ‎‎‎02 ‎March ‎2021‏‎ """ # List of the color. color_list = ["Red","Green","White" ,"Black"] # Printing the first and last memeber of the list/....
79c7afafbfedabea6284ed63ab8ee0ef399436b8
AdityaJsr/Bl_week2
/week 2/basicPython/bit32Or64.py
422
3.75
4
""" Title - Write a Python program to determine if the python shell is executing in 32bit or 64bit mode. on operating system. Author name - Aditya Kumar Ceation time - ‎‎02 ‎March ‎2021 ‏‎ Modified time - ‎‎‎02 ‎March ‎2021‎ """ # For 32 bit it will return 32 and for 64 bit it will return 64 import struct def printB...
2111c30c63c95d8ced37e1ae5e1b90e29a14fb0f
AdityaJsr/Bl_week2
/week 2/dictP/mulKey.py
507
3.890625
4
""" Title - Write a Python program to check multiple keys exists in a dict1ionary. Author name - Aditya Kumar Ceation time - ‎‎04 ‎March ‎2021 ‏‎ Modified time - ‎‎‎04 ‎March ‎2021‎ """ dict1 = { 'name': 'rahul', 'class': 'XII', 'rollNo': '15' } print('The value is',dict1.keys() >= {'class', 'name'}) print('Th...
f8f85b9fcba3256b1bba2b885014e824471fe1c8
AdityaJsr/Bl_week2
/week 2/array/acessViaindex.py
1,030
3.9375
4
""" Title - Write a Python program to create an array of 5 integers and display the array items. Access individual element through indexes. Author name - Aditya Kumar Ceation time - ‎‎03 ‎March ‎2021 ‏‎ Modified time - ‎‎‎03 ‎March ‎2021‎ """ import array as arr # import logging # logging.basicConfig(level=logging.DE...
5de52fcb51cf062e250533875d749f7fcd0c5a1e
AdityaJsr/Bl_week2
/week 2/dictP/createDict.py
587
4.125
4
""" Title - Write a Python program to create a dictionary from a string. Note: Track the count of the letters from the string. Sample string : 'w3resource' Expected output: {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1} Access individual element through indexes. Author...
7b753e2fb062f13672116c2b9ed3b786ff36e4e6
AdityaJsr/Bl_week2
/week 2/list/cloneList.py
353
3.734375
4
""" Title - Write a Python program to clone or copy a list. Author name - Aditya Kumar Ceation time - ‎‎05 ‎March ‎2021 ‏‎ Modified time - ‎‎‎05 ‎March ‎2021‎ """ a = ['hello', 'world', 'This', 'is', 'the', 'orignal'] b = list.copy(a) print(b) b.remove(a[-1]) print(b) b.append('dupliacate') print("List 1 : ",a) print...
09514dbbe9dbb6d06f9aad9bae59bedeee27c8cc
AdityaJsr/Bl_week2
/week 2/dictP/tableFormat.py
333
3.921875
4
""" Title - Write a Python program to print a dictionary in table format. Author name - Aditya Kumar Ceation time - ‎‎04 ‎March ‎2021 ‏‎ Modified time - ‎‎‎04 ‎March ‎2021‎ """ d = {'C1':[1,2,3],'C2':[5,6,7],'C3':[9,10,11]} for row in zip(*([key] + (value) for key, value in sorted(d.items()))): print(*row)
f86beeaad22dae0caf63d8138b653c18dc2d32b0
AntonBelski/Algorithms-and-Data-Structures
/Sort/merge_sort.py
581
3.984375
4
# Merge Sort def merge_sort(array): n = len(array) if n <= 1: return array left = merge_sort(array[:n // 2]) right = merge_sort(array[n // 2:]) return merge_arrays(left, right) def merge_arrays(array1, array2): result = [] len_a1 = len(array1) len_a2 = len(array2) l = 0 ...
12b7605d5c328c17556e8600a5a02f4d1b4c3b57
daniiarzzzzz/Python04
/lesson2/lesson2.3.py
534
3.671875
4
num = 19 == 19 class Age: def __init__(self, age): self.age = age def __add__(self, other): age = self.age + other.age return Age(age) def __sub__(self, other): pass def __getitem__(self, key): return self.age def __eq__(self, other): return sel...
c0dffe3b0d3d43ff4d37efd630854639212a4cc3
inzane1y/homework
/percolation/2d/percolation.py
2,366
3.6875
4
# percolation.py import numpy as np import sys # Global variable needed flag = False # Functions def matrix_fill(p, n): ''' Fills square matrix with 0 and 1. ''' return np.random.rand(n, n) < p def matrix_print(matrix): ''' Prints the matrix on the screen. ''' print(matrix) def ...
2ff14537453888ee76aa45ea6894099104519754
abdelrahmanabdelnabi/15-puzzle-solver
/frontier.py
1,340
3.875
4
from collections import deque from puzzle import Node class QueueFrontier: def __init__(self): self._q = deque() self._set = set() def insert(self, node): if node.state in self._set: raise ValueError("a node with an identical state is already in the frontier") self._q.append(node) self._set.add(node.s...
854cad3f7020414527b440df02e09f8ebb96d536
LearnPhy/FundaPython
/implementation_geometry.py
422
3.671875
4
from geometry.rectangle import info as rectangle_info, calculate_rectangle_area from geometry.triangle import calculate_triangle_area, info as triangle_info a = 10 b = 20 print(f'\n{triangle_info()}') print(f'the triangle area of base: {a} and height: {b} is {calculate_triangle_area(a, b)}') print(f'\n{rectangle_inf...
cbd191e8c4a12ed3ca0cd5cc7658541f23e42e7e
pganssle/babi
/babi/horizontal_scrolling.py
662
3.609375
4
def line_x(x: int, width: int) -> int: if x + 1 < width: return 0 elif width == 1: return x else: margin = min(width - 3, 6) return ( width - margin - 2 + (x + 1 - width) // (width - margin - 2) * (width - margin - 2) ) ...
e1fb63c9cbcfdda281ad2de4e95f1cf0b6853572
tscott8/machine_learning
/classifiers/nnetwork.py
13,876
3.59375
4
import numpy as np from sklearn import datasets from sklearn.preprocessing import normalize from sklearn import cross_validation from sklearn.datasets.base import Bunch from copy import deepcopy learn_speed = 0.3 # the update frequency class Neuron(object): """ A single neuron """ def __str__(self, neuron_i...
f39d1e71036a89b14a5641694bd189ba9df34d3a
Stereo101/pySudoku
/sudoku.py
2,681
3.546875
4
import re from heapq import heappush,heappop #Solve the sudo puzzle logically, or recursively search for a # solution with the smallest guess possible def solve(sudoString): sudo = logicalSearch(sudoString) if(isDone(sudo)): return sudo guesses = getSmallestGuess(sudo) if(guesses == 'failed to fin...
423df06c344e381a8d09156226b10ef17f37bebd
thatguysilver/pswaads
/listing.py
966
4.21875
4
''' Trying to learn about the different list concatenation methods in py and examine their efficiency. ''' import time def iterate_concat(): start = time.time() new_list = [] for i in range(1000): new_list += [i] end = time.time() return f'Regular iteration took {end - start} seconds.' d...
fc142fd8626e0dccd4a4c4ae1fae454cf999e4cc
thatguysilver/pswaads
/stack.py
785
3.75
4
#In which your struly implements a stack in python. class Stack: def __init__(self): self.items = [] def is_empty(self): #Tells us if it's empty. return self.items == [] def push(self, item): #Adds item to top of stack. self.items.append(item) def p...
af6af7ae62a1afc667fcf6dc282ad5ab886e651f
dcperriseau/intro-datascience
/Assignment 3/friend_count.py
1,606
4.0625
4
''' Problem 3 Consider a simple social network dataset consisting of a set of key-value pairs (person, friend) representing a friend relationship between two people. Describe a MapReduce algorithm to count the number of friends for each person. Map Input Each input record is a 2 element list [personA, personB] where p...
6e634bca226cd9051e88ab83606017905a090cd1
veronica-hatala/FloatingBalloon
/visuals.py
1,572
3.71875
4
import pygame import audio print("Hey there, in visuals py") print("There isn't anything here yet.") #we'll deal with this stuff later ''' pygame.init() pygame.display.set_caption("Balloon") display_width = 600 display_height = 800 # Colour definitions black = (0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) ...
aa21ade3ef582796463968ffa4d709187f176c27
ankitshah009/leetcode_python
/1665-minimum_initial_energy_to_finish_tasks.py
5,206
4.0625
4
#1665. Minimum Initial Energy to Finish Tasks #Hard # #You are given an array tasks where tasks[i] = [actuali, minimumi]: # # actuali is the actual amount of energy you spend to finish the ith task. # minimumi is the minimum amount of energy you require to begin the ith task. # #For example, if the task is [10, 1...
9bd5129244105d49b5b4d500ddc03ed14f58069b
ankitshah009/leetcode_python
/754-reach_a_number.py
1,700
3.921875
4
#754. Reach a Number #Medium # #You are standing at position 0 on an infinite number line. There is a goal at position target. # #On each move, you can either go left or right. During the n-th move (starting from 1), you take n steps. # #Return the minimum number of steps required to reach the destination. # #Example 1...
e27b6fdc1be97a60ff87cdaedf8081028ece8390
ankitshah009/leetcode_python
/1646-get_maximum_in_generated_array.py
2,280
3.84375
4
#1646. Get Maximum in Generated Array # # User Accepted: 3822 # User Tried: 4087 # Total Accepted: 3940 # Total Submissions: 8533 # Difficulty: Easy # #You are given an integer n. An array nums of length n + 1 is generated in the following way: # # nums[0] = 0 # nums[1] = 1 # nums[2 * i] = nums[...
7f0ff58004f538dfe3586179af7f5919cdb44746
ankitshah009/leetcode_python
/420-strong_password_checker.py
3,393
4.09375
4
#420. Strong Password Checker #Hard # #A password is considered strong if the below conditions are all met: # # It has at least 6 characters and at most 20 characters. # It contains at least one lowercase letter, at least one uppercase letter, and at least one digit. # It does not contain three repeating chara...
dbe88fb6260afa17378bb731788b4d39cdd85f59
ZhenhLi/image-processing
/test_9.py
3,813
3.546875
4
import numpy as np import cv2 # Project 9 # 分割珍珠并检测其边缘 image = cv2.imread(r"C:\Data\project\9\pearls2.jpg") cv2.imshow("image",image) cv2.waitKey() cv2.destroyAllWindows() #image_2 = image.copy() image_2,contours_2,hierarchy_2 = cv2.findContours(image[:,:,0],cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) image_n_...
e89a3d66dcf27e2838ff29a63aa867b1c119da52
kashmit2342/python-tutorial
/ex33/ex33/ex33.py
209
4.09375
4
i = 0 numbers = [] while i < 6: print(f"number appended is:{i}") numbers.append(i) i+=1 print(f"i now is:{i}") for number in numbers: print(number) print(f"all numbers {numbers}") print(numbers[2])
7734f9bfcb3ee8d456fb3b88335984ffcb75c0b6
preethamdp/python-practice
/choclate_wrapper.py
671
3.625
4
#!/bin/python3 import math import os import random import re import sys # Complete the chocolateFeast function below. def chocolateFeast(n,c,m): wrapper = n//c total_bars = n//c while wrapper>=m: temp = wrapper//m total_bars += temp wrapper = wrapper%m wrapper+=temp ...
6a73207a65ee8d8b09bf9e52d4f700ed0ef91fef
BurningWish/FSND-P1-Movie-Trailer
/media.py
890
3.78125
4
import webbrowser # movie class class Movie(): """ This class provies a way to store movie related information Attributes: title (str): This is the title of the movie storyline (str): This is the storyline of the movie poster_image_url (str): This is the movie poster as an URL ...
0d29eeda1f0c1d03c88b63a3c0b7aee230918df9
kkom/steganography
/pysteg/common/streaming.py
717
3.703125
4
import gzip import itertools import urllib.request def iter_remote_gzip(url): """Returns an iterator over the lines of a remote gzipped text file.""" with urllib.request.urlopen(url) as f: with gzip.GzipFile(fileobj=f) as g: for l in g: yield l def ngrams_iter2file(ngrams,...
82cc2b120565f7b845aa124de18b922843595906
kkom/steganography
/pysteg/common/itertools.py
3,610
3.75
4
import collections from itertools import chain, islice FilteredTuple = collections.namedtuple('FilteredTuple', 'reject item') def _output_tuple_fun(tuple_type): """Return a function to output an unnamed or named tuple.""" if tuple_type is tuple: def output_fun(object, count): """Output a...
eddf294f4a418a6d35cdb455561890a919e45bb5
kkom/steganography
/scripts/googlebooks/bindb/create_index.py
2,811
3.515625
4
#!/usr/bin/env python3 descr = """ This script will create an index from unigrams. The index is a text file that for each token has one line containing 3 tab separated values: 1. index of the token (from 1 to vocabulary size V) 2. token 3. partition of the token The tokens are first assigned partition, then sorted b...
8bd902f074cf7707837fe6a67ef04b2fcc28f9ff
roomly-ai/QuestionAnsweringDistilbert
/test.py
433
3.578125
4
from summarizer.summarizer import summarize_data from scraper import mainscraper user_question = "what is Schrodinger cat ?" # Scraping starts : # Get paragraphs from wikipedia articles using scraping fetched_answers = mainscraper.fetch_search_wiki( user_question=user_question, stops=1) data = ''.join([s for s ...
304769d3a15878e844f87a8fa360e8a7ee5a5c97
dan480/caesars-cipher
/main.py
1,364
4.3125
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import argparse from src.select_alphabet import select_alphabet from src.decoding import decoding_func from src.encoding import encoding_func """ The main file that runs the program logic. The function of creating a command line parser is implemented here. In the main () func...
9cb527a7db65a555b94da3a04f912cdd40f4e91c
AshishGoyal27/credit-card-validator
/credit_card_validator.py
717
3.890625
4
cardNumber = input("Enter a 16-digit card number:") original_card_num = "".join(cardNumber.split()) a = list(original_card_num) #double the value of every second digit for i in range(0,len(a)): if i%2 == 0: a[i] = str(int(a[i]) *2) if len(a[i])>1:#If doubling operation gives any digit great...
e8596546e32a9cd07f46b1400a1bd429e69c2980
sssanthosh107/TextCleaner
/Text_Cleaner.py
1,738
3.6875
4
import numpy as np import pandas as pd import re import os import json import sys with open('Num2Txt.json', 'r') as f: Num2Txt = json.load(f) print("1 for String \n2 for filename (add .txt)") input_option= input() flag=0 if input_option=="1": print("Please enter a sentence/paragraph to clean") input_str...
0f933a230dd8ad77afc63e9f98ed8e425bd5303d
sklucioni/TwitterResearch2020
/general_utilities.py
3,051
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 14 13:50:33 2020 @author: jimwaldo General routines that only need to be written once. """ import json import pickle import subprocess """ Basic reading and writing of pickled objects or json objects to/from a file. These functions will not check ...
a88b9f3b4f6cfbe225f25495750c17f3806ed20e
ishaansingh1028/Stock-Prediction
/stock_prediction.py
3,193
3.78125
4
from pandas.core.frame import DataFrame import streamlit as st import pandas as pd import yfinance as yf import requests from bs4 import BeautifulSoup import datetime import plotly.express as px from fbprophet.plot import plot_plotly from fbprophet import Prophet #Method to Scrape Wikepedia and the results ...
1ab36289e006bd2385ea25588a52c8d78415e7aa
Tchomasek/Codewars
/Codewars/4 kyu/Next bigger number with the same digits.py
1,298
3.765625
4
def next_bigger(n): digits=[] result=-1 max=0 for char in str(n): digits.append(int(char)) index=0 curr=[] unchanged=[] for i in range(2,len(digits)+1): curr=digits[-i:] if curr[0]<curr[1]: index=i break else: r...
0189fd3e5481ef77d5c213a9b314dedff557be82
Tchomasek/Codewars
/Codewars/6 kyu/Salesman's Travel.py
3,682
3.546875
4
def travel(r, zipcode): address_list = r.split(',') result = [] for address in address_list: ad_split = address.split() zip = ' '.join(ad_split[-2:]) #print(zip) if zipcode == zip: print(zip) result.append(address.replace(zipcode,'')) street_num_l...
e4ff6115024035a576ffcb2759f1ae5b8b9b6f6c
Tchomasek/Codewars
/Codewars/6 kyu/Sum of Digits_Digital Root.py
215
3.671875
4
def digital_root(n): while True: if n > 9: n_str=str(n) n=0 for num in n_str: n+=int(num) else: return n print(digital_root(456))
c9a18125f74caacb4b470d986bf7e09fe119b180
Tchomasek/Codewars
/Codewars/6 kyu/Sort the odd.py
663
4.3125
4
def sort_array(source_array): result = list(source_array) even = {} for index,num in enumerate(source_array): if num % 2 == 0: even[index] = num result.remove(num) result.sort() for index,num in even.items(): result.insert(index, num) return result print(...
0adb0d78954c719dadafd33dde275e43387b70bc
Machin-Learning/Exercises
/Section-1/Data Types/set.py
1,475
4.40625
4
# #Set # 1. Set in python is immuttable/non changeable and does not show duplicate # 2. Set are collection of element seprated by comma inside {,} # 3. Set can't be indexed or...
f6b584f4a4315fc01bba5463bca09b968f9f2d76
Machin-Learning/Exercises
/Section-1/Data Types/variables.py
1,191
4.125
4
# Variables in python # var = 5 # print(var) # var = "Muzmmil pathan" # print(var) # Data Types # 1. int() # 2. str() # 3. float() # 4. list() # 5. tuple() # 6. set() # 7. dict() num = 4 #integers are a number "without point / non fractional / Decimal from 1-9 only" print(type(num)...
2aad491f01a537ef4b93fe244e99ec541d3bc374
Machin-Learning/Exercises
/Section-3/Fuction and Method/Aggregate Functions/max_min_sum_mean_median_mode.py
166
3.640625
4
import statistics as s list1 = [3,5,7,9,2,1,1] print(max(list1)) print(min(list1)) print(sum(list1)) print(s.mean(list1)) print(s.median(list1)) print(s.mode(list1))
57568e11dcbddafd51b1548d8cabd7062b4996e6
Machin-Learning/Exercises
/Section-3/Fuction and Method/Anonymous Function/map_filter_zip.py
1,140
3.59375
4
from functools import reduce # filter(function, iterable) marks = [76,84,56,12,40,80,95] def marks_check(li): if li > 50: return True else: return False # ls_checked = list(filter(marks_check, marks)) ls_checked = list(filter(lambda li:li > 50, marks)) print(ls_checked) # map(func, iter1) s...
94f03f87bc88a62fcdcb3e215b6d3157a5d77149
Machin-Learning/Exercises
/Section-3/Fuction and Method/User Input/user_input.py
251
4.28125
4
# User Input # To get input from user we use input() method name = input("Enter your name: ") # Remember input() take input in string format age = input("Enter your age: ") print(f"Welcom {name}") print(f"Your life Expectancy {100 - int(age)} Years")
d9e48b09f2c3a902b3009279f89263b5eee7087e
yashbagla321/Mad
/computeDistancePointToSegment.py
1,014
4.15625
4
print 'Enter x and y coordinates of the point' x0 = float(input()) y0 = float(input()) print 'Enter x and y coordinates of point1 then point2 of the line' x1 = float(input()) y1 = float(input()) x2 = float(input()) y2 = float(input()) import math def computeDistancePointToSegment(x1,y1, x2,y2, x3,y...
f500547d5b468a5814222a53a97b8482fac5a7bf
kenrick95/code-archive
/2015-08/cf-gym-100735-I.py
222
4.03125
4
a = int(input()) b = int(input()) c = int(input()) if a + b == c or a + c == b or b + c == a \ or a + a == b or b + b == a \ or a + a == c or c + c == a \ or b + b == c or c + c == b: print("YES") else: print("NO")
ec9e43af05614832215bbbad490fe38f4be7ef58
JangHJoon/PYTHON_STUDY
/180504/keywordFunc.py
289
3.625
4
def kF(kind, *args, **kwgs): """ args 남은 인수 kwgs 키워드를 설정한 인수들 """ print(kind) print("-"*30) for arg in args: print(arg) print("-"*30) for kw in kwgs: print(kw,":",kwgs[kw]) kF(1, 2, k=3) kF(1,2,3,4, k=4, g=5) kF((1,2),(1,2),(3,2),[1,2],{'k':2})
e17934ab932c870eefc51b8b08baa72cc69496db
Shashank01-26/Calculator
/Calculator.py
3,685
3.8125
4
from tkinter import * import parser root = Tk() root.configure(background="lightblue") root.title("Calculator") #get the user input i = 0 def get_val(num): global i display.insert(i,num) i += 1 def calculate(): entire_string = display.get() try: a = parser.expr(entire_str...
2404d426817f2176b4f169351aefc7d2de9c7dc1
mxu007/leetcode
/14_Longest_Common_Prefix.py
7,573
4.03125
4
# Write a function to find the longest common prefix string amongst an array of strings. # If there is no common prefix, return an empty string "". # Example 1: # Input: ["flower","flow","flight"] # Output: "fl" # Example 2: # Input: ["dog","racecar","car"] # Output: "" # Explanation: There is no common prefix amon...
55454910a3c81ae3f3217d6ad4eba49ed6510159
mxu007/leetcode
/581_Shortest_Unsorted_Continuous_Subarray.py
3,784
4.125
4
# Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. # You need to find the shortest such subarray and output its length. # Example 1: # Input: [2, 6, 4, 8, 10, 9, 15] # Output: 5 # Expla...
779d264224d95b723ebf6541836c5d537e840c65
mxu007/leetcode
/506_Relative_Ranks.py
2,284
4.03125
4
# Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal". # Example 1: # Input: [5, 4, 3, 2, 1] # Output: ["Gold Medal", "Silver Medal", "Bronze Medal", "4", "5"] # Explanation: The first three ...
1445b999492c40b4b2126d97bddc031b5df45954
mxu007/leetcode
/198_House_Robber.py
2,366
3.796875
4
# You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into ...
0f4082186ca082da8027f99556d134a29a679eff
mxu007/leetcode
/476_Number_Complement.py
5,609
4.03125
4
# Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. # Note: # The given integer is guaranteed to fit within the range of a 32-bit signed integer. # You could assume no leading zero bit in the integer’s binary representation. # Example 1: #...
baf2c1d410702bad1feddf9899794edeee2d9b24
mxu007/leetcode
/561_Array_Partition_I.py
2,665
3.828125
4
# Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible. # Example 1: # Input: [1,4,3,2] # Output: 4 # Explanation: n is 2, and the maximum sum of pairs is 4 = min(1, ...
387c2e1245560464e2c7952af309612c033a3dda
mxu007/leetcode
/303_Range_Sum_Query_Immutable.py
2,480
3.84375
4
# Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. # Example: # Given nums = [-2, 0, 3, -5, 2, -1] # sumRange(0, 2) -> 1 # sumRange(2, 5) -> -1 # sumRange(0, 5) -> -3 # Note: # You may assume that the array does not change. # There are many calls to sumRange functi...
88a6b09bbd4c933f14b174ac783a968cd5ffad26
mxu007/leetcode
/350_Intersection_of_Two_Arrays_II.py
1,962
4.09375
4
# Given two arrays, write a function to compute their intersection. # Example 1: # Input: nums1 = [1,2,2,1], nums2 = [2,2] # Output: [2,2] # Example 2: # Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] # Output: [4,9] # Note: # Each element in the result should appear as many times as it shows in both arrays. # The res...
c61144758e23993f9e390d2c9e86197edd6359ae
mxu007/leetcode
/67_Add_Binary.py
2,626
3.78125
4
Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" https://leetcode.com/problems/add-binary/description/ # 1) itearti...
e66624068cd931796b57fd1e179c2e1a0c16961a
mxu007/leetcode
/860_Lemonade_Change.py
2,229
4.09375
4
# At a lemonade stand, each lemonade costs $5. # Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). # Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer, so that the net t...
36c03b8c2cea1cc4088fb2417c062f4b08e331f1
mxu007/leetcode
/680_Valid_Palindrome_II.py
2,194
4.03125
4
# Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. # Example 1: # Input: "aba" # Output: True # Example 2: # Input: "abca" # Output: True # Explanation: You could delete the character 'c'. # Note: # The string will only contain lowercase characters a-z. The ...
296046fe3653160049aa5afdd132d9bf90c01b2b
mxu007/leetcode
/771_Jewels_and_Stones.py
2,077
3.96875
4
# You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels. # The letters in J are guaranteed distinct, and all characters in J and S are letters. L...
e898d4e4b96bf10bdba01c473cfa8de608ff158d
mxu007/leetcode
/414_Third_Maximum_Number.py
1,890
4.1875
4
# Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). # Example 1: # Input: [3, 2, 1] # Output: 1 # Explanation: The third maximum is 1. # Example 2: # Input: [1, 2] # Output: 2 # Explanation: The ...
e2452dcb9156c934b08ed537ebd96af838df04d8
mxu007/leetcode
/507_Perfect_Number.py
1,734
3.75
4
# We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. # Now, given an integer n, write a function that returns true when it is a perfect number and false when it is not. # Example: # Input: 28 # Output: True # Explanation: 28 = 1 + 2 + 4 + 7 + 14 # No...
f920c5931cc9897b3f578ab3e4208e8ebd6da0a5
mxu007/leetcode
/475_Heaters.py
4,017
3.90625
4
# Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses. # Now, you are given positions of houses and heaters on a horizontal line, find out minimum radius of heaters so that all houses could be covered by those heaters. # So, your input will ...
534a1c56f5551f7a2c548a434020ca2d6067fe78
mxu007/leetcode
/190_Reverse_Bits.py
2,599
4.03125
4
# Reverse bits of a given 32 bits unsigned integer. # Example: # Input: 43261596 # Output: 964176192 # Explanation: 43261596 represented in binary as 00000010100101000001111010011100, # return 964176192 represented in binary as 00111001011110000010100101000000. # Follow up: # If this function is called m...
cf33f8e7697cdbdddd7425ff3954fd40fe048e13
mxu007/leetcode
/766_Toeplitz_Matrix.py
4,602
4.46875
4
# A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. # Now given an M x N matrix, return True if and only if the matrix is Toeplitz. # Example 1: # Input: # matrix = [ # [1,2,3,4], # [5,1,2,3], # [9,5,1,2] # ] # Output: True # Explanation: # In the above grid, the diago...
afce6ee420f6bf4ae47a50344da504156a0d2e78
civrev/PythonTutorials
/DeepLearning/wages.py
4,916
4.09375
4
#building neural network with keras and tensorflow for regression #based on a course I got from Datacamp.com 'Deep Learning in Python' #python3 ~/Documents/pyfiles/dl/wages.py #imports #I set random seed to reproduce console output import pandas as pd import numpy as np np.random.seed(16) from urllib.request import ur...
92cc3b5be14bdcb256a680ea1868cde49afac550
civrev/PythonTutorials
/MachineLearning/boston2.py
4,680
3.703125
4
#more machine learning with boston dataset! #python3 ~/Documents/pyfiles/boston2.py #which by the way, is just the absolute file path of boston2.py on my computer #made based on the class I got from DataCamp.com 'Supervised Learning with scikit-learn' #this is a REGRESSION model but with more advanced features #import...