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
5b73e668e8caa6f6015486bae9b6eabb425a3f28
gunslingeratlarge/python-crawler
/day01_urllib2/regex/findall.py
139
3.734375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- import re pattern = re.compile(r"\d+?",re.I) m = pattern.findall("hello 123456 0988") print m
c8089f34d19abee2aed751a91ca4231ad79ba532
fiatveritas/Algorithms
/Stanford_Course/Greedy_Algorithms_Minimum_Spanning_Trees_and_Dynamic_Programming/greedy_algorithm_difference.py
4,569
3.640625
4
#!/usr/bin/python3 import random #for randomizing lists import time import math def open_file(file_name): f = open( file_name, 'r') if f: print("file read!") lines = f.readlines() f.close() return lines else: f.close() def make_tuples_weight_length(list_of_interest): return [(int(line.split()[0]), int(li...
602cc1834c3d634afa6cb85047206227e88f91eb
zaheebshamsi/Makkajai-Dev-Challenge
/sales_tax.py
5,268
3.515625
4
# Copyright (c) 07-Mar-2021, Zaheeb Shamsi. All other marks are the property of their respective owners. __author__ = 'Zaheeb Shamsi' import sys def sales_tax(product_list, product_type): """ :param product_list: a list of products entered by the user. Checks for 4 scenarios : ...
0ade6f92218b859dff72301c47ca419c5dd64a48
NoveltyOFD/SG-Basic-Gen.03
/DataLatihan/answer1.py
342
3.5625
4
data1 = "Data1.txt" def readData(data1): x = [] with open(data1) as data : for line in data : x = line.split() return x teks1 = readData(data1) isi = [] for i in teks1 : if i == 'I' : isi.append('*') elif i == 'and' or i == 'The' or i=='you': isi.append('*'*3) else : isi.append(i) asd = ' '....
1bfcd06ba8a170468a45d5328b994c731dde66df
Yael2mil/poo
/primer_cuatri/semana_5/palindromo.py
1,990
4.03125
4
class Palindromo: #Definimos la clase def __init__(self): #definimos el constructor pass def comprobador(self, x): #Definimos el metodo que va a analizar si el texto es palindromo VOCALES = ( #listas para reconocer vocales acentuadas ("á", "a"), ("é", "e"), ("í", "i"), ("ó", "o"), ("ú", "u"), ...
d1b74c547dcf220e632e7eb69c82f2d19879a6d7
arunkumarpatange/fib100
/pyd/strings.py
4,528
3.6875
4
from pyd.datastructure import Stack def is_funny_or_not(str): for i in xrange(1, len(str)/2 + 1): print abs(ord(str[i]) - ord(str[i-1])) print abs(ord(str[-i]) - ord(str[-i-1])) if abs(ord(str[i]) - ord(str[i-1])) != abs(ord(str[-i]) - ord(str[-i-1])): print "Not Funny" break else: print "Funny" i...
b75927b7b2d8ec63a9b0e602723f33e9040e15f0
Shubham230198/sample-programs
/archive/p/python/capitalize.py
379
4.03125
4
import sys def capitalize(input): if(isinstance(input, str)): print(input.capitalize()) else: print('Input is not a string') if(__name__ == '__main__'): if(len(sys.argv) == 1): print('Usage: provide a string as the first command line argument') else: capitalize(sys.argv...
6fd0c35c77ae384dcec7f81216771e5afc46a66c
waer24/Python-abc
/files/Fabonacci.py
846
4.09375
4
#输入一个大于等于3的值n,输出斐波纳契数列的前n项。 # 注:斐波纳契数列:1,1,2,3,5,8,13,21...前两项为1,从第3项起,每一项是前两项的和 # print('please enter a number:') # num = int(input()) # i = 0 # sum = 0 # res = [] # # if i == 0: # for i in range(1,2): # i += 1 # sum = 1 # res = sum # print(res) # if i >= 2: # for i in range(1...
b4d99cb288956ff35860e00d0998f0f97ed340c3
Weeeendi/Python
/Data_visionable/mpl_squares.py
384
3.75
4
import matplotlib.pyplot as plt input_values=[1,2,3,4,5] squares = [1, 2, 6, 15, 19] plt.plot(input_values,squares, linewidth=3) #set up title of figure,and label the coordinate axis plt.title("Square Numbers", fontsize=24) plt.xlabel("Value",fontsize=14) plt.ylabel("Square of value", fontsize=14) #设置标记刻度的大小 plt.tick...
3ed6b5cd5667da65e8284aefbf79c6000de1fd45
Weeeendi/Python
/INSERTION-SORT.py
254
3.71875
4
A = [5,1,7,2,4,3] print(A[0]) for j in range(1, len(A)): key = A[j] #insert A[j] into the sorted sequence A[0..j-1] i = j - 1 while i >= 0 and A[i] < key: A[i + 1] = A[i] i = i - 1 A[i + 1] = key print(A)
cd9c8d54a9e9473d9f16b820f403c85c0d1330b5
gnuchev/homework
/indexof.py
171
3.59375
4
def indexof(listofnames, value): if value in listofnames: value_index = listofnames.index(value) return(listofnames, value_index) else: return(-1)
c318ca570f5bffa95560fc13a6db502472133dc5
oskarmampe/PythonScripts
/number_game/program.py
538
4.15625
4
import random print("----------------------------------") print(" GUESS THAT NUMBER GAME ") print("----------------------------------") the_number = random.randint(0, 100) while True: guess_text = input("Guess a number between 0 and 100: ") guess = int(guess_text) if the_number > guess: ...
898495ff58191f981bd876ce6b26e0c836c97ba6
brianrayxu/market-magic
/survivor_simulator.py
1,304
4
4
import random, math #-----------------------------------------------------------------# def simulate(sample, start, trials): """ sample = number of accounts in the simulation start = initial account size trials = number of trials we're running for """ population = [] for num in r...
c0221f552870797cf2d338e3017479ff2c66bc4a
dvardoo/usersExcel
/massAdduser.py
1,536
3.53125
4
#Small script for creating users from an Excel file. #Imports necesary modules. import pexpect as px import pandas as pd #Reads the file without headers or index. file = pd.read_excel("Names_mod.xls", header=0, index=0) #Funktion for removing unnecasary parts from the cell containing the phonenumber. def phoneSplit(...
51e8537e8ed7ac2d6d3ac5a6ccd72d508d08beb9
cyrilleeleazarb/CS491-FinalProject
/PlayerClass.py
489
3.5625
4
# Player class class Player: def __init__(self, player): # 'X' or 'O' self.player = player # Set player as player 'X' or player 'O' def set_player(self, player): self.player = player def get_player(self): return self.player def mark_square(self, column, row, curren...
8ed2ee72189b451698cfbc5b861cdbe5136cd3bc
StefGian/python-first-steps
/teenagerStory.py
588
4.375
4
#first method with or age = input("How old are you?") if(int(age)> 18 or int(age)<13) : print("you are not a teenager") else: print("you are a teenager") #second method with and age = input("How old are you?") if(int(age)< 18 and int(age)>=13) : print("you are a teenager") else: print("...
3049443c9a563cdcecd50556ecd1aeb8e1db0e6b
StefGian/python-first-steps
/maxOfThree.py
370
4.40625
4
#Implement a function that takes as input three variables, #and returns the largest of the three. Do this without using #the Python max() function! a = int(input("Type the first number: ")) b = int(input("Type the second number: ")) c = int(input("Type the thrid number: ")) if a>b and a>c: print(a) elif...
e533458e95f51527aef084e83c5aa90061e0987f
bigguyG/APIGames
/iss.py
1,392
3.515625
4
import requests import json import urllib.parse import time address=input('Enter current location:') #Obtain and print relevant Google Maps API data google_api='http://maps.googleapis.com/maps/api/geocode/json?' url=google_api+urllib.parse.urlencode({'address':address}) json_data=requests.get(url).json() ...
b5acc4ec2623e97346176f18e75adfdb43258ef8
adambiser/isle-of-the-dead-extractor
/extractor/imagelabel.py
5,265
3.671875
4
# # A widget to view images. # import tkinter.tix as tix import PIL from PIL import Image, ImageTk, FliImagePlugin from tkinter import messagebox class ImageLabel(tix.Label): """ A widget that displays an image that scales to fill the widget area while maintaining the correct aspect ratio. Also supp...
5abd5d37bb3f6f0009887bafe93b8d0aca0cf08b
bhatanirudh/python
/Love cAlculator.py
849
3.84375
4
print("Welcome to the Love Calculator!") name1 = input("What is your name? \n") name2 = input("What is their name? \n") name1=name1.lower() name2=name2.lower() count_t=name1.count("t") + name2.count("t") count_r=name1.count("r") + name2.count("r") count_u=name1.count("u") + name2.count("u") count_e=name1.count("e") +...
6fbeed4937a8c1424570926860d6c93a57f80ab6
ClayFx/COMP1730-Lab
/Lab-3/factors.py
3,964
4.28125
4
## COMP1730/6730 S2 2019 - Homework 3 # Submission is due 11.55pm, Monday the 26th of August, 2019. ## YOUR ANU ID: u6234544 ## YOUR NAME: Xuan Feng ## You should implement the two functions `count_factors(n)` and ## `count_prime_factors(n)` below. The `pass` statement is only a ## placeholder which you should repl...
8d715f2ea07489d60c2f50d6d710a0a46e26513e
Akhichow/PythonCode
/High_lowtryagain.py
896
3.890625
4
low = 1 high = 1000 print("Please think of a number between {} and {}".format(low, high)) input("Press ENTER to begin") guess = 1 guesses = 0 while low != high: # print("\t Guessing in the range of {} and {}".format(low,high)) guess = low + (high - low) // 2 high_low = input("My guess is {}. Is...
412a520a55edcaa026306556a477ff4fe01bed4a
Akhichow/PythonCode
/challenge.py
632
4.125
4
vowels = set(["a", "e", "i", "o", "u"]) print("Please enter a statement") sampleText = input() finalSet = set(sampleText).difference(vowels) print(finalSet) finalList = sorted(finalSet) print(finalList) # [' ', 'I', 'c', 'd', 'm', 'n', 'r', 's'] # My solution - # finalList = [] # # while True: #...
7360f240ef261adb5a814574befe6a91467cb7d7
rust-master/Python-Learn
/function.py
144
3.84375
4
# Functions def add(x, y): return x + y a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) print(add(a, b))
33be482e21de8d1c36cbea80eb94ed7a0b74c9dc
rust-master/Python-Learn
/DecisionMaking.py
143
3.9375
4
marks = int(input("Enter your marks: ")) if marks >= 90: print("Grade A") elif marks >= 80: print("Grade B") else : print("Fail")
b05e582b768d47130c6d763717fd8c47fb7b3874
ahmadsaad58/Grading-Script
/Submissions/Sample.py
464
3.53125
4
# File: Sample.py # Description: A representation of a good student file # Student Name: Good Student # Student UT EID: ga123 # Course Name: CS 313E # Unique Number: 85575 # Days Late: 0 # say hello to user def greet(name: str) -> str: return "Hello, " + name + "!" # say good bye to user def bye() -> st...
3cfc819928e6416ed82aa2d8b7a737c0cf399abf
FlyBird-S/Python_study
/spider/lib_beautifulsoup/test_bs4.py
1,644
3.53125
4
#coding utf8 import re import urllib2 import urlparse from bs4 import BeautifulSoup response = urllib2.urlopen(r"https://baike.baidu.com/item/%E9%AD%94%E6%B3%95/194834") if response.getcode() != 200: print response.getcode() list = response.read() soup = BeautifulSoup(list,'html.parser',from_encoding=...
afaf90901a5d0caccde0546f588ed311043b6306
FlyBird-S/Python_study
/base/base_two/functional.py
2,054
3.703125
4
import math def add(x, y, f):# input funct_name return f(x) + f(y) print add(25, 9, math.sqrt) #list map(funct,list) def format_name(s): return s*s print map(format_name, [1,2,3,4]) def format_name(s): #capitalize() title() return s[0].upper()+s[1:].lower() print "das da".capitalize(),"wwww ddd"....
3e0fa5bfc8d47ee47dedef31b4ceb632ce7986b2
fansiguo/NeuralNetwork
/gradient_descent/gradient_descent.py
745
3.859375
4
#!/usr/bin/env python3 import numpy as np import matplotlib.pyplot as plt def problem(x): e = 2.71828182845904590 return x[0]**5 + e**x[1] + x[0]**3 + x[0] + x[1] - 5 def error(x): return (problem(x)-0)**2 def gradient_descent(x): delta = 0.00000001 derivative_x0 = (error([x[0] + d...
d8a045f873127abf2e2443df489aa72c7298d8b8
yma010/hangman-py-project
/ps3_hangman.py
3,663
4.125
4
# Hangman game # import random WORDLIST_FILENAME = "words.txt" def loadWords(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the word list, this function may take a while to finish. """ print("Loading word list from file...") ...
60d00c0a404a950786d0f83affd95e35f8fe00f3
JasmineEllaine/fit2004-algs-ds
/Week 1/Tute/8-problem.py
623
4.25
4
# Write code that calculates the fibonacci numbers iteratively. # F(1) == F(2) == 1 def fibIter(x): seq = [1, 1] # Return fib(x) immediately if already calculated. if (x <= len(seq)): return 1 for i in range(1, x-1): seq.append(seq[i]+ seq[i-1]) return seq[-1] """ Time complexity: ...
d266b8a6b63be5fa5f86f294f07b1008103f3432
davidcotton/algorithm-playground
/src/dynamic_programming/min_steps_to_one.py
1,120
4.03125
4
"""Minimum Steps to One. On a positive integer, you can perform any one of the following 3 steps. 1.) Subtract 1 from it. ( n = n - 1 ), 2.) If its divisible by 2, divide by 2. (if n % 2 == 0, then n = n / 2), 3.) If its divisible by 3, divide by 3. (if n % 3 == 0, then n = n / 3). Now the question is, given a po...
1693a547bd0278f0675a13ee34e1fa63ee86a00c
davidcotton/algorithm-playground
/src/graphs/bfs.py
1,790
4.1875
4
"""Breadth-First Search Search a graph one level at a time.""" from collections import deque from typing import List, Optional from src.graphs.adjacencylist import get_graph from src.graphs.graph import Graph, Vertex def bfs_search(start: Vertex, goal: Vertex) -> Optional[List[Vertex]]: """Search for the goal v...
f2638c03eb06f73ef9a98510d7391bf7c852e140
davidcotton/algorithm-playground
/src/text_processing/trie.py
705
3.609375
4
"""Trie.""" class DefaultTrie: def __init__(self): self.root = Node @staticmethod def search(p, t): pass @staticmethod def find(node, key): for char in key: if char in node.children: node = node.children[char] else: ...
4e47d3878d8fd332d5f42ead36bca6b4bf12cb8a
davidcotton/algorithm-playground
/src/datastructures/map.py
4,138
4.25
4
"""Hash table.""" from abc import ABC, abstractmethod import math import random class Map(ABC): @abstractmethod def __init__(self, *args): for k, v in args: self.put(k, v) @abstractmethod def size(self) -> int: """Returns the number of elements in the map.""" pass...
4c67a8c0bb260235355a02caddad7d0d9c75a7e6
recursivecurse/Krishi-Seva
/functions.py
681
3.71875
4
from tkinter import * from tkinter import messagebox from PIL import Image, ImageTk #Functions are defined as follows def printt(): pass def quit(): exit() def about(): messagebox.showinfo("Demo","This is just a demo for menu buttons") def newWindow(): nwindow = Tk() nwindow.geometry("300x200")...
0247257d7baf3c98a3baa325a471e2a9ee3c3f24
mjb527/animals
/util.py
222
3.96875
4
# !usr/bin/python3 def getYesNoInput(): res = input("Enter Yes or No\n") if(res.lower().strip() == "yes"): return True elif(res.lower().strip() == "no"): return False else: getYesNoInput()
3e45b85ef5f23c04f70a185f66eee7910bd3499b
MasazI/Hi-Performance-Python
/prime.py
571
3.90625
4
import math import sys def check_prime(number): sqrt_number = math.sqrt(number) number_float = float(number) for i in xrange(2, int(sqrt_number)+1): if (number_float / i).is_integer(): return False return True if __name__ == '__main__': argvs = sys.argv argc = len(argvs) ...
2a44ee31fda450a5c04c201717be380f73ab205b
ernestyalumni/Tutorial-on-MetaClasses-for-Python--thanks-to-Eli-Bendersky
/tutmetacls.py
5,822
4.0625
4
# tutmetacls.py # Based on Eli Bendersky's website Python metaclasses by example # Shout outs to Eli Bendersky for his excellent website with excellent examples # # 20140607 # # Fund Science! & Help Ernest finish his Physics Research! : quantum super-A-polynomials - Ernest Yeung # ...
e696749aa47296d49c24c2c5adc3b16c9e2ba8c5
gunthercox/mathparse
/tests/test_replace_word_tokens.py
986
3.625
4
from unittest import TestCase from mathparse import mathparse class EnglishWordTokenTestCase(TestCase): def test_addition(self): result = mathparse.replace_word_tokens('1 plus 1', language='ENG') self.assertEqual(result, '1 + 1') def test_thirty(self): result = mathparse.replace_wor...
7e64e845366f95123d34c8c766064cc6dcb42c6c
girishf15/Python-Data-Structures
/Data_Structures/Sorting/bubble.py
829
4.125
4
def bubble_sort(arr): swapped = True while swapped: swapped = False for i in range(len(arr) - 1): if arr[i] > arr[i + 1]: arr[i], arr[i + 1] = arr[i + 1], arr[i] swapped = True # print(arr) return arr arr = [5, 7, 2, 47, 11, 10, 2, 3, ...
ef9d8af15889c4cd8c9a4105b5022dbcfa43feed
girishf15/Python-Data-Structures
/Data_Structures/Stack/stack_using_list.py
755
4.21875
4
# __author__ : girish ''' Stack in Python can be implemented using following ways: list collections.deque queue.LifoQueue ''' class StackTest: def __init__(self, stack=[], length=0): self.stack = [] self.stack_length = length def push(self, element): if len(self.stack) ...
f6f77d6f27542d7dba4919610d59dcebeb59674f
Jyin98/Mini-projects
/binary_converter/Basetenconverter.py
2,431
4
4
#DecimalToBinary.py # #Description: This program will convert base ten numbers to base two. # #Coded by John invalid = True; running = True; while(running): decimal = 0; binary = []; output = ''; output2=''; output3=''; output4=''; output4L=[]; output5=''; output5...
dae56ccc3994c839ad232c1f7c5b6b881a0d59ac
raulmogos/uni-projects
/FP/labs/obstruction/tests.py
1,068
3.625
4
from unittest import TestCase from ObstructionGame import Square, Board, Game class TestSquare(TestCase): def setUp(self): self.__sq = Square(1, 2) def test_row(self): self.assertEqual(1, self.__sq.row) def test_col(self): self.assertEqual(2, self.__sq.col) class TestBoard(Test...
0e8d70c240bb55196ed73debd8a3e007752126f9
raulmogos/uni-projects
/FP/labs/tema lab 05-07/ui_package/ui_console_module.py
13,958
3.625
4
''' ''' from errors.Errors import RepoError from errors.Errors import ValidError class Console(object): def __init__(self, serviceBook, serviceClient, serviceRental, undoService): self.__serviceBook = serviceBook self.__serviceClient = serviceClient self.__serviceRental = serviceRental ...
1cb441682be90079d43c9de98d42e4e4c0393725
raulmogos/uni-projects
/FP/labs/tema lab 01/set_A_p1.py
1,275
4.15625
4
''' PROGRAM THAT GENERATES THE FIRTS PRIME NUMBER AFTER A NUMBER N INPUT: N - a natural number OUTPU: P - THE FIRTS PRIME NUMBER AFTER N ''' def e_prim(x): ''' FUNCTION THAT CHECKS IF X PRIME OR NOT INPUT: X - a number OUTPUT: TRUE - IF X IS PRIEM FALSE - OTHER...
99f0af8b882d96b8f8bc6df1aa35110b17cbcea7
MihirMalani1712/PPL_LAB
/Assignment/Assignment6/shapes.py
1,190
4.15625
4
import turtle s = turtle.getscreen() t = turtle.Turtle() class shape: def __init__(self, sides = 0, length = 0) : self.sides = sides self.length = length class polygon(shape): def info(self): print("In geometry, a polygon can be defined as a flat or plane, two-dimensional with stra...
660aea75a1024b16e007b6dcdef4aca6cdf6ae77
blane612/for_loops
/tertiary.py
470
4.40625
4
# -------------------- Section 3 -------------------- # # ---------- Part 1 | Patterns ---------- # print( '>> Section 3\n' '>> Part 1\n' ) # 1 - for Loop | Patterns # Create a function that will calculate and print the first n numbers of the fibonacci sequence. # n is specified by the user. # # NOT...
c7242391e25da142dde776212f572e56693c3dcc
8ORI5/python_projects
/hangman/main.py
1,856
3.984375
4
# simple implementation of hangman game import random import string secret = ['PYTHON', 'java', 'kotlin', 'javascript'] word = random.choice(secret) play = True print("H A N G M A N") while play: ascii = string.ascii_letters random.seed() answer = random.choice(secret).lower() current = list("-" * ...
78ad24dfafe680d37b8f95d80bd4aeed811353ef
johnjkiran/session1-epai_jk
/session1.py
1,041
3.859375
4
def myFunc(): string='Cppsecrets' n=len(string) arr=[] for i in range(n): for j in range(i+1,n+1): a=string[i:j] arr.append(a) print(arr) def my_Func(): pass class Rectangle: ''' This is a Rectangle Class. 1. If r = Rectangle...
78982c98f4b467e5b335d3908a0a33f6a1ac7770
wujinfeng/pythonDemo
/example/fibonacci.py
1,163
3.546875
4
# 斐波那契数列实现 # 方法1 # num = int(input('你需要几项?')) # f1 = 0 # f2 = 1 # if num <= 0: # print('请输入一个正整数') # elif num == 1: # print('斐波那契数列:%d' % f1) # else: # print('斐波那契数列:', end='') # print(f1, f2, end=' ') # for n in range(1, num - 1): # f = f1 + f2 # f1, f2 = f2, f # print(f, e...
44db8f0a764a4af6a94741f114a801c6c3ab5de9
JJBarata/python3oo
/fatorial.py
392
4.21875
4
# Calculando o fatorial de um número: def fatorial(num): if num < 0: print('Não existe fatorial de número negativo. tente novamente!') elif num == 1: return 1 else: fact = 1 while num > 1: fact *= num num -= 1 return fact num = int(input('Dig...
aaa5cc40622e6c57737355bbd15407d7812cd1ad
konradrybicki/kryptografia
/Ćwiczenie 6/MyBlockchain/src/main.py
1,068
3.78125
4
# -*- coding: utf-8 -*- """ Moduł główny, odpowiadający za interakcję z użytkownikiem """ from src.Blockchain import Blockchain blockchain = Blockchain() blockchain.loadData() while(True): print() print("MyBlockchain 2021") print("-----------------") print("1. Show blockchain") print("2. Ad...
b39ac4d66464b1eda932fca9189e394ed94d7fc6
konradrybicki/kryptografia
/Ćwiczenie 3/PasswordHashing/src/User.py
1,800
3.640625
4
# -*- coding: utf-8 -*- from src import HashingModule from src.SQLManager import SQLManager class User: """ Klasa definiująca strukturę oraz zachowania użytkownika """ def __init__(self, login, password): self.login = login self.password = password def register(self): ...
0a36a3f9ecca8fe5d292c1264338f1908810d7dc
dongyoungkim-dy/Python-coursera
/[3] P4E/Page Rank.py
292
3.9375
4
score = input("Enter Score: ") sc = float(score) if sc >1.0 : print("Error, please enter the score in between 0 and 1.0") if sc >= 0.9: print("A") elif sc >= 0.8: print("B") elif sc >= 0.7: print("C") elif sc >= 0.6: print("D") elif sc < 0.6: print("F")
38107eee75c3bf01cac4e683227ee7c81ee764b9
AhiltonC/CursoPython
/Modulo2/Ejercicios/diversos2.py
658
3.921875
4
cant=int(input("Ingrese la cantidad de alumnos: ")) lista_alum=[] for i in range(cant): alumno={} nombre=input("Ingrese nombre del estudiante: ") alumno['nombre']=nombre alumno['notas']=[] for n in range(3): nota = float(input(f'Ingrese la nota {n+1} del alumno: ')) alum...
a636f07a4b0177e347795245496f9c1f6f0bb468
thisusernameistaken/PICO2013
/PICOCTF2013/EXTRA SCRIPTS/Bit(FIXED).py
252
3.546875
4
verify_arr = [193, 35, 9, 33, 1, 9, 3, 33, 9, 225] all_chars = range(0, 255) for hash1 in verify_arr: for char1 in all_chars: charHash = ((char1 << 5 | char1>> 3) ^111) & 255 if charHash == hash1: print (unichr(char1))
17fa3f5eeaadc5a60f31495416f3c143847dc38a
vadysa/box-plots-for-education
/1st-place/code/MakeDatasets.py
3,145
3.515625
4
############################################################################## # MakeDatasets.py - script to create datasets in a format conducive to # multi-multi classification and submission generation. # # For: DrivenData.org/ERS's BoxPlots for Education Competition # License: MIT (http://machinelearner.net/boxplo...
c05618bf2d2a60e4dc92fb37e66cdc41e2c81552
kinchit/MIT-ComputationalThinkingUsingPython
/MIT-6.00.1x/TryExceptWhile.py
143
3.5625
4
while True: try: a = input("Tell me first number:") a = int(a) break; except: print('Type Error')
97c787e5126aca2499067b57345549b265267da1
kinchit/MIT-ComputationalThinkingUsingPython
/MIT-6.00.1x/BisectionSearchCube.py
327
3.671875
4
x = 27 epsilon = 0.01 guess = 0 low = 0.0 high = x ans = (low + high)/2.0 while abs(ans ** 3 - x) >= epsilon: print("Low: ", low, " High: ", high) if ans ** 3 < x: low = ans else: high = ans ans = (low + high)/2.0 guess += 1 print("Number Of Guesses: ", guess, " Guess: ...
3559cd883c62161a0762c977397cb55c50340f40
kinchit/MIT-ComputationalThinkingUsingPython
/MIT-6.00.1x/LinkedList.py
622
4
4
# -*- coding: utf-8 -*- """ Created on Fri May 1 20:38:53 2020 @author: kinchitr """ class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def printList(self): temp = self.head ...
918e73ade6b27cb7145ea928c3a71b1722bfc6f1
kinchit/MIT-ComputationalThinkingUsingPython
/MIT-6.00.1x/isPoly.py
446
4.0625
4
def isValid(alist): temp = alist[:] temp.reverse() if temp == alist: return True else: return False def isPoly(): word = [] num = int(input("Enter the number of characters: ")) for i in range(num): ch = input("Enter Charater for word: ") word.a...
ab822bf98f38705b00c83e22f69a5a80fb0c5b2f
andruxa-smirnov/textclusteringDBSCAN
/3_distance.py
4,265
3.515625
4
#this program finds the distance between two files. The distance is measured from the tfidf scores of two files. #the function which finds the distance is matchscore(), the input parameters to the function is the names of the two files. import glob,os,sys class distance: def __init__(self): print("Distance module...
95129d5f96010051bd27f1a59ec4aa7e0b6024d6
eldar-nurtdinov/Python_tutorial
/task 3.py
353
4
4
def fibonacci(a): z = 1 if a > 2: z = fibonacci(a-1) + fibonacci(a-2) return z a = int(input('введите номер числа из последовательности Фибонначи')) c = [1] i = 1 x = 1 while i < a: c.insert(i, x) x = c[i] + c[i-1] i = i+1 print(c) print(fibonacci(a)) print(c[a-1])
7db6da330358ddc852363d6e1814668149edcf5d
Hamza50537/Deep-Learning
/Vectorization/Vectorization vs For loop.py
705
4
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np input_array=np.array([5,6,7,8,9,10]) print(input_array) # In[7]: import time alpha=np.random.rand(1000000) beta=np.random.rand(1000000) before=time.time() output=np.dot(alpha,beta) after=time.time() print(output) print("Vectorized Version: "+s...
e0ad92f4c8c1d1764745e178f7f6ac624eee00e6
GHLisz/ComposingPrograms
/Chapter1_BuildingAbstractionswithFunctions/1_6_4_FunctionsasReturnedValues.py
355
3.703125
4
# http://composingprograms.com/pages/16-higher-order-functions.html def square(x): return x * x def successor(x): return x + 1 def compose1(f, g): def h(x): return f(g(x)) return h def f(x): """Never called.""" return -x square_successor = compose1(square, successor) result = s...
f1bc0186c4f1e745ff2a8de8a994d269969dec43
GHLisz/ComposingPrograms
/Chapter1_BuildingAbstractionswithFunctions/1_6_9_FunctionDecorators.py
320
3.671875
4
# http://composingprograms.com/pages/16-higher-order-functions.html def trace(fn): def wrapped(x): print('-> ', fn, '(', x, ')') return fn(x) return wrapped @trace def triple(x): return 3 * x print(triple(12)) # equals to below def triple(x): return 3 * x triple = trace(triple)
7c079f00bb0bc1cd5d65505ef98f8b22b3855155
hmdantas/py-data
/blindAlignment.py
4,068
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Implementação do algoritmo "Blind Alignment" publicado em: Cauteruccio F., Fortino G., Guerrieri A., Terracina G. (2014) Discovery of Hidden Correlations between Heterogeneous Wireless Sensor Data Streams. In: Fortino G., Di Fatta G., Li W., Ochoa S., Cuzzocrea A., P...
109448adde53fefd8aba6c4bcb2d8bbc262007fa
valuntiny/leetcode_math_ii
/trailingZeroes_re.py
801
4
4
""" Quest: Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: 5 Output: 1 Explanation: 5! = 120, one trailing zero. Note: Your solution should be in logarithmic time complexity. ...
ba9d9499bbee323b7a6624ef73957bec8948c7f3
LogistyxCat/crash-course-python
/toppings.py
424
4.03125
4
#! python3 available_toppings = ['mushrooms','olives','green peppers', 'pepperoni','pineapple','extra cheese'] requested_toppings = ['mushrooms','french fries','extra cheese'] for topping in requested_toppings: if topping in available_toppings: print("Adding " + topping + ".") ...
8e6a489015f267aa98626a5c46f5d16b8b25bf94
LogistyxCat/crash-course-python
/list.py
504
3.625
4
#! python3 names = ['nolan','nury','sabastian','kiernan'] print("Good afternoon, " + names[0].title() + ".") print("Good afternoon, " + names[1].title() + ".") print("Good afternoon, " + names[2].title() + ".") print("Good afternoon, " + names[3].title() + ".") print() print("Original: \n" + str(names) + "\n") names....
b9e63f24013cba1cdd5981912fc62886c8904c3c
BlakeBrown/ABCS
/Heaps/average waiting time.py
966
3.515625
4
#!/bin/python3 import os import sys import heapq # # Complete the minimumAverage function below. # def minimumAverage(customers): heapq.heapify(customers) N = len(customers) pizzas = [] time = 0 totalWaitingTime = 0 while len(customers) > 0 or len(pizzas) > 0: while len(customers) > 0 and customers[...
be56727dd409eaa5767c41f65e2524b149f11ee7
davidms01/howtopyramid
/how_to_pyramid.py
761
3.515625
4
def ejercicio2(): j = 2 number_of_tries = int (input ()) # Numero de intentos numeros = [] for i in range (number_of_tries): numeros.append (int (input())) # Guardo cada intento for i in range (len(numeros)): # Para cada intento: # Mantengo dos contadore...
6c51c2c29a4c06fb1ea249756bd7645e3b030c35
Cap-Vin-Spime/mvmipy
/Computer Science Record.py
13,818
4.1875
4
#1 #TO LINEAR SEARCH AN ELEMENT IN A LIST AND DISPLAY THE FREQUENCY AND LOCATION def fun(l,x): count=0 for i in range(0,len(l)): if l[i]==x: print("Found location :",i) count+=1 print("Frequency of element :",count) a=eval(input("Enter a list :")) b=eval(input("Elem...
5472b89063b013fe94a4a45b57e91a81ba3ed4e1
unsik-kim/python_study
/class/21_5.py
221
3.90625
4
import turtle as t vertext, length = map(int, input().split()) angle = int(360 / vertext) t.shape("turtle") for i in range(vertext): t.forward(length) t.right(angle * 2) t.forward(length) t.left(angle)
54f2955f2613121246cb2c79dc943dabbb2334ac
unsik-kim/python_study
/class/17_2.py
183
3.78125
4
import random i = 0 while i != 1 : i = random.randint(1,45); print(i) for i in range(5) : for i in range(6) : print(random.randint(1,45), end='\t') print()
728774b8b079d07080ab32a72c3e5e0a6e51c4d4
WeeJang/basic_algorithm
/FindDuplicateSubtrees.py
1,619
4.09375
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """ Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them. Two trees are duplicate if they have the same structure with same node values. """ """ 其实这个问题考察的是 前/中/后序遍历的使用场景。 前序:先访问...
1fe9c200c7713bfbbb945b21b778af6b198007f9
WeeJang/basic_algorithm
/BiparGraphJudge.py
1,879
3.796875
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """N个学生,m对相互认识,问能否分成两组,让组内的人都互相不认识 """ #N个学生 N = 10 elems = range(N) friends = [(1,2),(4,5),(1,5),(2,4)] #friends = [(1,2),(4,5),(1,5),(1,4)] def is_bipar_graph(elems,friends): """ 二分图 判定(至少有两点,且所有回路的必须是偶数,不存在奇环 染色法 """ #结点染色字典 -1 未染色,0 red 1 black color_dict ...
452c04dfcbee4226b9460f82b492280e5a23a3f7
WeeJang/basic_algorithm
/GetMaxPathSumFromBinaryTree.py
653
3.5
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """ 返回二叉树最大路径的和 """ class Node(object): def __init__(self,value): self.value = value self.left,self.right = None,None """ DP 解决""" def get_max_path_sum(tree): def cal_tree(tree): """ 返回当前tee的最大路径和,和最大深度 (max_path_sum,max_deepth) """ if tree is None: ...
b45cee1cca2194752b5ec869294499fe8a1bf789
WeeJang/basic_algorithm
/InsertElemToBST.py
453
3.765625
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- class Node: def __init__(self,value): self.value = value self.left,self.right = None,None def insert_elem_into_BST(bst,value): def helper(c_bst,value): if c_bst.value > value: if c_bst.left == None: c_bst.left == Node(value) else: helper(c_bst.left...
f0d0497cde70eec25134ddfffb34ef82b72cf1b0
WeeJang/basic_algorithm
/SumOfFour.py
936
3.71875
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """ sum of four number # 排序 -> 搜索(DFS)-> 剪枝 """ def find_target_list(num_list,target,K,start_pos,end_pos): if target == 0 and K == 0: return [[]] if K == 0: return None if (end_pos - start_pos + 1) < K: return None if K > 0 and num_list[start_pos] > target: ...
1d723e06dbf3f04fb48a545eb42d8ffec62970ff
WeeJang/basic_algorithm
/Combination2.py
702
3.5
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """ 数组所有的可能排列组合 如[1,1,2] => [ [1,1,2], [1,2,1], [2,1,1]] """ import copy def AllCombination(array): """ """ def dfs(elems): """ 返回elems的全排列 param : list[int] return : list[list[int]] """ if len(elems) == 1: return [elems] res = [] visited = set() ...
d6192566a5778e4c5ec9536c5f30db470bca7439
WeeJang/basic_algorithm
/ShuffleanArray.py
1,260
4.28125
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """ Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums); // Shuffle the array [1,2,3] and return its result. Any permutation of [1,2,3] must equally likely to be returne...
4c8e86b293191c5e7c82a8b68b485f2870cd2c42
WeeJang/basic_algorithm
/SubsetI.py
1,404
3.796875
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """ 求子集问题(里面没有重复元素) Given a collection of integers that not contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2], a solution is: [ [2], [1], [1,2], [] ] ...
a84406c39f7b6cdb4bf810d8be9ecdc2766e1c2c
WeeJang/basic_algorithm
/MiddleOfArray.py
1,437
3.84375
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- """ 取两个排序数组的中位数(取两个排序数组的第K位数) """ def get_middle_of_arrays(array_a,array_b): """ middle of arrays """ def find_K_th(k,array_a,array_b,p_as,p_ae,p_bs,p_be): print "====K",k,"p_as",p_as,"p_ae",p_ae,"p_bs",p_bs,"p_be",p_be len_a = (p_ae -p_as + 1) len_b = (p_be -p_...
00fc6e8a50b2459bef08a0905d5ef8dec4b83c9d
luzangelarojasprieto/proyecto_semana1
/SEMANASANTA3.py
1,174
3.859375
4
#cargar la librería para GUI from tkinter import * #crear la ventana ventana = Tk() ventana.title("Calculo semana santa") ventana.minsize(300, 200) #agregar etiqueta Label(ventana, text="Año a calcular:").grid(row=0, column=0) #Agregar cajas de texto txtAño = Entry(ventana, width=10) txtAño.grid(row=0, co...
4f5b085dba1b78ddb4eef4519aaea3388b2167e9
albinafrolova/pythonProgramming
/WhileLoop.py
187
3.640625
4
#!/usr/bin/python # Simple while loop a = 0 while a < 15: print a, # Trailing comma supresses auto newline. if a == 10: print "made it to ten!!" a = a + 1
fe4b811a784dae6d93cb386bfee3f7338a1d7e3d
C-GDA-TC1028-005-2113/tarea1-CarlosRojasMedina
/assignments/03Promedio/src/exercise.py
354
3.71875
4
def main(): #escribe tu código abajo de esta línea a=float(input("Calificación de la materia: ")) b=float(input("Calificación de la materia: ")) c=float(input("Calificación de la materia: ")) d=float(input("Calificación de la materia: ")) e=(a+b+c+d)/4 print("El promedio es:",e) if __name_...
b3a2b03c03dfbdcec33b527b12b85608ed66ac59
ynonp/innoviz-advanced-python-software
/session2/object_oriented/syntax.py
308
3.578125
4
class Pet: def __init__(self, name): self.name = name self.age = 0 def bark(self): print("Wuff, Wuff") def grow_up(self): self.age += 1 p = Pet("Rocky") print(p.name) q = Pet("Jimmy") print(q.name) p.bark() p.grow_up() p.grow_up() p.grow_up() print(p.age)
957bb33f4814d6d4fe06bacd8438d786212e90fb
cckrishna/Livermore-2020-Fall-Python-Class
/Basics/Greetings.py
215
4.03125
4
# Greetings by name program # Accept a name - user input name = input("Enter your name: ") # Print the greeting with name print("Welcome to Python Programming", name) print(name, "Welcome to Python Programming!")
a19a91eb07f98d2b418581ede0e79e8f7281a265
alu0100834024/prct04
/src/ej_26.py
551
3.859375
4
from math import sqrt a=float(raw_input('Valor de a:')) b=float(raw_input('Valor de b:')) c=float(raw_input('Valor de c:')) if a==0 and b==0 and c==0: print 'La ecuacion tiene infinitas soluciones' else: if a==0 and b==0: print 'La ecuacion no tiene solucion' else: if a==0: x=-c/b print '...
40b18f98a3aae540d657057c9e39f81e9fd2746c
JakeJaeHyongKim/I211
/lecture 16-1(xml, tree parsing).py
251
3.5625
4
import xml.etree.ElementTree as ET root = ET.parse("students.xml") elements = root.iter() for elem in elements: print("Tag Name: ", elem.tag) print("Tag Text: ", elem.text) print("Children: ", list(elem)) print("-"*20)
ddcf17747d04fc0aeeb42911f188ce84712838e0
JakeJaeHyongKim/I211
/lecture 8-1(directory, file space).py
684
4.03125
4
#first, import OS #looks through all objects in directory #find total size of all files in bytes in that directory #use for loop to get all the file names in directory #for file, append to calculation #for folder,return to path #use os.path.getsize(file_name) with the file names that I got by for loop impo...
023e609eb767a6e0ec588b79fd38567e82c84225
JakeJaeHyongKim/I211
/lab 3-4(list comp, combined number in list).py
549
4.15625
4
#lab practical example #appeal only what I need as output, #1= sort it nums = ["123", "321", "435", "2468"] num_order = [num for num in nums if [digit for digit in num] == \ sorted([digit for digit in num])] print(num_order) lst1 = [1,2,3] lst2 = sorted([1,2,3]) #2= only odd numbers as ...
0cf4971577485c6476abeb98981d55a12650860f
JakeJaeHyongKim/I211
/lecture 15-2(SICE images, download all images from a link to folder).py
537
3.515625
4
#create folder #1. go to see url page #assign variable to link #download "image" files from the link to the folder that I created #Leave their original names import urllib.request, os, re def image_list(page): web_open = urllib.request.urlopen(url) contents = web_open.read().decode(errors = ...
788492173fdbcb18905c26ede1816705b670c1a1
JakeJaeHyongKim/I211
/group-hw3-3-4.py
818
3.859375
4
import sqlite3 db_con = sqlite3.connect("my_db.txt") cursor = db_con.cursor() userin1 = input("Who would you like to update?") userin2 = input("Please enter new title. ") userin3 = input("Please enter new email. ") userin4 = input("Please enter new areas. ") def update(cursor): SQL = "UPDATE...
af73c7286fa064ce93efc5302c7e3987578ab04f
JakeJaeHyongKim/I211
/lab 3-5(list comprehension, word to dash as output).py
221
3.859375
4
secret = input("Please enter the secret: ") secret_red = ["-" for let in secret if let.isalpha()] #.isalpha() is alphabets in letter #.isdigit() is digits in number print("redacted: ", "".join(secret_red))
5bf0db55a5bc7ca89f4e02cc1d0bbf195629bf45
JakeJaeHyongKim/I211
/lab 3-3(list comprehension, word to upper case).py
378
4.1875
4
#word list comprehension #if word contains less than 4 letters, append as upper case #if not, leave it as it is words= ["apple", "ball", "candle", "dog", "egg", "frog"] word = [i.upper() if len(i) < 4 else i for i in words] #not proper: word = [word.upper() if len(words) < 4 else word for word in words] #learn ...
445d7000c2aa6b9604a773932dfd074e345b247a
giocarro/BubbleSort-and-Words-Sort
/WordSort2.py
572
4
4
#!/env/bin/python def bubbleSort(data): n=0 m=0 l=len(data) r1=range(l) s=l-1 r2=range(s) for i in r2: for j in r2: if j==s: break elif data[j]>data[j+1]: a=data[j] data[j]=data[j+1] data[j+1]=a ...
de4cdd4606b6f7c44e9145d945674c651152143d
joshiprashanthd/neural_network
/deep_learning_library/activations.py
3,160
3.90625
4
# Author: Prashant Joshi # time: 12/29/2019 5:46 PM """ Activation perform non-linear operations on the output values, calculated by W * X + B """ from tensor import Tensor import numpy as np class Activation: """ The base class for the activation function. """ def func(self, inpu...