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
e81ffa79b45622559323d09e0a4143366e5009ae
cdacos/pygame_experiments
/breakout/breakout.py
4,525
4.09375
4
# Import the pygame library and initialise the game engine import pygame # Let's import the Paddle Class & the Ball Class from paddle import Paddle from ball import Ball from brick import Brick pygame.init() # Define some colors WHITE = (255, 255, 255) DARKBLUE = (36, 90, 190) LIGHTBLUE = (0, 176, 240) RED = (255, 0,...
dac4aab93f489de9850f4b01950af39d45ea7b4f
Adiel30/DevOps
/venv/DevOps/Test1.py
583
3.875
4
# y = 3 # v = 4 # z = 7 # b = "Sasazo" # # print (y) # print (b) # print (b) # print (str(y) + b) # print (b) # print(y + v * z) f = 14 x = 88 r = 3 d = 12 if x > f: print('BANANA') print('BANANA') if x < f: print('NANA') if x >= f: print('BANANA') if r != d: print('vvv') if x > f: ...
9f6be9485d25a970fe8ad3acb592639f1bed1265
Adiel30/DevOps
/venv/DevOps/Lesson2.py
646
3.8125
4
for Y in range(50): print(Y) for B in range(2,66): print(B) for V in range(3,33,3): print('EVA') Count = 4 while Count < 15: print('Huge') Count += 1 Count = 4 while Count < 15: print('Huge') Count += 1 if Count >=13: break for V in range(3,33,3): print('EVA') if V >...
d8e3ad776f6363a601cf573452fcc7a3d6ed3e70
Adiel30/DevOps
/venv/DevOps/GoogleAPI.py
497
3.515625
4
import urllib.request, json with urllib.request.urlopen( "https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurants+in+Jerusalem&key=AIzaSyB-Z0RBleTXb7JHLx6QhSANPeTiOkMyKj4")as places: googlePlaces = json.loads(places.read().decode()) print(googlePlaces) results = googlePlaces['result...
0645981bb86c9f7c89ee75552809e6e8cc892cba
JPMike/PAT_Basic
/1007_V3.py
407
4
4
#! usr/bin/env python #-*- coding: utf-8 -*- # 该程序有一定的几率可以不超时通过最后一个测试点 import math def is_prime(num): for div in range(2,int(math.sqrt(num))+1): if num % div == 0: return False return True max_num = int(input()) count = 0 for num in range(5, max_num+1): if is_prime(num) and is_prime...
7ab831cd88d56e2b496ba5c23584bd71bb4f290b
JPMike/PAT_Basic
/1010.py
579
3.5
4
#! usr/bin/env python #-*- coding: utf-8 -*- num_list = list(map(int, input().split())) result_list = [] for index in range(0, len(num_list)-1, 2): if len(num_list) == 2: result_list = [0, 0] break else: if num_list[index] * num_list[index+1] != 0: result_list.append(num_li...
48bb1f842846fd1df892a909db3d282e9f659f30
sandeepnita9/python-pdf-merger
/pdf-merger.py
1,030
3.734375
4
import PyPDF2 def mergePDF(pdfs, mergedpdf): #Create PDF merging class object mergeMyPDF = PyPDF2.PdfFileMerger() #read input pdf files path and merge them for fileToMerge in pdfs: input_pdf_file = open(fileToMerge, "rb") mergeMyPDF.append(input_pdf_file) #Create blank p...
46cd73be7db3127786474a3cbe65354294b9f6e7
smatinjou/PythonProgramming
/ex2/Prog1.py
169
3.875
4
x=int(input("enter x number ---> x = ")) y=int(input("enter x number ---> y = ")) z=[] for i in range(x+1,y): if i%2==0: z.append(i) print(z)
f4c18cff3f29c654dd58ea259a8cce714efbe9e4
Indra-Ratna/LAB4-1114
/lab4_problem6.py
666
3.875
4
#Indra Ratna #CS-UY 1114 #28 September 2018 #Lab 4 #Problem 6 f_24 = int(input("Please enter time in 24 hr format :")) hours_o = f_24//100 hours = 0 minutes = f_24%100 a_or_p = "" if(hours_o>12): a_or_p= "pm" if(hours<10): hours=str(hours).zfill(2) elif(hours_o==12): a_or_p = "pm" ...
69add1b6ac76a4b01e127ed5599452b5ba870963
cddedric/Python_things
/isogram/my_isogram_test.py
1,249
4.09375
4
""" def is_isogram(inputString): alphaOnlyString = '' #init string for own sanity for character in inputString: # loop through string if character.isalpha(): # check if character at point is a-z or A-Z alphaOnlyString += character # if character, add to string # alphaOnlyString is either letter...
29ac6660024da6d87500242f6ce13aeed5177973
paparent/sarpaminfohub
/scripts/scrape.py
8,078
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Scrapes values from the Sqlite database file and writes out nice JSON objects that map to either objects in Fluidinfo or rows in a relational database (for the purposes of import) """ import os import json import sqlite3 import sys import pprint from decimal import Dec...
5a8dcd064fdabe5eee859c80a214b8ec278ee612
APNovichkov/python-leetcode
/easy/isIsomorphic.py
599
3.859375
4
def isIsomorphic(self, s, t): """ Time complexity: O(n) where n is the lenght of s and t. It is O(n) because we are running through string s and string t simultaneously Memory Complexity: O(n) because we are storing a map of each unique character to another unique character """ m = {} ...
2ae0ba21834bab269edd9508bf8476d13fe7492d
APNovichkov/python-leetcode
/easy/pathSum.py
820
3.8125
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def hasPathSum(root, sum): """ :type root: TreeNode :type sum: int :rtype: bool """ if root is None: ...
e0c62280d0a17510b152d5aff2671bc89e0de4d4
DevOpsStuff/Programming-Language
/Python/PythonWorkouts/NumericTypes/run_timings.py
488
4.125
4
#!/usr/bin/env python def run_timing(): """ Asks the user repeatedly for numberic input. Prints the average time and number of runs """ num_of_runs = 0 total_time = 0 while True: one_run = input('Enter 10 Km run time: ') if not one_run: break num_of_runs ...
d8dd884b91298aee2121fc5158b0b0bc836af8b1
DJAcquila/ClientServer
/Project/uno/pygame/controls.py
6,821
3.546875
4
from uno.pygame.display import * import os,pygame def get_keypress(event): """ Main call function that grabs keypress events and returns logic values related to such keypresses. Note: if the QUIT event happens os._exit is called in which the entire PY-GAME instance is shutdown. O(1) runtime ...
a6ac809a786a46e806fdb2248af7faebdf3492cc
sharpshooter91/Vending-machine
/vending_machine.py
649
4.0625
4
sodas = ['Pepsi', 'Chery', 'Coce Zero', 'Sprite'] chips = ['Duritos', 'Fritos'] candy = ['Snikers', 'M&Ms', 'Twizlers'] while True: choice = input('Whould you like soda, some chips or candy? ').lower() try: if choice == 'soda': snack = soda.pop() elif choice == 'chips': ...
18ec7fda3d2e3b79c41a6f3f4c02c299a46ee5ab
nguyenvanson1998/Discrete-Optimization
/tsp/tsp/Greedy.py
1,193
3.59375
4
import math from collections import namedtuple Point = namedtuple("Point", ['x', 'y']) def distance(v1: Point ,v2 :Point): return math.sqrt( (v1.x - v2.x)**2 + (v1.y - v2.y)**2 ) def get_point(Points, v: int): x : Point x = Points[v] return x def edges_cost(Points: [Point], v1:int, v2:int): a =...
27a33e8e2c0a5a2faf864d7772cbb06dd8420b47
Jakasit/CP3-Akasit-Jaroensiri
/Assignments/Exercise21_Akasit_J.py
1,285
3.53125
4
from tkinter import * import math def leftClickButton(event) : result = float(textBoxWeight.get())/math.pow(float(textBoxHeight.get())/100,2) if result >= 30.0: labelResult.configure(text= (int(result),"อ้วนมาก"),fg= "red") elif result >= 25.0: labelResult.configure(text= (int(result),"อ้วน")...
c953a9930a8f4f4a1961ae7e386d459f61858ab5
jacksparling1/JackSparling-Python
/123Lab/123Lab.py
1,453
3.84375
4
def main(): numbGrade = int(input("What grade are you in?")) #print (yearinschool(numbGrade)) longyear = (yearinschool(numbGrade)) print (longyear) myList = [91.5, 88.1, 99.8, 93.4] getNumber= (gpa(myList)) print (getNumber) theNumber = (letterGrade(getNumber)) print (theNumber) ...
5310b9fd12649580ecbea5871411e5edad2b6949
gokul-raghuraman/gaussian-mixture-models
/GMM_RandomInit.py
1,270
3.796875
4
""" CS 6601 Artificial Intelligence Part 1: Implementation of Gaussian Mixture Models and EM This program runs the Expectation Maximization algorithm on an input image using Gaussian Mixture Model In this example, the means are initialized randomly """ import numpy from gmm_methods import * numClusters = 3 inputImag...
a59d1c0978c2a7414382184b7172b2171c22304f
JonathanCooper/advent-of-code
/2021/day01/prob1.py
229
3.65625
4
previous = None count = 0 with open('in.txt') as fh: for line in fh: depth = int(line.strip()) if previous: if depth > previous: count += 1 previous = depth print(count)
6aca4bcc836fea933816687489ccc099473f264a
JonathanCooper/advent-of-code
/2021/day02/prob1.py
659
3.78125
4
class Position(object): def __init__(self, horizontal, depth): self.horizontal = horizontal self.depth = depth position = Position(0, 0) with open('in.txt') as fh: for line in fh: line = line.strip() direction, distance = line.split() distance = int(distance) ...
d5a93b0e870d4df8b3683c869bee6ad3020689a2
JonathanCooper/advent-of-code
/2022/day02/prob1.py
1,241
3.6875
4
class Shape(object): def __init__(self, symbol): if symbol in ['A', 'X']: self.name = 'ROCK' self.shape_score = 1 self.beats = 'SCISSORS' self.loses_to = 'PAPER' elif symbol in ['B', 'Y']: self.name = 'PAPER' self.shape_score...
e8630c5030ce146aeafd8b55e74adb87ab216fd3
JonathanCooper/advent-of-code
/2022/day04/prob1.py
969
3.640625
4
''' Pair(27-89) contains Pair(7-88) ''' class Pair(object): def __init__(self, s): s = s.split('-') self.start = int(s[0]) self.end = int(s[1]) def overlaps(self, other): if self.start in [other.start, other.end]: return True if self.end in [other.start, ...
4228801b33abc707bfee5cc3d47e384f0f170bbb
JonathanCooper/advent-of-code
/2021/day08/prob1.py
297
3.734375
4
count = 0 with open('in.txt') as fh: for line in fh: line = line.strip() output = line.split('|')[1] output = output.lstrip() words = output.split() for word in words: if len(word) in [2, 3, 4, 7]: count += 1 print(count)
7d53c916f11390dd5a6d92609e6d4a5d326e0a93
JonathanCooper/advent-of-code
/2019/day4/prob1.py
726
3.734375
4
def meets_criteria(word): return ( len(word) == 6 and contains_double(word) and does_not_decrease(word) ) def contains_double(word): for i in range(len(word) - 1): if word[i] == word[i + 1]: return True return False def does_not_decrease(word): digits ...
a51a117b576cca68c7f05cebef6b3dc6f2fe9a2d
JonathanCooper/advent-of-code
/2021/day04/prob1.py
1,904
3.515625
4
import sys class Board(object): def __init__(self): self.rows = [] self.marked = set() self.board_len = 5 def add_row(self, row): self.rows.append(row) def mark(self, called_num): for row in range(self.board_len): for i, num in enumerate(self.rows[row...
8a10d7647dad3df50cf0e75343819bd22b2f0413
maxikfu/ML_HW2
/cnn_imdb.py
2,099
3.53125
4
import numpy as np import keras from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten, Activation from keras.layers import Conv1D, GlobalMaxPooling1D, Embedding from keras.datasets import imdb from keras.preprocessing import sequence from keras.optimizers import SGD max_features = 20000...
e4e82130ca69f4b9346dd7e025a6bb06c31d38d2
lk-greenbird/forbrl
/forbrl/agents/policies/base.py
746
3.546875
4
from abc import ABC, abstractmethod import numpy as np class Policy(ABC): def __init__(self, epsilon, algo='epsilon_greedy'): self.epsilon = epsilon def epsilon_greedy(self, feats): '''Epsilon-greedy policy: with probability epsilon, do random action, otherwise do default sampling.''' ...
ef51a44d9396c0785e3f24a78ca677f7bf80a015
mp/loan-test
/loan test.py
549
4.0625
4
# Whether a bank customer qualifies for a loan # constants MIN_SALARY = 20000.0 MIN_YEARS = 3 def main(): # get the customers annual salary salary = float(input('Enter your annual salary: ')) # Get number of years in the job years_on_job = int(input('Enter the number of years employed: ')) # Ch...
23285e8bd188b024f6fecd02518286a5bf7462fe
vivian-li00/msci446
/apriori/tutorial/apriori.py
1,098
3.765625
4
################################# # # Example adapted from http://intelligentonlinetools.com/blog/2018/02/10/how-to-create-data-visualization-for-association-rules-in-data-mining/ # ################################# # Import necessary python libraries import pandas as pd import csv from mlxtend.preprocessing import T...
3d855830ea3db5b3b74edc95221ce803a7f365c7
Mozes721/PythonCrashCourse
/chapter_7/movie_tickets.py
315
3.96875
4
prompt = "How old are you? " prompt += "\n Enter 'quit' if your finished" while True: age = input(prompt) if age == 'quit': break age = int(age) if age <= 3: print("its free!") elif age >= 3 and age <= 12: print("the ticket is 10$") else: print("15$ price")
122f637e84c5e5004fd039a44edc78f44b846fcc
Mozes721/PythonCrashCourse
/chapter_11/language_survey.py
395
4
4
from chapter_11.survey import AnonymousSurvey question = "What language did you first learn to speak?" my_survey = AnonymousSurvey(question) my_survey.show_questions() print("Enter 'q' to quit at any time/n") while True: response = input("Language ") if response == 'q': break my_survey.store_respo...
115b864e68805e0937bcd6fb1841951cb60260fd
Mozes721/PythonCrashCourse
/chapter_8/City_name.py
250
3.8125
4
def city_country(city,country): return(city.title() + ", " + country.title()) city1 = city_country('Riga', 'Latvia') print(city1) city2 = city_country('Tallin', 'Estonia') print(city2) city3 = city_country('Copenhagen', 'Denmark') print(city3)
85300815bbd19bf84a2c728b80a146147695ebd6
Mozes721/PythonCrashCourse
/Chapter_10/Division.py
367
4.03125
4
print("Give me two numbers") print("Enter 'q' to quit") while True: first = input("Enter first number: ") if first == 'q': break second = input("Enter first number: ") if second == 'q': break try: answer = int(first) / int(second) except ZeroDivisionError: print(...
fcd3be2c6655efc88645fa1ba8034640f58fe428
Mozes721/PythonCrashCourse
/chapter12/Alien_Invasion/bullet.py
1,122
3.921875
4
import pygame from pygame.sprite import Sprite class Bullet(Sprite): def __init__(self, ai_settings, screen, ship): #creates a bullet object at ships current postion super(Bullet, self).__init__() self.screen = screen #create a bullet rect at (0,0) and set correct position ...
e9dd739d069a251c9e19e8016939a3e5fcf5f0a9
Mozes721/PythonCrashCourse
/Chapter_10/Favourite_number.py
185
3.875
4
import json number = input("Whats your favourite number?") with open('favourite_number.json', 'w') as f: json.dump(number, f) print("Is this your number of choice " + number)
1fc547ddd30a2152cf2682d28939d1cc6ca8de40
Srizon143005/Neural-Networks-Algorithms
/01. Nearest Neighbor Algorithm/Nearest Neighbor Algorithm.py
1,621
3.546875
4
""" Title: Nearest Neighbour Algorithm Author: Azmain Yakin Srizon """ """ Class 1: y=x*2 Class 2: y=x*5 """ import math # Declaring train data train_data = [[1,2,1],[2,4,1], [3,6,1],[4,8,1], [5,10,1],[1,5,2], [2,10,2],[3,15,2], [4,20,2],[5,25,2]] # Declaring t...
9bfc4dd44934fa9d5bfda2ef8afabb61c17e43c4
VladyslavKharchenko/udacity-hadoop-mapreduce
/lesson8/post_answer_length/reducer.py
1,392
3.671875
4
#!/usr/bin/python import sys import csv def reducer(): reader = csv.reader(sys.stdin, delimiter='\t') prev_post_id = None average_answer_len = 0.0 answers_count = 0 question_len = None for line in reader: if len(line) == 3: curr_post_id, curr_post_len, type = line ...
0a3f0e3ac34c3bcb1fcc8e9a7a4e2e8f3114499b
smallcaier/life-of-python
/python基础/基础2.py
6,268
4.09375
4
""" 函数: 定义: 对功能或者动作的封装 f(x) = x + 1 语法: def 函数名(形参): 函数体(return) 函数名(实参) 形参: 函数声明的时候的变量 分类: 1. 位置参数 2. 默认值参数 3. 动态传参 *args 位置参数的动态 接收到的是元组 **kwargs 关键字参数的动态 接收到的是字典 ...
95ce6cd272a20867cdd599db051196589a0a4ff6
Hemie143/Regex_Engine
/Problems/Time/main.py
238
3.578125
4
class Time: def __init__(self, hour, minute): self.hour = hour self.minute = minute @staticmethod def from_string(time_string): hour, minute = time_string.split(":") return Time(hour, minute)
bc6639bd31a37574da77951768dd85de3649b83c
Hemie143/Regex_Engine
/Problems/Unpacking/main.py
249
3.96875
4
def unpack(input_tuple): # your code here unpacked = tuple() for i in input_tuple: if isinstance(i, str): unpacked = unpacked + (i, ) else: unpacked = unpacked + tuple(list(i)) return unpacked
f5f23a9af0293b9aeb68690bea4ab999d8e790fa
Hemie143/Regex_Engine
/Problems/Several testings/main.py
229
4
4
def check(x): if x.isnumeric(): x = int(x) if x >= 202: print(x) else: print("There are less than 202 apples! You cheated on me!") else: print("It is not a number!")
740b6d89a712b4113204d9df7ed1e8e5c1920464
Ahsanmumtaz1105/paf
/utils/Util.py
5,073
3.53125
4
def compare_dictionaries(dict1, dict2, id1=None): """ """ if dict1 is None and dict2 is None: return True, "Both the dictionaries are None" if dict1 is None or dict2 is None: return False, "One of the dictionary contains None" if (type(dict1) is not dict) or (type(dict2) is not dic...
ad8a07170c3d88b748ff381267efdc0e8730b4c9
carolinegbowski/recipe_project_backend
/seed.py
644
3.546875
4
import sqlite3 def seed(): with sqlite3.connect('data.db') as conn: cursor = conn.cursor() SQL = """ INERT INTO accounts (email_address, password_hash, first_name, last_name, token) VALUES ("caroline.gbowski@gmail.com", "password_hash", "Caroline", "Grabowski", "1111111111");...
784a7634af6875cff2bc58dad7280a1a3237ff0a
carlosivanx/python_django
/sorteio.py
680
3.8125
4
from random import randint print ("Bem vindo") #print (numero_sorteado) novo_jogo = True while novo_jogo != False: numero_sorteado = randint(1,100) contador = 1 while True: chute = int(input("chute um numero: ")) if chute == numero_sorteado: print ("parabens, vc é o cara") ...
4b1c8baf68c0ee37db3063dd0c10eaafcd28ab1b
vladyslavnUA/herd-immunity-simulation
/virus.py
1,387
3.90625
4
class Virus(object): '''Properties and attributes of the virus used in Simulation.''' def __init__(self, name, repro_rate, mortality_rate): self.name = name self.repro_rate = repro_rate self.mortality_rate = mortality_rate def test_virus_instantiation(): #TODO: Create your own tes...
475e09a89887e6cd7a5a5a75cc3ce8d8e09f7592
Carina6/python_suggestion
/91_suggestion/tests/100_test_list_pythonic.py
533
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2018/10/17 18:36 # @Author: hlliu from collections import defaultdict ''' 将d1 转化成: {'p': [1, 2, 3], 'h': [1, 2, 3]} ''' d1 = [('p', 1), ('p', 2), ('p', 3), ('h', 1), ('h', 2), ('h', 3)] def test_set_default(): result = {} for (key, value) in d1: ...
a87343d9397dd9b73da1f7a271379aa720159dff
Carina6/python_suggestion
/91_suggestion/tests/63_1_test_protocol.py
2,728
3.859375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 63:熟悉 Python 对象协议1 def test_protocol(): class A(object): # 字符串格式化中,如果有占位符 %s,那么按照字符串转换的协议,Python 会自动地调用相应对象的 __str__() 方法 # __repr__和__str__这两个方法都是用于显示的,__str__是面向用户的,而__repr__面向程序员 def __str__(self): print('calling __str__') ...
c504ab5185d334929c0cccc6afbf42287aaa314e
Carina6/python_suggestion
/91_suggestion/tests/64_test_pipe.py
1,007
3.859375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from re import findall from pipe import add, take_while, where, Pipe, groupby, select, sort, count # 64:利用操作符重载实现中缀语法 '''Pipe的使用''' def test_pipe(): def fib(): a, b = 0, 1 while True: yield a a, b = b, a + b # 计算小于4000000的...
0432fea96511d04ed501580d13bb8ed1bdb914c6
Carina6/python_suggestion
/91_suggestion/tests/39_test_counter.py
1,031
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from collections import Counter # 39:使用 Counter 进行计数统计 def test_counter(): some_data_list = ['a', '2', 2, 3, 5, 'c', '7', 4, 5, 'a', 'b'] some_data_set = {'a', '2', 2, 3, 5, 'c', '7', 4, 5, 'a', 'b'} c = Counter(some_data_list) print(c) print(list(c....
17326597d0597d16717c87c9bdf8733fb3acb77b
j1406493495/Other-someLearnCode
/python/learnPython.py
1,015
3.515625
4
#! /usr/bin/python import glo print glo.x a = "hello world" print id(a) a = "ni hao" print id(a) for y in range(0, 5, 2): print y for y in 1, 2, 3: print y if (glo.x == 2): print("a==2") else: print("a!=2") tuple_name = ("name", "age", "school") #can't modify, only-read list_name = ["boy", "girl...
1789198ef0b71b2d9b6292691489b7d7412a6150
mflood/whimsical
/anagram/is_anagram.py
538
3.703125
4
def is_anagram(s1, s2): size = len(s1) if len(s2) != size: return False tracker = {} for i in range(size): tracker.setdefault(s1[i], 0) tracker[s1[i]] += 1 if not tracker[s1[i]]: del tracker[s1[i]] tracker.setdefault(s2[i], 0) tracker[s2[i...
4a3727fd4fd97b1ea3fd2e3819a03160d2926d62
mflood/whimsical
/advent_of_code/flood_advent/utils.py
10,001
3.5
4
import argparse import re import logging import requests from typing import Iterator from typing import List LOGGER_NAME="advent" def init_logging(is_verbose: bool): """ Creates standard logging for the logger_name passed in """ logger = logging.getLogger(LOGGER_NAME) logger.setLevel(logging....
3633a05516f5cf974fb1502906846400c48c3e86
MddeLip/MODIS_AOD_PM25
/扩展库和扩展程序/程序/日期加减.py
598
3.859375
4
# -*- coding: utf-8 -*- # 日期: 2019/3/18 10:43 # 作者: xcl # 工具:PyCharm import datetime def get_day(date, step=0): """获取指定日期date(形如"xxxx-xx-xx")之前或之后的多少天的日期, 返回值为字符串格式的日期""" l = date.split("-") y = int(l[0]) m = int(l[1]) d = int(l[2]) old_date = datetime.datetime(y, m, d) new_date = (old_dat...
b7c34e632f39a211a53677955a9e7d92bd8afbd9
MddeLip/MODIS_AOD_PM25
/扩展库和扩展程序/程序/concat&ascending测试.py
382
3.671875
4
# -*- coding:utf-8 -*- # 日期:2019/2/9 20:51 # 作者:xcl # 工具:PyCharm import pandas as pd a = [[1, 3, 3], [4, 1, 6], [7, 8, 9]] a = pd.DataFrame(a) a.columns = ["A", "B", "C"] b = [[3, 5, 8], [2, 7 , 3], [6, 1, 5]] b = pd.DataFrame(b) b.columns = ["A", "B", "C"] c = pd.concat([a, b], sort=True, ignore_index=True) c = ...
0e10a3012b364307aa83b21ec50e7d3ffd5c6b84
GENADEE/ibsencoin
/networking/primitive/network_test.py
1,859
3.625
4
# this is from a tutorial # OK I'LL USE THE HTTP SERVER AFTER I FINISH PRIMITIVE SERVER AND CLIENT USING RAW TCP import socket ''' HOST, PORT = '', 8888 # AF_INET is better because AF_UNIX uses a file on your system or something wierd # SOCK_STREAM is better for TCP while SOCK_DGRAM is better for UDP (and obviously ...
d461e07deb80cc2b49be1fab1fcb32232cbaf67d
SpheITguru/Bresenham-s-line-drawing-algorithm
/Bresenham’s line drawing algorithm.py
1,418
4.0625
4
print("Enter the value of x1: ") x1 = int(input()) print("Enter the value of x2: ") x2 = int(input()) print("Enter the value of y1: ") y1 = int(input()) print("Enter the value of y2: ") y2 = int(input()) dx = x2 - x1 dy = y2 - y1 m = dy/dx if (dx > dy): steps = abs(dx) pk = 2*dy - dx print...
1bbcda51e0af02bc01394c857c2acf371863791c
pelvoc/LeetCode-Summer
/125.py
670
3.546875
4
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ if s==None: return True head=0 tail=len(s)-1 d="A-Za-z0-9" while head<=tail: cHead=s[head] cTail=s[tail] ...
a700984d0850da8ec7f4efbb45fc68526496698f
pelvoc/LeetCode-Summer
/143.py
986
3.90625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def reorderList(self, head): """ :type head: ListNode :rtype: void Do not return anything, modify head in-place instead. ...
b04b3d75d2a7b11f6bd4ff4dc4e41b86709edf71
pelvoc/LeetCode-Summer
/095.py
1,003
3.828125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def generateTrees(self, n): """ :type n: int :rtype: List[TreeNode] """ if n==0: ...
c97a0c87c86af3b4a6cdcc5ef910cc69a063da38
pelvoc/LeetCode-Summer
/337.py
697
3.65625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def rob(self, root): """ :type root: TreeNode :rtype: int """ res=self.robSub(roo...
7da4269b3790b0d65df36dda564a3abf9fcfcd38
the-osprey/neural-net
/NeuralNet2.py
5,580
4.0625
4
#created with inspiration from Neural Newtorks and Deep Learning! import numpy, random def sigmoid(x): return 1 / (1 + exp(-x)) #exp def sigmoid_prime(x): return sigmoid(x)*(1-sigmoid(x)) class NeuralNetwork(object): """Network class to represent a neural network sizes -- has number of neurons in...
bf8ecc02cdc73f44d6b33c68d7b60ce10fcae688
imbiginjapan/math_with_python
/quadratic.py
560
3.859375
4
from matplotlib import pyplot as plt from random import randint def quad(x): return x ** 2 + 2*x + 1 def draw_graph(x): print (x) for n in x: plt.plot(n, quad(n), marker = 'o') def get_vals(max): x = [] i = {} c = 0 while c < max: n = randint(0 - max,max) if n no...
36c8ed49912c554d94cf35a2523033f52c75d3fe
diedrebrown/pfch-spring2020-blue
/Code/Blue_ImgOpenCV2.py
1,958
3.65625
4
# Blue at the Rijksmuseum - Eval blue with OpenCV # This code is based on the tutorial, Introduction to Deep Learning with OpenCV, by Jonathan Fernandes. import numpy as np import pandas as pd import cv2 import csv #import images MeissenerblueMacaw = "MeissenerblueMacaw.jpg" VerspronckportGirLDressed = 'Verspronckpo...
89fb01ad557c557d466c769938d789f5c962032c
vharvey80/PythonExercises
/ConverterLbsOunces.py
709
3.71875
4
# Convertisseur de livres en onces / onces en livres def Convertisseur(n_lbs, n_onces, c_lbs, c_onces): rn_lbs = float(format(float(n_lbs.replace(",", ".")), '.1f')) rn_onces = float(format(float(n_onces.replace(",", ".")), '.1f')) k_lbs = (rn_lbs / c_lbs) k_onces = (rn_onces / c_onces) kilogrammes...
3fbaf597a2c06126fdf5d29afda52b51da4b1af9
YadavDeepak2310/csv_to_sql
/csv_to_sql.py
1,840
3.6875
4
''' This Program import all csv files in given directory path Remember all csv file metadata should be numeric and if text is included, individual text data shouldn't have any character = "," ''' import pandas as pd import os, re import numpy as np import sqlalchemy as sql from sqlalchemy import create_engine # Creat...
8f841be19aa43d9ac0bf5eda60dbb259c2945592
martinyordanov90/homework-hackBG
/exam/second2.py
301
4.09375
4
def second_largest(numbers): result = [] for number in numbers: if number not in result: result.append(number) if len(numbers) <= 1: return False result = sorted(result)[-2] return result number = [5,5,4] print(second_largest(number))
b6d63824607fdc546bd593effa83e97ee00e04d9
martinyordanov90/homework-hackBG
/exam/loss_or_profit.py
415
3.5
4
def loss_or_profit(income,outcome): result_income = 0 result_outcome = 0 result = 0 for x in income: result_income += x for y in outcome: result_outcome += y result = result_income - result_outcome if result > 0: result = "+" + str(result) elif result < 0: ...
54204fbd0f3b98da5d4092b13109b97a629c4fe3
martinyordanov90/homework-hackBG
/2/2-List-Problems/max_of_n.py
256
4.0625
4
n = input("Enter number: ") n = int(n) count = 1 current_max = 0 while count <= n: number = input("Enter number: ") number = int(number) if number > current_max: current_max = number count += 1 print("Max is:" + str(current_max))
9ae4d389926d2a273e0e249a5cb2a42834380597
martinyordanov90/homework-hackBG
/6/1-List-Functions/EQUAL LIST.py
218
3.78125
4
def equal_list(l1,l2): if len(l1) != len(l2): return False for index in range(0, len(l1)): if l1[index] != l2[index]: return False return True print(equal_list([2,3,4],[2,3,4]))
dc76496794d7270178185d78de061c180f4ea779
martinyordanov90/homework-hackBG
/6/1-List-Functions/LAST.py
98
3.5625
4
def last(items): last_index = len(items) - 1 return items[last_index] print(last([1,2,3]))
4971e98948537505400b801f593fe089f51ac79b
martinyordanov90/homework-hackBG
/6/2-String-Functions/change_ch_in_string.py
302
3.796875
4
def change_at(index, ch, string): result = "" n = len(string) for str_index in range(0, n): if str_index == index: result += ch else: result += string[str_index] return result index = 2 ch = "w" string = "Ivan" print(change_at(index,ch,string))
187e01d0cf349f7dfe5b67b38d75e7653f6cf548
martinyordanov90/homework-hackBG
/1/5-Saturday-Tasks/3_digits.py
152
3.6875
4
a = input("Enter number: ") a = int(a) b = input("Enter number: ") b = int(b) c = input("Enter number: ") c = int(c) print(str(a) + str(b) + str(c))
9be595b20160904451a410b08c227d5b5327086a
martinyordanov90/homework-hackBG
/8/swap.py
219
3.859375
4
def swap(index1,index2,numbers): temp = numbers[index2] numbers[index2] = numbers[index1] numbers[index1] = temp #return numbers my_list = [5,4,3,2,1] print(swap(0,4,my_list)) print(my_list)
90bd743f445ef9ab79c7b3e7160812e2fb3b778f
martinyordanov90/homework-hackBG
/1/5-Saturday-Tasks/reverse_int.py
185
4.09375
4
a = input("Enter number: ") a = int(a) reversed_number = 0 while a!= 0: digit = a % 10 reversed_number = reversed_number * 10 + digit a = a // 10 print(reversed_number)
f2349653399a4a90a26b191f6c79361a24a3faae
UW-ParksidePhysics/Fastenau-Andrew
/PYTHON_CHP3_1_[0,2].py
141
4.0625
4
### Program to convert Farenheit to Celcius ### def C(F): T = (9/5)*(F-32) return T print(C(32))
d43138c67e9fdc93fb744b413123f15a1a5f9db3
sakura1357/liaoxuefeng_python3_tutorial
/map_reduce_practise3.py
770
3.734375
4
from functools import reduce def str2float(s): # 字符转数字 def char2num(s): return {'0' : 0, '1' : 1, '2' : 2, '3' : 3, '4' : 4, '5' : 5, '6' : 6, '7' : 7, '8' : 8, '9' : 9, '.' : '.'}[s] # 整数部分 def fn(x, y): return x * 10 + y # 切割字符串并进行处理计算 [s1, s2] = s.split('.') # 整数部分正...
58ec2b55c7a6ffaeafa9fbcc36e034b9f1b77609
SaiKiranReddyPitta/test
/cspp1-practice/cspp1-assignments/m5/p3/p3/square_root_bisection.py
474
3.984375
4
''' Author: Sai Kiran Reddy Pitta Date: 3 Aug 2018 Encoding: UTF-8 ''' def main(): """ This function computes the square root of a given number""" number = input() epsilon = 0.01 low = 0 high = int(number) ans = (high + low) / 2.0 while abs(ans ** 2 - int(number)) >= epsilon: if ...
9056a38e97d10e93d4139a0318c718bb4d1a53dc
SaiKiranReddyPitta/test
/cspp1-practice/M3/hello_happy_world.py
69
3.78125
4
happy=int(input("Enter Number ")) if (happy>2): print("hello world")
e2b33b6dc4c3ea66d93ad67de1e51aee2d94bde1
SaiKiranReddyPitta/test
/cspp1-practice/M3/sum_1_end.py
71
3.609375
4
S=int(input("Enter Sum")) a=S while(a>0): a=a-1 S=S+a print(S)
f6600fb9407674f0cc49c83290a3e854686f4ec8
SaiKiranReddyPitta/test
/cspp1-practice/cspp1-assignments/m22/assignment1/assignment1/read_input.py
349
3.890625
4
''' Author: Sai Kiran Reddy Pitta Date: 25-08-2018 ''' def read_the_input(): ''' Sub string ''' given_string = "" number_1 = int(input()) for i in range(number_1): given_string += input() + '\n' print(given_string) def main(): ''' Main function ''' read_the_inp...
2b4de7c93be629642c7f2b6b4f0f87765bfd1d34
SaiKiranReddyPitta/test
/cspp1-practice/cspp1-assignments/m10/p1/assignment1.py
603
3.609375
4
''' ************************ Author: Sai Kiran Reddy Pitta Date: 9 August 2018 Encoding: utf - 8 ************************ ''' def get_available_letters(letters_guessed): ''' calling function ''' output = list('abcdefghijklmnopqrstuvwxyz') for i in letters_guessed: output.remove(i) return...
ad810639d9f0b8b4545b3641e6bd0c0cd976f916
aswathyp/TestPythonProject
/Sessions/2DArray.py
910
4.25
4
# Two-Dimensional List a = [[1,2], [3,4], [5,6]] # Via Indices for i in range(len(a)): for j in range(len(a[i])): print(a[i][j], end=' ') print('\n') # Via Elements for row in a: for element in row: print(element, end=' ') print('\n') # Generate 2D n = 3 m = 4 arr = [[0] * m] * n #doe...
1aa76c29644208c7094733bfbb3a876c1ffb9b83
aswathyp/TestPythonProject
/Assignments/Loops/2_EvenElementsEndingWith0.py
362
4.1875
4
# Even elements in the sequence numbers = [12, 3, 20, 50, 8, 40, 27, 0] evenElementCount = 0 print('\nCurrent List:', numbers, sep=' ') print('\nEven elements in the sequence: ') for num in numbers: if num % 2 == 0: print(num, end=' ') evenElementCount = evenElementCount + 1 print('\n\nTotal Co...
a8223414af17196ca240a7acf94aaf4141f30bee
aswathyp/TestPythonProject
/Assignments/List/5_EqualPairs.py
340
3.71875
4
# 5. Pairs are equal, count them as one numList = [int(i) for i in input('Enter Num List: ').split()] print('Current List: ', numList) uniquePairCount = 0 for i in range(0, len(numList)): if numList.count(numList[i]) % 2 == 0: uniquePairCount = numList.count(numList[i]) / 2 if print('Unique Pair Count:...
e0fe9a4a068ebbdd0956bbfc525f83551b75b2b0
gowtham9394/Python-Projects
/Working with Strings.py
788
4.40625
4
# using the addition operator without variables [String Concatenation] name = "Gowtham" + " " + "Kumar" print(name) # using the addition operator with variables first_name = "Gowtham" last_name = "Kumar" full_name = first_name + " " + last_name print(full_name) # using the new f strings [after python 3.6] print( f"...
19479b209a9bd7153e4db14e35c1ffe523c559c9
DEBANJANAB/Leetcode-August-Challenge
/Max_Depth.py
532
3.640625
4
class Solution: def dfs(self, node, max_depth=0, current_depth=0): if not node: #if previous node was a leaf return max(current_depth, max_depth) max_depth=self.dfs(node.left, max_depth, current_depth+1) #dfs in left branch max_depth=self.dfs(node.right, max_depth, c...
fefdc32978077af3b7a1b59e4bfdc40170b91ae9
Mamun-Developer/User-Info-Storage-Project
/user.py
2,903
3.78125
4
class User: def __init__(self, phone, name, age, gender): self._phone = phone self._name = name self._age = age self._gender = gender def get_phone(self): return self._phone def get_name(self): return self._name def get_age(self): return sel...
f9bfecf22f03336080907a61c1f21adc95668396
pinnockf/project-euler
/project_euler_problem_1.py
490
4.3125
4
''' Multiples of 3 and 5 Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ''' def main(threshold): multiples = [] for number in range(threshold): if number...
4d014439b8d7cf4d3fa64ce962cc02c5eeb12484
nikotlichnik/python_labs
/lab1/lab1.py
2,373
3.671875
4
# Программа преобразования CSV файла списка группы # ИТМО в XML файл с разделением студентов по полу # # Автор - Штрейс Никита, гр.P3320 import csv from lxml import etree # Функция разбивки имени на составляющие части def get_name(fullname): name_parts = fullname.split() surname = name_parts[0] name = n...
70b822a120f8c0e25e87856305c3b8a5463cfa2a
DanielRojas2002/Creador-y-manejador-de-una-db
/Codigo.py
7,770
3.6875
4
import sys import sqlite3 from sqlite3 import Error from plyer import notification from funciones import tipos from funciones import insertar from funciones import crear from funciones import agregar contador2=1 contador3=1 separador=("*"*40) opcion=1 listaatributos=[] listabase=[] contador=0 #Menu principal while o...
39174efc1179e43c9e2f18e3a63e664b3e53b38c
gdario/Notes
/tensorflow_notes/src/mnist_conv_with_l2_regularization.py
1,424
3.59375
4
from keras.datasets import mnist def process_dataset(x, y): """ Transform the keras version of mnist into numpy arrays suitable for TF. :param x: the numpy array with the pixel intensities. :param y: the numpy array with the class labels. :return: a tuple with x, y converted and reshaped. """ ...
4b4dfe81a413b4ebe8922c3c76150675c377301e
nelsontodd/Python-projects
/ExpressionTree.py
5,904
3.71875
4
# File: ExpressionTree.py # Description: Takes equations and makes them into expression trees # Student Name: Nelson Morrow # Student UT EID: ntm432 # Course Name: CS 313E # Unique Number: # Date Created: 04/22 # Date Last Modified: class Stack (object): def __init__ (self): self.stack = [] def _...
cb03fb3db0fc9b3672d37e93b90b8ae7b4300fee
nelsontodd/Python-projects
/TestLinkedList.py
11,436
3.921875
4
# File: TestLinkedList.py # Description: Linked list class # Student Name: Nelson Morrow # Student UT EID: ntm432 # Partner Name: - # Partner UT EID: - # Course Name: CS 313E # Unique Number: # Date Created: 03/30 # Date Last Modified: class Link (object): def __init__ (self, data, next = None): ...
b44d69f7649409185a36554b917d14d5e9f57157
nelsontodd/Python-projects
/Triangle.py
4,043
3.734375
4
# File: Triangle.py # Description: Finds the greatest path sum through three different methods # Student Name: Nelson Morrow # Student UT EID: ntm432 # Course Name: CS 313E # Unique Number: # Date Created: 04/16 # Date Last Modified: import itertools import math from itertools import * #def permutation...
b56e0272c2632b3b85657535568dc242c7504b62
shefali-pai/comp110-21f-workspace
/exercises/ex05/utils.py
1,572
4.28125
4
"""List utility functions part 2.""" __author__ = "730466264" # Define your functions below from typing import List def main() -> None: """Entry of function.""" list_1: List[int] = [1, 3, 5] list_2: List[int] = [1] a_list: List[int] = [1, 2, 3, 4, 5] number_1: int = 1 number_2: int = 4 ...
7e23e4a71a4ced9fe2a06c2208e4d8e06cabfdae
shefali-pai/comp110-21f-workspace
/exercises/ex03/tar_heels.py
456
3.734375
4
"""An exercise in remainders and boolean logic.""" __author__ = "730466264" # Begin your solution here... integer: int = int(input("Enter an int: ")) statement_1 = integer % 2 == 0 statement_2 = integer % 7 == 0 statement_3 = integer % 14 == 0 if statement_3: print(str("TAR HEELS")) else: if statement_1: ...
3654c2a1ca8756660b6da99b2d571c6a508a9568
shefali-pai/comp110-21f-workspace
/exercises/ex07/data_utils.py
2,561
4.15625
4
"""Utility functions.""" __author__ = "730466264" from csv import DictReader def read_csv_rows(filename: str) -> list[dict[str, str]]: """Read the rows of a csv into a 'table'.""" result: list[dict[str, str]] = [] file_handle = open(filename, "r", encoding="utf8") csv_reader = DictReader(file_handle...
57c9be6b9a7b2d5d4873d1f4fcc9bb0b19266ced
s18838/MIW
/temp/plot.py
267
3.71875
4
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import pandas as pd x = list(range(0,10)) y = list(range(0,10)) plt.figure(figsize=(7,5)) plt.plot(x, y, '--or') plt.title("Simple example") plt.xlabel("Element index") plt.ylabel("Element value") plt.show()