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
bcb37528d0354282b943cf79ce0a2a7367f4feb9
rahuladream/JS-Python-Algorithm
/Week1/Python/add-two-numbers.py
454
3.578125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1, l2): l1 = int("".join(str(n) for n in l1[::-1])) l2 = int("".join(str(n) for n in l2[::-1])) retu...
05560abde88bfca0cde278883e67f56c449a49d0
NERC-DTP-Students/climate-predictor
/climatepredictor/plot.py
5,601
3.65625
4
""" Makes plots of the planet surface and two levels of atmosphere depending on an array of parameters. To see the parameters, check out under the function make_plot. """ import numpy as np import matplotlib.pyplot as plt import matplotlib.path as mplPath Solar = 1368 #Wm^2 albedo = 0.3 em1 = 0.5 em2 = 0.5 sigm...
4f311f21290ab22ba430e57fd6de740bcde83645
ruiz239/Senior-Design
/Adafruit_Python_SSD1306/examples/sleep.py
613
3.59375
4
import RPi.GPIO as GPIO from time import sleep GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) x=3 def Setup(Enable): GPIO.setup(Enable,GPIO.OUT) GPIO.output(Enable,GPIO.HIGH) #Sleeping Driver return def clockwise(Enable,stepper,speed,loop,direction,clockwise): GPIO.output(Enable,GPIO.LOW) #Enab...
1daa3e8d80bf34ec4dd4413c0aafc753911e9044
Aristekrat/hipstertron_data
/test/test_helpers/dateh.py
1,234
3.5
4
import unittest import re import warnings # All dates should have a defined format by the time they're ready to be converted: # Month, day, year. Create a function that splits the string and tests each component to see if matches what it is supposed to # Appears to work def break_into_components(context, results): a...
4b1fec45d3777d2cfb1e1c6d62209b7a5d661c45
GeraldKiliany/PostureWatcher
/Development/SeniorDesignSeatedTiming.py
982
3.875
4
#Senior Design ECE 1896 Posture Watcher #Gerald Kiliany #Timing to Determine if sitting for too long import time #Define variables isSeated = True samplePeriod = 1.0 seatCount = 0 standCount = 0 timeElapsed = 0 oversittingThresh = 5 #samples of sitting in a row that will generate alert for sitting too long notsitti...
87087ac6b4ac76ea586487ef95b86f7a2c842204
RianGirard/python_oop_user
/user_chaining.py
1,437
3.59375
4
class User: def __init__(self, username, email_address): self.name = username self.email = email_address self.account_balance = 0 def make_deposit(self, amount): # first parameter of every method should be "self" self.account_balance += amount ### NB: the "...
064a2a885c68fd60471aa2c2304ce7645b769d7b
jackreichelt/Intercom-Range-Finder
/tests/distance_calculator_test.py
1,924
3.765625
4
import unittest from distance_calculator import angle_between_points, great_circle_distance RADIUS = 6371 # Assuming a spherical earth OFFICE = {'latitude': 53.339428, 'longitude': -6.257664} # Intercom location class TestDistanceMethods(unittest.TestCase): def test_same_position(self): # assertAlmos...
dc5c1502a0a022ab40191eea9d2738683e5ca916
piyush01234/Python-Pattrens
/pattren9.py
424
3.9375
4
for i in range(1,6): for j in range(1,6): if (i==2 and j==3): print(" ",end='') elif (i==2 and j==4): print(" ",end='') elif (i==3 and j==4): print(" ",end='') elif (j>=i and j<=4+i ): print("*",end='') ...
a4485603a3cb796d7f05d13303ca78a85ab1d833
Swiftal13/Turtle-Projects
/Turtle_house.py
1,965
3.578125
4
import turtle #importing module root = turtle.Screen() #making window root.title("Elyas's house!") #window title root.bgcolor("#b5f9ff") #window color turtle = turtle.Turtle() turtle.color("black", "#f2eed3") turtle.begin_fill() turtle.forward(300) turtle.left(90) turtle.forward(2...
af073359449cf7cdc37bbd8ca2be0317e4ac360a
ansekk/infa_2021_lavrov
/lab5/game.py
12,427
3.84375
4
# Импорт библиотек import pygame from pygame.draw import * from random import randint from random import random # Инициализация pygame.init() FPS = 60 screen = pygame.display.set_mode((1200, 600)) SONG_END = pygame.USEREVENT + 1 # Задаем цвета RED = (255, 0, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) GREEN = (0, 2...
b9a5baaf1116125cd96b6be3d8a5fe043dc754d8
vserousov/Control-Homework-2
/Control/__init__.py
4,653
3.734375
4
# coding=utf-8 __author__ = 'Сероусов Виталий' from MathFunctions import * import pickle class Control(object): """ Cтатический класс для управления интерфейсом программы """ def __init__(self): raise NotImplementedError @staticmethod def try_parse(text): """ Пар...
c46883bd6e50760194f037b0373db2ceca25fd9b
calvincruzader/EPIproblems
/hash_tables/12_1_test_for_palindromic_permutations.py
690
3.875
4
''' Problem: Write a program to test whether the letters forming a string can be permuted to form a palindrome. Solution: Throw the string into a hash table. Each character is a key and the value is the counts of each char. We will have a palindrome if there is at most one odd-count character ''' from collections ...
ca22008f8549129bc30f0c39f39cfd120050e8cc
AlexGoAhead/python_hw_first
/2.py
201
3.734375
4
# Найти результат выражения для произвольных значений a,b: (a2 + b2) % 2 alpha = 5 beta = 10 gamma = (alpha**2 + beta**2) delta = gamma % 2 print(delta)
a9b1a27671110efa7e44898b6626d5574127089a
plk29a/learning
/PyLadies/zadanie 5.py
541
3.515625
4
print('cięcie stringa') a = '12' b = '12345' c = '123456' d = '12345678910111213141516' e = 'abcdefg' def tnij (string, dl): if len(string) < dl: global lista lista = [string] if len(string) == 0: #tego da się napewno jaość uniknąć w kodzie, ale nie wiem jak :(, ma za zadanie usu...
756841d6d1f7eb4503f1e9f8812948cc7d8fae91
vaibhavranjith/Heraizen_Training
/Assignment3/#3/Q2.py
789
3.640625
4
r=int(input("Rows: ")) c=int(input("Cols: ")) lst=[] for i in range(r): lst.append(list(map(int,input().split(" ")))) mx=lst[0][0] mn=lst[0][0] for i in range(r): for j in range(c): if(lst[i][j]>mx): mx=lst[i][j] if(lst[i][j]<mn): mn=lst[i][j] print(f"Max: {m...
ae8b2861ad9d3f9a1c71cbd557329328f29fcd91
vaibhavranjith/Heraizen_Training
/Assignment1/Q21.py
114
4.09375
4
f=int(input("Enter any number:\n")) p=1 for i in range(1,f+1): p=p*i print(f"The factorial of {f} is {p}")
238ca82b5245a1800aa4a7929233a2166ab5ad80
vaibhavranjith/Heraizen_Training
/Assignment3/#3/Q4.py
129
3.765625
4
# Q4 vowels=["a","e","i","o","u"] word=input("Enter a word: ") print(len(list(filter(lambda ele: ele in vowels,list(word)))))
f7eb0bfd643b4d386350d8a220d768d734e2041b
vaibhavranjith/Heraizen_Training
/Assignment1/Q8.py
354
4.25
4
#registration problem (register only people above the age 18) name=input("Enter the name: \n") mbno=int(input("Enter the mobile number:\n")) age=int(input("Enter the age:\n")) if age<=18: print("Sorry! You need to be at least 18 years old to get membership.") else : print(f"Congratulations {name} for...
b5b98c4d7bbcebdf695b3f400c02eaeed24616b9
vaibhavranjith/Heraizen_Training
/Assignment1/Q11.py
115
3.765625
4
a,b=int(input("Enter the num1\n")),int(input('Enter the num2\n')) print(f"The result (differrence) is {abs(a-b)}")
a2910949f7de558e68b329c2d0c85565330627eb
vaibhavranjith/Heraizen_Training
/Assignment1/Q15.py
186
4.21875
4
num=int(input("Enter the number of natural numbers to be generated:\n")) print(f"First {num} natural numbers are: ",end="") for i in range(1,num+1): print(str(i)+" ",end="")
6c5ab4e9611109f235e89925555adb0e860f490d
vaibhavranjith/Heraizen_Training
/Assignment1/Q22.py
90
3.890625
4
n=int(input("Enter a number:\n")) sum=0 for i in range(1,n+1): sum+=1/i print(sum)
5b58504cf30a7c27b97e5cbf483d99595970989c
vaibhavranjith/Heraizen_Training
/Assignment1/Q53.py
133
3.640625
4
for i in range(1,4): for j in range(1,4): if j==i: continue else: print(f"{i} {j}")
2489798f6086aa8e1ae1489036dd9925df641fae
vaibhavranjith/Heraizen_Training
/Assignment1/Q1.py
112
3.828125
4
#Q1 a,b=int(input("Enter num1: 2")),int(input("Enter num2: ")) print(f"sum of {a} and {b} is {a+b}")
86ae26436b5e6adb41ff0013cb718af1aebb4719
pranithmacha/python-design-patterns
/patterns/singleton.py
1,451
4.09375
4
"""" The 'Singleton' DP is all about ensuring that just one instance of a certain class is ever created. It has a catchy name and is thus enormously popular, but it's NOT a good idea -- it displays different sorts of problems in different object-models. What we should really WANT, typically, is to let as many instances...
f726bf8d008b31187032e6a784da1eec78d67ed8
Dionisiohenriq/Python-Learning
/alura_python/list.py
830
3.953125
4
# listas são mutáveis # se é preciso uma sequencia sem tipos definidos, nem posições, usam-se listas # caso seja necessário uma sequência com elementos definidos em posições definidas, usam-se tuplas class ContaCorrente: def __init__(self, numero): self.numero = numero self.saldo = 0 def deposita(self, valor):...
e563732e0c4613d96718dbe04f094fb26a4823da
Dionisiohenriq/Python-Learning
/alura_python/Filmes/playlist.py
1,182
4.1875
4
# herança é usada tanto para o reuso, quanto para absorver o polimorfismo(ducktyping), # herança pelo polimorfismo - atributos, métodos # herança pelo reuso de código e remoção de duplicação # herança = extensão # composição = conceito de 'tem um' ao invés de 'é um' # Classes abstract based classes - abc - obrigam a im...
794ff300544b10b752941fd5515de486ea98dcb0
Dionisiohenriq/Python-Learning
/pythonSocratiayt/basics_python.py
3,528
4.53125
5
# #There are some ways to write strings code with quotes in python: # print("This is an example without quotes") # print("This is anoter 'example' with quotes") # print("""This is "another" 'example'""") # # # #This is because the interpretator need the same pattern to recognize a begin and a end of the string. # #The...
fdd9193f656fe7ca2d2bd88410c16faa957e2eb1
fvlima/simple-model
/simple_model/utils.py
638
3.671875
4
import re def capitalize_first(string: str) -> str: return string[0].upper() + string[1:] if string != '' else string def camel_case(string: str) -> str: string = capitalize_first(string) for separator in ('_', '-', ' '): if separator not in string: continue string = ''.join(...
6d2394afe7224d89cb01098a880827a103228c81
jabayless/Jordan-Bayless-Projects
/Python/programmingAssignments/PA3/mkPlot.py
1,089
3.703125
4
import numpy as np from matplotlib import pyplot as plt import sys def read_file(filename): """This function reads two comma seperated numbers from each line of a file.""" data = np.genfromtxt(filename,delimiter=',') return data[:,0], data[:,1] def make_plot(x, y, name, log_x=False, log_y=False)...
ea466820d9602abbbb3ec8425b5fe0cf0a4c97db
lukevanin/python-assesment
/Two.py
1,413
3.703125
4
from datetime import date from utils.bitcoin_api import Bitcoin from utils.exchange_api import CurrencyExchange class Program: """Write a script in a file Two.py - When running the script in the command line, user should be shown: 1. The 15min delayed bitcoin market price in EUR 2. Monthly conversio...
78e8588539a6a3251b88b19837b35e1c533a80fc
cgrice/twittermap
/googlegeo.py
2,031
3.5
4
import urllib import xml.dom.minidom def geocode(address): # This function queries the Google Maps API geocoder with an # address. It gets back a csv file, which it then parses and # returns a string with the longitude and latitude of the address. # This isn't an actual maps key, you'll have to get one yourself....
42c88ac7220f517e275632ea3aaa47b31a14e008
eeue56/SimpleGames
/EvenWins/Python/EvenWins.py
3,263
3.703125
4
from random import randint import sys class Player(object): def __init__(self, name): self.name = name def amount_to_take(self, items): print 'There are {} objects left. How many will you take?'.format(items) while True: try: amount = int(raw_input('Plea...
f6ed2539e9e1cc55891a2602755fd23c55893e91
reritom/Cuttle
/simulator/sub_components/shift_register.py
833
3.890625
4
class ShiftRegister(): ''' Type of list to represent a shift register input gets added to the front of the list, all other elements are pushed out. The last element gets lost ''' def __init__(self): self.register = [0 for i in range(8)] def shift(self, bit): sel...
bb3b04baf74550ea0cc12ff62e717d90fc2ceca7
hack-e-d/Rainfall_precipitation
/Script/prediction_analysis.py
1,567
4.5
4
# importing libraries import pandas as pd import numpy as np import sklearn as sk from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt # read the cleaned data data = pd.read_csv("austin_final.csv") # the features or the 'x' values of the data # these columns are used t...
0e5a6332cf9f89644f8f4ac02129fb350107c4db
deshwalmahesh/ML-Helpers
/EDA.py
15,164
3.984375
4
import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from scipy import stats from scipy.stats import norm class EDA(): ''' Very basic EDA class to show the very basic nature of data. dataframe is not required for the __init__() constructor to make it very generic. ...
fa906e8bfa42376c0f05dd3850a30efa371fcdd0
NoDanCoder/holbertonschool-interview
/0x00-lockboxes/0-lockboxes.py
594
3.8125
4
#!/usr/bin/python3 """ lockboxes module """ def openBox(boxes, box, memo): """ itertate recursively truough list of boxes and save them on memo set """ for key in boxes[box]: if key not in memo and key < len(boxes): memo.add(key) openBox(boxes, key, memo) ret...
e3187b055b6db5a497b94602820ac86b8671e637
rajagoah/Tableua_rep
/EmployeeAttritionDataExploration.py
2,105
4.125
4
import pandas as pd df = pd.read_csv("/Users/aakarsh.rajagopalan/Personal documents/Datasets for tableau/Tableau project dataset/WA_Fn-UseC_-HR-Employee-Attrition.csv") #printing the names of the columns print("names of the columns are:") print(df[:0]) #checking if there are nulls in the data #note that in pandas do...
e9774d4c88c89091109073fb0d04db61a893e48a
panyingji/pythontest
/python_basis/lesson01/test.py
401
3.5625
4
# encoding=utf-8 """ *********************************************** @ project : myproject @ filename : test.py @ author : LEONE @ ide : PyCharm @ createtime : 2019-05-22 10:45:08 @ desc : *********************************************** """ import keyword print('Hello') print(round(2/3,3))...
e9601dbeb0a1817b4356403896b65542971279cb
panyingji/pythontest
/python_basis/lesson03/test.py
582
3.578125
4
# encoding=utf-8 """ *********************************************** @ project : myproject @ filename : test.py @ author : LEONE @ ide : PyCharm @ createtime : 2019-05-22 10:45:08 @ desc : *********************************************** """ # info = [1,2,3,4,5,6,7] # print(info[::-1]) # # a...
da91ced706c7954ec75a651593bfe7c832212919
K-State-Computational-Core/example-10-releases-python-denea-clark
/src/guess/Renderer.py
2,690
3.78125
4
"""Guessing game renderer. Author: Russell Feldhausen russfeld@ksu.edu Version: 0.1 """ from typing import List from src.guess.GuessResult import GuessResult class Renderer: """Guessing game renderer.""" @staticmethod def print_hello() -> None: """Print hello message.""" print("Welcome ...
a5427d366ec9e6529819a42b0b3b0ce1f716918b
Brobz/8queen_annealing
/annealing.py
2,479
3.75
4
from board import * import math class Annealing(): ### HYPERPARAMETERS ### max_k = 250 # Spot criteria; Max iterations start_c = 0.1 # Initial c for heating beta = 1.1 # For heating alpha = 0.95 # For cooling L = 30 # Neighbour tries per iteration r_max = 0.9 # Stop heating starting tem...
e113ff84c8741a27652afa7d4cbe6a82786e7a4c
CodecoolKRK20171/battleship-in-the-oo-way-blaromtom
/UI.py
2,923
4.0625
4
import constants def ask_if_single_player(): ''' Function to ask user if he wants to play in sigle player mode Return: ------- bool ''' print('(1) - One player\n(2) - Two players') while True: choose = input('Choose option: ') if choose == '1': return True ...
6880029999cc796c97175f38929af169d9f847d6
lsh424/algorithm
/etc/tower_of_hanoi.py
277
3.859375
4
def solution(n): answer = [] def hanoi(n, f, tmp, t): if n == 1: answer.append([f, t]) else: hanoi(n - 1, f, t, tmp) answer.append([f, t]) hanoi(n - 1, tmp, f, t) hanoi(n, 1, 2, 3) return answer
6a69a3cf1736a80679475d50f75d62cba82e92c2
DariaMinieieva/skyscrapers
/skyscrapers.py
5,485
4.15625
4
''' Module for checking a board for skyscrapers game Link to GitHub: https://github.com/DariaMinieieva/skyscrapers ''' def read_input(path: str): """ Read game board file from path. Return list of str. """ result = [] with open(path, "r", encoding="utf-8") as input_file: for line in ...
2c25567847813a6b87ab0952612e89fad3123b66
EGleason217/python_stack
/_python/python_fundamentals/course_work.py
1,988
4.25
4
print("Hello World!") x = "Hello Python" print(x) y = 42 print(y) print("this is a sample string") name = "Zen" print("My name is", name) name = "Zen" print("My name is " + name) first_name = "Zen" last_name = "Coder" age = 27 print(f"My name is {first_name} {last_name} and I am {age} years old.") first_name = "Zen" la...
b10a03e53fd216fba29c40f8f08f95d344a89450
EGleason217/python_stack
/_python/python_fundamentals/Python_opp.py
959
3.6875
4
class User: def __init__(self, username, email_address): self.name = username self.email = email_address self.account_balance = 0 def make_deposit(self, amount): self.account_balance += amount def make_withdrawal(self,amount): self.account_balance -= amount def di...
cdb3bbfef6f483a45869e2af3d64ceb49df717b8
BrendanSigale/geospatial_programming_assignments
/bsigale_quiz_2.py
802
3.9375
4
## Brendan Sigale ## Geospatial Programming ## Quiz 2 ## Question 1 mystr = input('Enter a String: ') search = input('Enter a string to search for: ') if search in mystr: print("Yes") else: print("No") ## Question 2 testList = [2, 8, 64, 16, 32, 4] testList == testList.sort() print(testList[-2]) ## ...
c1aa1f15f9ae357083c3e19fd5f039e5e79796ed
joohoyo/LeetCode
/python3/easy/E13.py
566
3.546875
4
# 13. Roman to Integer # https://leetcode.com/problems/roman-to-integer/ # 5 class Solution: def romanToInt(self, s: str) -> int: subs = {"IV": 4, "IX": 9, "XL": 40, "XC": 90, "CD": 400, "CM": 900} symbols = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} result = 0 ...
29995df601c89aa7021e301f7740a2b708392ad9
joohoyo/LeetCode
/python3/medium/M3_3.py
548
3.640625
4
# 3. Longest Substring Without Repeating Characters # https://leetcode.com/problems/longest-substring-without-repeating-characters/ class Solution: def lengthOfLongestSubstring(self, s: str) -> int: i = 0 j = 0 n = len(s) result = 0 d = {} while j < n: i...
ca452c9eff9a20a3e1c6308a47f578d12270f2cd
EFraim/trans-vpn
/ethvpn/test/streamer.py
2,443
3.5
4
import threading import zlib import time import random class Streamer: """ Runs a thread that send and receives packets over a PacketChannel. """ def __init__(self, channel, nsend, nrecv, timeout, interval = 0.3, maxsize = 1000): """ channel - the chanel to use nsend - ...
eebae7c65507fac8f7f0b27e52044f50a8f702ab
rconnol/git_buckets
/brScraper.py
4,241
3.671875
4
#!/usr/bin/env python3 import urllib.parse import sys import pdb import pandas as pd from bs4 import BeautifulSoup from selenium import webdriver class BasketballReference(object): """BasketballReference.com scraper, using their url API. The scraper has the following properties: Global Attributes: ...
5badabbd193685cb67ba8779b0595f3bb013fbbd
Swanntutu/Polynomes-French-Python
/POLYNOMES.py
6,178
3.8125
4
class poly(object) : def __init__(self,l=None): '''les attributs de poly sont -s la liste du polynome (suite a support fini) -degre son degre''' if l == None : self.suite = [0] else : if type(l) is not list : ...
2a585f085a104e399c0a623e278a25642d8c0166
anthonytrevino/Monday
/objectsandclasses.py
1,870
4.15625
4
class Person(object): def __init__(self, name, email, phone): self.name = name self.email = email self.phone = phone self.friends =[] self.greeting_count = 0 def greet(self, other_person): self.greeting_count += 1 print("Hello {0}, I am {1}!".format (oth...
2a453e10933951568b799bda9f08a68168942b47
rk0576/rezolvarea-problemelor-if-while-for
/probl1.py
256
3.65625
4
n=eval(input("introduceti nr de zile=")) if (n==29 or n==28): print("februarie") elif n==30: print("aprilie,iunie,septembrie,noiembrie") elif n==31: print("ianuarie,martie,mai,iulie,august,octombrie,decembrie") else: print("eroare")
08a35ad533e3e85ee7596f96f605d0ff07f2972c
ankit3466/Python
/problem7.py
572
4.03125
4
op=''' press 1 for create single file : press 2 for multiple file creation : press 3 for touch -c command : ''' print(op) c=input("Enter your choice") if(c=='1'): fname=input("enter file name : ") f=open(fname,'w') f.close() print("File created") elif(c=='2'): n=int(input("how many file you want to create : ")) ...
2b8cc99b152989f2b38a8219dfc0b8d6384215d9
ekateryna-rodina/100-days-python-challenge
/classes/game/actors.py
2,296
3.703125
4
import random # Rolls classes class Roll: def __init__(self): self.name = '' class Rock(Roll): def __init__(self): super().__init__() self.name = 'Rock' class Paper(Roll): def __init__(self): super().__init__() self.name = 'Paper' class Scissors(Roll): def __init...
cdf54f108bf8e4d7b26613b3d6ac3dcac3083157
ColorfulCodes/ATM
/ATM .py
1,073
4.15625
4
# We will be creating a bank account class BankAccount(object): balance = 0 def __init__(self, name): self.name = name def __repr__(self): return "This account belongs to %s and has a balance of %.2f dollars." % (self.name, self.balance) def show_balance(self): print "Y...
d6f03177ebeaabd7f39af658679973a566a024a1
Subbs66/Optimization_techniques
/SIngle variable functions/Fibonacci_search.py
1,409
4.03125
4
import numpy as np def f(x): #enter the expression here f=6*np.exp(-2*x)+2*x**2 return f # # b=5 # # a=-5 # # l=0.01 # # epslon=0.005 # #f is the list of fibonacci seires expansion. # limit=(b-a)/l def fibonacci(n): if n < 1: return 0 elif n == 1: return 1 else: return...
a149aeeb0cbfcd01dc6f14af827e3933aa47ffe6
OldEase/infa_2021_gridnev
/turtle2/2turtle1.py
209
3.65625
4
import turtle import random turtle.shape('turtle') turtle.color('black', 'black') i = 0 while i < 50: x = random.randint(0, 360) turtle.left(x) turtle.forward(20) i = i + 1 turtle.done()
069a943662c0140f5776ea5fc50cfd382fd573fd
OldEase/infa_2021_gridnev
/turtle1/turtle11.py
372
3.90625
4
import turtle turtle.shape('turtle') turtle.color('black', 'black') turtle.left(90) def drawl(x): i = 1 while i < 73: i = i + 1 turtle.left(5) turtle.forward(x) def drawr(x): i = 1 while i < 73: i = i + 1 turtle.right(5) turtle.forward(x) i=5 while i<1...
2ac616b075510311fef89ae6d573505f4d740f85
YulanJS/Intro_to_Artificial_Intelligence
/HW1/testhomework1.py
3,194
3.828125
4
# ----------------------------------------------------------------------------- # Name: testhomework1 # Purpose: Test functions for homework 1 # # Author: Rula Khayrallah # ----------------------------------------------------------------------------- import homework1 import unittest class TestHomewo...
7d9b2153aa7967160ecb962faa598f405daf56ee
rosstripi/problemotd
/2014-03-14.py
448
4.09375
4
""" description: program to find longest palindrome in a string author: rossbot """ def reverse(s): return s[::-1] def find_palindrome(text): longest = "" for leng in range(2,len(text)+1): for pos in range(len(text)-leng+1): piece = text[pos:pos+leng] half = leng/2 ...
a480028090d34b8fc58487cead0ed91123d5e04c
patrykk96/zai
/Cwiczenia 3/Zadania 1-6/Zadanie5.py
561
3.703125
4
class Calculator: def __init__(self, liczba_1, liczba_2): self.liczba1 = liczba_1 self.liczba2 = liczba_2 def add(self): return self.liczba1 + self.liczba2 def difference(self): return self.liczba1 - self.liczba2 def multiply(self): return self.licz...
dcfcb5b271d215ea0ac0e8d4a76d90bab020d091
EmineHatunGur/python_homework
/homework3.py
804
3.734375
4
import random as rnd name=input("Kullanıcı adı giriniz:") print(f'Welcome {name}') kelimeler=["kalem","silgi","python","java","bilgisayar","mühendis"] def word(): kelime_sec=rnd.choice(kelimeler) alınan_kelime=["_"]*len(kelime_sec) tahmin=5 print(alınan_kelime) while tahmin > 0: harf = 0 for kara...
74d4b8510022110b283a9327a0c272adf8c2f383
metabismuth/esalg-a04-tarefa1
/main.py
5,040
3.578125
4
#!/usr/bin/env python from queue import Queue from person import Person, PersonHeap, generate_person from utils import get_severity, is_int, get_option sev = ["Azul", "Verde", "Amarelo", "Laranja", "Vermelho"] queue = Queue() heap = PersonHeap() def show_stats(): print("\nFila de espera: %d pessoa%s" % (len(qu...
dde5c4982b3a03e1c44d086a5a86924d91e83b1b
kylejablonski/Python-Learning
/conditionals.py
786
4.46875
4
print("Hello, World! This is a conditionals program test.") # prompts for a value and checks if its more or less than 100 maxValue = int(input("Please enter a value: ")) if maxValue > 100: print("The max value of {0} is greater than 100!".format(maxValue)) elif maxValue < 100: print("The max value of {0} is l...
a1a1db477a38647aa4d0989bfdebb76a7fd92c18
foname/contact-book-extractor
/tests/test_song_decoder.py
803
3.515625
4
import unittest from song_decoder import songDecoder class TestSongDecoder(unittest.TestCase): def test_basic_string(self): self.assertEqual(songDecoder("WUBWEWUBAREWUBWUBTHEWUBBACKYARDWUBMYWUBFRIENDWUB"), "WE ARE THE BACKYARD MY FRIEND", "Should match given example") def test_replace_one_space(se...
664786d2d9a2a2a813af50e071d5a967722491c9
loomstar/zip64-codes
/snake.py
3,443
3.53125
4
from microbit import * from random import randrange import neopixel def zip_plot(x, y, colour): zip_led[x+(y*8)] = (colour[0], colour[1], colour[2]) zip_led = neopixel.NeoPixel(pin0, 64) class Snake(): def __init__(self): self.length = 2 self.direction = "down" self.head = (4, 4) ...
ae8ee65d9527b2edfd5b393bb69d70016ddabede
Gafan154/MichaelGafan
/FactGood.py
483
4.1875
4
print("Factorial") def FactInput(): global num num=0 num = input("enter interger number: ") if not num.isdigit(): FactInput() def Fact(num): f=1 while num > 1: f=f*num num-=1 return(f) more='y' while more == 'y': FactInput() ...
33de7e691ca65a230c76d269d1ae6f5a9e6647eb
Lonabean98/pands-problem-sheet
/es.py
812
4.40625
4
#This program reads in a text #file and outputs the number of e's it contains. #It can also take the filename from an argument on the command line. #Author: Lonan Keane #The sys module provides functions and variables used to # manipulate different parts of the Python runtime environment. import sys # sys.argv retur...
cfc6da03a27c785f5e8d5f85512573a588a6f54a
kzecchini/dsp
/python/advanced_python_csv.py
538
3.921875
4
import csv from advanced_python_regex import Faculty def write_emails(data): ''' Given an initial csv file, will create a list of emails and write those to a new csv file with the title 'emails.csv'. ''' original_csv = Faculty(data) emails = original_csv.emails() f = open('emails.csv', 'w'...
59940333b3327ab581193a8db4b61a04bd38ef4a
jk810/goog_fb
/level3-3.py
486
3.5
4
def answer(M, F): M = int(M) F = int(F) n_gens = 0 while M > 0 and F > 0: if M == F: break elif M > F: mod = M / F M -= F * mod n_gens += mod else: mod = F / M F -= M * mod n_gens += mod # P...
6c413a502e5805d58feca2ec8956a9dcab259811
BhupeshXD/Hacktoberfest_21
/program/kadane_Algo.py
595
3.65625
4
#kadane algorithm (largest sub-contiguous sum array) def maxSubArraySum(a,size): curr_sum = 0 max_sum = 0 #sum so far st=0 #start index end=0 #ending index poi=0 #pointer for i in range(0,size): curr_sum = curr_sum + a[i] if max_sum < curr_sum: st= poi end...
8ca914e7fca00e304d150786ff8b832c7bc80264
shivaang12/wordifier
/wordifier/wordifier.py
4,415
4.15625
4
"""Main module.""" from . import helper import itertools def number_to_words(number: str) -> str: """ Args: - number: A string representing US vanity phone number. e.g. "+1-800-724-6837", "1-800-724-6837", "8007246837" Returns: - str: a string which contains plain digit number. ...
4d97af23a0be7dcc0ffdfde4cfdb004c5c8ab574
21354768/Faith
/add what is your name.py
63
3.671875
4
print("Hello World") name=input("Hello, what is your name?")
028ef354ab87048c660f7c74c1d117f43b23b757
elimbaum/euler
/002/002.py
411
4.21875
4
#! /usr/bin/env python3.3 """ Project Euler problem 002 Even Fibonacci Numbers by Eli Baum 14 April 2013 """ print("Project Euler problem 002") print("Even Fibonacci Numbers") n = int(input("Upper Limit: ")) # Brute-Force calculate all of the fibonacci numbers a, b = 0, 1 sum = 0 while True: a, b = a + b, a i...
1f341dec6a19daad68ae3cd636a1d395d1c539dd
elimbaum/euler
/003/003.py
687
4.25
4
#! /usr/bin/env python3.3 """ Project Euler problem 003 Largest Prime Factor by Eli Baum 14 April 2013 """ from math import * print("Project Euler problem 003") print("Largest Prime Factor") n = float(input("n = ")) """ We only need to find ONE prime factor. Then we can divide, and factor that smaller number. ...
f4e1979ea6b3840df4e7a19f71965a32a7378b1f
elimbaum/euler
/041/041.py
1,030
3.5
4
#coding: utf-8 # Project Euler 041 # Largest pandigital prime # # answer: 7652413 import math # checks if n is m-digit pandigital, where m is the length of n # NOTE this doesn't actually work properly. Only gives if no repeated digits. def isPandigital(n): digits = set() digits.add(0) while n > 0: ...
229d7747aa0ad0bb926db022b511f4198f3fb2d0
keivanipchihagh/AUTHUB
/03/Data Structures and Algorithms/notes/codes/Bubble Sort.py
420
3.78125
4
# Import libraries import random # Settings length = 10 debug = False # Create a list arr = [i for i in range(length)] # Shuffle the list random.shuffle(arr) # Algorithm for i in range(len(arr)): for j in range(len(arr) - i - 1): if arr[j] > arr[j + 1]: arr[j], arr[j + 1] = arr[j + 1], arr[j...
2aa4a954d83a4e6773947d6fef64ff41cc2f1986
keivanipchihagh/AUTHUB
/03/Data Structures and Algorithms/notes/codes/Merge Sort.py
1,045
4.28125
4
import random def merge_sort(array): # Return condition if len(array) <= 1: return # Find middle middle = len(array) // 2 # Find left hand left_side = array[:middle] # Find right hand right_side = array[middle:] # Sort first half merge_sort(left_side) # Sort se...
e05d23b8f68f0fcf422ce4a91f5aed4fdfa7630c
samiatunivr/NLPMLprojects
/linearRegression.py
1,821
4.53125
5
__author__ = 'samipc' from numpy import loadtxt def linearRegression(x_samples, y_labels): length = len(x_samples) sum_x = sum(x_samples) sum_y = sum(y_labels) sum_x_squared = sum(map(lambda a: a * a, x_samples)) sum_of_products = sum([x_samples[i] * y_labels[i] for i in range(length)]) a...
4cd0311380b58d94159e3c87cd631b04356eccb3
pranavjain97-zz/LeetcodePractice
/Python Solutions/binaryTreePaths.py
939
4.0625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None # Given a binary tree, return all root-to-leaf paths. # For example, given the following binary tree: # 1 # / \ # 2 3 # \ # 5 # All root...
1363e83d6f5a734c5a014a2bc4364423e7b0eaf1
alehpineda/left_outer_join
/left_outer_join.py
1,675
3.96875
4
import itertools def left_outer_join(file_a, col_a, file_b, col_b): ''' file_a and file_b are file path strings col_a and col_b are non-negative integers Prints out a left_outer_join of two CSV files, with the specified 0-index columns as the join keys. For simplicity, assume that a match only...
91f974b6597229fe3904f31e9ebc98b52e966a5d
timfornell/PythonTricksDigitalToolkit
/Lesson4.py
514
4.25
4
""" Lesson 4: Implicit returns """ # Python will automatically return None, all following functions will return the same value def foo1(value): if value: return value else: return None def foo2(value): """ Bare return statement implies 'return None'""" if value: return value ...
e9bf38d421fcca4978dcea564f3db4b67f96b67c
ArnyWorld/Intro_Python
/9.-Objetos.py
869
3.9375
4
#Los objetos son similares a los arrays, ya que almacena información de #distinto tipo, para acceder a un elemento se ayuda de un KEY persona = { 'nombre' : 'Arni', 'profesion': 'Informática', 'edad': 25 } print(persona['nombre']) #recuperar información nombre = persona['nombre'] print(nombre) #Agregand...
3f3ce30522dc34b97d1db423092598cf0d56ed80
ArnyWorld/Intro_Python
/8.-Condicionales.py
1,735
4.125
4
#Las condicionales nos permiten realizar una acción cuando se cumple cierta condición edad = 15 if edad >= 18: print('Eres mayor de edad') else: print('Eres menor de edad') experiencia = 3 if experiencia == 3: print('Tienes experiencia de 3 años') else: print('No tienes la experiencia solicitada') ...
74947bb810701b2946a2fd4fc39a580042cb1f6c
platform6/ga_python
/class_notes/W5/day-02/2.py
789
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 15 18:22:53 2020 @author: platf """ import os def read_csv_data(file_name): # os.path.abspath(__this__) = current working file # os.path.dirname() = current dir where the file is contained. data = {} try: current_folder = os.path.dirname(os....
f582ef5f156770b094e815099ad9dfb7bc187041
platform6/ga_python
/class_notes/W2/day-01/two.py
1,549
4.03125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 22 18:54:33 2020 @author: platf """ my_list = [1, 2, 3, "Joe", 11.1] print(1 in my_list) # prints true as that object exists in my list name = "Garrett" print('a' in name) # prints true as the 'a' is part of the iterable string # age = 22 # print(22 in age) # ...
6e580ea63194712ddcfd9d7667d77b37b1ff125e
platform6/ga_python
/class_notes/W2/day-02/3.py
1,072
3.984375
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 24 18:45:06 2020 @author: platf """ # two dictionary objects dict1 = { "first_name" : "John", "last_name" : "Doe", "classes_taken" : ('Python', 'Java'), "grades" : (100, 55) } dict2 = { "first_name" : "Suresh", "last_name" : "Sigera", "...
d957b34668aa3188ea7abe0d1f2f56311b4261c4
platform6/ga_python
/class_notes/W3/day-02/lab/lab.py
1,308
3.671875
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 1 18:43:32 2020 @author: platf """ one_day_of_hourly_temperatures = [ 67, 67, 68, 69, 71, 73, 75, 76, 79, 81, 81, 80, 82, 81, 81, 80, 78, 75, 72, 70, 67, 65, 66, 66 ] one_day_of_hourly_humidity = [ 60, 65, 65, 70, 70, 70, 70, 75, 75, 75, 75, 80, 80...
9e7e8e368653de33259874b584162a75cbede6a4
markliu2013/machine-learning
/toturial_projects/mock/utils.py
830
3.5625
4
import numpy as np ''' Perceptron的sign函数。参考李航2.2 ''' def sign(x): return -1 if x < 0 else 1 ''' 一般的sigmoid函数在输入大整数时会返回1,导致log操作时报错。经过我的测试这个方法最好使。 https://stackoverflow.com/questions/52423163/sigmoid-function-returns-1-for-large-positive-inputs ''' def sigmoid(x): sig = 1 / (1 + np.exp(-x)) # Define sigmoi...
d9e8bfbbf6a53ba9a224c5d7889bc3eff43b4d64
markliu2013/machine-learning
/toturial_projects/mock/knn_base.py
1,040
3.5625
4
import numpy as np from utils import distance ''' https://github.com/SmallVagetable/machine_learning_python/blob/master/knn/knn_base.py https://github.com/Dod-o/Statistical-Learning-Method_Code/blob/master/KNN/KNN.py ''' class KNN(object): def __init__(self, k=20, p=2): self.k = k self.p = p ...
43a1f6f02c30bbdf2186dd1b5fa66822042d7d76
TomasPalacios223/desafios
/desafio6.py
354
3.9375
4
"""el siguiente programa imprime la cant de letras a, que tiene una cadena de caracteres ingresada por teclado""" cadena = input("Ingrese una cadena de caracteres : ") cant = 0 cadena=cadena.lower() for letra in cadena: if letra == "a": cant = cant + 1 print("la cadena ingresada tiene la siguiente cant...
5b09b43656c5f7ef9e7062ffe66664219537ee08
Siddharths8212376/cg_algorithms
/tests/test_circle.py
895
3.59375
4
#Program to plot a point from cg_algorithms.circle_algorithms import circle_algorithms from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * import sys import math import time def init(): glClearColor(0.0, 0.0, 0.0, 0.0) gluOrtho2D(-250.0, 250.0, -250.0, 250.0) def plot_points(): g...
3ecd0628bc2bc88c2fcdf41191c1690b3ad4ec62
ShionHXC/learn_python3
/d_circle.py
465
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 循环 print(range(3)) print(list(range(3))) sum = 0 for x in range(101): sum += x print(sum) total = 0 n = 100 while n > 0: if n < 20: break total += n n -= 1 print(total) i = 0 while i < 10: i = i + 1 if i % 2 == 0: # 如果n是偶数,执行continue语...
dd113b79e3ea24153d0c23f74636a3e9d715f92c
shymarrai/pset6
/dna/dna.py
2,288
3.671875
4
import sys import csv DNA_AGATC = "AGATC" DNA_AATG = "AATG" DNA_TATC = "TATC" def main(): base, dna_sequence = verify_args() sequence = read_sequence(dna_sequence) people = read_people(base) dna = compare_sequences(sequence) person = lookup_people(people, dna) if person: print(person...
bfd9249f486daa509c087da812386dfbb599f0b7
geeta-kriselva/python_excercise
/emaillog_probs/Sorting_hour.py
860
4.03125
4
#Write a program to read through the mbox-short.txt and figure out the #distribution by hour of the day for each of the messages. You can pull the hour #out from the 'From ' line by finding the time and then splitting the string a #second time using a colon.Once you have accumulated the counts for each hour, #print out...
5d54fac367fd107da96dbebc34f99ffa55188742
geeta-kriselva/python_excercise
/Prime_number.py
599
4.125
4
# Checking, if user input number is prime a number. if not printing all the facors. n= input("Enter the number: ") try: num = int(n) except: print("Enter only integer number") quit() if num > 1: factor = [] a = 0 for i in range(2,num+1): if (num % i) == 0: factor.insert(a,i) ...
7a9a1750ded5514f460d3566a816392bc3093dfe
reggies28/tarea-IA
/imagenescontador/neural_network_imgcontador.py
9,245
3.984375
4
# python notebook for Make Your Own Neural Network # code for a 3-layer neural network, and code for learning the MNIST dataset # (c) Tariq Rashid, 2016 # license is GPLv2 import numpy # scipy.special for the sigmoid function expit() import scipy.special # library for plotting arrays import matplotlib.pyplot # ensure ...
472922618a2084c0b8c05c5b47f19daeb1e145db
seryogin17/dlcourse_ai
/assignments/assignment2/layers.py
5,604
3.59375
4
import numpy as np def l2_regularization(W, reg_strength): """ Computes L2 regularization loss on weights and its gradient Arguments: W, np array - weights reg_strength - float value Returns: loss, single value - l2 regularization loss gradient, np.array same shape as W - gra...