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
3d8eaebda59ce03927c28a1b41d44248e2885614
BerilBBJ/scraperwiki-scraper-vault
/Users/1/1019987/threecirclesunderneath-each-otherpy.py
838
4.28125
4
""" This program draw three circles underneath each other""" import turtle turtle.color('Red') turtle.circle (50,360) turtle.right(90) turtle.up() turtle.forward(10) turtle.forward(50) turtle.forward(50) turtle.left(90) turtle.color('yellow') turtle.circle(50,360) turtle.up() turtle.down() turtle.right(90) turtle.up()...
5b4242afafd61aa1efbb9369038baf0f48bf3482
BerilBBJ/scraperwiki-scraper-vault
/Users/B/bcoughlan/galway-arts-council.py
10,122
3.546875
4
############################################################################### # Basic scraper ############################################################################### import sys, logging, mechanize, unicodedata import scraperwiki from BeautifulSoup import BeautifulSoup # This function strips any unicode or ...
160c528fd82fe12a0c492b51308c9fbbd68252f7
BerilBBJ/scraperwiki-scraper-vault
/Users/1/1022752/consumption.py
2,654
3.640625
4
import scraperwiki from BeautifulSoup import BeautifulSoup print "List of countries by electricity" HtmlPage = scraperwiki.scrape('http://en.wikipedia.org/wiki/List_of_countries_by_electricity_consumption') WebPageSource = BeautifulSoup(HtmlPage) scraperwiki.metadata.save('data_columns', ['Rank', 'Country','Electrici...
0bb4d8a07f9f9aa31a5ecb898337890f4f4ab6f7
BerilBBJ/scraperwiki-scraper-vault
/Users/E/edmilton/01_-_cpis_em_aberto_-_sao_paulo.py
3,252
3.625
4
# Scraper 01 - Obter as CPIs em aberto na câmara municipal de São Paulo. # URL que será raspada: http://www1.camara.sp.gov.br/cpi_joomla.asp # URL principal (de onde a url acima é chamada através de um iframe): http://www.camara.sp.gov.br/index.php?option=com_wrapper&view=wrapper&Itemid=38 # Dados que serão raspados: #...
89d1c011c6bbd1337425e3b2073b34c21d542fdf
BerilBBJ/scraperwiki-scraper-vault
/Users/E/eszak/bostoncom_ap_news_headlines_scraper.py
2,854
3.875
4
# Hi Elana, # I'm gonna give you a few hints :-) # ~ Zarino import scraperwiki import lxml.html # the html module is simpler than etree import requests # We request the webpage from the Boston Globe's server: content = requests.get('http://www.boston.com/news/education/') # The server responds with something. We prin...
65476f8759151ad5f99b915914cca4600988956f
BerilBBJ/scraperwiki-scraper-vault
/Users/D/drj/canada-temperature-summary.py
10,642
3.515625
4
# canada-temperature-summary # Summary of the data held in the canada-temperature-data scraper # David Jones, 2011-08-31, Climate Code Foundation import scraperwiki import itertools import re def bin_counts_by_station(ds): """For each station in the database *ds*, count the number of records (*l*). Return a ...
99953e049a03d5ba5435db3e82955631be77236c
BerilBBJ/scraperwiki-scraper-vault
/Users/R/Ravinder_kaur/ravinder_team.py
3,306
3.671875
4
import scraperwiki from BeautifulSoup import BeautifulSoup def scrape_table(soup): #to define coloumns name used in table scraperwiki.sqlite.save('data_columns', ['Team', 'Team Code','Team Nationality', 'Team Leader', 'Key Riders','Last Year (Best)']) table = soup.find("table...
49938ae96e3793a2a0eeeaf5370f2f747d5af89e
BerilBBJ/scraperwiki-scraper-vault
/Users/E/erikadeal/wikipedia_page_history.py
6,316
3.671875
4
#This scraper queries the Wikipedia API, retrieves the full revision history of an article, and saves the results in a CSV file. We did not use the Scraperwiki database because of an outage while writing the script, so this script would actually be run from a program rather than the browser. We used this history for th...
d627f02395efd7cf6f11379c3e54bfb10ada8590
BerilBBJ/scraperwiki-scraper-vault
/Users/I/ithiad/guardian-leeds-cutswatch-reports.py
3,270
3.5
4
import scraperwiki from BeautifulSoup import BeautifulSoup ############################################################################################ # Helper function to scrape a reports list page and store records. ############################################################################################ def sc...
6931f7abda0b6a4a396fb9e72a6d925d93bea72a
BerilBBJ/scraperwiki-scraper-vault
/Users/C/callkalpa/cyberwordsview.py
606
3.5
4
import scraperwiki scraperwiki.sqlite.attach("cyberwords") print '''<h1>CyberWords</h1> counting words in cyber space...<br/> ''' data = scraperwiki.sqlite.select('''count(*) from cyberwords.swdata''') print '''<p>Number of distinct words: ''', data, '''</p>''' # Blank Python sourcescraper = '' import scraperwik...
4b2815c35eb484e7a23d373efdbd797deba756ab
BerilBBJ/scraperwiki-scraper-vault
/Users/H/helgeholler/arba_-_argentina_contribuyentes_con_deuda_de_imp_1.py
3,542
3.6875
4
#forked from https://scraperwiki.com/profiles/pablocesar/ #to learn more about scraping from string import ascii_lowercase import urllib2 import re import scraperwiki import lxml.html import urlparse def get_html(url): user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (...
8b4ba98187f7f30f931af2a69e4663902b2fc77c
BerilBBJ/scraperwiki-scraper-vault
/Users/G/ghall09/huffingtonpost_rss_scrape_v2.py
1,506
3.578125
4
from urllib import urlopen from BeautifulSoup import BeautifulSoup import re #open and read webpage webpage = urlopen("http://feeds.huffingtonpost.com/huffingtonpost/raw_feed").read() #locate article title title = re.compile('<title>(.*)</title>') #locate article link link = re.compile("<link rel.*href=(.*)/>") #s...
c24a97de0006a6812cf3cb1fec0a82539dcbfa03
BerilBBJ/scraperwiki-scraper-vault
/Users/S/sym/adnams-pubs.py
4,858
3.515625
4
import csv import re import urllib2 import BeautifulSoup from scraperwiki import datastore from scraperwiki import geo class Outcodes(): def __init__(self): self.download_outcodes() def download_outcodes(self): """ Downloads a CSV file from http://www.freemaptools.com/ and p...
6eb106f25a5ca13979f67e697258fee90aa7ae7e
BerilBBJ/scraperwiki-scraper-vault
/Users/A/ashi/uk_gdp.py
3,174
3.75
4
import scraperwiki from BeautifulSoup import BeautifulSoup def scrape_table(soup): #here we define the table with column names scraperwiki.metadata.save('data_columns', ['Website', \ 'Year,quarter','GDP,adjusted for inflat-ion,£m','% change','GDP,adjusted for inflation,£m','inflation-adjusted per capita,£...
5e9503def3ba023d01e0342027be2b775c75388b
BerilBBJ/scraperwiki-scraper-vault
/Users/J/jedawson/cornell_police_daily_crime_log.py
998
3.59375
4
# grab the webpage import scraperwiki html = scraperwiki.scrape("http://dailycrimelog.cupolice.cornell.edu/?RepID=2627") print html #download the html import lxml.html root = lxml.html.fromstring(html) p = root.cssselect("div tr") print lxml.etree.tostring(p) for tr in root.cssselect("div tr"): tds = tr.cssselect...
79ae5f1667ac9d321b0f17d2f6508bf0bf4b08af
BerilBBJ/scraperwiki-scraper-vault
/Users/Z/zopsi/uk_towns_and_cities_2.py
2,702
3.796875
4
# All UK Towns and Cities and their coordinates # Based on a scraper written by Ross Jones # Town and City names scraped from Wikipedia: # http://en.wikipedia.org/wiki/List_of_towns_in_the_United_Kingdom # http://en.wikipedia.org/wiki/List_of_cities_in_the_United_Kingdom # Towns and Cities geolocated by the Geonames A...
102b263e3e3cec252a18c1eb845437bbd54e7ded
stacy867/password-locker
/credentials.py
2,203
3.671875
4
import pyperclip class Credential: credential_list= [] """ class that generates credentials. """ def __init__(self, account, username, password,email): self.account = account self.username = username self.password = password self.email= email # Crede...
c9be013cf4a061b15fd370145606dc5e5ffab2ac
ndkheswa/coding-bootcamp
/coding-bootcamp/banking.py
1,235
3.859375
4
#!/usr/local/bin/python3 class Account: AMOUNT_MIN = 150 def __init__(self, balance, account_type): self.balance = balance self.account_type = account_type if self.balance >= self.AMOUNT_MIN: self.active = True return print(f'A new account has been crea...
b65074eadf63a10c9f78bb7500b9d7834caeaf79
Anno1994/NLP
/Aufg2_JMH/src/main/Bank.py
4,357
3.890625
4
import threading import datetime from enum import Enum class Bank(object): """Bank class which holds accounts""" accounts = [] def __init__(self): """Constructor""" self.accounts = [] def deposit(self, accNo, amount): """deposit function which adds the amount(...
e05e6fedfe675dc4714ddae965cf599afa629130
umeshkhaniya/Finding-Hidden-Messages-in-DNA-Bioinformatics-I-
/freq_mismatch.py
749
3.921875
4
# Frequent Words with Mismatches Problem: Find the most frequent k-mers with mismatches in a string. # Input: A string Text as well as integers k and d. (You may assume k ≤ 12 and d ≤ 3.) # Output: All most frequent k-mers with up to d mismatches in Text. #Code Challenge: Solve the Frequent Words with Mismatches Prob...
0cb2d2b33e51bb56f0f422a2ae5aad4adb813c40
mekiah343/mate
/Program/powerGenorated.py
755
3.546875
4
# Find the highest value of velocity that is not in a cabel area / squigily line from math import pi seaWaterDensity = 1025 # kg/m^3 turbineDiameter = float(raw_input("Diameter of turbines: ")) turbineRadius = turbineDiameter / 2 turbineArea = (turbineRadius * turbineRadius) * pi efficiencyValue = float(raw_input("...
8c87142a368139f89f6b9072c12d18fbc8f7bcb1
M4THYOU/TF-Tutorial
/main.py
11,792
3.890625
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data #import a big dataset #from tensorflow. 70k images: 55k training, 10k testing, 5k validation #just a bunch of images of handwritten numbers. #These images are 28x28 pixels #All tensors are basically just matrices with a defined shape. m...
0cb9e48b9ed72ccfbc29f61c02c203f0aa57733b
Martin-Ascouet/tp11_2nd_annee
/Exercice5.py
1,951
3.703125
4
class Matrice: def __init__(self, data): self.__data = data def __str__(self): return "|"+str(self.__data[0][0])+" "+str(self.__data[0][1])+"|\n|"+str(self.__data[1][0])+" "+str(self.__data[1][1])+"|\n-------" def __add__(self, M): a = ([self.__data[0][0] + M.__data[0][0], self.__d...
8f872ae832a6b0a8c3296c46581eb390fca1c4e4
expelledboy/dabes-py-ddd-example
/domain/common/constraints.py
701
4.15625
4
def create_string(field_name: str, constructor: function, max_len: int, value: str): """ Creates a string field with a maximum length. :param field_name: The name of the field. :param constructor: The constructor function. :param max_len: The maximum length of the string. :param value: The valu...
b763671aa6e2edab48338ca9250b4ec7d1039944
NFellenor/AINT357_Content
/P3_Recursion_Dynamic_Programming/P3_Recursion_Dynamic_Programming/P3_Recursion_Dynamic_Programming.py
729
4.25
4
#Practical 3: Recursion and dynamic programming: #Recursivley compute numbers 1-N: def sumOf(n): if (n <= 1): return 1 return n + sumOf(n - 1) #Recursive line print("Input value for n.") n = int(input()) #Set value for n by user print("Sum of values from 1 - n:") print(sumOf(n)) #Recursivel...
55e4dfdee78c036091ba3cb6ab601deb499ff51e
gaderut/CloudComputing-docker
/SVM/timeParser.py
1,091
3.78125
4
class timeParser: def __init__(self, timestring): sp = timestring.split(':') if len(sp) == 2: self.hour = float(sp[0]) self.min = float(sp[1]) else: self.hour = float(timestring) self.min = 0.0 def __lt__(self, other): return s...
1a00efb58530a386af8938fbf9b43a223a277d55
PerlMonker303/machine-learning-fashion
/feature_scaling.py
763
4
4
import numpy as np def feature_scaling(X): ''' Applies feature scaling on a given matrix :param X: :return: triplet [X_scaled, lmbda, mu] where X_scaled is the modified matrix, lmbda is the mean average and mu is the standard deviation We will need this last two values for when we scale...
9597ad6dd77e5e510b01a30e78ce24f588a72e4b
afaan5556/dash_weatherdata
/getdata.py
4,741
3.515625
4
import pandas as pd import os import csv ## CONSTANTS # Directory where TMY data lives DIRECTORY = '../../../tmy_data/' # A file in the directory to access df columns DUMMYFILE = '690150TYA.csv' ## CATCHER / PRE-SETUP DATA STRUCTURES # Dictionary which will have keys:epw station name, values:dataframe DF_DICT = {} # ...
ac3874c1f628834a3f4e06041e74aa97601efc92
shannan1989/ShannanPython
/WordCloud/colored.py
1,549
4.03125
4
#!/usr/bin/env python """ Image-colored wordcloud ======================= You can color a word-cloud by using an image-based coloring strategy implemented in ImageColorGenerator. It uses the average color of the region occupied by the word in a source image. You can combine this with masking - pure-white will be interp...
ba29f8acfec7b67305c7326c6d3ecfab1e4a7bb0
Nishad00/Python-Practice-Solved-Programs
/The Minion Game.py
2,261
3.734375
4
# Kevin and Stuart want to play the 'The Minion Game'. # Game Rules # Both players are given the same string, . # Both players have to make substrings using the letters of the string . # Stuart has to make words starting with consonants. # Kevin has to make words starting with vowels. # The game ends when ...
22dc7651851f3296a2eac7d6d7e035a212ad885a
Nishad00/Python-Practice-Solved-Programs
/Validating_Roman_Numerals.py
588
4.1875
4
# You are given a string, and you have to validate whether it's a valid Roman numeral. If it is valid, print True. Otherwise, print False. Try to create a regular expression for a valid Roman numeral. # Input Format # A single line of input containing a string of Roman characters. # Output Format # Output a single ...
6b16132c96ad015944ff56395b2702e423df5624
Mefodii/AdventOfCode_2019
/days/day_13.py
4,998
3.578125
4
ADD = "01" MULTIPLY = "02" INPUT = "03" OUTPUT = "04" JIT = "05" JIF = "06" LT = "07" EQ = "08" ADJUST_RELATIVE_BASE = "09" END = "99" POSITION_MODE = "0" IMMEDIATE_MODE = "1" RELATIVE_MODE = "2" SCORE = -1 BLOCK = 2 PADDLE = 3 BALL = 4 ###############################################################################...
6497fa8dda3be3030f931b566ad1866f9f460165
guozhe001/Loan-Calculator
/Problems/Small scale/main.py
121
3.65625
4
numbers = [] while True: s = input() if s == ".": break numbers.append(float(s)) print(min(numbers))
1fcf727d7a8164398dddd7dfcbd5c0a02951d2e4
guozhe001/Loan-Calculator
/Loan Calculator/task/creditcalc/creditcalc.py
7,418
4.15625
4
# Stage 1/4 start # loan_principal = 'Loan principal: 1000' # final_output = 'The loan has been repaid!' # first_month = 'Month 1: repaid 250' # second_month = 'Month 2: repaid 250' # third_month = 'Month 3: repaid 500' # write your code here # print(loan_principal) # print(first_month) # print(second_month) # print(t...
5b048b1ad1d0ce754814ae499428fe72b84048e1
ikedaema2018/algorithm_and_data_structure
/s-3-2-1.py
674
3.65625
4
# 挿入ソート data = [5,2,4,6,1,3] new_data = [data[0]] def print_result(x, y): for n in x: print(n, end=' ') for n in y: print(n, end=' ') print('\n') for idx, n in enumerate(data[1:]): new_idx = idx + 1 print_result(new_data, data[new_idx:]) change_flag = False for nidx, v in enumerate(new_data): ...
6378f7d70184e5e6d7148f3f40c858545683506d
ikedaema2018/algorithm_and_data_structure
/s-6-3-1.py
824
3.65625
4
# コッホ曲線 # なんとなく写経 import math class Point: def __init__(self): self.x = None self.y = None def koch(n, a, b): if n == 0: return s, t, u = Point(), Point(), Point() th = math.pi * 60.0 / 180.0 s.x = (2.0 * a.x + 1.0 * b.x) / 3.0 s.y = (2.0 * a.y + 1.0 * b.y) / 3.0 t.x = (1.0 * a.x + 2.0 * ...
35f10ea897580ce47d4fd020aa9bb9781b1a87e4
Trent-Farley/All-Code
/Python1/Train Ride/yourturn.py
621
4.40625
4
#Create a trapezoid Calculator-- Here is the formula ((a+b)/2)*h #USER input #Create a test to see if an in is even use % (mod) to test #divisible by zero. USER INPUT #Find the remainder of a number -- Number can be your choice #Find the volume and area of a circle from user input #volume = 4/3 *pi*r^3 #Area ...
53e913d4ffb73db49f8a5d92069c42cae1c908b8
Trent-Farley/All-Code
/Python1/Assignment 3/sum_list.py
732
3.796875
4
################################ # Trent Farley CS161 8AM # Assignment 3, part 2, file sum # # Specificatons- # Write a program that opens a file and sums # all of the numbers within the file. # # Pseudocode- # Using a with statement combined with open file ard write # ...
bc3c2922bcba4c9df80c88bedf268a36f7a9cf60
Trent-Farley/All-Code
/Python1/Old stuff/time_test.py
225
3.734375
4
t= float(input("How many secons? only 1-86,400 will work")) day= t // (24*3600) t= t % (24 *3600) minutes= t/60 hour= t // 3600 t %= 60 seconds=t print("Hours, Minutes, Seconds --> %d:%d:%d" % (hour, minutes, seconds))
9a7a7be1657ff95c6ad6eba58bb1bce27adce8c5
Trent-Farley/All-Code
/Python1/Old stuff/Assignemt2.py
671
4.375
4
# Farley, Trent # Assignemt 2 # Problem Analysis: Write a program to calculate the volume # and surface area of a sphere. # Program specifications: use the formualas to create a program # that asked for a radius and outputs the dimensions. # Design: # I need to create a float input value. Once that value is cal...
535395bc9b94395d35599cb0fd63148cceb90a6f
Trent-Farley/All-Code
/Python1/Old stuff/happybirthday.py
1,656
3.53125
4
import turtle import random # set the background color for the page bg = turtle.Screen() bg.bgcolor("light Blue") tommy = turtle.Turtle() tommy.shape("turtle") tommy.speed(1) # draw lines tommy.penup() tommy.goto(-190, -180) tommy.color("yellow") tommy.pensize(6) tommy.pendown() tommy.goto(190,-18...
c70935b5a689951f8503091386c083c375c34817
Trent-Farley/All-Code
/Python1/Old stuff/lab2_part2.py
400
4
4
import turtle import random count = int(input("How many shapes? \n:: ")) for n in range(int(count)): turtle.color(random.random(),random.random(),random.random()) turtle.begin_fill() for i in range(8): turtle.forward(60) turtle.right(60) turtle.end_fill() turtle.forwa...
0078e190c9108a595e69bf0dd6abe8d35b9c8c8a
Trent-Farley/All-Code
/Python1/Assignment 3/Cipher.py
1,002
3.9375
4
############################################# # Trent Farley # CS161; 8AM # Assignment 3, Part 4, Caeser Cipher # Specifications- # Pseudocode- # I will need two lists, one for the old word and another for the new one # The next step will be to use a range functionto cycle through each # letter, change...
516b2d8f9bb4a2ffcdf63e4f0b8f3c6f2fd0ef1f
raphaelm/ba-dynfil
/dynfil/utils/linalg.py
1,388
3.5
4
import numpy as np def tridag(a, b, c, r): """Solve linear system with tridiagonal coefficient matrix. a is the lower band, b is the diagonal, c is the upper band, and r is the right hand side. The solution is returned in u. [b1 c1 0 ... ] [u1] [r1] [a1 b2 c2 0 ... ] [ :] [ :]...
3dd61d69f726c1985289cf9b585758577b2f144c
shiva2492/TicTacToe-The-Game-
/tictactoe.py
3,178
3.9375
4
# Deciding the data structure to use for the grid initial_grid = [[' ',' ',' '] for i in range(3)] # print(initial_grid) # Function to print the grid def printGrid(): for row in initial_grid: row_str = '' for i in range(len(row)): if i == 0 : row_str += "| {} |".form...
2b8eb76b4162442da56ba1aaf0ff755e076e7501
Menda0/pratical-python-2021
/7_data_structures_exercises.py
1,228
4.40625
4
# 1. Create a list with 5 people names # 2. Create a tuple with 5 people names ''' 1. Create 6 variables containing animals (Example: Salmon, Eagle, Bear, Fox, Turtle) 2. Every animal must have the following information 2.1 Name, Color, Sound 3. Create 3 variables for animal families (Exa...
7404f874819261a132afccf8937de39a39860cf7
stahura/school-projects
/CS1400/Projects/rabbits_JRS.py
2,774
4.28125
4
''' Jeffrey Riley Stahura CS1400 Project: Rabbits, Rabbits, Rabbits Due March 10th 2018 Scientists are doing research that requires the breeding of rabbits. They start with 2 rabbits, 1 male, 1 female. Every pair reproduces one pair, male and female. Offspring cannot reproduce until after a month. Offspring cannot hav...
76e71896361d9d5d061ef04cc651c284a5d86f50
stahura/school-projects
/CS1400/Py Exercises/EXC4.py
2,262
4.0625
4
from graphics import * import math def target(): win = GraphWin('Target') outerOne = Point(100,100) circOne = Circle(outerOne,50) circOne.setFill('red') circOne.draw(win) outerTwo = Point(100,100) circTwo = Circle(outerTwo,40) circTwo.setFill('blue') circTwo.draw(win) outerT...
dcff5580878a8a4a8056926412dc8a18ab231970
stahura/school-projects
/CS1400/Py Exercises/EXC5_numvalue.py
599
4.0625
4
def numvalue(): name = input("Enter a single name: ") value = 0 for letter in name: #To account for the spaces in between names if letter == " ": letterValue = ord(letter)-32 #To account for the letter that may be uppercase elif ...
9d8743ff21061a86cedeb1474061e85b19c30a7f
stahura/school-projects
/CS1400/Projects/farmer_john.py
3,640
3.84375
4
#Jeffrey Riley Stahura #10617813 #CS1400-001 #Due Feb. 24th # Programming Project #3: Farmer John's Field # # #We need to determine the area of a shaded region that is left in the center after creating 4 circles # Steps # Draw the 4 circles that mirror each other across the X and Y...
338abae0bf9f13439fc3a5f611ec372d0b5b558d
MarcPartensky/Python-2018
/BigOrSmall.py
259
3.875
4
import random Solution=random.randint(0,100) Guess=int(input("Guess: ")) while Guess!=Solution: if Guess>Solution: print("Too big") if Guess<Solution: print("Too small") Guess=int(input("Guess: ")) print("Nice u found it")
a4db00ec5e1ca4070e17250a69931628cfb0b049
MarcPartensky/Python-2018
/test de bouton.py
287
3.515625
4
from tkinter import * import math def clavier(event): touche = event.keysym if touche=="Return": print("Je suis génial") fenetre = Tk() canvas = Canvas(fenetre, width=500, height=500) canvas.focus_set() canvas.bind("<Key>", clavier) canvas.pack() fenetre.mainloop()
e99b3eaadebd40bfc5a7883b26231725c3c4e662
MarcPartensky/Python-2018
/Deep Learning Sendex 2.py
2,324
3.6875
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist=input_data.read_data_sets("/tmp/data/", one_hot=True) n_nodes_hl1=500 n_nodes_hl2=500 n_nodes_hl3=500 n_classes=10 batch_size=100 def neural_network_model(data): hidden_1_layer={"weights":tf.Variable(tf.random_normal([784,...
7cd5e4d3f6e1eb9fb21b3fc1e40d55e60117357f
xz353/Zhu_Xinying_python
/Zhu_Xinying_hw1.py
11,730
4.46875
4
# -*- coding: utf-8 -*- """ @author: xinying zhu """ #You grades are influended by your format, please refer to the format that Professor G has shown during the lecture. The content #we expect between """ are questions you are trying to solve, your input parameters and your output. Once you corrected #them, I am more t...
182ae086243e942974e87365ea4ff37824786cf0
glimmercn/Euler-Project
/src/solution/p100- arranged probability/p100.py
205
3.65625
4
''' Created on Jan 28, 2013 @author: kan ''' import math a = int(1000/math.sqrt(2)) while True: b = int(math.sqrt(2) * a) if 2 * a * (a-1) == b * (b-1): print(a) #break a += 1
35866732235707c734413a5b691765851380bc1a
johnsogg/cs1300
/homeworks/hw-3-maps/doggies.py
910
4
4
# create an associative array like this: dog = { 'name' : 'Sputnik', # dog's name 'pronoun' : 'he', # pronoun: he/she/it 'pos_pron' : 'his', # possessive pronoun: his/her/its 'age' : 4, # dog's age (an integer) 'occupation' : 'Being Awesome', # note last comma is ok }...
e559b46dd650db58b644524f0c4a8f92ea2ca791
johnsogg/cs1300
/code/py/objects.py
495
3.78125
4
class Phone: vendor = "Unknown" model = "Unknown" def ring(self): print "The phone " + self.vendor + " is ringing" gabes_phone = Phone() print "Gabe's phone: ", gabes_phone print "Gabe's phone vendor:", gabes_phone.vendor jillian_phone = Phone() jillian_phone.vendor = "Samsung" jillian_phone.mod...
e99e3544eed9a000f67f50aac98fb08c6519c64d
johnsogg/cs1300
/code/py/lists.py
482
4.125
4
my_empty_list = [] print type(my_empty_list) my_list = [ 1, 7, 10, 2, 5 ] my_stringy_list = [ "one", "three", "monkey", "foo"] my_mixed_list = [ 42, "forty two", True, 61.933, False, None ] for thing in my_list: print "My thing is:" + str(thing) print "" for thing in my_stringy_list: print "My stringy thi...
5db9ead048cc8ff4b9dcee00ca006875f9348818
ari7946/Sprint-Challenge--Hash-Theory
/hash-tables/ex1/ex1.py
396
3.546875
4
# lecture code solution def get_indices_of_item_weights(weights, limit): weights_dict = {} for i in range(len(weights)): weight = weights[i] if (limit - weight) in weights_dict: return (i, weights_dict[limit - weight]) else: weights_dict[weight] = i return() if __name__ == '__main__': ...
50ef96b6eede9bf61e8c6d843c950c962258e8ff
markscottwright/adventofcode2017
/python/day7.py
3,172
3.6875
4
import collections class Program: def __init__(self, name, weight, children=[]): self.name = name self.weight = weight self.children = children @classmethod def parse(cls, line): fields = line.split() name = fields[0] weight = int(fields[1][1:-...
dfce779af93f5b4d4aaf0e74ee98ba1cf5dace14
markscottwright/adventofcode2017
/python/hexcell.py
2,268
3.65625
4
import math class HexCell: """A cell in a hex grid""" def __init__(self, x, y): self.x = x self.y = y def n(self): return HexCell(self.x, self.y+1) def ne(self): return HexCell(self.x+1, self.y+0.5) def se(self): return HexCell(self.x+1, self.y-0.5) def s(self): ...
8dda2155057ffef530ce424682786dcf8ec3ef58
jfan3/BootCamp2018
/ProbSets/Comp/SDP4.py
1,917
3.65625
4
import box import random import time import sys def game (name, t): remaining = list(range(1,10)) flag = True time1 = time.time() t_remain = t while flag & (len(remaining)!=0) & (t_remain>0): r = roll(sum(remaining)) if not box.isvalid(r, remaining): flag = False ...
12183c6d111eed9b38757e939c3e28ba0051cd01
tannerbender/E01a-Control-Structues
/main10.py
1,789
4.21875
4
#!/usr/bin/env python3 import sys, utils, random # import the modules we will need utils.check_version((3,7)) # make sure we are running at least Python 3.7 utils.clear() # clear the screen print('Greetings!') #printing the word "greetings" colors = ['red','orange','yellow',...
68071d5b1f40dabd181462d2d5200ca88d1ef1b1
cugis2019dc/LucineK
/temp.py
796
4
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ print("Hello, my name is Lucine") 5*2 5/2 5**2 8/9*3 print("5*2") def multiply(a,b): multiply = a*b print(multiply) def sum(a,b,c): sum = a+b+c print(sum) sum(1,2,3) def area(...
36cc2b81e8c17f789d8c1271e9edb497fb9b3b28
FilipposDe/algorithms-structures-class
/Problems vs. Algorithms/problem_2.py
2,625
4.3125
4
def rotated_array_search(input_list, number): """ Find the index by searching in a rotated sorted array Args: input_list(array), number(int): Input array to search and the target Returns: int: Index or -1 """ if len(input_list) == 0: return -1 return sea...
f9bee4a9dc1194255cac529aacdf1c3a215bf934
FilipposDe/algorithms-structures-class
/Problems vs. Algorithms/problem_3.py
3,682
4.3125
4
def mergesort(arr): # Descending sort if len(arr) <= 1: return arr mid_index = (len(arr)) // 2 left_part = arr[:mid_index] right_part = arr[mid_index:] left_part = mergesort(left_part) right_part = mergesort(right_part) return merge(left_part, right_par...
1ac86130d656b3d0f92811e15d46d6cf5854efb2
Mossaka/grabbing_UCSD_courses
/new_code/course.py
5,756
3.5
4
import re class Course(object): def __init__(self, course_id, name, content): """ Initialize the course id, name, and content Notice that the course_id and name are pre_processed """ # course id and name need to go over the string_correct function self.ID = self.id_...
8ceb3abd315fbbbab24f27938dbb3899675afd2e
laltin/pdf-tools
/split.py
1,114
3.546875
4
#!/usr/bin/python import pyPdf import sys def split (input_file, output_format): """ splits a pdf file into single page pdfs """ input = pyPdf.PdfFileReader( open(input_file, "rb") ) for i in range(input.numPages): output = pyPdf.PdfFileWriter() output.addPage(input.getP...
11868952ed679c3cfca0d644d5da9ff8de5e05b2
LyaraCorp/Jeu-du-loup-garou-python
/algorithme de base.py
1,169
3.65625
4
if 'name' == 'name': loup=Loup(["jean miche","kevin","gertrude","neuf","françois","bourdin","courgette","licorne","tesla",'milka','bite','couille','testicule droit','chocolatine','testicule gauche','ponyta','mamie']) print(loup.nom_role()) if loup.nb_player() < 10 : votes = input('Entrez les votes (...
2762d2a71e63f0ca4e1ee0ed26e2288812b981b0
roopak07/python
/python code 2.7 version codes/vpython ultrsonic.py
559
3.78125
4
from visual import * myscreen=display(title='box virtual') myscreen.width=1600 myscreen.height=1000 myscreen.range=(12,12,12) frontbox=box(length=0.1,width=10,height=5,color=color.green,pos=(6,0,0)) #if we make pos=(0,0,0) we cant see 3d box we can see only a straight line backbox=box(length=0.1,width=10,height=...
d0a2ca18da57d5f0e84d5c0611e6ecbb15dc27c4
roopak07/python
/python code 2.7 version codes/ploting 2 lines.py
641
3.859375
4
import numpy as np import matplotlib.pyplot as pt x=[1,2,3,4,5] y=[2,4,6,8,10] pt.plot(x) #plots x with respect to 0,1,2 pt.plot(y,'r^')#r=red line ,^ = triangle ,#plots y with respect to 0,1,2 pt.plot(x,y,'g--')#plots x with respect to y,o- =orange line,g=green line, -- = doted lines pt.plot(x,y,'bo') #plots x ...
375b802f7d5fcb3b2c4205b4be1c3c7eba6bdb34
almakhann/Codeforces
/271A.py
273
3.578125
4
a = (input()) def counter(a): b = ''.join(set(a)) if len(a) == len(b): return a else: return False t = 0 while t == 0: a = str(int(a)+1) result = counter(a) if result != False: print(result) break
31a893157317d7e2a750ee8a3537e7a5211e516b
almakhann/Codeforces
/520A.py
274
3.609375
4
n = int(input()) m = input() text = 'abcdefghijklmnopqrstuvwxyz' if n >= 26: l = [] for i in m.lower(): if i in text: l.append(i) if len(set(l)) == 26: print('YES') else: print('NO') else: print('NO')
216eab57e46158d5ea1ccd9a2ac706549a4e2e57
thaisnl/crud
/backend/app/common/validacoes.py
2,640
3.78125
4
import re, string # ------------------------------------- VALIDAÇÕES ------------------------------------- # Função para checar se a string só contém letras def checar_somente_letras(atributo, novo_atributo): if not all(x.isalpha() or x.isspace() for x in novo_atributo): raise AttributeError("O campo " + ...
3e41b82f6dc47a53f61d38b8317b9a085448f9be
vecchp/ProgrammingInterviewsExposed
/Chapter5/kevin_bacon/bacon_number.py
1,666
3.515625
4
from csv import reader from collections import deque class ActorNode: def __init__(self, name): self.name = name self._links = {} self.bacon_number = -1 @property def links(self): return self._links class Movie: def __init__(self, title): self.title = title ...
e5dc6c63b5ef321551acca98720625b7dae97b00
Neha-startup/Function
/sum.py
479
3.71875
4
# add_numbers naam ka function likhiye jo do numbers ko arguments ke tarah le aur fir unka sum print karta hai. Arguments ka naam number1 aur number2 hona chaiye. Input :- def add_list(): a=[] b=[] sum=0 s=[] for i in range(0,5): l1=int(input("enter the number")) l2=int(input("enter ...
0c6bd0800bf3c1dd2700d50fc7f64de1996ecb5b
Rashi876/python-tasks
/Task 7.py
369
4.125
4
a=float(input("Enter the first number")) b=float(input("Enter the second number")) c=float(input("Enter the third number")) if(a>b): if(a<c): median=a elif(b>c): median=b else: median=c else: if(b<c): median=b elif(a>c): median=a else: med...
b1e8207766fccfa966761b97ef6bf2f78fa3f036
labiaixiaoxin/myselenium
/studyDemo/class_call_demo.py
267
3.5625
4
class CountDemo: def __init__(self,a,b): self.a = a self.b = b def __call__(self): return count(self.a,self.b) def count(a,b): return a + b if __name__ == '__main__': countdemo = CountDemo(1,3) countdemo1=countdemo.__call__() print(str(countdemo1))
0244029696dae8f62056f5a9ec987e027a5f9ecb
AH-Toby/PythonBasic
/code/9.python面向对象(二)/demo03.py
1,152
4.15625
4
# 老猫将自己的一身本领传给小猫,同时狗狗也将自己看家的本事传给了小猫 # 定一个父类 class Cat(object): def __init__(self): self.kongfu = "厉害的捉鱼本领" def make_fish(self): print("利用%s抓鱼" % self.kongfu) # 定义第二个父类 class Dog(object): def __init__(self): self.kongfu = "厉害的看家本领" def kanmen(self): print("利用%s看家" %...
51258236a37e0b5176015747f8092b880467a498
AH-Toby/PythonBasic
/code/2.python基本语法/demo07if-elif-else.py
239
3.984375
4
height = int(input("请输入你的身高(cm):")) if height > 150: print("身高超过150cm需要买票!") elif height >0 and height <= 150: print("身高在150cm以下免费!") else: print("输入的数值有问题")
a8d2af8c4c022f911a012507e1415f4017206c95
AH-Toby/PythonBasic
/code/2.python基本语法/demo03Exercise01.py
382
3.9375
4
""" 要求:从键盘获取自己的年龄,判断是否大于或者等于18岁,如果满足就输出“哥,已成年,网吧可以去了” > 1. 使用input从键盘中获取数据,并且存入到一个变量中 > 2. 使用if语句,来判断 age>=18是否成立 """ age = int(input("请输入年龄:")) if age >= 18: print("哥,已成年,网吧可以去了")
e9b08120ec28fc706882df62b3b437b80ad1f3aa
AH-Toby/PythonBasic
/src/17.比较关系运算符.py
759
3.875
4
# -*- coding: utf-8 -*- # @Time : 2023/8/15 23:18 # @Author : toby # @File : 17.比较关系运算符.py # @Software: PyCharm # @Desc: a = 15 b = 20 # 1.比较运算符 # 等于:== print(a == b) # 不等于:!= print(a != b) # 大于:> print(a > b) # 小于:< print(a < b) # 大于等于:>= print(a >= b) # 小于等于:<= print(a <= b) # 2.逻辑运算符 # and:左右表达式都为True,整个表达式...
f6d0db0db67bf05fea117949489f8a461a86088b
JacobMikkelsen/aoc2018
/02/part1.py
767
3.875
4
#!/usr/local/bin/python3 def doubles_and_triple (s): counts = dict() # print(s) for letter in s: # print(letter) counts[letter] = 1 if letter not in counts else counts[letter] + 1 double = False triple = False for count in counts.values(): if count ==...
ae17299d7ada3eaaf3f2f906a76fe2e682e0610d
rperezmendoza/CS471A3
/helper_funcs.py
2,291
3.640625
4
import sys ''' Given a complete command, return the function portion of the command e.g if command = "get data.txt" return "get" ''' def get_cmd_type(input): return input.split()[0] ''' Determine if the given command is defined ''' def invalid_cmd(input): all_cmds = ['get', 'put', 'ls', 'lls', 'quit'] ret...
62d96f23cab872d0febe124f61b8b9d6357f93e3
febrianimanda/StudyGroup
/stringtask.py
194
3.59375
4
kata = "Febrian".lower() vowels = ['a','i','u','e','o','y'] x = [] for y in kata : if y not in vowels : x.append(y) titik = ['.' for i in range(0,len(x))] for a,b in zip(titik,x): print a,b,
80fdba6faeed7bfe2e6cad138903390d72c228b4
Barbariansyah/pyjudge
/test/no_of_triangle/no_of_triangle_9.py
258
3.78125
4
def no_of_triangle_9(a, b, c): if a <= 0 or b <= 0 or c <= 0: return 0 elif a+b>c and a+c>b and b+c>a: return 3 elif (a+b>c and a+c>b): return 2 elif a+b>c or a+c>b or b+c>a: return 1 else: return 0
4258ee738af904684f7d8037c4a5fd2c3a84f7ff
Jesussilverioe/Python-Adventures
/Classes.py
475
4.15625
4
class Dog: """Class to create a dog object""" def __init__(self, name, age): self.name = name self.age = age def sit(self): print(f"{self.name} is sitting...") print(f"{self.name} is sit.") def roll(self): print(f"{self.name} is rolling...") print(f"...
9a2217dfc394aa29a241fe2018b2cd169030716f
xiao-bo/leetcode
/easy/factorialTrailingZeroes.py
553
3.609375
4
class Solution(object): def trailingZeroes(self, n): """ :type n: int :rtype: int """ #Runtime: 20 ms, faster than 46.99% of Python online submissions for Factorial Trailing Zeroes. #Memory Usage: 11.8 MB, less than 17.65% of Python online submissions for Fac...
8aedddceba82e672804710eaa7486c2d30534af9
xiao-bo/leetcode
/easy/maximumDepthofBinaryTree.py
2,074
3.9375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def add(self,arrow,val): if arrow == 'l': self.left = TreeNode(val) elif arrow == 'r': self.right = TreeNode(val) ...
be02ba3aa308bd3231644c4ccef05f4c526e4d37
xiao-bo/leetcode
/array/medium/NumberofLaserBeamsinaBank/number_of_laser_beams_in_a_bank.py
2,397
3.65625
4
from typing import List class Solution: def numberOfBeams(self, bank: List[str]) -> int: # brute method is O(mn) # using math to solve, time complexity is O(nm+m)without refactor # Runtime: 334 ms, faster than 25.59% of Python3 online submissions for Number of Laser Beams in a Bank. ...
b6d19cb6643cacd5293dd1b914666272ff2ed4b8
xiao-bo/leetcode
/medium/trend1.py
588
3.5625
4
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def getSum(i): sumDigit = 0 while i > 0: sumDigit = sumDigit + (i % 10) i = i / 10 return sumDigit def solution(N): # write your code in Python 3.6 if isinstance(N, int)== False: return...
f97aa2d81fbf68c05b1f2adc178b7423d6e88188
xiao-bo/leetcode
/array/easy/removeDuplicatedFromSortedArray/removeDuplicatesFromSortedArray_old.py
1,656
3.8125
4
class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ length = 0 pivot = 0 i = 1 if len(nums) < 1: ## if nums is empty return -1 elif len(nums) == 1: return 1 ...
8eadaf061f2058ceb77961c06047d5b5fc298dc3
xiao-bo/leetcode
/easy/binaryTreeLevelOrderTraversal.py
2,166
3.984375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def add(self,arrow,val): if arrow == 'l': self.left = TreeNode(val) elif arrow == 'r': self.right = TreeNode(val) ...
f0c2b7da6bac55c808d9462d8a07356da2f7ffaf
xiao-bo/leetcode
/easy/pathSum.py
2,165
3.9375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def add(self,arrow,val): if arrow == 'l': self.left = TreeNode(val) elif arrow == 'r': self.right = TreeNode(val) ...
640b73962e13e5bc0e28f4d02aaf5ca1613200cc
xiao-bo/leetcode
/array/easy/removeDuplicatedFromSortedArray/RemoveDuplicatesFromSortedArray.py
1,085
3.8125
4
from typing import List # https://leetcode.com/problems/remove-duplicates-from-sorted-array/submissions/ class Solution: def removeDuplicates(self, nums: List[int]) -> int: # method 1 using two index # Runtime: 134 ms, faster than 30.22% of Python3 online submissions for Remove Duplicates f...
82c3477e13e0713e73265fc16fc90be133b8eeca
xiao-bo/leetcode
/medium/array/3sum/testThreeSum.py
614
3.515625
4
from threeSum_2021 import Solution def testThreeSum(): s = Solution() nums = [-1,0,1,2,-1,-4] expected_result = [[-1,-1,2],[-1,0,1]] result = s.threeSum(nums) # 先檢查數量,以免兩邊長度不一 assert len(result) == len(expected_result) for x in expected_result: if x in result: contin...
4df7b2e5a18720b006eb196cae7b1af1d30ba3a2
xiao-bo/leetcode
/medium/trend2.py
838
3.734375
4
def solution(A): # write your code in Python 3.6 if not A: return 0 longest = 0 #hashTable = {} checkTable = {} for i in range(0,len(A)): hashTable = {} index = i if index in checkTable: continue while True: print('i = {} A...
b4c34e89a818ee97d4582902d7d48dcdd9d6b69d
xiao-bo/leetcode
/easy/sameTree.py
2,447
3.875
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def add(self,arrow,val): if arrow == 'l': self.left = TreeNode(val) elif arrow == 'r': self.right = TreeNode(val) ...
6971c8e7c53d01ea7793cea23458c09f84b865bf
feicccccccc/RL_random_exercise
/policy_iter_jacks_car_rental.py
6,764
3.71875
4
import numpy as np # Hyper parameter: discount_factor = 0.9 location1_avg_request = 3 location1_avg_return = 3 location2_avg_request = 4 location2_avg_return = 2 accuracy = 50 reward_for_rental = 10 reward_for_moving = -2 max_car = 20 # Step 1: Init Parameter # Total state space (0-20) at each side, element = Value ...
d8f8ecb010545b4e922a89801a65739109ace989
DanielCalvoC/ZEPPELIN
/zeppelin/scrape_lyrics.py
2,135
3.625
4
'''This program scrapes lyrics from an arist page on www.lyrics.com and saves them as text files in the specified directory''' import os import shutil import requests from bs4 import BeautifulSoup def save_all_lyrics(url, directory): """ Download each song lyrics from every lyric html page from the artist ...