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
5b5b2327e84313fca65952be1f103454b6f63797
annatjohansson/complex_dynamics
/Python scripts/M_DEM.py
2,566
3.8125
4
def M_Dist(cx, cy, max_it, R): """Computes the distance of a point z = x + iy from the Mandelbrot set """ """Inputs: c = cx + cy: translation max_it: maximum number of iterations R: escape radius (squared)""" x = 0.0 y = 0.0 x2 = 0.0 y2 = 0.0 dist = 0.0 it = 0 ...
bb975ed0ea6680a8f09e4f7307c3cc56bde2d83d
NguyenThienBao/SE_Python
/Lab01/Demo02.py
274
3.859375
4
def main(): a = 10 print(a) b = int(input("Plz enter a number: ")) print(b) c = float(input("Plz enter a float number: ")) print(c) d = b + c print("b + c = d - ", str(b) + " + " + str(c) + " = ", d) if __name__ == '__main__': main()
be63345a6c6a052fa14e442f14548633f118a34f
MurliCSE/LearningPython
/Learning.py
2,697
4
4
# Singe line comment ''' Multi Line comment ''' #Welcome to Python! ''' Python is a high-level programming language, with applications in numerous areas, including web programming, scripting, scientific computing, and artificial intelligence. It is very popular and used by organizations such as Google, NASA, the CI...
811d54bfdd3d88b7b048218cde9aae2d35c643ce
TheMellyBee/udacity-projects
/support-classes/linear-alg/quiz1.py
317
3.609375
4
from vector import Vector vector1 = Vector([8.218,-9.341]) vector2 = Vector([-1.129, 2.111]) print "One" print vector1.plus(vector2) print "Two" vector3 = Vector([7.119, 8.215]) print vector3.minus(Vector([-8.223, 0.878])) print "Three" vector4 = Vector([1.671, -1.012, -0.318]) print vector4.scalar_mult(7.41)
0232446325b58ecb878807316e3007eff77940fe
lalitp20/Python-Projects
/Self Study/Basic Scripts/IF_STATEMENT.py
213
4.34375
4
# Example for Python If Statement number = int(input(" Please Enter any integer Value: ")) if number >= 1: print(" You Have Entered Positive Integer ") else: print(" You Have Entered Negative Integer ")
c60128013d7e1ae2ccbf729b611e3135b51ed40e
lalitp20/Python-Projects
/Self Study/Basic Scripts/Comparison Operator.py
298
3.96875
4
a = 9 b = 4 print(" The Output of 9 > 4 is : ", a > b ) print(" The Output of 9 < 4 is : ", a < b ) print(" The Output of 9 <= 4 is : ", a <= b ) print(" The Output of 9 >= 4 is : ", a >= b ) print(" The Output of 9 Equal to 4 is : ", a == b ) print(" The Output of 9 Not Equal To is : ", a != b )
5f3d608227e523bb63f4a45e60bd9f9a120ef346
lalitp20/Python-Projects
/Self Study/Basic Scripts/Bit Wise Operators.py
347
3.90625
4
a = 10 b = 12 print("Bitwise AND Operator On 9 and 65 is = ", a & b) print("Bitwise OR Operator On 9 and 65 is = ", a | b) print("Bitwise EXCLUSIVE OR Operator On 9 and 65 is = ", a ^ b) print("Bitwise NOT Operator On 9 is = ", ~a) print("Bitwise LEFT SHIFT Operator On 9 is = ", a << 1) print("Bitwise RIGHT SHIFT Opera...
c0597e939d13b6fdecd2e374868a4547128ee79a
lalitp20/Python-Projects
/Self Study/Basic Scripts/String Indexing_1.py
377
4.125
4
x = (11, 21, 31, 41, 51, 61, 71, 81, 91) # Positive Indexing print(x[0]) print(x[3]) print(x[6]) print('=======\n') # Negative Indexing print(x[-1]) print(x[-5]) print(x[-7]) print('=======\n') # Accessing Nested Tuple Items Mixed_Tuple = ((1, 2, 3), [4, 5, 6], 'Lalit') print(Mixed_Tuple[0][0]) print(Mixed_Tuple[...
b203678db14a642b6da0446d34aa0223a7010718
lalitp20/Python-Projects
/Self Study/Basic Scripts/For_ELSE Statement.py
263
4.25
4
number = int(input(" Please Enter any integer below 100: ")) for i in range(0, 100): if number == i: print(" User entered Value is within the Range (Below 100)") break else: print(" User entered Value is Outside the Range (Above 100)")
5c0159a664bbc98b445b9e652e8b00dbc079a21b
lalitp20/Python-Projects
/Self Study/Basic Scripts/Iteration.py
103
3.5625
4
x = [1, 2, 3, 4, 5, 6, 7, 8, 9] for Number in range(len(x)): x[Number] = x[Number] * 10 print(x)
7b70d150000739cb2e83695b2908f09c6e1e13bf
hfyeomans/python-100days-class
/day_13_debugging/debugging fizzbuzz.py
1,094
4.15625
4
# # Orginal code to debug # for number in range(1, 101): # if number % 3 == 0 or number % 5 == 0: # print("FizzBuzz") # if number % 3 == 0: # print("Fizz") # if number % 5 == 0: # print("Buzz") # else: # print([number]) for number in range(1, 101): if number % 3 == 0 and number % 5 == 0: #...
8358d64850f1a3a442ea174daf52cedc451ca7f6
NazeerBZ/Pic-Simias
/MorphologicalTransformation.py
3,120
3.640625
4
from PyQt5 import QtCore, QtGui, QtWidgets # Import the PyQt5 module we'll need import numpy as np import cv2 #Morphological transformations are some simple operations based on the image shape. #It is normally performed on binary images. It needs two inputs, one is our original image, #second one is called structuri...
f1e22a69bf09af636894cd4497bca7f998c764ec
hanyun2019/Machine-Learning-with_Python
/ch01/OverviewSample.py
13,181
3.75
4
# Introduction to Machine Learning with Python # Chapter 1: Overview # Refreshed by Haowen Huang import numpy as np from scipy import sparse import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.neighbors import KNei...
624ed7131931046800119d8e23316bebc34c16cc
sshillyer/cs325-projects
/project4/City.py
599
3.578125
4
# from Edge import * class City(object): def __init__(self, label, x, y): self.label = str(label) self.index = int(label) self.x = int(x) self.y = int(y) # self.adj = set() def __str__(self): ''' Override string method for easy printing of city informati...
31f0e7e8706c96b4cfec85332b5ed4ca517e9bc3
sshillyer/cs325-projects
/project4/TspGraphMatrix.py
1,175
3.5
4
import tsp_helper_functions class TspGraphMatrix(object): def __init__(self, vertices): self.V = vertices # Vertices (cities) self.v_count = n = len(vertices) # Number of vertices (cities) # Initialize and fill in the adjacency matrix # See stackoverflow.com/q...
5bf7b52e8961a49b3667ae1731295ae1719a0900
aishtel/Prep
/solutions_to_recursive_problems/geometric_progression.py
655
4.34375
4
# Geometric progression using recursion # starting term = a = 1 # factor = r = a2/a1 # Find the nth term - 8th term # 1, 3, 9, 27, ... def geo_sequence(a, r, n): if r == 0 or r == 1: raise Exception("Sequence is not geometric") if n < 1: raise Exception("n should be >= 1") if a == 0: ...
219c903dc87a29cd0c9b2fc8fa91ef7570f8a60e
aishtel/Prep
/solutions_to_recursive_problems/gcd_lcm.py
963
4
4
# Greatest common divisor and least common multiple in python using recursion # This can also be found by importing math function and using math.gcd and math.lcm def gcd(a, b): try: if b == 0: return a elif a == 0: return b else: return gcd(b, a % b) ...
f5dab06d3a74c77757d299124fbe8bcabbfa3c07
aishtel/Prep
/solutions_to_recursive_problems/factorial_recursive.py
465
4.5
4
# Return the factorial of a given number using recursive method. # Example: # n = 6 # fact = 6*5*4*3*2*1 = 720 def factorial(n): if n < 0: raise Exception("n should be >= 0") elif n == 0: return 1 elif n == 1: return 1 else: return n * factorial(n - 1) print "The fac...
b5773b810b4844e9868ff5ab63ba156aad500f59
yayaysya/wxpython_learning
/xml_python/main.py
893
3.53125
4
#!/usr/bin/env python # coding=gbk ''' this is a python file about how to use xml in python pyhton prase the xml with the ElementTree Way ''' try: import xml.etree.cElementTree as ET except ImportError: import xml.etree.ElementTree as ET def xml_prase(xml_file): tree = ET.ElementTree(file=xml_fi...
d5d66badeefb003f0d8356f94586ed89d869fc5e
Andrew-Callan/linux_academy_python
/age
248
4.15625
4
#!/usr/bin/env python3.7 name = input("What is your name? ") birthdate = input("What is your birthday? ") age = int(input("How old are you? ")) print(f"{name} was born on {birthdate}") print(f"Half your age is {age/2}") print(f"Fuck you {name}")
fc5e925c08e8addecc17de1e671eba8ef9d8df3f
jonathanFielder/slither_into_python_exercises
/ch3_test.py
399
3.828125
4
#calculates total amount of rabbits over a specified time based on begining number of rabbits input by user while True: rabbits = int(input('enter num of rabbits:')) years = 4 months_in_year = 12 months_to_double = 3 x = years * months_in_year / months_to_double print(x) while x...
db1447bcef8c170aa18b59d1cda27f06e15762ed
jonathanFielder/slither_into_python_exercises
/decimal_rounder.py
174
3.609375
4
e = 2.7182818284590452353602874713527 while True: x = int(input('Enter how many decimals to display for e: ')) print('{:.{}f}'.format(e,x))
64b553e710743d6fb559d203e78448217345511a
jonathanFielder/slither_into_python_exercises
/slither_ch3.py
267
3.984375
4
x=7 y=5 z=x-y radius_of_earth=6371 pi=3.14 surface_area=4*pi*(radius_of_earth**2) print(surface_area) name = input('Enter your name:') print('hi ' + name) number = int(input('what number would you like squared ' + name + '?')) print(number ** 2)
090a887aad10757f23fc4bb57813a28c341b48fa
jonathanFielder/slither_into_python_exercises
/ch11_question4.py
344
3.796875
4
d1 = {"k1": True, "k2": True, "k3": True, "k4": True} d2 = {"k6": True, "k2": True, "k5": True, "k1": True, "k8": True, "k4": True} intersection = {} for i in d1: #print(i) if i in d2: #print('check') if d1[i] == d2[i]: #print('ok') intersection[i] = d1[i...
04aa5f70291ca7680c993b748b5ff45b2de58a17
jonathanFielder/slither_into_python_exercises
/arithmetic.py
904
4
4
def add(*a): result = 0 for arg in a: result += arg return(result) def subtract(*a): result = a[0] i = 1 if len(a) >= 2: while i < len(a): result = result - a[i] i += 1 else: result = -a[0] return(result) def multiply(*a)...
f16732c11385a1746c3b47319f0adcb9a26d1880
jonathanFielder/slither_into_python_exercises
/ch15_question5.py
760
4.0625
4
import sys def file_set(): #open file and create word list split try: with open(sys.argv[1], 'r') as file: words = {word.strip() for word in file} return(words) except: with open('words_alpha.txt', 'r') as file: words = {word.strip() for word ...
2b36e068233b1b3026fdea662d98b4219f4f354d
jaghen/python-test
/main.py
6,968
3.59375
4
# Prueba tecnica para el proceso de carga ETL de un archivo # Desarrollado por Sergio Silis import glob import pandas as pd from pandas.api.types import is_numeric_dtype from pandas.api.types import is_string_dtype from datetime import datetime from datetime import date import os import sqlite3 as sql # Funciones aux...
f1d5ec6176f52201257698fcbcc0aa69b1921f5e
kkhamutou/WikiBase_UW_Project
/gui/main_gui.py
3,565
4.03125
4
# main_gui.py python3 """ This module is design to run the GUI main application. The GUI is written in tkinter library. """ import tkinter as tk import tkinter.font as tkfont from gui.wiki_window import WikiMain from gui.game_window import GameMain from gui.stat_window import StatMain class Application(tk.Tk): ...
880cd28be0e59af032da250f2605afa8e35c67b5
WannJJ/Maze-Generation-Python
/generate_maze.py
2,899
3.984375
4
# -*- coding: utf-8 -*- """ Created on Mon May 3 15:58:45 2021 @author: dell Maze generation Idea: use Prim's Algorithm http://weblog.jamisbuck.org/2011/1/10/maze-generation-prim-s-algorithm.html """ import random """ w, h are even """ def generate_board(w: int=9, h: int=9): assert w%2...
7d808d9f82b601e1d26fd70fb91c2dcfb9b9c970
shivam-gh/dsa_using_python
/Searching algorithms/binary_search.py
613
3.984375
4
# binary search can be implemented only on sorted array/list # <----time complexity----> # best average worst # O(1) O(log n) O(log n) def binary(arr,beg,end,key): if beg<=end: mid=(beg+end)//2 if arr[mid]==key: return 1 elif arr[mid]>key: return binary(ar...
9d26d08fdd825e1b6644c1cb70bda6daeba0f33a
ToshimichiYamada/python_code_for_research
/robust_regressuion.py
1,958
3.5
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 14 19:17:08 2016 Robust nonlinear regression in scipy """ import numpy as np import matplotlib.pyplot as plt # Define data generator: def generate_data(t, A, sigma, omega, noise=0, n_outliers=0, random_state=0): y = A * np.exp(-sigma * t) * np.sin(om...
fdcea0d9ce3a4687a06f1ae43ee2a92d6b03a59f
vinaykumarlodari/Python
/Turtlerace.py
904
4.0625
4
import turtle # import the modules from random import randint # to make the random movement of turtles use ranindt() from random module wn = turtle.Screen() # Create a screen wn.bgcolor('cyan') t = turtle.Turtle() t.penup() t.goto(-70,100) t.pendown() for i in range(11): t.hidet...
0a35c766c3abc007843fd3b54396023eaf37ca57
trishamrkt/csc326-assignment2
/q3.py
832
3.71875
4
def my_map(func, iterable): result_map = []; # Iterate through all the elements in iterable # Apply func to each element for elem in iterable: new_elem = func(elem) result_map.append(new_elem) return result_map def my_reduce(func, iterable): if len(iterable) == ...
8edc09c1324db50aee3b81e4640546619607109b
faisalkhan91/RSA-Algorithm
/RSA.py
5,402
4.09375
4
#!/usr/bin/python3 ############################################################################################# # Program by Mohammed Faisal Khan # # Email: faisalkhan91@outlook.com # # ...
63ed1d0fbf3fa9c775dd82e2e0b512e2fb86440d
jayshreevyas/programming-test
/program-4.py
213
3.671875
4
Problem-4: Get the total count of number list in the dictionary which is multiple of [1,2,3,4,5,6,7,8,9] sol: n=int(input("Input a number ")) d = dict() for x in range(1,n+1): d[x]=x*x print(d)
041d83dfbfac46f9a32967341dde6cd14833d269
sidhant-khamankar/Guessing-Game
/GuessingGame.py
1,366
3.78125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: from random import randint num=randint(1,100) guesses=[] count=1 print("Guessing Game \nGuess should be less than 1 or greater than 100 \nOn Your first turn, if guess is within 10 of the number, output WARM \nfarther than 10 away from the number, output COLD \nOn all su...
1755a8601c2c67c1dfebe58f715ec25d5495932d
raphrueda/Python2Perl
/test01.py
121
3.828125
4
#!/bin/usr/python #Complex expressions in for loops a = 10 b = 20 for i in range(a/b*2, a/b*2 + b*b*b/a): print i
7c80f1c15b2ab31c0ca7018bc618ec2d5bf3403a
raphrueda/Python2Perl
/demo05.py
284
3.984375
4
#!/bin/usr/python #Prints the prime number up to the given number #Written by Raphael Rueda import sys print "enter a number" num = int(sys.stdin.readline()) if num > 2: print "2" for n in range(1, num+1): for x in range(2, n): if n % x == 0: break if x == n-1: print n
220af404ec0e6cb9f0ca0ad6403d266cf8e85f17
PushkarGarg02/HowToAutomateStuffRepo
/Practice/inventory_update.py
367
3.5625
4
dragonLoot = ['gold coin','dagger','gold coin','gold coin','ruby'] inventory = {'gold coin': 38, 'dagger': 20} def addToInventory(inventory, addedItems): for newItem in dragonLoot: inventory.setdefault(newItem, 0) inventory[newItem] += 1 addToInventory(inventory,dragonLoot) for k,v i...
e667936801cbfe626f5e21ffa9e87fa233842370
SweetyTugz/ReminderApplication
/alarm.py
472
3.515625
4
import winsound from win10toast import ToastNotifier def timer(reminder,seconds): notify=ToastNotifier() notify.show_toast("Reminder",f" ""Alarm will go off in (seconds) Seconds""",duration=10) notify.show_toast(f"Reminder",reminder,duration=10) frequency=2000 duration=1000 winsound.MessageBee...
9bf6c7c21571ea0745e9e816b9aade5b0f1f305c
Amritpal-001/100-days-of-code
/EulerProject-solvedExamples/Problem 41.py
1,045
3.53125
4
#problem 41 import random n = [1,2,3,4,5,6,7,8,9] def randnumgeneratorXdigitNum(x): b = '' a = n[:x] for i in range(0,len(a)): random_num = random.choice(a) a.remove(random_num) b += str(random_num) print(b) #randnumgeneratorXdigitNum(4) x = 4 def factorial(x): a =...
2392e97ec210f3bc9e21cd0214ccaee564e682ae
Amritpal-001/100-days-of-code
/EulerBase/Euler_solutions/Getting primes .py
1,820
4.03125
4
def getPrimesBelowN(n=1000000): """Get all primes below n with the sieve of Eratosthenes. @return: a list 0..n with boolean values that indicate if i in 0..n is a prime. """ from math import ceil primes = [True] * n primes[0] = False primes[1] = False primeList = [] r...
342b1c5a3e23bf4d3f698a88a9d2f87dffe9e9f4
Wyuchen/python_hardway
/16.py
1,036
4
4
#!/usr/bin/python #coding=utf-8 #笨办法学 Python-第十六题 #文件的相关操作 from sys import argv script,file_name=argv print 'the read of file name is %s' %file_name #打开一个文件 file=open(file_name,'rw+') print ''' 文件操作的命令: 1.close – 关闭文件。跟你编辑器的 文件->保存.. 一个意思。 2.read – 读取文件内容。你可以把结果赋给一个变量。 3.readline – 读取文本文件中的一行。 4.truncate – 清空文件,请小心使用该命...
1c84b38bb37582851c05603793f51697860ac906
Wyuchen/python_hardway
/48.py
929
4.125
4
#/usr/bin/python #encoding=utf8 #笨方法学python-第四十八题 #目的:编辑出一个能够扫描出用户输入的字,并标注是那种类型的程序 #定义初始化的数据: Direction=['Direction','north','south','east','west'] Verb=['Verb','go','stop','kill','eat'] Adjective=['Adjective','the','in','of','from','at','it'] Noun=['Noun','door','bear','pricess','cabine'] print '用户可以输入的词有:' print Dir...
e5de3dc1d18e6f517f24b58851dd96d88b007999
Wyuchen/python_hardway
/29.py
484
4.28125
4
#!/usr/bin/python #coding=utf-8 #笨办法学 Python-第二十九题 #条件判断语句if people=20 cats=30 dogs=15 if people < cats: print 'too many cats!too little people' if people > cats: print 'too many people,too little cats' if people < dogs: print 'the world is drooled on' if people > dogs: print 'the world is dry' dogs+=...
ec373f840dc1d23a69be556df07d3f4b4cc3bf9c
Wyuchen/python_hardway
/20.py
797
4.03125
4
#!/usr/bin/python #coding=utf-8 # 笨办法学 Python-第二十题 #函数和文件结合 from sys import argv script,file=argv #读取文件内容 def read(f): print f.read() #指针回到开头 def rewind(f): f.seek(0,0) #读取一行文件内容 def read_a_line(line_count,f): print line_count,f.readline() #关闭文件 def close(f): f.close() current_file=open(file) print 're...
3e7b21d4fc0b9776ec7990f6aff7e5ae7abe7d1c
dianeGH/working-on-python
/menu/main.py
1,100
4.53125
5
#Write a program that allows user to enter their favourite starter, main course, dessert and drink. Concatenate these and output a message which says – “Your favourite meal is .........with a glass of....” def function_1(): user_name = input("Hi there, what's your name? \n") #print ("Nice to meet you " + user_name + "...
a832cb2734d37c5c81297b7d5ced47d5eb8c568a
dianeGH/working-on-python
/18112020-classwork/main.py
804
3.78125
4
import pandas as pd data = pd.read_csv("ign.csv") print(data.shape) # how may rows and columns print(data.head(3)) #prints the first (number) of rows () auto retireves 5 rows print(data.tail(4)) #prints the last (number) of rows as above for auto number print(data["platform"]) print(data["score"].mean()) # mean of the ...
09b28c6215e30d68fe17becca9b4495559ccb9de
dianeGH/working-on-python
/depreciation/main.py
349
4.28125
4
#A motorbike costs £2000 and loses 10% of its value every year. Using a loop, print the value of the bike every following year until it falls below £1000. print("Today, Jim bought a motorbike for £2000.00") year = 1 cost = 2000 while cost >1000: print("At the end of year ",year,", Jim's bike is worth £", cost) ...
977e03b90cb992afed1d1aa5cdba8c24f831a27e
binzecai/CS6476
/sift/harris.py
7,561
3.765625
4
import cv2 import numpy as np import matplotlib.pyplot as plt def get_interest_points(image, feature_width): """ Implement the Harris corner detector (See Szeliski 4.1.1) to start with. You can create additional interest point detector functions (e.g. MSER) for extra credit. If you're finding spu...
e9e5866348ea57eefce86a2ae22b23990c4bb6fc
andreas-anhaeuser/py_utils_igmk
/test/test_chronometer.py
3,754
3.515625
4
#!/usr/bin/python3 """Testing suite for chronometer.Chronometer.""" import unittest from time import sleep from misc.chronometer import Chronometer ################################################### # TESTING # ################################################### class Context...
2ec1ad5a217e098c695451ed5588f574920d56c4
andreas-anhaeuser/py_utils_igmk
/datetime_intervals.py
43,190
3.75
4
#!/usr/bin/python """Implentations of time intervals, daytime periods and a seosons.""" import datetime as dt from collections import Iterable class Interval(object): """A time interval. Each bound may be inclusive or exclusive. Default is inclusive for lower bound and exclusive for upper bound. ...
2d2f09051efb89e1616e745a7e8beb433a9fca9d
MoisanuStefan/PyBackgammon
/dice.py
1,226
4
4
import random import arcade class Dice: """ Dice is used to mimic a dice that generates random rolls from 1 to 6 ... Attributes ---------- faces(): List List containing the textures for dice faces roll() Returns random number in [1,6] double_roll() Return 2 ran...
55b4e104dc532534f9a5c48fc06c4ff441fab21b
appigeeta/PythonRevise
/Pythonrevise/eventPlaner.py
1,045
3.78125
4
#!usr/bin/python #general sketch for for organising an event. class booking: def __init__(self,date,time): self.date=date self.time=time #printing just to make sure print date print time class place: def place_sele(self,indoor,outdoor): self.indoor=indoor self.outdoor=outdoor class attendees: def att(s...
fa4df0ac57ff1d00717b64cb9217e2691ec22195
DavidKenyon96/Various-Python-Programs
/NQueensProblem.py
1,200
3.84375
4
# NQueensA_DBK.py import random from itertools import permutations NQ_solutions = 0 NQ_conflicts = 0 iterations = 0 N = int (input("Input an 'N' value (must be larger than 3): ")) while (NQ_solutions is 0): cols = [random.randint(0,N-1) for cols in range(N)] # Generate a candidate NQ solution [random.randint(...
e86148fcf758aba045541d4d006191a187c8a6e6
jiyoungkimcr/Python_Summer_2021_2
/HW6_Bank.py
4,001
3.984375
4
class Customer: last_id = 0 def __init__(self, firstname, lastname): self.firstname = firstname self.lastname = lastname Customer.last_id += 1 self.id = Customer.last_id def __repr__(self): return 'Customer[{},{},{}]'.format(self.id, self.firstname, self.lastname) c...
d5697b02306cb0afaaa174e48441b13f75c85a62
Nacho114/python_course
/course/chapter3/example_for.py
847
3.8125
4
def int_from_cmd(prompt): return int(input(prompt)) def print_member(member): print('Name: ', member[0], ', age: ', member[1]) def print_member_list(member_list): print('Members:') for member in member_list: print_member(member) def mean(numbers): mean_value = 0 for nber in number...
8dc3bbc8fa1f7a1dc7d517cf330c2bfa2028abc6
redhotcode/secthing
/solution.py
3,573
3.5625
4
#!/usr/bin/env python from lxml import html, etree import requests import re import json class SECFiling: ''' Simple class for parsing SEC Filings obtained from the internet into plain text paragraphs and splits the "financial" paragraphs (a.k.a. those paragraphs containing a dollar sign) i...
3824fb27aa0a6a84ccc0349a32f685504c11040c
logansmithbayarea/Draw-flower
/turtle_drawusaflower.py
1,277
4.0625
4
import turtle def draw_square(s_turtle): for s in range(1,5): s_turtle.forward(110) s_turtle.right(90) def draw_circle(f_turtle): for f in range(1,5): f_turtle.circle(80) def draw_triangle(t_turtle): for t in range(1,3): t_turtle.left(60) t_turtle.for...
5361bceaf8f580c2855c45a3396525a7a326bffa
shubhneetkumar/python-lab
/anagram,py.py
203
4.15625
4
#anagram string s1 = input("Enter first string:") s2 = input("Enter second string:") if(sorted(s1) == sorted(s2)): print("string are anagram") else: print("strings are not anagram")
da3e9563e8338fbd61e1701c497bdbd8ad015f28
shubhneetkumar/python-lab
/frequency.py
150
4
4
strA = input("Enter a string") res = {} for keys in strA: res[keys] = res.get(keys, 0) + 1 print("Frequency of each character : \n",res)
adcc60b82032aded3ad04e4ea075eee27665d854
tonib/tokens-rnn-tensorflow
/tests/rnnnumbers.py
4,299
3.640625
4
import tensorflow as tf import tensorflow.feature_column as feature_column from tensorflow.contrib.estimator import RNNClassifier import tensorflow.contrib.feature_column as contrib_feature_column import test_utils from typing import List # Test to make a char RNN predictor # Simple sample text to learn: repetitions ...
fa1cd0af3edd4227793b74655a2e370e38f242fb
tonib/tokens-rnn-tensorflow
/input_data.py
1,457
3.609375
4
from enum import Enum import os from typing import List class InputData: """ The train data: A text file """ #def __init__(self, data_file_path : str , token_mode : TokenMode , sequence_length : int ): def __init__(self, args : object ): # Input file file path = os.path.join( args.data_di...
553e6ab87a793c2335c2330f29e9fb07be7f75b7
Bhumireddysravani/sravani
/armstrong.py
159
3.859375
4
num=int(input()) sum=0 temp=num while temp>0: digital=temp%10 sum=digital**3 temp//=10 if num==sum: print("yes") else: print("no")
c69eda975eaa6a5d7da163d458845a1e4a9e3366
iloveyii/tut-python
/loop.py
259
4.15625
4
# For loop fruits = ['banana', 'orange', 'banana', 'orange', 'grapes', 'banana'] print('For loop:') for fruit in fruits: print(fruit) # While loop count = len(fruits) print('While loop') while count > 0: print(count, fruits[count-1]) count -= 1
e0e96d3e2e2c7cf3b4418c0f971e8b7fa1a60d7c
iloveyii/tut-python
/classes/c1.py
330
3.828125
4
class Employee: def __init__(self, firstName, lastName): self.firstName = firstName self.lastName = lastName def fullName(self): return '{} {}'.format(self.firstName, self.lastName) emp_1 = Employee('Alex', 'Kan') emp_2 = Employee('John', 'Doe') print(emp_1.fullName()) print(emp_2.fu...
a309771759a1a85fd999d6b8234a167dc770bc76
kungming2/translator-BOT
/code/zh_processing.py
46,564
3.53125
4
#!/usr/bin/env python3 """ CHARACTER/WORD LOOKUP FUNCTIONS Ziwen uses the regular code-formatting in Markdown (`) as a syntax to define words for it to look up. The most supported searches are for Japanese and Chinese as they account for nearly 50% of posts on r/translator. There is also a dedicated search function...
da5e5e77eda1eceea51353b30b518c06519fad9d
dmcnavish/adventOfCode
/advent_of_code/day5.py
803
3.65625
4
__author__ = 'davidmcnavish' from util import get_input def process_instructions(jumps, use_strange_jump=False): steps = 0 current_idx = 0 total_jumps = len(jumps) while current_idx < total_jumps: next_move = jumps[current_idx] if use_strange_jump and next_move >= 3: jump...
c37c206e3f151d4f32742604a24209182aa8864c
geryglez777/personal-budget-calculator
/personal_budget_calc.py
373
3.84375
4
item_dict = {} def data_entry(): item = '' cost = 0.0 end_entry = '' while end_entry[0:1].lower() <> 'y': item = input('Enter Item: '\n) cost = input('Enter Cost for: {}\n'.format(item)) end_entry = input('Would you like to add another item, y/n\n') return item, cost dat...
18d042cf54ea62744b7123a97d89d121cd7af889
eugenemonnier/data-structures-and-algorithms
/code_challenges/insertion_sort/insertion_sort.py
264
3.96875
4
def insertion_sort(arr): for index, num in enumerate(arr): idx = index while idx > 0 and num < arr[idx - 1]: arr[idx] = arr[idx - 1] idx -= 1 arr[idx]= num return arr print(insertion_sort([2,3,5,7,13,11]))
c2df88b5db78abb930acafb4af0f9649ac5612d8
eugenemonnier/data-structures-and-algorithms
/code_challenges/get_edges/get_edges.py
329
3.546875
4
from code_challenges.breadth_first_graph.breadth_first_graph import BFG class GE(BFG): def get_edges(self, node_a, node_b): neighbor_list = self.adj_map.get(node_a) for neighbor in neighbor_list: if neighbor['node'] == node_b: return 'true, ' + str(neighbor['weight']) return 'f...
4d0444b4b444424d6587b0b55e935857cc69953a
Louis-Mont/Sudoku
/Core/utils.py
441
3.625
4
def sq_o(n): return (n // 3) * 3 def tryremove(c, v): try: c.remove(v) except ValueError: pass except KeyError: # TODO : Not Good Sudoku pass return c def rm_coll(r_items, items): """ :param r_items: the items you want to be removed from the list :para...
9cf29f133f30226c91d3a462366ead5e6d0eca18
geekmichael/python-learning
/mindstorms.py
3,006
4.15625
4
import turtle def initWindow(title = "Welcome to the turtle zoo!", bgColor = "white", delay = 10): # Initialises the window for drawing window = turtle.Screen() window.setup(width=600, height=500, startx=0, starty=0) window.title(title) window.bgcolor(bgColor) # Slow down the drawing speed ...
ee5f15707242184f822ab27a6e05f93b3c296344
thiagocosta-dev/Gerador_senha_simples
/senha_para_filas.py
806
4.125
4
# AUTOR: Thiago Costa Pereira # Email: thiago.devpython@gmail.com print('=-' * 20) print('-- GERADOR DE SENHA --'.center(40)) print('=-' * 20) senhas_comuns = [0] senhas_pref = [0] while True: print() print('--' * 20) print('[1] SENHA COMUM') print('[2] SENHA PREFERENCIAL') print('[3] SAIR') ...
485a5ce7d9571ba75380e4ec104873ab981ef331
adhansu/Calculator
/FinalCalc.py
3,506
3.8125
4
from tkinter import * root = Tk() root.geometry('500x500+450+150') root.title('Calculator') root.config(bg='#223441') root.resizable(width=False, height=False) def button_click(number): enter.insert(END, number) def button_clear(): enter.delete(0, END) def button_add(): first_number = enter.get() glo...
44faead1ab49742364d7e795c81aee7829517e81
Ironeer/ProgrammingTasks
/Python/expert/multiprocessing/primParallel.py
4,465
3.515625
4
import os import math import time from multiprocessing import Process,Queue,Manager def timed(function): '''timing decorator''' def wrapper(*args, **kwargs): # we don't know about arguments... start = time.time() result = function(*args, **kwargs) # ...so we just pass what we got ...
c17c07f5a342dca4d8d895f27b775185762682b2
xingyue1124/py-test
/test/士兵射击.py
1,960
3.984375
4
# 二、需求: # 1)士兵瑞恩有一把AK47 # 2)士兵可以开火(士兵开火扣动的是扳机) # 3)枪 能够 发射子弹(把子弹发射出去) # 4)枪 能够 装填子弹 --增加子弹的数量 class Gun: # 创建构造方法,给对象的属性赋值(型号,弹夹中子弹数目) def __init__(self,model,bullet_count): self.model = model self.bullet_count = bullet_count # 自定义实例输出方法,替换默认的输出操作 def __str__(self): return...
879ea4bff00a9594f284cb1f4325762ba6e241af
brunokiyoshi/Nanodegree-MLE-capstone-project
/train/model.py
1,190
3.5
4
import torch.nn as nn import torch class LSTM(nn.Module): """ This is the simple RNN model we will be using to perform Financial Time-series Analysis. """ def __init__(self, input_dim, hidden_dim, num_layers, output_dim): """ Initialize the model by settingg up the various layers. ...
383f97c5f7b3964fd73f85177a2232b303563f7f
lumafragoso/Funcoes_Analise_Funcao_Randint
/main.py
501
3.671875
4
import random def principal(): lista = [] inicial = int(input('Inteiro inicial do intervalo? ')) final = int(input('Inteiro final do intervalo? ')) n = int(input('Quantidade de escolhas? ')) for i in range(n): elemento = random.randint(inicial, final) lista.append(elemento) for j...
023ce95c7722201b119e0e049201c5bc56365837
dlftls38/college
/python/sumrange.py
513
3.625
4
def sumrange(m,n): if m<n: return n+sumrange(m,n-1) elif m==n: return m else: return 0 return sumrange(m,n) def sumrange2(m,n): sum=0 while m<=n: sum = n + sum n = n-1 return sum #교수님이 한 방법 def sumrange3(m,n): if m <= n: return m + sumran...
beeb7a8ffd745aadadca0ca356f3c2ad5a605b07
dlftls38/college
/python/fill_Triangle.py
1,264
3.609375
4
from tkinter import* tk = Tk() canvas = Canvas(tk, width=210, height=210) canvas.pack() canvas.create_polygon(10,10,50,10,50,50,fill="red",outline='black') canvas.create_polygon(50,10,100,10,50,50,fill="yellow",outline='black') canvas.create_polygon(100,10,150,10,150,50,fill="green",outline='black') canvas.create_pol...
a2568e0e474ef4de9bc33af502fd30f89782e72b
Spaqin/AAL-2017L
/datastructures/treasure.py
318
3.78125
4
class Treasure(object): def __repr__(self): return self.__str__() def __str__(self): return "value: {} size: {}, city: {}".format(self.value, self.size, self.city) def __init__(self, value=0, size=0, city=None): self.value = value self.size = size self.city = city
e50da950e23d03141c4e4f548ac23e6feec49748
James-Cristini/bot_o_matic
/src/utils.py
2,307
3.984375
4
from __future__ import print_function from builtins import input import os import pickle def clear_console(): """ Simply runs the clear/cls command on the console to make it easier to read what is going on. """ os.system('cls' if os.name == 'nt' else 'clear') def press_enter_to_continue(): """ Simply ...
580c275bc2bd3394aae13f831d36e0b588bc2024
MariomcgeeArt/CS2.1-sorting_algorithms-
/iterative_sorting2.py
2,069
4.34375
4
#funtion returns weather items are sorted or not boolean #creating the function and passing in items def is_sorted(items): # setting variable copy to equal items copy = items[:] #calling sort method on copy copy.sort() # if copy is equal to items it returns true return copy == items def bubble...
c02fe6cb5e797f479d276743eab662a55f8160b3
Roberto117/twenty-one
/twenty-one.py
8,309
3.828125
4
from Player.player import Player from Deck.deck import Deck from Player.hand import Hand players = []#list to store the players currently playing deck = Deck()#The Deck being used for the game bank = Hand("Bank")#the bank HIT_INPUT = "H" STAND_INPUT = "S" SPLIT_INPUT = "$" def addPlayers(): #add new players to t...
0c9b2ce66f583d96d5f8aa5dba43f3c17a73dd4a
igorsteinmacher/pythonCI_class
/v0/prime.py
198
3.921875
4
def is_prime(number): if (not type(number) is int): return False if (number <= 1): return False for element in range(2,number): if (number % element == 0): return False return True
d55991c851bb45a0bb03a9ddee2eacee52e8c934
shanico91/Gene_Block_data_mining_in_bacterial_genomes
/tree_node.py
724
3.640625
4
class TreeNode: def __init__(self, name_value, num_occur, parent_node): self.name = name_value # gene cog number self.count = num_occur # in how many genomes this gene appeared in a valid window self.parent = parent_node self.children = {} self.last_update = 0 # th...
527694235d23a867f3d195b18db55b53ec167bd4
jdjake/CompetitiveProgramming
/Euler/40_champernownes_constant.py
214
3.578125
4
listed = [] x = 0 while len(listed) < 1000101: for digit in list(str(x)): listed.append(digit) x += 1 product = 1 i = 1 while i < 10000000: product*=int(listed[i]) i *= 10 print(product)
dde799471aedad88a2e5ec0a79dbf586d2f9fa8e
jdjake/CompetitiveProgramming
/Euler/31_coin_sums.py
509
3.8125
4
coin_sum_hash = {} british_coins = (1,2,5,10,20,50,100,200) def coin_sum(amount, coins): if (amount, coins) in coin_sum_hash.keys(): return coin_sum_hash[(amount, coins)] if (amount == 0): return 1 elif (not coins): return 0 current = coins[0] possible = [coin_sum(amount - current*x, coi...
b40a434cf49126560b59272992e223eed3b78d22
ppfenninger/ToolBox-WordFrequency
/frequency.py
1,918
4.21875
4
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string from pickle import load, dump def getWordList(fileName): """ Takes raw data from project Gutenberg and cuts out the introduction and bottom part It also tranfers the entire text to lowercase and removes punctuation ...
a6cfc0ffa58b6d4c86b5148e0c7807de9c02f018
LeehXD/Python-Basic
/Exercicios Basicos Python/Exercicio 13.py
268
3.703125
4
nome = input('Digite seu nome:') salario = float(input('Digite seu salário R$')) resultado = salario + (salario * 15 / 100) print('Sr(a){}\n' 'Parabéns ouve um aumento de 15% em seu salário.\n' 'Salário atualizado R${}' .format(nome,resultado))
211156d74abe03579f4d44b0201d4837cce8c25b
Masachusets/Tuples
/tuples.py
238
3.6875
4
def tupl(a): b = [] for i in range(0, len(a)): if i % 2 == 0: b.append(a[i] * 2) else: b.append(a[i] - 2) b = tuple(b) print(b) a = (1, 2, 3, 4, 5, 6, 7, 8, 9, 0) tupl(a)
4785fc7a6bfb4111687fe2b21a41a08b2b353ea1
lucas54neves/algorithms-in-python
/src/trees/binary_search_tree.py
2,042
3.671875
4
class BinarySearchTree(): def __init__(self, root_value): self.root = Node(root_value) def add_node(self, value): node = Node(value) if self.root is None: self.root = node else: old_node = self.root current_node = old_node.left if node.v...
c127da0e7bf2078aa65dfcbec441b1c6dd6e7328
Habibur-Rahman0927/1_months_Python_Crouse
/Python All Day Work/05-05-2021 Days Work/Task_2_error_exception.py
2,582
4.34375
4
# Python Error and Exception Handling """ try: your code except: message """ # try: # with open('test.txt', mode='r') as open_file: # openFlie = open_file.read() # print(data) # except: # print("File is not found") # print('Hello, its working') """ try: you...
e3c9317f8306debacbe45ddee534ee74aad30723
Habibur-Rahman0927/1_months_Python_Crouse
/Python All Day Work/23-05-2021 Days Work/OOP_1.py
3,661
3.96875
4
""" Syntax: class Pencil: <statement-1> . . . <statement-N> Properties of class: class ClassName: ''' This class or design help us to create a pencil ''' Attributes - Variables Behabiours - Methods (Functions) Pillar of OOP: - Class & Object - Discussion topic - Abstruction - Private ...
8d6d3111419da58aff1fac7ad9ca9068bc631c6b
Habibur-Rahman0927/1_months_Python_Crouse
/HackerRank problem solving/problem_no_1.py
377
4.0625
4
num = int(input()) if (1<num and num<100 or num>0): if (num%2)!= 0: print(num,"Weird") elif (num%2) == 0 : if (2<num and num<5): print(num,"Not Weird") elif (6<num and num<20): print(num,"Weird") elif num>20: print(num,"Not Weird") elif num>0: ...
466d6300151c9f00a57c9b10fbcea58fd9278149
Habibur-Rahman0927/1_months_Python_Crouse
/Python All Day Work/30-05-2021 Days Work/debugging.py
162
3.65625
4
def square(num): result = num**2 print(result) return def main(): for i in range(1, 11): square(i) if __name__=='__main__': main()
ebc54a6955ebe113dad58dd0eed16b3caff2ce89
Habibur-Rahman0927/1_months_Python_Crouse
/HackerRank problem solving/problem_no_6.py
1,101
4.21875
4
def leapYears(years): leap = False if(years%400 == 0): leap = True elif years%4 == 0 and years%100 != 0: leap = True return leap years = int(input()) print(leapYears(years)) """ years = int(input()) if (years%4 == 0): if(years%100 == 0): if(years%400 == 0): ...
0263169bc533086f5e606db5f7d1ba8a2e65de2c
NeelRa/NR
/PRIME NUMBER.py
195
4.125
4
a=int(input("ENTER A NUMBER ")) for x in range(2,a): if a%x==0: print "IT IS A COMPOSITE NUMBER" break else: print "IT IS A PRIME NUMBER"
88a224e472293b2f74bb70282ef658a44d84e1a3
641i130/vocaloid-speech-generator
/create-save.py
1,372
3.5
4
""" _ _ _ | \ | | ___ | |_ ___ ___ _ | \| | / _ \ | __| / _ \ / __| (_) | |\ | | (_) | | |_ | __/ \__ \ _ |_| \_| \___/ \__| \___| |___/ (_) There are two possible ways we could go about solving this problem. We could make the user input a vpr file for t...