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
11159e9e46469e2c9f9a8a362fe590f55d292997
UnderDogLearning/python
/NumberGuessingGame.py
880
4.09375
4
# Number Guessing Game: import random guessesTaken = 0 print("Welcome to Gussing Game ") print("Hello! What is your name? ") myName = input() print('Well, ' + myName + ', I am thinking of a number between 1 and 20.') number = random.randint(1, 20) while guessesTaken < 6: print('Take a guess.') guess = i...
9e0a3cf48f109d1764db5939e030cfcee7d692e2
UnderDogLearning/python
/complex_json.py
2,039
3.78125
4
# Handing the Json nested file: #work with complex Json and extract data from it #Iterate through Json data which has list, json string, nested Json. Here I will explain how to work with complex Json and extract data from it import json def checkList(ele, prefix): for i in range(len(ele)): if (isinstance...
f74e3aaff1778023fc4d7180c9c3e7a96cd871ee
MatthewGerges/CS50-Programming-Projects
/MatthewGerges-cs50-problems-2021-x-sentimental-readability/readability.py
2,780
4.125
4
from cs50 import get_string # import the get_string function from cs50's library def main(): # prompt the user to enter a piece of text (a paragraph/ excerpt) paragraph1 = get_string("Text: ") letters = count_letters(paragraph1) # the return value of count_letters (how many letters there are in a...
5c5f1801b51078fdbaf5274ba0100cd2071eb38c
MatthewGerges/CS50-Programming-Projects
/MatthewGerges-cs50-labs-2021-x-birthdays/application.py
2,439
3.78125
4
import os from cs50 import SQL from flask import Flask, flash, jsonify, redirect, render_template, request, session # Configure application app = Flask(__name__) # Ensure templates are auto-reloaded app.config["TEMPLATES_AUTO_RELOAD"] = True # Configure CS50 Library to use SQLite database db = SQL("sqlite:///birthd...
da488efb041e58f2e67718c7ee4fd4293b36e223
kvamsi7/Python_L2_Assignments
/prgm3.py
211
3.5
4
''' handling exception''' c = 0 def f2(x): try: c+= 1 b = x + c print(c) return b except Exception as err: print(err) print(f2(1)) print(c)
a0b908959d6c6bbd6d902b061b41258fce2bcae7
LandscapeGeoinformatics/GRQA_src
/preprocessing/GLORICH/glorich_preprocessing.py
14,072
3.546875
4
# Import the libraries import datetime import os import geopandas as gpd import pandas as pd import numpy as np import hashlib # Function for stripping whitespace from string columns def strip_whitespace(df): for col in df.columns: if df[col].dtype == object: df[col] = df[col].str.s...
0ccffb80d50c39d3ebcfaf6cc45db853762833b9
Augmented-Reality-Comps/backend
/walkAround/datasource.py
1,233
3.5
4
import psycopg2 class DataSource: def __init__(self): pass def getData(self, query): ''' this is the actual query to the database. every function that wants information from the database MUST call this function ''' # Login to the database connection = self.login() # Query the dat...
f3779d8bd7d12e4ca6f2fdb3d7710f9b14d91bf6
seabre/citybuilder
/cb-scripts/point-convert.py
448
3.640625
4
#!/usr/bin/python from sys import stdin def convert_point(lon_str, lat_str): lon = round(float(lon_str), 3) lat = round(float(lat_str), 3) return (lon, lat) def main(): lines = stdin.readlines() print "[" for l in lines: (lon_str, lat_str, _) = l.split(',') (lon, lat) = con...
602ea8ecddf9d0747115b17773236b33780a8507
TTUSDC/practical-python-sdc
/Week 1/notes/testing.py
1,407
4.1875
4
print("Hello World") pizza = 3 print(pizza) pizza = 3.3 print(pizza) pizza = "i like pizza" print(pizza) pizza = 333333333333 print(pizza) # + - / ** * // % x = 3 y = 5 print(x - y) print(x + y) print(x // y) print(x * y) print(x ** y) print(30 % 11) # True, False # and, or, is, not print(True is True) print(Tru...
a4bad5bf1285ea89be936906ed69f16c05f9d355
FrostyTheLonely/Python
/test.py
1,390
3.703125
4
from tkinter import * def donothing(var=''): pass class interface(Tk): def __init__(self, name='Interface', size=None): super(interface, self).__init__() if size: self.geometry(size) self.title(name) self.frame=Frame(self) self.frame.pack()...
2fb626bd6631b8ede2be9c9fe60a44e955f4666b
aNLPer/AlgorithmNotes
/Leetcode/test.py
821
3.546875
4
import random class Solution(object): def __init__(self, nums): """ :type nums: List[int] """ self.array = nums self.original = nums def reset(self): """ Resets the array to its original configuration and return it. :rtype: List[int] """...
b3fc8fb5b02cebc3effd18f5b10af66aa645242a
aNLPer/AlgorithmNotes
/Algorithm/DynamicProgramming/LongestIncreasingSequence.py
1,110
3.859375
4
""" 300. Longest Increasing Subsequence Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Note: There may b...
5263292467eef236f7185fe14816b067ead978e3
aNLPer/AlgorithmNotes
/Algorithm/BinaryTree/Traverse.py
3,678
3.875
4
""" 介绍二叉树的遍历(前序、中序、后序遍历) """ # 二叉树的遍历 from collections import deque class Solution(object): def __init__(self): self.ans = [] def preorderTraversal_recur(self, root): """ :type root: TreeNode :rtype: List[int] """ if root == None: return [] ...
3c75198d39ef5a519610aecd5bc9b162385fb2d4
YKato521/ironpython-stubs
/release/stubs.min/System/Diagnostics/__init___parts/Stopwatch.py
2,471
3.53125
4
class Stopwatch(object): """ Provides a set of methods and properties that you can use to accurately measure elapsed time. Stopwatch() """ @staticmethod def GetTimestamp(): """ GetTimestamp() -> Int64 Gets the current number of ticks in the timer mechanism. Re...
34740944fe71365f4c9a9a6242bdea68e5789e62
rnhibatullah/invention_idea_generator
/raw_object.py
992
3.71875
4
class RawObject: def __init__(self, name, cost,novelty, size, skill, viable ): self.name = name if cost <15 and cost > 0 : self.cost = cost else : print("cost of {} {} not in range of 1 - 10 ".format(self.name,self.cost)) return if novelty <10 and cost >0 : self.novelty = novelty else : ...
c46a860bd99dc8e6df086be204822b9b11b312b6
Daria-T/py-for-begginers
/src/main/lesson4/task3.py
296
3.71875
4
# Используюя numpy вычислить среднее арифметическое для 100 случайных числе. import numpy as np from numpy import array from numpy.random import seed from numpy.random import rand seed(3) values = array(rand(100)) print(np.mean(values))
fa4348c886de9e98fee1878c424aab1ebe8e448e
marina-h/lab-helpers
/primer_helper.py
813
4.15625
4
#!/usr/bin/env python # -*- coding: utf8 -*- import readline reverse_comp_dict = {'A':'T', 'T':'A','G':'C', 'C':'G'} def melting_temp(p): Tm = 0 for n in p: if n == 'A' or n == 'T': Tm += 2 if n == 'G' or n == 'C': Tm += 4 return Tm def reverse_comp(p): reverse = "" for n in p[::-1]: reverse += re...
26ddeb9c91066e4bfd2ae820d434aa686c4ffdcd
ronie2/war
/war/base_shop.py
1,634
3.890625
4
class Shop(object): """Shop class providing methods to manipulate player's palnes""" def __init__(self, equipment): """ Args: equipment (dict): DB of the game palnes in the following format: 'planes': { <plane_id:int>: { '...
f883e815f7b4ea4bd03a04ded5265ffb473dc607
capatch/finalProject
/test_1.py
541
3.53125
4
from tkinter import * import tkinter.font from gpiozero import LED import RPi.GPIO RPi.GPIO.setmode(RPi.GPIO.BCM) led=LED(14) win=Tk() win.title('LED Toggler') myFont=tkinter.font.Font(family='Helvetica', size = 12, weight = 'bold') def ledToggle(): if led.is_lit: led.off() ledButton['text']='Tu...
ae6a511723cc0f54dc39d56b2c9ed70ed3bb9305
lnbe10/Math-Thinking-for-Comp-Sci
/combinatory_analysis/dice-game.py
2,755
4.1875
4
# dice game: # a shady person has various dices in a table # the dices can have arbitrary values in their # sides, like: # [1,1,3,3,6,6] # [1,2,3,4,5,6] # [9,9,9,9,9,1] # The shady person lets you see the dices # and tell if you want to choose yor dice before # or after him # after both of you choose, # them roll your ...
dfbb1d0a6d09d617ce6a3d30579a40a6793b3f71
AndyDaly90/FYP_PythonScraping
/FYPSprint3/car_crawler.py
2,922
3.515625
4
# -*- coding: utf-8 -*- from __future__ import print_function import mechanize from bs4 import BeautifulSoup import re import urllib2 def clean_url(data): """ In order to make requests across the network I need a clean URL (example : http://www.desiquintans.com/articles/). This is done by using a regular...
40d29a3a935db6151ee3e06f4d4bd7dbc1e6c815
idane19-meet/meet2017y1lab5
/add_numbers.py
262
3.765625
4
def add_numbers(start, end): c = 0 for number in range(start, end + 1): print(number) c = c + number return(c) test1 = add_numbers(1,2) print(test1) test2=add_numbers(1,100) print(test2) test3 = add_numbers(1000,5000) print(test3)
2e79930ea3e3a80484e3f2d2fe4279970c6c3ec9
johnksterling/falconcodingclub
/madlib/madlibs_dynamic.py
519
4.0625
4
import random keep_playing = True madlibs = [] madlibs.append("I would like to {verb} at the {place}") madlibs.append("When I was a child a was afraid to {verb} at the {place}") madlibs.append("Is the {place} where you like to {verb}") while keep_playing: madlib = random.choice(madlibs) verb = input('enter a ...
7750ffc47e269a9b87001c4299d19e969af1f30f
johnksterling/falconcodingclub
/analytics/names/summarize_name.py
370
3.8125
4
import csv name = input('What name would you like to search? ') NAME_INDEX = 1 YEAR_INDEX = 2 COUNT_INDEX = 4 with open('input.csv', 'r') as csvfile: reader = csv.reader(csvfile) next(reader, None) for row in reader: year = row[YEAR_INDEX] count = row[COUNT_INDEX] if row[NAME_INDEX...
f07a7a11cca03a01d509100b4cc60bb99825829e
TanmayPriyadarshi/Coding_Blocks
/pattern_mountain.py
666
3.796875
4
def Main(): try: N = int(input("\nEnter the number")) if N > 10: raise Exception for i in range(1, N + 1): j = 1 while j <= N: if j <= i: print(j, end=' ') else: print(' ', end=' ') ...
6a86ef0e9ed02f1deea5979e760cbcbecbc51857
shanereid19/Final-Project
/FirstDraft.py
2,907
3.953125
4
import pygame import time # For my project I plan to create a game simialr to pong but modified to be more like a soccer game. # The game is called "Soccer Pong". # Therefore, as a reulst I have imported "pygame" and "time" to use in the interface of the game. # I will use pygame to design the game and time is an impo...
433fde58590d64d945c2ee79560d40f8e8dfb43f
choijaehoon1/programmers_level
/src/test60.py
515
3.546875
4
def trans(num): answer = '' while num > 0: answer = str(num%2) + answer num //= 2 return answer def solution(s): zero_cnt = 0 time = 0 if s == "1": return [0,0] else: while s != "1": new_s = s.replace('0','') length =...
a1e461eb0d83cbf08167139b198cc63e83d459b1
choijaehoon1/programmers_level
/src/test28.py
447
3.546875
4
def solution(phone_book): # 범위가 커서 터지므로 유사한 번호가 오게 정렬 후 다음값과 비교 phone_book.sort() # O(N Log N) for i in range(len(phone_book)-1): if phone_book[i] in phone_book[i+1]: # 안에 들어가 있는 형태 if phone_book[i+1].index(phone_book[i]) == 0: # i+1번째에서 i번째 인덱스를 찾는데 접두어인지 check return F...
0c90a32f4293acf4d1cd06cb6a738ea39608600c
choijaehoon1/programmers_level
/src/test77.py
705
3.515625
4
def score(cnt): if cnt >= 6: return 1 elif cnt >= 5: return 2 elif cnt >= 4: return 3 elif cnt >= 3: return 4 elif cnt >= 2: return 5 return 6 def solution(lottos, win_nums): mask = lottos.count(0) # print(mask) if mask == 0: cnt = 0 ...
5566ab29cd5b0bea8f9ec3e99110fa94d955cb7a
choijaehoon1/programmers_level
/src/test90.py
1,469
3.578125
4
def binary(x): tmp = '' while x > 0: n = x % 2 x //= 2 tmp = str(n) + tmp return tmp def solution(n, arr1, arr2): answer = [] tmp_list = [['#']*n for _ in range(n)] new_arr1 = [] new_arr2 = [] for i in arr1: num = binary(i) if len(num) != n:...
7b49830e3e184c294c303018d1a8dd94ecc6e9cf
choijaehoon1/programmers_level
/src/test33.py
648
3.6875
4
answer = 0 def dfs(numbers,target,i): global answer if i == len(numbers): # 끝까지 수행했을 때만 확인(i가 인덱스 범위 벗어날때가 끝까지 수행한 것임) if sum(numbers) == target: # 종료 조건 answer += 1 return else: dfs(numbers,target,i+1) # 재귀먼저 수행(맨 처음 주어진 numbers가 target과 같을수도 있으므로) numbers[i]...
763e59a4dd2ca848e41297c3002c8a9297f41979
PiGuy23/ThereminPi
/Testing/FunctionTest.py
672
3.8125
4
#An example of a running avg done with a function from time import sleep vals = [1] * 13 vals2 = [3] * 4 d = 1 d2 = 4 def f_avg (arr): k = len(arr) -1 i = 0 while i < k: arr[i] = arr[i+1] i = i+1 global d global d2 x = int(input()) if (k == 12) : if x == 1.0...
193945b7cdebfd846f466c69e25be71937df24da
PiGuy23/ThereminPi
/Testing/RunAvgTest.py
657
3.53125
4
#Works really well. Thi bigger the better from time import sleep vals = [0] * 4 b = 0 def average(arr, next, hol): k = len(arr) -1 i = 0 while i < k: arr[i] = arr[i+1] i = i+1 if next == 1.0: arr[k] = hol[0] else: arr[k] = next hol[0] = next ...
eb077fce1e2eb66846fefd42afd9871c3d7e1129
karolxxx/Regex-project
/phone.py
489
3.671875
4
import re import time print('Welcome, you have won 1 million dollars! Please verify your phone number!') time.sleep(2) #sleep content = input('Please enter your number:') # content = "111-111-1111" numberRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') result = numberRegex.search(content) if result is not None: time...
a60df60f1bd19896da30e8d46be5fee3a020413c
battyone/Practical-Computational-Thinking-with-Python
/ch4_orOperator.py
220
4.125
4
A = True B = False C = A and B D = A or B if C == True: print("A and B is True.") else: print("A and B is False.") if D == True: print("A or B is True.") else: print("A or B is False.")
72de8c1646257560a280b2a139bea22f86515258
tx621615/pythonlearning
/025inherit1.py
2,713
3.71875
4
# 类变量和成员变量的继承规则 """ 1,对于类变量x,最开始Children1和Children2都没有赋值x,所以都等于1。当Children1赋值2之后值就变了,但Children2还是之前的1,当父类修改为3后,由于Children2一直没有赋值,所以等于修改后的父类的x值3,直到Children2自己赋值才是4。 2,对于实例变量y,最开始child1和child2都没有对y赋值,所以都等于1。当child1变成2之后就变成2,但child2还是之前的1,即使父类实例par改变y的值为3,child2还是为1。直到child2自己赋值为4才改变。 1,对于类变量x,最开始Children和GrandChildren都没有...
1c9483e36d864bd7a8f5722f60801cda7e6c521f
tx621615/pythonlearning
/02tab.py
223
4.15625
4
# 测试缩进,python中没有大括号,通过相同的缩进表示同一个代码块 if True: print("Answer") print("True") else: print("Answer") print("False") # 缩进不同则不在同一个块中
b33f2ed903c56bda63a02dac1bfe99882f0bfaed
JDRanpariya/question_paper_scraper
/qPull.py
871
3.5
4
from selenium import webdriver from bs4 import BeautifulSoup # set the chromedriver to interact with chrome.exe to scrape webpage driver = webdriver.Chrome(""" enter your chromedriver path """) driver.get("https://engineering.jainuniversity.ac.in/") question_paper = open("Question_Paper.txt", "a") while(True): # ...
255c09b29bc9cd76e730a64a0722d24b003297c8
ugneokmanaite/api_json
/json_exchange_rates.py
1,068
4.3125
4
import json # create a class Exchange Rates class ExchangeRates: # with required attributes def __init__(self): pass # method to return the exchange rates def fetch_ExchangeRates(self): with open("exchange_rates.json", "r") as jsonfile: dataset = json.load(jsonfile) ...
9f4bffa47c541d34029428166d2af6b9138d9b2c
MathewsPeter/PythonProjects
/inheritence.py
529
3.703125
4
class A: def __init__(self, a): self.a = a def disp(self): print(self.a) class B(A): def __init__(self,a,b): A.__init__(self, a) self.b = b def disp(self): print(self.a,self.b) class C(B): def __init__(self,a,b,c): B.__i...
9445b358d4c35b1caec4c3bc2620b47ef514d331
MathewsPeter/PythonProjects
/biodata_validater.py
1,124
4.5625
5
'''Example: What is your name? If the user enters * you prompt them that the input is wrong, and ask them to enter a valid name. At the end you print a summary that looks like this: - Name: John Doe - Date of birth: Jan 1, 1954 - Address: 24 fifth Ave, NY - Personal goals: To be the best programmer there ever was. ''...
f105606ceb0d3a72e2d35e88a78952fed10f38a7
MathewsPeter/PythonProjects
/bitCountPosnSet.py
408
4.15625
4
''' input a 8bit Number count the number of 1s in it's binary representation consider that as a number, swap the bit at that position ''' n = (int)(input("enter a number between [0,127] both inclusive")) if n<0 or n>127: print("enter properly") else: n_1= n c = 0 while n: if n&0b1: ...
207a64f73bfea0453920889718fe099ed8f611ae
Ahmed-Zoher/Python_Based_Projects
/XML_Parser_Lab/bonus_sort.py
582
4.0625
4
""" CONTENTS: 1)Bubble Sort Algorithm 2)Selection Sort Algorithm """ def my_bubble_sort(b): for n in range(0,len(b)-1): for a in range (1,len(b)-n): if b[a-1]>b[a]: temp = b[a] b[a]=b[a-1] b[a-1]=temp def my_selection_sort(b): for n in range(1,len(b)): for a in range (n,0...
52b5aa090d6eefd26c773af730bbd2eb1ec54d03
Zob-code/Inceptial-Assignment
/Ex43.py
5,820
3.703125
4
from sys import exit from random import randint from textwrap import dedent class Scene(object): def enter(self): print("This scene is not yet configured") print("Subscribe it and implement enter()") exit(1) class Engine(object): def __init__(self, scene_map): self.scene_map = ...
d1dac2b0984c21855a5b6b42185aaea62355a157
heman-oliver/Puligitham-II
/screen.py
903
3.609375
4
# IMPORTS import pygame from color import Color # /////////////////////////| # SCREEN CLASS FOR THE GAME| # /////////////////////////| class Screen(object): # CONTAINS THE ATTRIBUTES: WIDTH, HEIGHT, FONT, CLOCK def __init__(self): self.screen_width = 1000 self.screen_height = 1000 ...
306385c68e724e165af399e5ef06ca719f56f6f0
huwenbo920529/pythonBuiltIn
/collections_test.py
3,024
3.578125
4
# coding:utf-8 from collections import namedtuple, deque, Counter, OrderedDict, defaultdict # namedtuple() # namedtuple主要用来产生可以使用名称来访问元素的数据对象,通常用来增强代码的可读性, 在访问一些tuple类型的数据时尤其好用。 websites = [ ('Sohu', 'http://www.google.com/', u'张朝阳'), ('Sina', 'http://www.sina.com.cn/', u'王志东'), ('163', 'http://www.163.co...
cfb8789ffbdd2e4e09c43ddb6d326a32b8dc7fdd
huwenbo920529/pythonBuiltIn
/python_built_in_test.py
18,274
3.765625
4
# coding:utf-8 # 1.abs() 函数返回数字的绝对值。 import math print abs(-3.9) # 等价于,math.fabs(-3.9) print math.fabs(-3.9) # 2.dict() 函数用于创建一个字典。 # 语法: # class dict(**kwarg) # class dict(mapping, **kwarg) # class dict(iterable, **kwarg) print dict(a=1, b=2, c=3) # 传入关键字 print dict(zip(['a', 'b', 'c'], [1, 2, 3])) # 映射方式构造字典 prin...
e988f63eb96e701e6c40e8c48b3083603e36746a
nbandodk/Misc
/permutationOfPalindrome.py
440
3.578125
4
import string def isPermutationOfPalindrome(str): d = dict.fromkeys(string.ascii_lowercase, False) count = 0 for char in str: if(ord(char) > 96 and ord(char) < 123): d[char] = not d[char] for key in d: if d[key] == True: count += 1 if cou...
590026f07d4beb574733ce77b498c448653dd013
Prakhyath07/INEURON_ASSIGNMENTS
/ASSIGNMENT-3/3.1.1__myreduce.py
344
3.515625
4
def myreduce(func,iterable,initializer=None): l=len(iterable)-1 if initializer==None: a=iterable[0] for i in range(l): b=iterable[i+1] a=func(a,b) else: a=initializer for i in range(l): b=iterable[i] a=func(a,b) ...
b71c86c8d2f1bdb62981bf87d39f7b64785c26fa
Prakhyath07/INEURON_ASSIGNMENTS
/ASSIGNMENT-4/4.1.2__FILETERWRONGWORDS.PY
263
3.578125
4
def filter_long_words(words,n): long=[] if type(words) is list: for word in words: if len(word)>n: long.append(word) return long else: return "Plese enter words inside a list"
3966d55212271c1a681156beaee25f6820a076fc
zsamantha/coding_challenge
/calc.py
1,217
4.125
4
import math print("Welcome to the Calculator App") print("The following operations are available: + - / *") print("Please separate entries with a space. Ex: Use 1 + 2 instead of 1+2") print("Type \"Q\" to quit the program.") result = None op = None while(True): calc = input().strip().split() if calc[0].lower...
f23c780e6f960278ee0462ed83a828b475c58f1b
flipbug/2048_ai
/heuristicai.py
6,139
3.90625
4
import random import game import sys from util import get_possible_merges, UP, DOWN, LEFT, RIGHT # Author: chrn (original by nneonneo) # Date: 11.11.2016 # Description: The logic of the AI to beat the game. THRESHOLD = 8 MIN_THRESHOLD = 2 OPTIMAL_POSITION_WEIGHT = 2 BEST_MERGE_WEIGHT = 2 FUTURE_MERGE_WEIGHT = ...
31d0b19e04fce106e14c19aec9d7d6f463f0d852
panchaly75/MyCaptain_AI
/AI_MyCaptainApp_03(1).py
863
4.3125
4
#Write a Python Program for Fibonacci numbers. def fibo(input_number): fibonacci_ls=[] for count_term in range(input_number): if count_term==0: fibonacci_ls.append(0) elif count_term==1: fibonacci_ls.append(1) else: fibonacci_ls.append(fibonacci_ls[count_term-2]+fibonacci_ls[count_ter...
e5ad375c76600d598f605ed7434046c40d7b356b
flaviocardoso/myCodelearnpythonTHW
/ex15.py
388
3.828125
4
from sys import argv #import of system argv script, filename = argv #argument of scropt and file name (insert) txt = open(filename) # open file print ("Here's your file %r" % filename) # print a string describer the file name print (txt.read()) # print from read file print ("Type the filename again:") file_again =...
5d8aad14ee2fc3f7dec59334444cfcbfd6359f52
SSDD11/Some-Small-Projects--Monty-Hall-
/ackermann.py
656
3.8125
4
''' Created on Apr 6, 2016 @author: Administrator ''' import math def ack(x, y): if x == 0: return y + 1 elif y == 0: return ack(x - 1, 1) else: return ack(x - 1, ack(x, y-1)) print "0, 0:", ack(0, 0) print "0, 2:", ack(0, 2) print "3, 0:", ack(3, 0) print "2,...
5e3c27923416fe3aa7921fef222d9b3c09182c28
jcberntsson/networks
/utils/loading.py
2,365
3.546875
4
# (c) 2019 Joakim Berntsson # Loading of data. import csv import pandas as pd import tensorflow as tf import numpy as np class Loader: """Data loading class with support for: * loading csv files using pandas * data curation * column selection * creating train/test split with normalization. No...
1b96269e657f2792c7a35b4f2f4ade76f1cc2bd7
premlogan/Early-Warning-System-to-Predict-Students-at-Risk-of-Not-Graduating-High-School
/utils.py
5,787
3.5625
4
# Import libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt # Function desc: load_data function reads SQL query to extract data from Postgres db and loads into dataframe # Input: .txt file SQL ETL query and engine with database connection information # Returns: Dataframe with data extrac...
88edd09cd4cb32f70797774e6e41686dac33f515
bughunt88/python_study_2020
/python_basic/test.py
214
3.671875
4
def solution(arr, divisor): answer = [] list = [] for i in arr: if i%divisor == 0: list.append(i) list.sort() return list print(sum(range(1,3)))
bf3b1c591e8834c6f9448d48bdb55285244925c8
bughunt88/python_study_2020
/python_basic/python_for.py
2,007
3.734375
4
# 파이썬 반복문 # FOR 실습 # 코딩의 핵심 # for in <collection> # <Loop body> for v1 in range(10): # 0~9 print(v1) print() for v2 in range(1,11): # 1~10 print(v2) print() # 2의 배수 for v3 in range(1,11,2): print(v3) # 1 ~ 1000 합 sum1 = 0 for v in range(1,1001): sum1 += v print('1 ~ 1000 Sum : ', sum1) ...
ebb169123be03b88cdd6dcfab33657bd4a60f573
Devlin1834/Games
/collatz.py
1,792
4.15625
4
## Collatz Sequence ## Idea from Al Sweigart's 'Automate the Boring Stuff' def collatz(): global over over = False print("Lets Explore the Collatz Sequence") print("Often called the simplest impossible math problem,") print("the premise is simple, but the results are confusing!") print("Lets s...
6d670cc158afe0b3c3e6206c0c351a49237ca6b8
ssxday/Python35
/functions.py
5,298
3.9375
4
# -*- coding: utf-8 -*- # 列表作为参数传递 def jisuan(args=[]): x, y = args # 在函数内部解包,但参数数量必须等于列表长度 return x + y print(jisuan([1, 2])) # 参数需要传列表,而不能只传值 # 传递可变参数!!! def changing(*args): # 用*表示引用元组 print(args) changing(1, 2, 3, 6) def search(*t, **d): # 用**表示引用字典 keys = d.keys() values = d.values...
20c8b0d87a129a10d668cee8b57209fae5c79ce5
ssxday/Python35
/gothrough.py
667
3.59375
4
# -*- coding:utf-8 -*- # 遍历目录文件及子文件夹 def gothr(path = './overall'): import os l = os.listdir(path) decration = '' for ford in l: decration = '-' if os.path.isdir(path + os.sep + ford): print(decration,ford) gothr(path + '/' + ford) elif os.path.isfile(pat...
70dcf217c9557716d42a3bda038e51ab1d5e39e7
ssxday/Python35
/stack&queue.py
272
3.671875
4
lst = ['apple', 'banana', 'cherry', 'durian', 'elva', 'fig', 'grape'] # 堆栈 #进栈 lst.append('honey') print(lst) #出栈 lst.pop() print(lst) # 队列 # 入队 lst.append('housewife') print(lst) # 出队 lst.pop(0) #队列出队用pop(0) print(lst)
06c762e9658bf1b06a403ba8a53181c67272cfb6
ssxday/Python35
/xiancheng.py
3,718
3.765625
4
# -*- coding:utf-8 -*- def isPrime(n=3): if n <= 1: return False for i in range(2, n // 2 + 1): if n % i == 0: return False else: continue return True def forthrd(start=2, step=100, mark=''): fltr = filter(isPrime, range(start, start + step)) i = 0 ...
0f3aee647a23837b86c52f2f185f2b06d35fb6de
ssxday/Python35
/group-rename.py
512
3.953125
4
# 批量修改文件后缀程序 def mrename(src = 'haha',dst = 'txt',srcdir = '.'): src = '.' + src dst = '.' + dst warning = input('警告!你确定要把后缀为'''+ src +'的文件修改为' + dst + '的后缀吗?(Y/N):') if warning not in ['y','Y']: exit('还好你放弃了') import os files = os.listdir(srcdir) for filename in files: if ...
aa401bd02b779ddfbe5302e616e12a9f3876aba2
ssxday/Python35
/input.py
166
3.875
4
x = input('x=') #input的都是字符串,要输入数字需要再后面转换类型 x = int(x) x = x+1 print('x=',x) y = int(input('y=')) if x<y: print(x+y)
fda4e26f03bd1c99534e50d042a0102d3a80f01a
ssxday/Python35
/whatday.py
525
3.90625
4
# 写一个根据日期计算星期几的模块 def whatday(s = '19860831'): #s是传进来的日期字符串 s = str(s) # 强制转换类型,传进来的是数字还是字符串都无所谓了 import time,datetime time_s = list(time.strptime(s,'%Y%m%d')) # print(time_s) days = { 0:'星期一', 1:'星期二', 2:'星期三', 3:'星期四', 4:'星期五', 5:'星期六', ...
81ca064bad2a277ab5adf7e01c1dc6b11ff78910
cpe202fall2018/lab0-AlekTheGreat
/planets.py
437
3.734375
4
#Alek Ramirez #013927364 #9-24-18 # #Lab 0 #Section 13 #Purpose: Solving for the weight on different planets #Comments: def weight_on_planets(): weight = float(input('What do you weigh on earth? ')) WoM = weight * 0.38 WoJ = weight * 2.34 print('\nOn Mars you would weigh {:0.2f} pounds.\n' ...
f56b7728d9dd9677b8bb498a9c679e1961da4bdc
Adomkay/sql-intro-to-join-statements-lab-nyc-career-ds-062518
/sql_queries.py
933
3.515625
4
# Write your SQL queries inside the strings below. If you choose to write your queries on multiple lines, make sure to wrap your query inside """triple quotes""". Use "single quotes" if your query fits on one line. def select_hero_names_and_squad_names_of_heroes_belonging_to_a_team(): return "SELECT superheroes....
0082bcd072d04e3ee7ea6f0301ae72d4a05dd97e
chriszhang3/checkers
/main.py
1,593
3.9375
4
from tkinter import Tk, Label from Board import Board from UI import UI from Computer import Computer def main(): option = input("Press h to play against a human player. \nPress c to play against a computer player. \n") while option != "c" and option != "h": option = input("Invalid input. Try again: "...
26a77eaf507d1b0107e311ee09706bc352e70ced
ScottG489/Task-Organizer
/src/task/task.py
2,528
4.125
4
"""Create task objects Public classes: Task TaskCreator Provides ways to instantiate a Task instance. """ from textwrap import dedent # TODO: Should this be private if TaskCreator is to be the only # correct way to make a Task instance? class Task(): """Instantiate a Task object. Provides att...
6f3619f2726fba6e2f6a01eff7d633e7b0acdaea
ohmaj/rockspock
/game.py
1,443
3.765625
4
import random class game: def __init__(self,name,player1,player2): self.name=name self.player1=player1 self.player2=player2 def getHumanChoice(self): playerChoice= input('enter # for choice 1:rock 2:paper 3:scissors 4:Spock 5:lizard: ') if int(playerChoice) in ran...
4c34d295e42684443f40bef31e8a1a8d646761c3
robJolley/PythonVision
/BilateralFilter_Sobel_Canny.py
4,620
3.59375
4
""" ======================================================= Simple image blur by convolution with a Gaussian kernel ======================================================= Blur an an image (:download:`../../../../data/elephant.png`) using a Gaussian kernel. Convolution is easy to perform with FFT: convolving two sign...
4f2f17050ed4c4c8db4d722fe642284d1359127b
GH-Zhou/interview-prep
/Session 2/02-Sort-Sorted-Lists.py
5,707
4.3125
4
import unittest import heapq # ---- Definition of ListNode Class # A ListNode is a node in the linked list with its value and next property pointing to the next node class ListNode: def __init__(self, val): self.val = val self.next = None # Comparator for heapq def __lt__(self, other): ...
86af8c55ca5cbfa8dedebd3dede4b048c74fa8a9
GH-Zhou/interview-prep
/Session 3/05-Decode-Ways.py
2,858
3.796875
4
import unittest # ---- Test Cases # 1) Input: "" Output: 0 # 2) Input: "0" Output: 0 # 3) Input: "1" Output: 1 # 4) Input: "10" Output: 1 # 5) Input: "12" Output: 2 # 6) Inp...
96b15dbc03157c924f356d11062a67800fd3d175
simenheg/euler
/057/problem57.py
998
3.90625
4
# It is possible to show that the square root of two can be expressed as an # infinite continued fraction. # √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... # By expanding this for the first four iterations, we get: # 1 + 1/2 = 3/2 = 1.5 # 1 + 1/(2 + 1/2) = 7/5 = 1.4 # 1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666....
a43cfd28ceeff948ab356981f708cac198643ed8
wzy414033395/DiscreteMathProgrammingProjects-1
/ProgrammingProject2/quicksort.py
853
3.84375
4
#Discrete Mathematics #CSIS Programming Project 2 #Gordon Portzline #Zhengyu Wu #Brad Rohbock #QuickSort pulled from online repository # """https://gist.github.com/anirudhjayaraman/897ca0d97a249180a48b50d62c87f239""" def quicksort(lista,start,end): i = start j = end pivote = lista[(start + end)//2] sw...
2904498a6402126bae0c6577b098541a00e395ec
IvanIlin22/myWork
/level00/ft_print_numbers/ft_print_numbers.py
71
3.609375
4
i = '0' while i <= '9': print(i, end = "") i = ord(i) + 1 i = chr(i)
4b95b8dbae3dc31930e33139ae9f3677469cb71c
thejacobhardman/Powerball
/Powerball.py
10,096
3.984375
4
# Jacob Hardman # Intro To Programming # Professor Marcus Longwell # 3/6/19 # Python Version 3.7.2 # Importing pkgs import os import random import decimal # Clears the screen def cls(): os.system('cls' if os.name=='nt' else 'clear') ########################################################## GLOBAL VARIABLES ####...
db11b8cd747205d5bcb9dd5b96f50fd826ad4392
ZedRover/stats-algo
/老婆的代码/Sep 9_week1.py
3,070
4.65625
5
""" 统计软件与算法 2020年9月9日 """ """ PYTHON INTRODUCTION """ # Addition, subtraction print(5 + 5) print(5 - 5) # Multiplication, division, modulo, and exponentiation print(3 * 5) print(10 / 2) print(18 % 7) print(4 ** 2) # How much is your $100 worth after 7 years with 10% return each year? print(100*1...
04f03ef2d9a649d4b9f65ef6783e169a14ee05e1
ZedRover/stats-algo
/老婆的代码/统计软件_Sep 16_week2.py
4,155
3.984375
4
""" 统计软件与算法 2020年9月16日 """ """ Remark(array subsetting) """ import numpy as np #2D numpy array np_2d = np.array([[1.73,1.68,1.71,1.89,1.79], [65.4,59.2,63.6,88.4,68.7]]) #2d numpy array subsetting np_2d[0] #first row np_2d[0,:] #first row np_2d[0:1,1:3] np_2d[0...
46271c71606f4a0c5d8bea5244401d1db8419b67
cl199406/python-data-structure-code
/treeOrder.py
677
4
4
#遍历树 #前序遍历 def preorder(tree): if tree: print(tree.getRootVal) preorder(tree.getLeftChild()) preorder(tree.getRightChild()) else: return None #后序遍历 def postorder(tree): if tree: preorder(tree.getLeftChild()) preorder(tree.getRightChild()) print(tree.getRootVal()) else: return None #中序遍历 def ino...
cabd755951f46f0e6454a9342e4e7198113ff33c
cl199406/python-data-structure-code
/selectSort.py
347
3.78125
4
#selectSort 选择排序 def selectSort(alist): for fillslot in range(len(alist)-1,0,-1): positionMax=0 for location in range(1,fillslot+1): if alist[location]>alist[positionMax]: positionMax=location alist[fillslot],alist[positionMax]=alist[positionMax],alist[location] return alist print(selectSort([54,26,93,1...
3ac26042891246dead71c85f0fd59f5f7316a516
akhilpgvr/HackerRank
/iterative_factorial.py
408
4.25
4
''' Write a iterative Python function to print the factorial of a number n (ie, returns n!). ''' usersnumber = int(input("Enter the number: ")) def fact(number): result = 1 for i in range(1,usersnumber+1): result *= i return result if usersnumber == 0: print('1') elif usersnumber < 0: print(...
d289be40f557068715fd14f141c3c24c7f516324
akhilpgvr/HackerRank
/nested.py
640
3.515625
4
namelist = list() gradelist = list() numbers = list() newlist = list() counter = int(input()) for i in range(counter): name = namelist.append(input().strip()) grade = gradelist.append(input().strip()) studentlist = [list(l) for l in zip(namelist,gradelist)] for list in studentlist: for element in list:...
a412e958ac2c18dd757f6b5a3e91fd897eda6658
akhilpgvr/HackerRank
/fuzzbuzz.py
435
4.1875
4
''' Write a Python program to print numbers from 1 to 100 except for multiples of 3 for which you should print "fuzz" instead, for multiples of 5 you should print 'buzz' instead and for multiples of both 3 and 5, you should print 'fuzzbuzz' instead. ''' for i in xrange(1,101): if i % 15 == 0: print 'fuzzb...
f44d2629a566d9a7e9ce2336d442fde4dd87ba20
jzferreira/datastructures
/python/linked_list/linked_list.py
6,609
4.28125
4
#!/bin/python3 class Node: '''Classe que representa um item do Linked List''' def __init__(self, data = None): self.data = data self.next = None class LinkedList: '''Classe que representa a estrutura de classe LinkedList''' def __init__(self, head = None): self.head = head ...
3f8ea5f051b82e120e22782a1551c664a6fb8ea7
maciexu/pandas-Foundations
/Case_study.py
12,233
4.25
4
# what if there's no header???->header=None # Import pandas import pandas as pd # Read in the data file: df df = pd.read_csv(data_file) # Print the output of df.head() print(df.head()) # Read in the data file with header=None: df_headers df_headers = pd.read_csv(data_file, header=None) # Print the output of df_head...
a8942c180a6a472c9481a8f581047e37844ff2e3
sidv1905/Python-programs
/Prac/revnumber.py
211
3.59375
4
#reverse of an number N=int(input('enter')) mylist=[] for i in range(0,N): n=input() mylist.append(temp) for reverse in mylist: rev=0 while(n>0): dig=n%10 rev=rev*10+dig n=n/10 print(rev)
4cfe8c7b648fea193a18ecbe38fe47686d62d411
sidv1905/Python-programs
/Codechef/turbosort.py
130
3.65625
4
t=int(input()) arr=[] for i in range(t): temp=int(input()) arr.append(temp) arr.sort() for sorti in arr: print(sorti)
d5e9f2961664be8cdb4248b657290c4f3d57a6fd
sidv1905/Python-programs
/Snackdown/combinations.py
652
3.625
4
def makeNumber(number, digits, path = []): if digits == 1: if number not in path: path += [number] path.sort() if number < 10 and path not in combinations: combinations.append(path) else: nums = list(range(1, min(number - digits + 2, 10))) ...
99618bf4dc37025a2a5ba52e1b71c8b22d205bef
sidv1905/Python-programs
/Prac/reversestring.py
76
3.75
4
s=input("enter a string") s=s.split() sx=s[::-1] sx=" ".join(sx) print(sx)
cea57889ff008ab9227ae48c07a56cbed8a5f78e
sidv1905/Python-programs
/Codechef/fitsquare.py
154
3.53125
4
T=int(input()) while T>0: B=int(input()) ans=0 while B>=2: B=B-2 base=B//2 ans=ans+base print(int(ans)) T=T-1
ec5f230755901f9a0c5dc17a03da7831ddbc0326
neighborpil/PY_WebCrawlingStudy
/Week1/Day2_8_EscapeCharacter.py
348
3.84375
4
""" # Escape character - 사용하다 보면 특수한 regular expression의 실제 문자를 사용하고 싶을 때에는 - 앞에다가 '\'를 붙여주면 된다 - special character가 아니라 그냥 문자가 된다 """ import re x = 'We just received $10.00 for cookies.' y = re.findall('\$[0-9.]+', x) # \$ : real dollar sign print(y)
7620e6d03efeb674fad8fb5d3b2565c78ddeaf2f
neighborpil/PY_WebCrawlingStudy
/Week2/Day6_Question3.py
825
3.5625
4
""" [질문 3] http://python-data.dr-chuck.net/comments_42.xml 해당 URL의 xml을 load한 후, comments의 총 갯수와 comments에 있는 각 count들을 모두 더해서 출력하는 파이썬 프로그램을 작성해주세요. (urllib, xml.etree.ElementTree 등을 import 하여 사용하시면 됩니다.) * """ import xml.etree.ElementTree as ET import urllib.request, urllib.parse, urllib.error import re raw = urlli...
0cacf9f1b270d2814847c7d4091de5592bc47bad
SherriChuah/google-code-sample
/python/src/playlists.py
1,501
4.1875
4
"""A playlists class.""" """Keeps the individual video playlist""" from .video_playlist import VideoPlaylist class Playlists: """A class used to represent a Playlists containing video playlists""" def __init__(self): self._playlist = {} def number_of_playlists(self): return len(self._playlist) def get_all_p...
f8cfd25b751825375fc4a164104a149a5220fd22
Manish-Kumar317/Python-Assgn.
/Program 1.py
174
4
4
a=30 b=10 print("additon of two numbers is",(a+b)) print("additon of two numbers is",(a-b)) print("additon of two numbers is",(a*b)) print("additon of two numbers is",(a/b))
c55506a58a3547970149ed7b11225fcfeee5f193
tryhear/info
/bak/zanbu.py
6,020
3.671875
4
import random from icecream import ic import sqlite3 import stackprinter # 0为阴,1为阳 # —为阴 ——为阳 X为老阴 O为老阳 def 抽签(): 签 = "" 备选字符 = [0, 1] 三枚铜钱 = [] 爻序 = 1 爻列表 = [] 变爻序号 = [] 变爻次数 = 0 变卦 = "" for i in range(6): for j in range(3): 摇卦 = random.choice(备选字符) ...
861ada8af86a6060dfc173d19e0364e2132a447e
DataActivator/Python3tutorials
/Decisioncontrol-Loop/whileloop.py
944
4.21875
4
''' A while loop implements the repeated execution of code based on a given Boolean condition. while [a condition is True]: [do something] As opposed to for loops that execute a certain number of times, while loops are conditionally based so you don’t need to know how many times to repeat the code going in. ''' ...
23011b3f23f690d63031dfb0691b58b8b883ba0d
AineKiraboMbabazi/analysis-api
/statisticsapi/models/government.py
412
3.625
4
class Government(): """Government class defining the Government model""" def __init__(self, name, photo, status, created_by, creation_date, updated_by, updated_at): self.photo = photo self.name = name self.updated_by = updated_by self.status = status self.created_by ...