blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
599b56585ac98d54c80362bfc8a974ad57fc784c
troywsmith/pygo
/arrays/idk.py
752
3.84375
4
""" Given an array of sorted integers, return a string array that contains the ranges of consecutive integers """ def create_range(lower, upper): s = str(lower) + '-' + str(upper) return s def hi(arr): rangeString = '' isRange = False for i in range(0, len(arr)): while (i < len(arr) ...
034e159b3ce979fb1de98e24a0fb66528863e672
JulyKikuAkita/PythonPrac
/cs15211/DailyTemperatures.py
3,426
4.09375
4
__source__ = 'https://leetcode.com/problems/daily-temperatures/' # Time: O(N) # Space: O(W) The size of the stack is bounded as it represents strictly increasing temperatures. # # Description: Leetcode # 739. Daily Temperatures # # Given a list of daily temperatures T, return a list such that, # for each day in the in...
81d4660e546ddb900ccdcfcc56dcfdc8734a3524
softpaper95/algorithm
/3.연습장.py
120
3.953125
4
list = [[2, 5, 3], [4, 4, 1], [1, 7, 3]] for i in list: n, m = i print(n, m) # print('n:',n,'m:',m, "h:", h)
f044be8bb559e253609ffe680137d2dca2bcd1e5
isi-vista/vistautils
/vistautils/scripts/tar_gz_to_zip.py
3,219
3.875
4
import argparse import os import tarfile from zipfile import ZipFile USAGE = """ Converts a (un)compressed tar file to .zip This is useful because .zip allows random access, but the LDC often distributes things as .tgz. zip version will be input name with .tar/.tar.gz/.tgz stripped (if present), .zip added...
ef64195b69ba7216b18eb12dc8ae686f302c51fd
addkap92/Python-Crash-Course
/5-3 Alien Colors #1.py
234
4.03125
4
alien_color = ['green', 'yellow', 'red'] color = input("An alien was just shot down! What color was it?\n") if color in alien_color: print("You got 5 points!") else: print("You didn't get any points, try for the green ones!")
3acfc01fa9bee4a622f248823bc59837d04d486f
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/5fcf51ad35524c0f917bc7ecceb49e0d.py
581
3.546875
4
import re class Bob: def hey(self, statement): if self.silence(statement): return 'Fine. Be that way!' elif self.yelling(statement): return 'Woah, chill out!' elif self.question(statement): return 'Sure.' else: return 'Whatever.' ...
0f64ad2a86c8bbe6329296e94bd8b8ac563b95f9
156076769/spark-exam
/pyspark-s3-parquet-example/pyspark-scripts/nations-parquet-sql-local.py
2,169
3.53125
4
""" File name: nations-parquet-local.py Author: Jonathan Dawson Date Created: 6/8/2016 Date Modified: 6/8/2016 Python Version: 2.7 PySpark Version: 1.6.1 Example of loading .parquet formatted files into a in-memory SQLContext table and running SQL queries against it. This script is configured to run against a local i...
e200a5924596e1f13298af034dce4e75fd63042f
Thiagolivramento/linguagem_II
/CRUD/contoles.py
3,714
3.703125
4
# Criando a tabela se necessário class CreateTable: def createTable(con): with con: cur = con.cursor() cur.execute("Drop se a tabela Musica existir") cur.execute( "CREATE TABLE Musica(Id SERIAL PRIMARY KEY, Nome VARCHAR(25), Autor VARCHAR(25), Gênero V...
b225b5c6cfc3df7a0dbefce4b35cb4beca8841c2
esethuraman/Problems
/graphs/GraphAdjacencyList.py
1,109
3.8125
4
class Graph: def __init__(self, vertices_count): self.vertices_count = vertices_count self.adj_list = [None] * vertices_count def add_edge(self, frm, to): if None == self.adj_list[frm]: self.adj_list[frm] = [] if None == self.adj_list[to]: self.adj_list[...
cb45393c9f6891233c61940941825c7bb7615e16
mine1984/Advent-of-code
/2015/day03/day03a.py
830
3.8125
4
# Santa is delivering presents to an infinite two-dimensional grid of houses. # Moves are always exactly one house to the north (^), south (v), east (>), or west (<). # # Santa ends up visiting some houses more than once. How many houses receive at least one present? class player: def __init__(self): self...
259c33a5ad1e751f688bc58aed2d22dc2fae0d75
LukeBrazil/fun_fair_danger
/room3.py
3,661
4.03125
4
# ROOM3 ROTTEN TOMATOES: Go ahead , pick your poison, a bucket full of rotten tomatoes at your disposal. import random from pip._vendor.colorama import Fore, Back, Style def Tomato(): rotten_tomatoes = 3 # get 3 chances for a hit (accumalator) game_running = True play_again = "y" ogre_conquered = False ...
43e7260f6c00190aec82c4161269046ad6f96508
hjqjk/python_learn
/Learning_base/main/multiprocessing/mp_multiprocess1.py
420
3.5625
4
#!/usr/bin/env python #_*_ coding:utf-8 _*_ #利用Pool的map,起多进程 from multiprocessing import Pool import time def f(x): time.sleep(0.5) return x*x if __name__ == '__main__': #print map(f,[1,2,3,4,5,6,7]) #串型处理,花费时间长 p = Pool(10) #设定进程池,最多只能起5个进程 print p.map(f,[1,2,3,4,5...
a1f120204d8c4baa3066322ee1041141cce50db9
mattecora/dbscout
/utils/sample_ds.py
517
3.734375
4
""" sample_ds.py Extract a random sample from a dataset. Arguments: - The dataset to be sampled - The output dataset - The fraction to be sampled """ from sys import argv from pyspark import SparkContext # Create the Spark context sc = SparkContext(appName="sample_ds") # Read the input file ...
b053c98cd247402e21fb4a5c9840e980372fe5f5
hyang012/leetcode-algorithms-questions
/053. Maximum Subarray/Maximum_Subarray.py
540
4.03125
4
""" Leetcode 53. Maximum Subarray Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. """ def maxSubArray(nums): """ :type nums: List[int] :rtype: int """ if nums is not None and len(nums) != 0: cu...
3b5eedc47e5c52ab44ae8db20accb62c6882a7f0
UWPCE-PythonCert-ClassRepos/SP_Online_Course2_2018
/students/TinaB/lesson02/generators.py
799
4.1875
4
#!/usr/bin/env python3 """ Last week we looked at Spotify’s top tracks from 2017. We used comprehensions and perhaps a lambda to find tracks we might like. Having recovered from last week’s adventure in pop music we’re ready to venture back. Write a generator to find and print all of your favorite artist’s tracks f...
6d3b2fce5fe9344b82e54042fe7f9a4b9c49dd75
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_74/175.py
7,974
4.15625
4
#!/usr/bin/env python """Problem Blue and Orange are friendly robots. An evil computer mastermind has locked them up in separate hallways to test them, and then possibly give them cake. Each hallway contains 100 buttons labeled with the positive integers {1, 2, ..., 100}. Button k is always k meters from the start of...
8fb96fcd8cc90e472107db6303a18508090bcc8c
Maelibe/Pythons-tasks
/EDX/Task2 Bisection search.py
900
4.125
4
print("Please think of a number between 0 and 100!") print("Is your secret number 50 ?") left = 0 right = 100 guess = abs(left - right)/2 while True: print("Enter", "'h'", " to indicate the guess is too high.", end=" ") print("Enter", "'l'", " to indicate the guess is too low.", end=" ") inp = str(input(" "...
dd1170d995d68b47d212083975bf21569c7c236f
dojojon/SpookyHouse
/step08/game.py
4,545
3.515625
4
import pygame from random import randint def render_sky(): "Draw the sky" screen.blit(sky_image, (0, 0)) return def render_windows(): "Draw the window back grounds" screen.blit(windows_image, (0, 0)) return def render_house(): "Draw the house" screen.blit(house_image, (0, 0)) r...
4e32036ea75cd097b2840ac7c1f593a57ae0482d
GrishaAdamyan/All_Exercises
/if3.py
211
3.890625
4
print('Duq hashvel giteq?') x = input() print('Duq giteq te qani taric e baxkacac hayoc aybuben@?') y = input() if x == 'yes' or x == 'no' and y == 'yes' or y == 'no': print('RIGHT') else: print('WRONG')
37ab77ef07786bf8d5f12328e87fdc5fdffaba14
Guillermocala/Py_stuff
/Diseño_microelectronico_digital/clase2/Ejercicio5.py
531
3.953125
4
# Escrita un programa que de cómo resultado un archivo de texto con # una matriz que muestre todas las combinaciones de multiplicación de # los número 1 hasta 10. def main(): print("\t\tTablas de multiplicar") res = "" for x in range(1, 10): for y in range(10): res += str(x) + " x " + s...
44444bb0aa1dd061da161bfffdaee160270b6e50
bamboodew/jackfrued_Python-100-Days
/src/Day001_FirstPython/test_if.py
299
3.671875
4
from random import randint print(2 ** 10) i = randint(0, 1000) s = input("请输入:") num = int(s) # print(i) while num != i: if num > i: print("大了\n") elif num < i: print("小了\n") s = input("请再输入:") num = int(s) print("\n猜对了")
dd168e740e7d91cf6ad292401019e06d0052e8c5
nilay0512/Nilay_test
/Task-2-Assignment/Program7.py
75
3.6875
4
x=range(7) for i in x: if i==3 or i==6 : continue print(i)
168da40a1d580813f63274c4eaf00cea31fae2f4
bigsaigon333/BaekjunOnlineJudge
/2667.py
1,903
3.640625
4
# Date: 2020-08-31 Mon 21:47 # 1st try: 1h 8m 31s # Comment: 언어에 대한 확신이 없으니까, 사소한 문법이 틀린게 아닌지 계속 찾게 된다 # runtime-error가 발생하였는데, 이는 group 개수가 N개가 넘을때를 고려하지 않고 배열을 선언하여서이다. # intput, output을 잘 확인하자. 이번 문제에서는 각 그룹에 번호를 부여할 필요가 전혀 없었다. 그냥 갯수만 세면 되는 문제였다 # 필요한 것만 구현하자 import sys from collections import deque def print_ta...
9ddcbc4ed0bf4ac34d242ecf62763a27f1e7f502
Bhuvanjeet/Food-Recommendation-Engine
/food_recommendation.py
2,292
3.65625
4
# -*- coding: utf-8 -*- """food_recommendation.ipynb @author: Bhuvanjeet **Food Recommendation Engine** To recommend food items based on similarity in 'brand' and 'ingredients'. **Project Overview:** **1-Exploratory Data Analysis - EDA** **2-Vectorization** **3-Cosine Similarity** **4-Input and Output** """ i...
7dc8043b3fdaa189dfd6d657d9bfa06e18706780
queeniekwan/mis3640
/session06/ex_06.py
1,679
4.25
4
def factorial(n): """ return the factorial number for integer n """ if isinstance(n, int): if n == 0: return 1 else: return n * factorial(n-1) else: return 'Please enter an integer' def fibonacci(n): """ return the nth fibonacci number ""...
cbb786472b417f3a39a899d58e1d93444af1224c
Blossomyyh/leetcode
/lastSubString.py
1,476
3.5625
4
""" My idea is simple, it is kind of DP or linear search or whatever ... One observation is that the answer should reach the end of string s. Otherwise, you can always extend the hypothetical answer to the end of string s which will be lexicographically larger than the hypothetical answer. Next, let's assume the cu...
77747b46d1b04ba4289250e88a5b6722f39ec9a0
harshjoshi02/Hacktoberfest2020
/Python/Tasks/count_of_students_in_class.py
489
3.890625
4
#Write a Python program to count the number of students of individual class from collections import Counter classes = ( ('V', 1), ('VI', 1), ('V', 2), ('VI', 2), ('VI', 3), ('VII', 1), ) #we will need a dictionary to store the repeated students of a sections' tally classdict = {} for c in class...
6c511b63f8a6d213cc1e91f1e17663d2419e8b29
sunnycol/warmup
/hw5.py
2,905
3.71875
4
#!/usr/bin/python __author__ = "Stephen Li" __email__ = "stephen.liziyun at gmail dot com" import sys class AdjacencyListGraph(object): """Adjacency list implementation of undirected weighted graph. """ def __init__(self): self.nodes = [] self.edges = {} def add_edge(self, u, v, weight):...
0c6ccfd2691b91957241b03b95db39706371af7a
liwzhi/Zillow-house-prediction
/Desktop/machineLearning-master/combination.py
1,559
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 16 11:19:58 2015 @author: weizhi """ class Solution: # @return a list of lists of integers def combine(self, n, k): result = [] self.combineRecu(n, result, 0, [], k) return result def combineRecu(self, n, result, start, intermedia...
d9342615a47041d97ca0ae0da06260fc8a6f991e
jennyChing/leetCode
/264_nthUglyNumber2.py
1,650
4.21875
4
''' 264. Ugly Number II Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. Note that 1 is typically treated as an ugly number. Hint: 1. The naive approach...
62e47f6d7ad7af4c7c12e39a1f15fc1604453b7a
Zia-/Mathematical-Code-Solutions
/src/12.wave-array.py
786
4.3125
4
""" author: Dr. Mohammed Zia https://www.linkedin.com/in/zia33 Problem Statement: Given a sorted array arr[] of distinct integers. Sort the array into a wave-like array and return it In other words, arrange the elements into a sequence such that arr[1] >= arr[2] <= arr[3] >= arr[4] <= arr[5]..... more: https://practic...
a1bde9fbe11c689f7af590139e646629e0346982
666graham666/-
/ex11.py
184
3.640625
4
import turtle turtle.shape('turtle') turtle.left(90) n = 50 def but(n): turtle.circle(n) turtle.circle(-n) x = 1 while x <=20: but(n) n += 5 x += 1 input()
ab62c974d019074eb8cae38a24f25e1570111ed5
raduvieru/turtle
/turtle9.py
766
3.9375
4
import turtle from math import pi, sin screen = turtle.Screen() def poligon(n, r): if n < 3: exit() turtle.penup() alpha = (n - 2) * 180 / n #marimea ungiului intern din poligon #turtle.reset() turtle.goto(0, 0) turtle.forward(r) turtle.left(180 - alpha/2) # turtle.left(-alpha ...
d890399e968d766a92352106caea8a6b7d9c195b
bayysp/PythonTutorial
/SplitFunction.py
271
4.09375
4
#split function is using for split a string with parameter #for example print("Bayu:Ai:Yola".split(":")) #it will put a 'Bayu' 'Ai' and 'Yola' into array #it also can be access by an index print("My Name is "+"Bayu:Ai:Yola".split(":")[1]) #it will show 'My Name is Ai'
3e205542c2f403e4ff5caaf408b53590f347cfee
tzm25/Self-Taught-Programmer
/For loop.py
814
3.765625
4
blog_post=["","The 10 coolest math functions in Python","", "How to make HTTP requests in Python", "A tutorial about data types in python"] for post in blog_post: if post == "": continue else: print(post) myString="This is a string" for char in myString: print(char) for x in ...
6e9700312c738043ac64245558d3454395910f3a
kamalkoushik24/zap
/pset6/readability/readability.py
971
3.890625
4
from cs50 import get_string # importing the cs50 library letter = 0 sentence = 0 # initializing all the variables word = 1 text = get_string("Text: ") # getting the text from the user n = len(text) # getting the length of the text for i in range(n): if ((text[i] >= 'A' and text[i] <= 'Z') or (text[i] >= 'a' and...
4526cc38e3a8b1de8aa92c99281bdd8126c1411c
junyechen/Basic-level
/1046 划拳.py
1,444
3.75
4
""" 划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字。如果谁比划出的数字正好等于两人喊出的数字之和,谁就赢了,输家罚一杯酒。两人同赢或两人同输则继续下一轮,直到唯一的赢家出现。 下面给出甲、乙两人的划拳记录,请你统计他们最后分别喝了多少杯酒。 输入格式: 输入第一行先给出一个正整数 N(≤100),随后 N 行,每行给出一轮划拳的记录,格式为: 甲喊 甲划 乙喊 乙划 其中喊是喊出的数字,划是划出的数字,均为不超过 100 的正整数(两只手一起划)。 输出格式: 在一行中先后输出甲、乙两人喝酒的杯数,其间以一个空格分隔。 输入样例: 5 8 10 9 12...
0dbec13ea22b6b03e0ed526e03dcb011eacc9a71
tobigrimm/adventofcode2020
/day03/day03.py
775
3.953125
4
#!/usr/bin/env python3 import sys from typing import List def navigate_slope(map: List[str], x_inc: int = 1, y_inc: int = 3) -> int: h = len(map) w = len(map[0]) x, y = 0, 0 trees = 0 while x < h: if map[x][y] == "#": trees += 1 x += x_inc # simulate the endless...
2a5effb1eafc11da5c0c5ad8a606ee5701bdea3a
Tanuki157/Chapter-2
/Chapter 2.py
5,265
3.921875
4
def personal_info(): #program that shows first and last name, address, phone number #and, what college major this person wants print("Taylor") print("Short") print("74 W. Shady St. Rossville, GA 307041") print("706-858-4395") print("Film editing") def total_purchase(): first = float(inp...
216811689504a8e5d57bcc840ae4fbe978565984
RaymondZano/MBAN-Python-Course
/1 Dishes_Duties.py
4,428
4.09375
4
""" Dean Luis and Dean Amber have both been assigned to wash the dishes after the Winter Ball. They are trying to divide the work evenly, and Dean Luis gets the great idea that one person should wash the cups, plates, and silverware, while the other washes the pots and pans. * It takes 15 seconds to wash one cup, an...
c47d08e4a3cac57bc8adee6a853ce03fd20c1f19
manthanmtg/zero-to-hero-in-python-in-30-days
/day7/break.py
105
3.53125
4
for i in range(1, 30): if(i == 12): break print(i, end = " ") print("Loop completed")
3fe488913d5fd6d60d06c0f4239cbff947b8fed8
RapAPI/Server
/rearrange.py
6,699
3.9375
4
import re import pronouncing from random import shuffle def parse_cmu(cmufh): """Parses an incoming file handle as a CMU pronouncing dictionary file. Returns a list of 2-tuples pairing a word with its phones (as a string)""" pronunciations = list() for line in cmufh: line = line.strip() ...
3a407255d23d6ef331b509ef6f4a0fe91437c342
Molly-l/vbn
/day03/recursion.py
286
4.0625
4
""" 就一个数n的阶乘 """ # def recursion(n): # resule = 1 # for i in range(1,n+1): # resule *= i # return resule # 递归函数 def recursion(n): # 递归的终止条件 if n <= 1: return 1 return n * recursion(n - 1) print(recursion(3))
bc5d5dd0dad669c59ebf7b97e8ff3cbab772e813
rockerishFox/AI_Lab5
/utils.py
1,598
3.5
4
from math import sqrt def read_graph_from_file(filename): routes = [] with open(filename, 'r') as file: cities_no = int(file.readline()) for i in range(cities_no): city_routes_string = file.readline().strip().split(',') city_routes = [float(route) for route in city_ro...
e4171c75fa8c3eadae239181dd5da3c3f9c41c5a
thehanemperor/LeetCode
/LeetCode/Math/Basic/69. Sqrt(x).py
437
3.640625
4
class Solution: def mySqrt(self, x: int) -> int: if x< 2: return x left,right = 2, x//2 while left <= right: mid = left + (right -left)//2 num = mid ** 2 print(mid,num) if num > x: right = mid - 1 elif n...
25cfd89c01a46439b18ec47b495b3a7171c16943
dmendelsohn/project_euler
/solutions/problem_067.py
703
3.6875
4
import utils # Just compute the continuous path from top of triangle to bottom with highest sum (same as Problem #18) def compute(verbose=False): MEMO = {} def best_to_point(grid, i, j): if (i,j) in MEMO: return MEMO[(i,j)] elif (j > i) or (i < 0) or (j < 0): return 0 ...
53fd549fd499b72e7e9159565fa6e048b77bc7d9
karanpradhan/Real-Estate-Price-Estimation
/original_data/dictionary.py
7,720
3.640625
4
#!/usr/bin/python2 #---------------------------------- # dictionary.py #---------------------------------- # # builds a dictionary to translate between ints and words # simplest usage: # my_dict = dictionary(['testfile.txt']) # build word -> int mapping # print my_dict.translate_file('testfile.txt') #...
cd4657440add50b7598df9bab42ee4e4c9c3163b
nicholas-lau/G16OutputAnalyser
/MiscellaneousFunctions.py
204
3.71875
4
def jobChoice(user_operations): print("\n==================== Job Choice ====================\n") for count, operation in enumerate(user_operations): print(count+1, operation) return 1
8a279d2f585a3cb655252fb5e379a89c6feb0a66
Silentsoul04/FTSP_2020
/W3_2020_School/Python_Try_Except_Finally_Blocks.py
4,091
4.3125
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 25 11:17:16 2020 @author: Rajesh """ ''' Python Try Except Finally :- ----------------------------- ''' NOTE :- There are we have mainly 3 blocks like listed below. 1) try block 2) except block 3) finally block 1) try block :- ---------------- It is used to test the e...
e8093d1a48765300a829ab40f053a1ba3c881025
Huikie/Rush-Hour
/Code/Algorithms/breadthfirst.py
3,294
4
4
from Code.Classes.board import Board import copy as copy import time import queue class Breadthfirst: def __init__(self): self.breathfirst = [] self.board = Board() self.boards = [] self.archive = {} self.queue = queue.Queue() def breadthFirst(self, size): """F...
c13fe4c8a3aafa2b9e427a78385900d33470e611
laszlobalint/python-playground
/loops.py
513
3.78125
4
warriors = ['Superman', 'Batman', 'Flash', 'Donatello'] # Whole loop for warrior in warriors: print(warrior) # Partial loop for warrior in warriors[1:3]: print(warrior) # Searching loop for warrior in warriors: if warrior == 'Flash': print(f'{warrior} - fast and powerful') break else: ...
b9564579442a6b50cc3c79aea47c571d857dfed4
cyndyishida/MergeLinkedLists
/Grading/LinkedList.py
1,409
3.9375
4
class LinkedListNode: def __init__(self, val = None): """ :param val of node :return None Constructor for Linked List Node, initialize next to None object """ self.val = val self.next = None def __le__(self, other): ''' :param other: Link...
97104d4277a4a88ec6ac9ebe45552ddfa29a3509
Aleti-Prabhas/geekforgeeks
/binary_to_decimal.py
471
3.9375
4
#User function Template for python3 class Solution: def binary_to_decimal(self, str): sum=0 i=0 while(str!=0): dec=str%10 no=no+dec.pow(2,i) str=str//10 i=i+1 # Code here #{ # Driver Code Starts #Initial Template for Python 3 if __name__ =...
f67575beee6e12b97af73b76b74f07e22966b074
welsny/solutions
/414.Third_Maximum_Number.py
285
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import heapq class Solution(object): def thirdMax(self, nums): """ :type nums: List[int] :rtype: int """ res = heapq.nlargest(3, set(nums)) return res[-1] if len(res) >= 3 else res[0]
8964adcf965c4cb8b34026d36a81d332ec89b6aa
gmt710/leetcode_python
/hot/48_rotate.py
548
3.671875
4
class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ if len(matrix) == 0 or len(matrix[0]) == 0: return [] r = len(matrix) c = len(matrix[0]) for i in range(r): ...
16a758055c853ef5d5a893467da190bb2f59cdfa
adixie/bank-account
/bank.py
1,253
3.8125
4
class BankAccount: def __init__(self, name, email, account_balance, interest_rate): self.name = name self.email = email self.account_balance = 0 self.interest_rate = 0.05 def deposit(self, amount): self.account_b...
a52c8f556aba5e6537ac8022ec118d7c1c10fe37
TonyPeng2003/final_exam
/final_exam/27.py
276
3.59375
4
Tony = {'age':'15','most_famous_book':'Angel',,'country':'US'} Livia = {'age':'14','most_famous_book':'Get OUt',,'country':'China'} Mike = {'age':'17','most_famous_book':'Miao Cat','country':'UK'} persons = [Tony,Mike,Livia] for introduction in persons: print(introduction)
d9cab76dec27f4e73acd545e204f5a75f6ab243e
zp89n11/pythonproject
/py_practical_1/Hero.py
841
3.6875
4
# -*- encoding: utf-8 -*- # @ModuleName: House,英雄类。是所有之类英雄的父类, # @Function: # @Author: 张鹏 # @Time: 2021/3/28 0:12 class Hero: # 血量 hp = 0 # 攻击力 power = 0 # 台词 speakLines = "" '''英雄的名''' name = "" def speak_lines(self): print(f"{self.speakLines}") def fight(self, enem...
5e778ba91617ebb0b4c3df2b9449223706ad62f3
HigorSenna/python-study
/guppe/lambdas_e_funcoes_integradas/len_abs_sum_round.py
879
3.96875
4
""" Len. Abs, Sum, Round len() -> retona o tamanho de um iteravel abs() -> Retorna o valor absoluta de um número inteiro ou real sum() -> Recebe como parâmetro um iteravel, podendo receber um iteravel, retorna a soma total dos elementos, incluindo o valor inicial OBS: O valor inicial default é 0 round() -> retorn...
515b089b3b116a0c9a23a5ae075fa06e92d70f43
shoichiaizawa/edX_MITx_6.00.1x
/lecture05/l5_problem02.py
681
3.984375
4
def recurPower(base, exp): ''' base: int or float. exp: int >= 0 returns: int or float, base^exp ''' # Your code here if exp == 0: return 1 elif exp == 1: return base else: return base * recurPower(base, exp-1) # ---------- # Test cases # ---------- print r...
b5d56c6db7e27374d62672b20e60b723f96cc4ce
bdavs/Piratebot
/json_helper.py
1,578
3.59375
4
import json """reading the ship file to add all the users ships to the dataspace""" def to_dict(self): """creates a dict from ship params""" return { 'captain': self.captain, 'cannons': self.cannons, 'crew': self.crew, 'armor': self.armor, 'sails': self.sails, '...
61b650e7f4fb367c3dd3a403f6fa186e15d790b3
Trotuga/CYPIrvinBM
/libroo/problemas_resueltos/problema2_10.py
664
3.953125
4
A = int(input("Escribe un numero: ")) B = int(input("Escribe otro numero: ")) C = int(input("Escribe otro numero: ")) if A > B: if A > C: print(f"El numero {A} es el mayor. ") elif A == C: print(f"El numero {A} y {C} Son iguales y son los mayores. ") else: print(f"El numero {C} es el...
7ccf210029ea1b73bb94a5f033e68a455aaebe72
ARORACHAITANYA/hackerrank
/Strings/#4 Find a string.py
145
3.65625
4
import re def count_substring(string, sub_string): s = [m.start() for m in re.finditer(f'(?={sub_string})', f'{string}')] return len(s)
95cf67d35d6815db7285909e6bcb3fe31869377e
igorkoury/cev-phyton-exercicios-parte-2
/Aula18 - Listas (Parte 2)/ex084 – Lista composta e análise de dados.py
1,129
4.1875
4
'''Exercício Python 084: Faça um programa que leia nome e peso de várias pessoas, guardando tudo em uma lista. No final, mostre: A) Quantas pessoas foram cadastradas. B) Uma listagem com as pessoas mais pesadas. C) Uma listagem com as pessoas mais leves.''' dados = [] pessoas = [] mai = men = 0 while True: ...
dd7866aef9c2da91ab6cfc7b50533056a788e451
gjcraig/TrafficDataProject
/venv/graph.py
1,977
3.640625
4
from functions import * import matplotlib.pyplot as plt import math from random import gauss data = df("Road_Safety_Data.csv") # # Bar chart x = ['Fatal', 'Serious', 'Slight'] counts = [header_count('Accident_Severity', 1), header_count('Accident_Severity', 2), header_count('Accident_Severity', 3)] x_pos = [i for i,...
dfd291d7abb06c1fd6a1564a17bf5e1a716d6877
mosman94109/primes
/product_of_primes.py
1,427
4.59375
5
#!/usr/bin/env python """ From number theory: Product of primes less than n is less than or equal to e ** n as n grows. This script computes the sum of the logarithms of all the primes from 2 to some number n (identfied as LARGE_NUM in this script), and prints out the sum of the logs of the primes, the number n, and...
43b97f9c198e7e45918642fb13bfb39df55527fa
irfankhan309/DS-AL
/Py_Codes/my_practice/python_series/test.py
3,426
4.125
4
import time def hotel(): '''this hotel function is for booking the table with defined numbers as per requirement and taking input of from consumer what he exactly requires\nwe have table numbers starts with 100 to 200 i.e..,\nwe have large space to book table as it containing 100 tables starts with 100 and end...
103ec4738bc045f7f76db1681173005058243904
blackrain15/Machine_Learning_Basics
/Linear Regression_Gradient Descent/Linear Regression_Sample Implementation.py
3,074
4.0625
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt #Import the training dataset into a pandas dataframe. The training data has 2 variables x = Distance in KMs driven by a driver, y = Profit in $ mydata = pd.read_csv("ex1data1.txt", header = None) #Plot the training data in a 2D graph to visualize...
25f0502b6cb2a66dcfa3bfc7fc2aef9bf2404ab9
adliaulia/Basic-Python-B4-C
/Pertemuan-4/dictionary.py
231
4.21875
4
#dictionary data tdk terurut, dapat diubah, dan memiliki index dict = {"brand":"Ford","model":"Mustang","year":1964} print(dict) for x in dict: print(x) #change value dict["year"] = 2021 print(dict) x = dict["year"] print(x)
605658e533374eb2b3ad57dc932747dd711c0b48
Aasthaengg/IBMdataset
/Python_codes/p02880/s442407760.py
162
3.6875
4
a = int(input()) f = False for i in range(1,10): for j in range(1,10): if i*j == a: f = True if f: print("Yes") else: print("No")
b7898ba2627d58b1c0925b535390676118f7db06
romeorizzi/temi_prog_public
/2018.12.05.provetta/all-CMS-submissions-2018-12-05/2018-12-05.11:51:15.087870.VR437289.conta_inversioni.py
627
3.53125
4
""" * user: VR437289 * fname: ALVIANO * lname: MASENELLI * task: conta_inversioni * score: 100.0 * date: 2018-12-05 11:51:15.087870 """ # -*- coding: utf-8 -*- # Template per la soluzione del problema conta_inversioni from __future__ import print_function import sys if sys.version_info < (3, 0): input = raw_in...
1b55d13658a614199c02f8d8adce229bf3ef1ed1
lmycd/leetcode
/leetcode/Find the Difference.py
954
3.625
4
""" Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was added in t. """ class Solution(object): def findTheDifference(self, s, t): """ :type s: str ...
43a2fcf1d49f1044cf9a146e4d9186aa86ac9676
xpandi-top/ML-THUAUS
/a_overall_data.py
1,715
3.859375
4
""" 数据的类型: 类别, 日期, 数值,ID 数据的分布:每个特征下的数据分布 数据之间的关系:correlation数据的类型: 类别, 日期, 数值,ID 数据的分布:每个特征下的数据分布 数据之间的关系:correlation """ import pandas as pd import matplotlib.pyplot as plt import numpy as np import seaborn as sns def general_describe(df): """ general describe about the data :param df: data frame type ...
20edec4365350ab8c1c536acd84b6759325ac220
samyhkim/algorithms
/121 - best time to buy and sell stock.py
352
3.53125
4
def maxProfit(prices): if not prices: return 0 min_price = prices[0] max_profit = 0 for i in range(1, len(prices)): min_price = min(min_price, prices[i]) max_profit = max(max_profit, prices[i] - max_profit) return max_profit print(maxProfit([7, 1, 5, 3, 6, 4]) == 5) print(m...
9d7e4ca0821bc374cccf5962fe051afd1f18b5e9
flexgp/novelty-prog-sys
/src/PonyGE2/src/utilities/representation/python_filter.py
739
3.8125
4
def python_filter(txt): """ Create correct python syntax. We use {: and :} as special open and close brackets, because it's not possible to specify indentation correctly in a BNF grammar without this type of scheme.""" indent_level = 0 tmp = txt[:] i = 0 while i < len(tmp): tok...
b56aadf481681d4ca69854217a239e241ba6b474
nitinaggarwal1986/learnpythonthehardway
/ex16c.py
1,206
4.75
5
# To use the argv command to take the filename as the argument. from sys import argv # Taking filename as a parameter passed to the python script. script, filename = argv # To check with user if they want to overwrite the file mentioned. print "We're going to erase %r." % filename print "If you don't want that, hit C...
05a6f105cbe24dec3a85aff65327b220eb70ecb2
MAPLE-Robot-Subgoaling/IPT
/data/HW3/hw3_401.py
716
4.15625
4
def main(): temp = float(input("Please enter the temperature: ")) tempMeasure = input("Please enter 'C' for Celcius, or 'K' for Kelvin: ") if tempMeasure=="C": if temp<=0: print("At this temperature, water is a (frozen) solid.") elif temp>0 and temp<100: print("At thi...
8a6765506aa60bbab1bd60051ed7975848e1e811
1BM18CS114/ADA_LAB
/ass1.py
1,265
3.53125
4
##Tower of hanoi def toh(a, c, b, n): if n == 1: print("Move Block from {} to {}".format(a,b)) else: toh(a, b, c, n - 1) toh(a, c, b, 1) toh(b, c, a, n - 1) #toh("a", "b", "c", 3) ##GCD using recursion def gcd(m, n): if m == n: print(m) return if m > n: gcd(m - n, n) else: gcd(m, n - m) ...
af08a3c0f75f20781de7e5b22f20af1592cd5b09
Davitkhachikyan/HTI-1-Practical-Group-2-Davit-Khachikyan
/homework_5/is_palindrome.py
270
4.21875
4
def is_palindrome(word): while len(word) != 0: if word[0] == word[-1]: word = word[1:-1] is_palindrome(word) else: return "No" return "Yes" user_input = input("Enter a text") print(is_palindrome(user_input))
89a6ee402450f535c585e82f964fd85294fd86ef
miaopei/MachineLearning
/LeetCode/github_leetcode/Python/escape-the-ghosts.py
1,764
4.0625
4
# Time: O(n) # Space: O(1) # You are playing a simplified Pacman game. # You start at the point (0, 0), and your destination is (target[0], target[1]). # There are several ghosts on the map, the i-th ghost starts at (ghosts[i][0], ghosts[i][1]). # # Each turn, you and all ghosts simultaneously *may* move # in one of ...
348da7bf6f2fe6f5f49c5deddecb8bff389a35b6
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/word-count/421ec0af42d04ad4ad2c6d283b03ae26.py
208
4.09375
4
def word_count(phrase): '''Returns dict with word counts for a given phrase.''' count = {} for word in phrase.split(): count.setdefault(word, 0) count[word] += 1 return count
c0b0dc4cb349c9bfbdd5a4ab59fc3414ab370da5
adheepshetty/leetcode-problems
/String/String to Integer.py
1,809
3.953125
4
#author: Adheep import unittest class Solution: ''' Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minu...
70fb879c448d9043713eb0a2945b790db0284f4e
lhf860/leetcode_python
/dynamic_programming_03/爬楼梯.py
974
4.1875
4
# coding:utf-8 """ 是一维动态规划的应用题 问题描述: 假设你正在爬楼梯,需要n阶才能到达楼顶,每次你可以爬1个或者2个台阶,你有多少种不同的方法可以爬到楼顶 思路: 若想爬到楼顶n处,只有两种可能:1)从n-1层楼顶向上爬一层, 这种只需要计算到达n-1层的方法数 2) 从n-2层向上爬2层,这种方法只需要计算爬n-2层的方法数,之后将二者相加即可。 计算到达n层的方法数=到达n-1层的方法数 + 到达n-2层的方法数; 计算n-1层的方法数=到达n-2层方法数 + 到达n-3层的方法数 ...... ...
9b39a8a8288b323cfa818d7927c339ccf1ed2680
akshit113/HackerRank-Practice-Problems
/love letter.py
799
3.734375
4
#!/bin/python3 import math import os import random import re import sys # Complete the theLoveLetterMystery function below. def theLoveLetterMystery(s): orig = s if s == s[::-1]: return 0 s = list(s) left = ord(s[0]) right = ord(s[-1]) count = 0 cnt = 1 while right > left: ...
b6bdd33d0758144123403146b43305d619d805cf
shun8800/CondigTestStudy
/PythonFunction/Sorting/sort_selection.py
588
3.671875
4
# 정렬 : 데이터를 특정한 기준에 따라 순서대로 나열하는 것 # 문제 상황에 따라서 적절한 정렬 알고리즘이 공식처럼 사용 됨 # 선택 정렬 : 처리되지 않은 데이터 중 가장 작은 데이터를 선택해 맨 앞의 데이터와 바꾸는 것 # 선택 정렬 : O(N^2) array = [7, 5, 9, 0, 3, 1, 6, 2, 4, 8] for i in range(len(array)): min_index = i for j in range(i+1, len(array)): if array[min_index] > array[j]: ...
9c8a3729328aec5135afa1f713a930801745c79d
xiyiwang/leetcode-challenge-solutions
/2021-04/2021-04-28-uniquePathsWithObstacles.py
1,042
3.921875
4
""" LeetCode Challenge: Unique Paths II (2021-04-28) A robot is located at the top-left corner of a m x n grid. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid. Now consider if some obstacles are added to the grids. How many unique...
e7615c060f5978bab50367d49a0fcee3db2e8033
limianscfox/Python_learn
/Python_Crash_Cours_2rd/7/7.1/test_7_3.py
153
4.28125
4
num = input("please enter a number:") if int(num) % 10 == 0: print(f"{num} is Multiples of 10 !") else: print(f"{num} is not Multiples of 10 !")
16bab867ad7dcd837e4a3f051238a127dce3d1fa
IgnacioLoria1995/cursoPythonTest
/ejercicio2.py
793
3.90625
4
#programa de prueba II clientes = int(input('Ingrese numero de clientes entre 1 y 120: ')) while clientes < 1 or clientes > 120: print('por favor ingrese un numero entre 1 y 120') clientes = int(input('Ingrese numero de clientes entre 1 y 120: ')) else: for i in range(clientes): print('cliente nume...
55dd9013223f0678f63f4cc14e04cb817e857bac
danilobellini/wta2015
/code/54_metaclass.py
610
3.640625
4
import sys class Metaclass(type): def __init__(cls, name, bases, namespace): print("Initializing class {}\n" "bases: {}\n" "namespace: {}" .format(name, bases, namespace)) if sys.version_info.major == 2: # Python 2 exec("""class M1(object): __metaclass__ = Met...
035f30c36350af1644a9e69a834650148cdbca17
AdamBures/ALGHORITHMS-PYTHON
/selection_sort.py
310
3.890625
4
def selectionSort(arr): for i in range(len(arr)): minimum = i for j in range(i+1,len(arr)): if arr[j] < arr[minimum]: minimum = j arr[minimum],arr[i] = arr[i], arr[minimum] return arr arr = [5,1,3,4,6,7] print(selectionSort(arr))
7577861b457a184044a9daa6b3e6e6b2c80c6307
patchgi/mitsuboshi
/app.py
242
3.828125
4
#coding:utf-8 import random if __name__=="__main__": result="000" while result!="012": rand=random.randint(0,2) result=result[1:]+str(rand) print(("燃やせ","友情","パッションは")[rand]) print ("ミツボシ☆☆★")
949b0d67dc7bdc024bb6c9d31ddf3954da858d58
murphylan/python
/Parent.py
766
3.96875
4
class Parent: # 定义父类 parentAttr = 100 def __init__(self): print ("调用父类的初始化方法") def parentMethod(self): print ('调用父类的方法') def setAttr(self, attr): Parent.parentAttr = attr def getAttr(self): print ("父类属性 :", Parent.parentAttr) class Child(Parent): # 定义子类 ...
adc353e3b5ec35710c2f1824546e9ad77cc791b5
raffg/supermarket_optimization
/supermarket_optimization.py
3,768
3.875
4
# This script identifies association rules based on existing records of # buyer’s transactions at a supermarket. The input is a whitespace # delimited data file, where each row records the SKU numbers of items # in a single transaction. The script finds the most common items sold # together. The set size for the common...
9c060bf97546ed6ca73ab89befe16b642ebdf7ef
candido00/Python
/Python Exercicios/lerParImpar.py
336
3.96875
4
num = int numeros = [] count1 = 0 count2 = 0 while(num != -1): num = int(input("INFORME UM NUMERO OU( -1 ) PARA ENCERRAR: ")) numeros.append(num) for x in(numeros): if(x % 2 == 0 and x != 0): count1 += 1 elif(x % 2 !=0 and x != -1): count2 += 1 print("PARES: ",count1) print("IMPARES: ",c...
4f52f88a3c45582df6693400b93596fddc1ef965
anthony-frion/Flow-shop-heuristics
/heuristics.py
10,826
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 3 16:56:13 2020 @author: Anthony """ import random import ordonnancement as o import flowshop as f import numpy as np # schedules jobs according to a sequence and returns the corresponding length def evaluate(sequence, nb_machines) : ordo = o.Or...
150734135781073166497c06bb3a981f620d576a
coderFH/python
/stage-01/13-python文件操作/14-python文件练习.py
2,119
3.59375
4
# #实现文件的复制操作 # sourceFile = open("a.txt","r",encoding="utf-8") # desFile = open("a_dat.txt","a",encoding="utf-8") # # while True: # content = sourceFile.read(1024) # if len(content) == 0: # break # desFile.write(content) # # sourceFile.close() # desFile.close() # # print("===========================...
32e3a62408e671df28a234f828c51aba2ed1421e
erknuepp/CIS2348
/Homework2/HW2Zy910.py
407
3.8125
4
# Lauren Holley # 1861058 import csv frequency = {} file = input() with open(file, 'r') as csvfile: word_reader = csv.reader(csvfile, delimiter=',') for row in word_reader: for word in row: if word not in frequency.keys(): frequency[word] = 1 else: ...
782a1671833d187c6e169815d68240d60d80c933
amarasm/KidEd
/KidEdCat.py
4,640
4.09375
4
#User Story 1: As a user I can choose a category and based on what I’ve chosen I will be able to learn it. import json import random def loadCateg(): with open('Categories.json') as data_file: file = json.load(data_file) categ = file["categories"] return categ def AskToChooseACateg(categ): ...
e581f4e834f21985baf4413b4172b6ad1b179220
GRE-EXAMINATION/UCTB
/UCTB/utils/multi_threads.py
2,657
3.703125
4
import os from multiprocessing import Pool, Manager from functools import reduce # (my_rank, n_jobs, dataList, resultHandleFunction, parameterList) def multiple_process(distribute_list, partition_func, task_func, n_jobs, reduce_func, parameters): """ Args: distribute_list(list): The "data" list to ...
970910d5ea6cb2fb4acdbe100cd5f2b4defe9c77
VPoint/PythonExperiments
/D3-Lists/d3q1.py
955
4.09375
4
# Cette programme affiche le nombre des valeurs positives ( alors, strictement plus grande # que zero) dans un liste donné par l'utilisateur. def positive(l): ''' paramètres (un liste) et retourne un entier Cet fonction utilise un boucle pour parcourir la liste donnée et compter le nombre des valeurs posi...