blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a3b4387c1574d6d8c7c0a4acb4b6fb4bb60479a8
gonzalob24/Learning_Central
/Python_Programming/Queues/Deque.py
1,423
4.3125
4
# Creating a class to create deques # Deque demonstrates behavior of Queues and Stacks # Its a double ended Queue class EmptyQueueError(Exception): pass class Deque: def __init__(self): self.items = [] def is_empty(self): return self.items == [] def add_front(self, item): # This ...
c1733d7d7ee1434d36b4e771a58fa22951b76d4c
kiranmai524/python_tutorial
/euler10.py
377
4.25
4
def is_prime(digit): now=3 while (now*now)<=digit: if digit%now==0: return False else: now+=2 return True numprime=1 #considering 2 as only even prime we only check the odd numbers num=1;sum=2 while num<2000000: num+=2 if is_prime(num): sum+=num numprime+=1 print "the sum of prime numbers belo...
8ee6cfcff8eb512516a7143844473228ad6d03b2
schw240/Preparing-coding-test
/백준/10단계/별찍기10.py
1,370
3.578125
4
n = int(input()) # 출력할 배열 초기화 모두 *로 채워주고 빈칸이 들어갈부분은 밑에서바꿔준다. list = [['*'] * n for i in range(n)] def starprint(n, list): # if n < 3: # 1일때는 바로 내보내어 *이 출력하게만든다. return if n == 3: # 3일때 빈칸은 직접 채워준다. list[1][1] = " " else: starprint(n//3, list) # 재귀를 통해 이전리스트를 완성시키고 넘겨준다. ...
9417be6383f8b5382428b4ba1dcacb4a7b1e66db
E477n/WeWear
/Match/color_match.py
10,152
3.546875
4
def color_match(a, b): scheme = list() main0 = list() # 黑白两色 main1 = list() # 高饱和度配色 main2 = list() # 高饱和度撞色 main3 = list() # 非高饱和度配色 hmin = a[0] - 20 hmax = a[0] + 20 # 0主题色 黑白大类 if a[2]>=0 and a[2]<=0.1: #外套 coat = list() for each in b[0]: ...
c0f93681a3a1222bca364f1f62c8fbabdda04057
nyu-ml-final-project/NyuPoly-CS6923-Fall16
/Lesson 10 - Clustering/kmeans_exercise.py
2,444
4.28125
4
""" Simple implementation of K-Means clustering You'll need to complete three methods 1. fit() 2. _compute_centroids() 3. _compute_labels_and_score() @modified by Gustavo Sandoval = Nov 2016 @author Ruben Naeff - August 2015 """ import numpy as np class KMeans(): """Find k clusters in the given da...
5a22e2d72170b8241ac4b57c85f6c016033ae028
haw230/bubble-sort
/bubble_sort/main.py
274
3.671875
4
def bubble_sort(ls): ''' Write bubble sort! ''' pass def swap(ls, i): ''' Write the code to swap two items in ls. Remember that ls will store a reference so editing it inside of swap() will change it for bubble_sort() as well. ''' pass
a0969dfc22ed4afc68666f814da64d5439fdcdc7
pi408637535/Algorithm
/com/study/algorithm/offer/剑指 Offer 68 - II. 二叉树的最近公共祖先.py
2,173
3.8125
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def lowestCommonAncestor(self, root, p, q): """ :type root: TreeNode :type p: TreeNode :type q: TreeNode :rtype: TreeNode ...
1ef3d0932648045ebf1e1eaae3876a8bf18c4858
mublan11/Calculadora-Testing
/calculadora.py
1,766
3.875
4
import math """ Autor: Diego Misael Blanco Murillo. Fecha: 06/SEP/17 """ class Calculadora(): def __init__(self): self.resultado = 0 def obtener_resultado(self): return self.resultado def suma(self, num1, num2): try: self.resultado = num1 + num2 exc...
30505d4e6aa3aba6ec5353649cfe6d3334e4f370
shaggyday/codes-from-school
/Tic Tac Toe.py
12,845
3.9375
4
# Harry Tian & Star Song: a Tic Tac Toe game using Zelle graphics from graphics import * import time import random class TicTacToe: """Class to represent tic tac toe playable game with simple graphics """ def __init__(self): """ No arguments, 2 instance variables are created here - 1. th...
5b9618686446980d6c9a9c1820cfd9c13f154970
AsemDevs/ItemCatalog
/somecities.py
2,442
3.546875
4
from database_setup import User, Base, Place, City from sqlalchemy.orm import sessionmaker from sqlalchemy import create_engine # engine = create_engine('sqlite:///citiescatalog.db') engine = create_engine('postgresql://catalog:password@localhost/catalog') # Bind the engine to the metadata of the Base class so that th...
a20a7e7b8961acf833708d5dc880b933f44f30d5
doctorlove/turtles
/pso.py
2,348
3.65625
4
#See https://visualstudiomagazine.com/Articles/2013/11/01/Particle-Swarm-Optimization.aspx?Page=2 import math import random class Particle: def __init__(self, x, name): self.x = x self.best = x self.velocity = random.random() #TODO try 0 instead self.name = name self.history = [] def __str__(...
268d4610f507daef5fe4626eebc7fb6041825dfc
emir-naiz/first_git_lesson
/Courses/1 month/3 week/day 2/Задача №4 add,remove,pop.py
493
3.9375
4
list1 = [1,2,3,4,5,6] # список def change_list(mode,number): # функция if mode == 'add': list1.append(number) elif mode == 'remove' and number in list1: list1.remove(number) elif mode == 'pop': if number > len(list1): print('Вы ввели слишком большое число') else: ...
9dda3a87af440015f9a86d401746093f5d31f2a0
tbindi/Artificial-Intelligence-a4
/Part1/binaryDT.py
18,554
3.5
4
#Disclaimer:- #I wrote this code for an assignment in another course - Applied Machine Learning. I have just reused it here by making necessary changes. #All of this code is written by me only. I am just citing myself if that's a thing. :D # Author: Mohit Galvankar # Builds decision tree and classifies input data...
6ff840f43f65f3e2180722f306a1991599463e88
NDCHRIS2003/python_programs
/MINOR PROJECT/comp_int_with_validation.py
1,207
4.34375
4
# Date January 2020 # A simple program to calculate the Area of a Triangle # Author = Ndubuisi Okpala import time # This will give the user the directive on how to use this program print("This program is used to calcualte compound interest") print("You will be asked to provide some parameters to be able to calcualte...
b6c68fef11797a7e91d5abcaa13fd2c91d6496fc
Divij-berry14/Python-with-Data-Structures
/Run Length Encoding.py
218
3.703125
4
def RunLength(s): d = {} output = "" for i in s: d[i] = d.get(i, 0) + 1 for key, value in d.items(): output = output + key +str(value) return output s = input() print(RunLength(s))
d9c3eeaa7fe05426381328c31219b7b495cbdd00
enlambdment/my_pcc
/ch_8/cars.py
414
3.890625
4
def make_car(manufacturer, model_name, **car_specs): """Build a dictionary containing everything we know about a car model.""" profile = {} profile['manufacturer'] = manufacturer profile['model_name'] = model_name for key, value in car_specs.items(): profile[key] = value return profile my_car = make_car('hon...
6341c2f69eb47a65d21b63a486075640965a6517
Reizerk-amd/Projects-of-school
/Datos.py
236
3.890625
4
#input es para guardar datos input("") #variable con input y mensaje de salida dato=input("Digite un número") #números dato = int(dato) dato + 5 print(dato) #float dato = float(input("Digite un dato ")) print(dato+5)
114c1dc40ff9ca1fe3cb9fefda2957c0d0557a3e
amat17mir/algorithms-and-theorems
/primenumberprinter.py
257
3.515625
4
n = 35 def solution(n): prime_nums = [] for num in range(n): if num > 1 for i in range(2, num) if (num % i) == 0 break else: prime_nums.append(num) return prime_nums solution(n)
8d8fee549b3b0ec66ff10edccdcd524b5342b914
HariniAS/SDET_Python
/act1.py
193
3.90625
4
name = input ("Enter your name") age = int(input("enter your age")) year = str ((2020-age) + 100) print ("you will be 100 years old in" + year) print ("you will be 100 years old in" , year)
4d69e4a54ebd2949d161ae414c91cbd8c283b306
surojitfromindia/PythonAlgos
/SortAlogoExc.py
555
4
4
def InsertSort(A): # first get a key for i in range(1, len(A)): # get first key key = A[i] # get the prior element to compare j = i - 1 # start the loop while A[j] > key and j >= 0 : # swap/ shift 1 room right A[j + 1] = A[j] #...
c46853b16222932c441c304c7f2ca5b29cb82118
potatoHVAC/leetcode_challenges
/algorithm/207.1_course_schedule.py
3,372
3.953125
4
# Course Schedule # https://leetcode.com/problems/course-schedule/ # Completed 4/26/19 ''' Approach 1. Create a doubly linked graph. 2. Remove leaf nodes from tree and delete their references in parent nodes. 3. Repeat 2 until tree is empty or no more leaves exist. 4. Return True if tree is empty. ''' class Node: ...
d5db3791621295e8392ae21f0e047bf60645a9d6
anasmansouri/S5_PFA_ABS
/friction_coefficient_plot.py
661
3.546875
4
import math import matplotlib.pyplot as plt A = [0.9, 0.7, 0.3, 0.1] B = [1.07, 1.07, 1.07, 1.07] C = [0.2773, 0.5, 0.1773, 0.38] D = [0.0026, 0.003, 0.006, 0.007] slip_x = [i for i in range(0, 100)] labels = ["dry concrete", "wet concrete", "snow", "ice"] friction = list() for i in range(0, len(A)): friction.app...
06652da7d08f8b4a8db505e5e3f2a1e45c9fa6b9
kaoutarS/Easy-Graph
/easygraph/classes/directed_graph.py
23,387
3.8125
4
from copy import deepcopy class DiGraph(object): """ Base class for directed graphs. Nodes are allowed for any hashable Python objects, including int, string, dict, etc. Edges are stored as Python dict type, with optional key/value attributes. Parameters ---------- graph_attr : ...
f506c682d4480074859dff93c41dcc0800db7cee
Sun-Zhen/leetcode
/0801-0850/0819-MostCommonWord/MostCommonWord.py
1,106
3.859375
4
# -*- coding:utf-8 -*- """ @author: Alden @email: sunzhenhy@gmail.com @date: 2018/4/16 @version: 1.0.0.0 """ class Solution(object): def mostCommonWord(self, paragraph, banned): """ :type paragraph: str :type banned: List[str] :rtype: str """ word_dict = dict() ...
96753e879f1a94f6b1fefd2d0664da87ef294488
kostas-simi/first_python
/register and login_1.py
2,948
3.703125
4
import sqlite3 from datetime import datetime,date conn = sqlite3.connect('data/Containers.db') c = conn.cursor() def countContainers(x,y): z = x - y if z>=0 and z<=170: return True return False boxesOut = 0 dataIn = list() dataOut = list() while True: choice = in...
2bf344be10a708546dbf10334b5b7b7ed97cfed0
Bukacha88/softuni_python_advanced
/tuples_and_sets/04_count_symbols.py
221
3.71875
4
text = tuple(map(str, input())) occur = {} for char in text: if char not in occur: occur[char] = 0 occur[char] += 1 for key, values in sorted(occur.items()): print(f"{key}: {values} time/s")
2618281e85e663127c457e2aead0c0189119c570
MihailFrolov/Programlama_I
/13 Mart 2018/Ödev3.py
1,874
3.59375
4
#ilk6= İlk 6 ay dönemi #yg= Yazılım gelirleri #fg= Finansman gelirleri #usg= Ürün satış gelirleri #cm= Çalışan masrafları #kg= Kira giderleri #dm= Donanım maliyeti #son6= Son 6 ay dönemi #yillikkar= Yıllık kar #kar_ilk6= İlk 6 ayın karlılığı #kar_son6= Son 6 ayın karlılığı def ilk6(yg,fg,usg,cm,kg,dm): ...
8c4ca0eeb70386827165b124405a1bf4299951fd
dipika-d/Pythonic
/Data-Structures/sorting_with_heapq.py
833
4.125
4
import heapq nums = [-1,2,-3,4,-5,6,-7,8,-9,10] # convert the list into heap heap = list(nums) heapq.heapify(heap) # heap[0] will always be the smallest number in a heap # heap[-1] therefore will be the largest number print(heap) print('*'*20) print("Smallest in heap = ",heap[0]) print('*'*20) print("Largest in he...
a1a980869143f0fc8eccd7a65ab68444974cba2d
claudiodornelles/CursoEmVideo-Python
/Exercicios/ex089 - Boletim com listas compostas.py
1,517
3.6875
4
""" Crie um programa que leia nome e duas notas de vários alunos e guarde tudo em uma lista composta. No final, mostre um boletim contendo a média de cada aluno e permita que o usuário possa mostrar as notas de cada aluno individualmente. """ notas = [] aluno = [] alunos = [] soma = n_notas = 0 while True: nome = ...
bd54e1d915c6072465e615aa6e8df7d03819e423
Pranav016/DS-Algo-in-Python
/Stack/BalancedParanthesis.py
608
3.921875
4
def balanced(s): stack=[] for char in s: if char in '{([': stack.append(char) elif char==')': if not stack or stack[-1]!='(': return False stack.pop() elif char==']': if not stack or stack[-1]!='[': return F...
9761d3da5f4327961448c912e3d37fae3d7aace7
usufruct/knight-rider
/tests/unittests/chess/board_test.py
4,074
3.8125
4
import unittest import math from chess import Board class TestBoard(unittest.TestCase): def test_example(self): self.assertTrue(True) def test_init(self): board = Board() actual = [x.distance for x in board.squares] expected = [math.inf for x in range(64)] expected[0] ...
8bfdbde94ed88f87b3abf8b59f8b2a0d9f280756
v-shchenyatskiy/GB_Python
/1. Lesson_1/les01_2.py
1,084
4.0625
4
# Пользователь вводит время в секундах. # Переведите время в часы, минуты и секунды # Выведите в формате чч:мм:сс. Используйте форматирование строк. # 1 s * 60 = 1 m * 60 = 1h = 3600 s # 1h * 24 = 1d = 86400 s user_sec = int(input('Введите время в секундах: ')) # 1 - считаем часы days = 0 hours = user_sec...
fa93578fa64ad4b0151443ef9dbe7b417e1a33e0
JBustos22/Physics-and-Mathematical-Programs
/differential equations/Lorenz.py
1,496
4.25
4
#! /usr/bin/env python """ This program uses the Runge-Kutta method to solve the Lorenz equations. The Lorenz equations model seemingly chaotic weather phenomena. Using the 4th order Runge-Kutta method, the three equations are solved and a plot of y vs t and x vs z is created. The first plot shows the chaotic nature...
354d9f616446ceaf37dc39f45606d57417081bbf
Ambotega/CPT-Questions
/guess_the_number.py
533
4.15625
4
#!usr/bin/python ''' A very simple guess the number program ''' from random import randint random_number = randint(1,10) print("I have a number, its between 1 and 10, Can you guess the number?") while True: your_guess = input("Enter Guess: ") try: your_guess = int(your_guess) ...
ce5457678e0742d76a9e7935a257cd1af6e05617
RobertElias/PythonProjects
/GroceryList/main.py
1,980
4.375
4
#Grocery List App import datetime #create date time object and store current date/time time = datetime.datetime.now() month = str(time.month) day = str(time.day) hour = str(time.hour) minute = str(time.minute) foods = ["Meat", "Cheese"] print("Welcome to the Grocery List App.") print("Current Date and Time: " + month ...
dcf0cfac745c49c289caab2daf993f63d297b42f
ayushchopra96/hangman
/hangman_soln.py
2,329
4.25
4
from string import * from hangman_lib import * ## Constants MAX_MISTAKES = 6 #state variables secret_word = get_random_word() letters_guessed = [] mistakes_made = 0 ##helper function... def word_guessed(): '''Returns True iff player has successfully guessed the word''' for letter in secret_word: if letter not ...
094d004d2c60cb5452cab57911a7d88fe4037513
InVinCiblezz/algorithm-in-python3
/divide_conquer/merge_sort.py
506
4.03125
4
#!/usr/bin/env python3 data = [2, 5, 8, 1, 23, 21, 14, 22, 9, 7] def merge(lo, hi): res = [] while lo and hi: if lo[0] < hi[0]: res.append(lo.pop(0)) else: res.append(hi.pop(0)) res = res + lo + hi return res def mergeSort(data): length = len(data) if ...
1ed70a531b478790b747bb2d3eb271013becddec
edwardmasih/Python-School-Level
/Class 12/12th - Project/Programs/18 largest no in matrix.py
733
4.0625
4
def locatelargest(a): l=[] for i in range(n): for j in range (x): l.append(a[i][j]) m=max(l) print "Largest No. :- ",m for i in range (n): for j in range (x): if a[i][j]==m: print "Largest Number Found! " print "at ro...
d07176ef66b7c3d4bcd13ee3be09742fbde29d20
mredig/Algorithms
/stock_prices/stock_prices.py
1,201
4.15625
4
#!/usr/bin/python import argparse def find_max_profit(prices): if len(prices) < 2: return 0 # set initial lowest and maxProfit values from actual array values lowest = prices[0] maxProfit = prices[1] - prices[0] # for each item in prices for index in range(1, len(prices)): pri...
86ae6950b1af23548c5c205f44a235357faf3361
HanchengZhao/Leetcode-exercise
/819. Most Common Word/mostCommonWord.py
689
3.578125
4
class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: paragraph = paragraph.lower() dic = {} word = "" most, freq = "", 0 for i in paragraph: if i.isalpha(): word += i else: if word and word...
9dceafbc77f1afac20a362947143528b2f711cf7
mrpandrr/My_scripts
/untitled folder/a116_buggy_image_step_31_AH.py
1,266
3.640625
4
# a116_buggy_image.py import turtle as trtl #Create a spider body spider = trtl.Turtle() #Create turtle object spider.pensize(40) # pen size 40 spider.circle(20) # pen circle #Create a spider head spider.goto(-30,9) spider.circle(2.5) spider.goto(0,0) #Configure spider legs legs = 8 length = 34 angle = 1...
3c83dee3aaf6eb7cffc040e715ae042a2cfa633e
ccirelli2/asyncio
/asyncio_/asyncio_notes.py
1,613
4.21875
4
# LEARN ASYNCIO ''' Coroutines: Coroutines look like a normal function, but in their behaviour they are stateful objects with resume() and pause() —  like methods. Pause: The way a coroutine pauses itself is by using the 'await' keyword. When you 'await' another coroutine, you 'step off' the event loop an...
357d432d04462c6c01fcd6d6e6199cf019300245
sabariks/pythonpgm
/stringsubstring.py
170
3.875
4
a=input() b=input() if a not in b: print(-1) else: print(1) # a,b=map(str,input().split()) # if a in b: # print('No') # else: # print('Yes')
c7bdc7fedaa1abd510616e50a8d9a417fb3acbdf
Pinacolada64/TADA
/server/convert_food_data.py
5,394
3.515625
4
#!/bin/env python3 import json from dataclasses import dataclass import logging @dataclass class Rations(object): number: int name: str kind: str # magical, standard, cursed price: int flags: list def __str__(self): return f'#{self.number} {self.name}' def read_stanza(filename): ...
757c592d9cb0b99d7229449374ebae18ffbb3e99
subenakhatun/python-task-03
/problem-09.py
238
4.0625
4
''' Write a function that computes the running total of a list. ''' number = int(input('Enter a running number range: ')) def sum(number): sum = 0 for i in number: sum = sum + i print(sum) sum(range(number))
e3cba78810f2d8d65f6e1c9c8233c103d16ac974
DmitryPukhov/pyquiz
/test/leetcode/test_DiameterOfBinaryTree.py
1,144
3.59375
4
from unittest import TestCase from pyquiz.common.TreeNode import TreeNode from pyquiz.leetcode.DiameterOfBinaryTree import DiameterOfBinaryTree class TestDiameterOfBinaryTree(TestCase): def test_diameter_of_binary_tree_12345(self): #[4,-7,-3,null,null,-9,-3,9,-7,-4,null,6,null,-6,-6,null,null,0,6,5,null,...
834f037ef439654ad22363559557fb118a6ff721
parkermac/ptools
/pm_dev/sphere_light.py
2,010
3.578125
4
# -*- coding: utf-8 -*- """ Plotting a 3D sphere with lighting """ import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def get_xyz_mesh(lon, lat, r): # makes a Cartesian mesh on a sphere # lon, lat are numpy vectors # r is a scalar (the radius) x = r * np.outer(...
18425edf1ac86961ed892c1c54a9ca91d21daa18
hyt0617/leetcode
/30-39/lc_39.py
709
3.515625
4
# !/usr/bin/env python # -*-coding: utf-8 -*- def combinationSum(candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ def dfs(nums, target, index, path, results): if target < 0: return if target == 0: results...
785c16b219d06e5969c26ab00420c9c14c04bff8
durhambn/CSCI_220_Computer_Programming
/Lab 6.py
2,557
4.09375
4
# Lab6.py # Name 1:Evan Tanner # Name 2:Brandi Durham def nameReverse(): """ Read a name in first-last order and display it in last-comma-first order. """ name = input("What is your name? ") name = name.split() firstName = name[0] lastName = name[1] print("The name reversed ...
07c12c44ccd68c92235164240f238f680357f76e
bluwhale97/fc-css
/Linked_List/Double_Linked_List.py
3,374
3.765625
4
class Node: def __init__(self): self.__prev = None self.__next = None self.__data = None @property def prev(self): return self.__prev @prev.setter def prev(self,prev): self.__prev = prev @property def next(self): return self.__next ...
00d068677543215104b1af3276d5c2e7fdff3153
rjzupkoii/SmallProjects
/google/foobar01.py
2,305
4.25
4
#!/usr/bin/python # Module level global to track the primes primes = set([2, 3]) # Given a value between 0 and 10 000, return the next five digits from a concatendated list of primes. def solution(i): # First we need to get the relevent prime numbers, even though the list is concatendated we really # don't c...
14c3e30d3a3c5b12e00c13de15fcf2b09742dbe2
AlexiaAM/Python-Bootcamp
/Problems/foreach.py
124
3.953125
4
#asi se hace un foreach animales = ["perro","gato","caballo","elefante","raton","raton"] for x in animales: print(x)
cc7806cc0ecb6ba83ac908890e384e828a2c3e21
JaminB/SmartTorrent-API
/smarttorrent/search/content/converters.py
553
4
4
#!/usr/bin/python class date: def __init__(self, dateString): self.dateString = dateString self.months = {'Jan' : '01', 'Feb' : '02', 'Mar' : '03', 'Apr' : '04', 'May' : '05', 'Jun' : '06', 'Jul': '07', 'Aug' : '08', 'Sep' : '09', 'Oct' : '10', 'Nov' : '11', 'Dec' : '12'} def convert(self): dateArray = self....
65f7df4eb97fec9e7f246597501df6c0af1b0b34
luisprooc/uno_game
/special_cards.py
2,625
3.59375
4
from random import randint class WildCards(): def __init__(self): self.color = "Black" self.list = [] def generate(self): for a in range(0,8): if a < 4: self.list.append(["+ 4",self.color]) else: self.list.append(["Choose color",s...
cffb7474a3976cdf8454412176edfebe1e6af984
arunabenji29/Sorting
/src/searching/searching.py
1,942
4.125
4
# STRETCH: implement Linear Search def linear_search(arr, target): # TO-DO: add missing code for i in range(0,len(arr)): if(arr[i] == target): return i return -1 # not found array = [5,3,1,4] target = 1 print(linear_search(array,target)) # STRETCH: write an iterative implementation of Bi...
3a135c0f3da0c2cdbf08bbdae952b944529c2acd
noelis/oo-melons
/melons.py
1,833
3.890625
4
from random import randint """This file should have our order classes in it.""" class AbstractMelonOrder(object): """Covers all orders, domestic and international""" def __init__(self, species, qty, country_code=None, order_type=None, tax=None): self.species = species self.qty = qty ...
d09eb4a32372910ad67c7bec72982e1d83086df7
jhgrove/P2_SP20
/Labs/CTA Ridership/cta_rider_lab.py
1,812
4.03125
4
""" CTA Ridership (25pts) Get the csv from the following data set. https://data.cityofchicago.org/api/views/w8km-9pzd/rows.csv?accessType=DOWNLOAD This shows CTA ridership by year going back to the 80s It has been updated with 2018 data, but not yet with 2019 unfortunately 1 Make a line plot of rail usage for the l...
9aaa144bdd903da852c47492b1500de505b68354
hguochen/algorithms
/python/linked_list_addition.py
1,662
4.28125
4
################################## ### Title: Linked List addition ## ### Author: GuoChen Hou ######## ################################## # Two numbers represented by a linked list, where each node contains # a single digit. # The digits are stored in reverse order, such that the 1/s digit is at the # head of the li...
7e8f216a4dc35ed46040924e7440c003a882fbec
wangs0622/learning_Algorithm
/sort/PQ.py
1,821
3.75
4
# _*_ encoding: utf-8 _*_ import queue from sort.maxPQ import printHeap minPQ = queue.PriorityQueue def heappush(heap, item): heap.append(item) _siftdown(heap, startpos = 0, pos = len(heap)-1) def heappop(heap): lastelt = heap.pop() if heap: returnitem = heap[0] heap[0] = lastel...
6a4e53ef5ebb687b7a776e5387a455ebc51e13c7
muhi28/Algorithms-And-Data-Structures-Python-
/sorting-algorithms/comparison-based-sorting/stooge_sort.py
1,149
4.09375
4
import random # initializes the list with random numbers def getData(n): data = [0] * n for i in range(n): data[i] = random.randint(1, 100) return data def stoogeSort(arr, i, j): # checks whether the value at the start is larger # then the value at the end if arr[j] < arr[i]: ...
db3e2242a2af0c1f6ac3975b8ae97c8d542a7834
laomu/py_1709
/python-base/days12_code/demo02_封装.py
2,596
4.5
4
# 定义一个类型——人的类型 class Person: def __init__(self, name, age): # 创建对象的时候,对属性进行赋值 self.name = name self.age = age self.money = 10000 # 创建了一个人的对象,姓名是tom,年龄是48 p = Person("tom", 48) # 生活中各种场景下,人的数据会发生变化,过了一年~年龄+1;派出所等级信息~登记姓名、年龄 # 程序代码中,可以通过不同的代码,操作对象的数据 p.name = "jerry"# 改名字 p.age = 18# 改年龄 print(p.name, p.age,...
de92dd278093341414d2e4ab4a01b38dd74ec76b
gwqw/LessonsSolution
/checkio/06_Ice_Base/06_IceBase_06_Colder-Warmer.py
4,070
3.546875
4
def calc_area(steps): minX = minY = 0 maxX = maxY = 9 for i in range(1,len(steps)): if steps[i][0] == 2 and steps[i][1] == 2: continue if steps[i][0] > steps[i-1][0]: if steps[i][2] == 1 and minX < steps[i][0]: minX = steps[i][0] elif steps...
46b5c84120b82269c6806ea24a35334818cbe2e5
rafaelperazzo/programacao-web
/moodledata/vpl_data/59/usersdata/260/48826/submittedfiles/testes.py
223
3.71875
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO #!/usr/bin/python b=0 a=float(input("digite a quntidade de discos)) for i in range(1,31,1): if b>a: maior=b else: maior=a b=a print(%d %.2f %(i,maior))
e7e888bdd77c218b707aa8a932ba3082b4c1e373
markloborec/Pythonigra
/src/app.py
1,017
3.71875
4
import random from src.domain import World class Console: def __init__(self,width,height): self.world = World(width,height,10) def draw(self): for y in range(self.world.height): for x in range(self.world.width): if self.world.hero.x == x and self.world.hero.y == y:...
aabbb492722ed999af85d7d2f9f312767a8eb3ec
kaci65/Nichola_Lacey_Python_By_Example_BOOK
/2D_Lists_and_Dictionaries/update_single_column.py
548
4.03125
4
#!/usr/bin/python3 """update a column by appending a new value using user input""" simple_array = [[2, 3, 1, 4], [5, 7, 6, 2], [8, 4, 9, 0]] row = int(input("Please enter a row number: ")) print(simple_array[row]) col = int(input("Please enter column number: ")) print(simple_array[row][col]) ques = input("Do you want...
0b0252409b69b3c61e51d2fec100389b2bf204d3
amuroni/DataScience
/Pandas_Data.py
921
3.671875
4
import pandas as pd import numpy as np # generating a random Series rng = np.random.RandomState(42) ser = pd.Series(rng.randint(0, 10, 4)) # generating a dataframe with 3 rows and four columns df = pd.DataFrame(rng.randint(0, 10, (3, 4)), columns=["A", "B", "c", "D"]) # applying a np ufunc will preserve the indices ...
122e34eea972814519fbc74a2b7d9196fa85caab
rameshkonatala/Programming
/Spoj/TRICOUNT.py
299
3.71875
4
def triangle(x): if x==1: return 1 elif x==2: return 5 elif x==3: return 13 else: if x%2==0: return 2+3*(int(triangle(x-1))-int(triangle(x-2))) else: return 3+3*(int(triangle(x-1))-int(triangle(x-2))) t=int(raw_input()) for j in range(t): a=int(raw_input()) print triangle(a)
d84fc96167144760391f4b8a20f05275bb502c77
mrdziuban/Projects
/my_solutions/Text/count_vowels.py
227
4.09375
4
def count_vowels(string): vowels = {'a': 0, 'e': 0, 'i': 0, 'o': 0, 'u': 0} for l in string: if l in vowels.keys(): vowels[l] += 1 return vowels string = input('Enter your string: ') print(count_vowels(string))
45830c0a489eee714eac5eaefd750d48db500490
CobyHong/CPE-101-Cal-Poly-2017
/Midterm Practice/Question 3/less5.py
190
3.59375
4
def less_than_5(list): list_str = [] for i in range(len(list)): if len(list[i]) < 5: list_str.append(list[i]) result = len(list_str) return result
1ad8ea93f2b3eb3f7e56bd6531be1b6c44b97456
xiholix/testSomething
/decorator/methodDecorator.py
1,658
4.15625
4
# --*--coding:utf8--*-- 'Method decorators allow overriding class properties by decorating,' 'without having to find the calling function.' import functools def wraper(arg1, arg2): def innerFunction(inputFunc): print(arg1) print(arg2) print("inner function") @functools.wraps(inpu...
b1ac7944d325630a2dcc0ca49cd7c42a40c10d05
hijinkim/BOJpractice
/1181.py
184
3.796875
4
n = int(input()) words = [] for i in range(n): words.append(input()) words = list(set(words)) words = sorted(words, key=lambda x: (len(x), x)) for word in words: print(word)
3c1278de7dec1598111586a469dfb81fdc08051f
MingduDing/My_codes
/05_single_cycle_link_list.py
3,423
3.890625
4
# -*- coding: utf-8 -*- class Node(object): """节点""" def __init__(self, elem): self.elem = elem self.next = None class SingleCycleLinkList(object): """单向循环链表""" def __init__(self, node=None): self.__head = node if node: node.next = node def is_empty(self): """链表是否为空""" return self.__head == Non...
75e90a9cd8983855132d06e9d4fbde27757295a5
terrameijar/realpy
/sql/update_delete.py
430
3.90625
4
import sqlite3 with sqlite3.connect("new2.db") as connection: cursor = connection.cursor() cursor.execute("UPDATE population SET population = 9000000 WHERE city = 'Chicago'") #delete data cursor.execute("DELETE FROM population WHERE city='Boston'") print "\nNEW DATA: \n" cursor.execute("SELE...
36d913ec6f630c9ec24c2f9d9af8ba958133afa0
skb30/UCSC-Python2
/homework3/solutions.py
4,666
4.46875
4
''' The standard form of a quadratic expression is ax^2 + bx + c where a, b and c are real numbers and a is not equal to zero. The degree of a quadratic expression is 2 and a, b and c are called the coefficients. For example, in the quadratic expression (3x^2 + 8x − 5), the coefficients are 3, 8 and -5 corresponding to...
fe23cffec8b5becb2edec5f817d049e11d466352
hguochen/code
/python/questions/google_autocomplete_feature.py
2,207
3.78125
4
""" Implement the google autocomplete feature Given a string which represents characters typed into a text box so far, Write as program to suggest words based on what i have typed so far Eg. input: cat output: [catnip, caterpillar, cats, catskills] """ class Node(object): def __init__(self): self.childre...
cf8646270d435ab39634cb27e35c019bc8919380
sj90hwang/ToBigs
/week5/Class/클래스과제_배포/main2.py
1,959
3.53125
4
############# # Apartment # ############# # 다른 파일에서 class import from Apartment import Apartment from Vile import Vile # 파일읽기 f = open("./Apartment.txt", 'r') N = int(f.readline()) # Apartment정보 객체로 만들어 입력받기 apartments = [] for i in range(N): row=f.readline().split(' ') a = Apartment(row[0], int(row[1])...
89fc0954f4c63d31bdcfd4921a67a47c44d2a92f
wypstudy/LeetCode-Python
/Algorithms/13.py
1,004
3.515625
4
# coding=utf-8 class Solution(object): def romanToInt(self, s): """ :type s: str :rtype: int """ # 打表 roman_map = {'': 0, 'M': 1000, 'MM': 2000, 'MMM': 3000, 'C': 100, 'CC': 200, 'CCC': 300, 'CD': 400, 'D': 500, 'DC': 600, 'DCC': 700, 'DCCC': 800,...
84519b04581400437f6e7c6d0dd102f1ed482b1a
martinleeq/python-100
/day-09/question-072.py
289
3.9375
4
""" 问题72 生成一个包含5个元素的列表,每个元素是100~200之间的随机数 """ import random a_list = [] for i in range(5): a_list.append(random.choice(range(100,201))) print(a_list) print('==================') a_list.clear() print(random.sample(range(100,201), 5))
bc92a194dc9330e18ecf42c2db2d183a34d89cf9
git874997967/LeetCode_Python
/easy/leetCode543.py
921
3.90625
4
# 543. Diameter of Binary Tree # why we need the global ans which is diff as other recurision? # because the diameter may or may not pass the root def diameterOfBinaryTree(self, root): self.ans = 1 if not root: return 0 def height(root): if not root: return 0 L = height(r...
d3f1b3d7a9221a8dcbb6a9585082ac346cd213b2
Yang-Ding/leetcode_Python
/70_Climbing_Stairs.py
335
3.6875
4
class Solution: # @param {integer} n # @return {integer} def climbStairs(self, n): if n==1: return 1 number_ways=[0]*(n+1) number_ways[1]=1 number_ways[2]=2 for i in range(3,n+1): number_ways[i]=number_ways[i-1]+number_ways[i-2] return ...
f08a8709cdf5455b9383b11f6da25c559607220f
uzzal408/learning_python
/basic/string.py
1,080
3.75
4
#asign multiline string a = """ Hello, I am Ismail Hossen Working In Aamra Infotainment Ltd I have 3 years experience in PHP Laravel Now Trying to working on python""" print(a) #Loop on string for ba in "banana": print (ba) #String Lenngth b = "Hello world" print(len(b)) # check phrase, word or character exist ...
9bab159da348bff509c98a232f11a62588072c69
Matozinho/CNC
/Trabalho3/codes/questao1.py
317
3.515625
4
import numpy as np from sympy import * def metEuler(function, h, x0, y0, endX): exp = lambdify(symbols('y'), (Symbol('y') + h * function)) yn = y0 xn = x0 while xn < endX: yn = exp(yn) xn += h return yn function = 0.8 * Symbol('y') print("Método de Euler: ", metEuler(function, 0.2, 0, 20, 4))
04303c2bc6179a4ebe1d6f7c35620a5186f1bd53
mated-pl/udemy_python1
/Part 3 rozbudowa kodu.py
5,146
3.53125
4
# 3.30 nested loop # listA = list(range(4)) # listB = list(range(4)) # product =[] # for a in listA: # klasyczna petla # for b in listB: # product.append((a,b)) # print(product) # # product = [(a,b) for a in listA for b in listB] # print(product) # # product = [(a,b) for a in listA for b in listB i...
cbb7c5528897836a536ed94c851de0b186460bb5
pauloalwis/python3
/leia.largura.altura.de.uma.parede.py
537
4
4
# Leia a largura e a altura de uma parede em metros, calcule a sua área e a quantidade # de tinta necessária para pintá-la, sabendo que cada litro de tinta, pinta uma área de 2m² largura = float(input('Digite a largura de uma parede em metros! ')) altura = float(input('Digite a altura de uma parede em metros! ')) are...
098459b4e0cbf7f0b106d153cf04bd8107e39920
Aasthaengg/IBMdataset
/Python_codes/p03136/s742640874.py
170
3.53125
4
n = int(input()) list01 = input().split() list02 = sorted([int(s) for s in list01]) a = sum(list02) - list02[-1] if list02[-1] < a: print('Yes') else: print('No')
502c7caf3223ce5dce9d9547c5ce0a8556a78deb
msk20msk20/Python
/20190918_24.py
190
3.671875
4
print ("Hello PYTHON") a = 100 b = 200 print (a + b) c = input() print (c) n = 10 m = 100 if (n%2 == 0): print ("me") if (m%2 == 0): print ("me, my friend")
19c29551480f5b953b73c61f53d720041bc3df85
Rushi21-kesh/30DayOfPython
/Day-14/Day-14_Yukta.py
295
3.84375
4
arr = [] n = int(input("Enter the number of elements : ")) for i in range (0,n): ele = int(input()) arr.append(ele) for i in range (0,n): for j in range(0,n-1): if(arr[i] < arr[j]): temp = arr[i] arr[i] = arr[j] arr[j] = temp print(arr)
e629b1cbabbeed0edad4b80d5c8a5df4d8af3b65
katgzco/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
441
4.15625
4
#!/usr/bin/python3 """ This is the module for add_integer """ def add_integer(a, b=98): """ add_integer' that add two number """ handle_a = isinstance(a, (int, float)) handle_b = isinstance(b, (int, float)) if handle_a is False or handle_b is False: raise TypeError("{} must be ...
27c2c85b7cda526fcaacfb4eda5cec4f54098c48
niandrea/comp110-21f-workspace
/exercises/ex01/numeric_operators.py
383
4.0625
4
"""COMP 110 Exercise 01, Numeric Operators.""" __author__ = "730396438" x: str = input("Left-hand side: ") y: str = input("Right-hand side: ") num_1 = int(x) num_2 = int(y) print(x + ' ** ' + y + " is " + str(num_1 ** num_2)) print(x + ' / ' + y + " is " + str(num_1 / num_2)) print(x + ' // ' + y + ' is ' + str(num_...
c02ebf7f8f1bea0c83494695ec6a4e6735afe075
ObiOscar/VariosEjerciciosPython
/desconposicionPrimos.py
1,284
4.0625
4
# Para que un numero sea primo, unicamente tiene que dividirse dos veces: # 1 - divisible entre 1 # 2 - divisible entre el mismo # En este bucle, empezamos por el dos hasta un numero anterior a el, por lo # que si en el bucle, alguna vez se divide el numero, quiere decir que no es # primo nu...
c9148793ee981c1ce4d21c13980254d3e35437fc
hortygp/github-course
/strings.py
419
3.875
4
#s1= 'aaa' #print(s1) #s="para voce meu amor" #print (s[0]) #print (s[5:10]) # cortar de 5 até 10 #print (s[: :-1]) de tras pra frente #print (s[: : 5]) passo de 5 em 5 #exemplo1 #s='iterando strings' #for c in s: # print (c) #exemplo 2 #s='iterando strings' #indice = 0 #while indice < len(s): # print(indice,...
9a83017150ebebc3bd4d819e9d152adea77243d0
cloubao/ISY_150_HOMEWORK
/week3/file_manipulation.py
684
4.0625
4
#!/usr/bin/python # Open the file for writing file = open("test.txt","w") file.write("Hello world\n") file.close() # Open the file for appending file = open("test.txt","a") file.write("This is the end\n") file.close() # Open the file for reading and modification file = open("test.txt","r+") # Print file cont...
7c95706ca1a9fe0df282f57b9da18c1639a508ae
Mudassir-Hasan/python-46-simple-exercise
/17.py
1,007
4.28125
4
# QUESTION : # 17. Write a version of a palindrome recognizer that also accepts phrase palindromes # such as "Go hang asalami I'm a lasagna hog.", "Was it a rat I saw?", "Step on no pets", # "Sit on a potato pan, Otis", "Lisa Bonetate no basil", "Satan, oscillate my metallic sonatas", # "I roamed under it as a...
4ec9764a6923f491e54b3855ff2f82b1791f83fb
harishjhaldiyal/CTCI-Solutions-in-Python
/4.8.py
1,366
4.125
4
""" 6 5 7 9 0 1 2 nodeA = 7 nodeB = 2 smaller example: 8 0 9 nodeA = 9 nodeB = 0 special case: 8 6 Pseudocode: 1) if root.left exists, search on the left subtree of the root whether both nodes (a), or either node (b), or no node exist (c) 2) other...
d19711ce50c6b5c09ee52b418ed6914d98f34324
guohaoyuan/algorithms-for-work
/offer/链表/6. 从尾到头打印链表/printListFromTailToHead.py
688
3.546875
4
# -*- coding : utf-8 -*- class Solution(object): def printListFromTailToHead(self, listNode): """ 我们使用一个栈,从头到尾存储节点 再将队列逆序 :param listNode: :return: """ # 1. 特殊情况:链表为空,则返回空 if not listNode: return [] # 2. 初始化栈stack stack = ...
4d88919fa5328b8cdf7c1f120aadff09ef634fa0
gaoyang836/python_text
/learning_test/mapreduce.py
3,250
3.828125
4
#map例子 # def f(x): # return x * x # r=map(f,[1,2,3,4,5,6,7,8,9]) # print(list(r)) #列表生成式 # print([n*n for n in [1,2,3,4,5,6,7,8,9]]) #基础写法 # def f(x): # return x * x # L = [ ] # for n in [1, 2, 3, 4, 5, 6, 7, 8, 9]: # L.append(f(n)) # print(L) #insert(结果顺序就乱了) # def f(x): # return x * x # L = [...
faf173dbc8ed51a013a7f33ed7f304f11cc157d3
nthomps49/firstlocalrepos
/Projects/Learning/addandsub4draft.py
986
4.34375
4
output_text = 'Hello, welcome to my math program\n' print(output_text) while True: try: choice = int(input("Choose 1 to add or 2 to subtract ") break if choice != 'add' or 'sub' or 'subtract': print('You must make a choice') exit() if choice == 'add': quantity = input('How many numbers ...
220cf768d4ec91f744f25da362d19969e38e7c52
federicoemartinez/problem_solving
/leetcode/vowel-spellchecker.py
1,465
3.65625
4
# https://leetcode.com/problems/vowel-spellchecker/ import re class Solution(object): def spellchecker(self, wordlist, queries): """ :type wordlist: List[str] :type queries: List[str] :rtype: List[str] """ d = {} d_vowels = {} for each in wordlist: ...
3fdb80ff384d96bd95b0ba6f5de8b4638acedffb
njdevengine/python-stats
/quartiles.py
751
3.8125
4
# Dependencies import matplotlib.pyplot as plt from stats import median import numpy as np ### Data Points arr = np.array([2.3, 10.2,11.2, 12.3, 14.5, 14.6, 15.0, 15.1, 19.0, 24.0]) arr # Find the median median(arr) # Use numpy to create quartiles q0 = np.quantile(arr,0) q1 = np.quantile(arr,.25) q2 = np.quantile(ar...
7cd139f0a3122b6e8302103be4538817ed426dcd
RaviC19/Rock-Paper-Scissors-Python
/rps_with_random_choice.py
1,335
4.28125
4
from random import choice for i in range(3): player = input("What is your choice? ").lower() options = ["Rock", "Paper", "Scissors"] computer = choice(options) print(player) print(f"The Computer chose {computer}") if player.lower() == computer.lower(): print("You and the computer chos...