Dataset Viewer
Auto-converted to Parquet Duplicate
blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d92e3e552a116e197b0b1e764ec0d58cb447267b
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/8a48ee8856204b46a1e4f8380a45d683.py
688
3.828125
4
# # Skeleton file for the Python "Bob" exercise. # def hey(what): #Testing for an empty string, or any lenthg of white space. #And return "Fine. Be that way!" if true if what.isspace() or what == '': return 'Fine. Be that way!' #Testing if the string has been written all in uppcase, ignoring the...
99c648d70caaddb758e854f62d0cfce5e9285a13
baewonje/iot_bigdata_-
/python_workspace/01_jump_to_python/4_input_output/1_function/3_164_3.py
371
3.671875
4
a=10 def vartest(a): print(a) # 전역 변수를 단순히 조회하는 것은 문제가 없다. # def vartest2(): # print(a) # a = a+1 # 지금과 같은 방식으로 전역 변수의 값을 수정 할 수 없다. # print(a) def vartest3(): global a print(a) a=a+1 print(a) vartest() vartest2()
52353e611a8d8c24b3e13f8916f8bf2ea82721d1
harrydadson/100daysofpython
/practice_python/Classes/07_concepts.py
1,282
3.671875
4
class Dog: def __init__(self, name, age, friendliness): self.name = name self.age = age self.friendliness = friendliness def likes_walks(self): return True def bark(self): return "arf arf!" class Samoyed(Dog): def __init__(self, name, age, friendliness): ...
bbda6b491a80b43dfff336de962c1d2188750f31
ivanamark/bdc
/controlflow/ifstat1.pyw
1,060
4.15625
4
points = 174 # use this input to make your submission wooden_rabbit="wooden rabbit" no_prize="Oh dear, no prize this time." wafer_thin_mint="wafer-thin mint" penguin="penguin" if 1<=points<=50: prize=wooden_rabbit elif 51<=points<=150: print(no_prize) elif 151<=points<=180: prize=wafer_thin_mint elif 181<=...
d08820c0088adf4d48241550a2e7047df9c3c86a
io-ma/Zed-Shaw-s-books
/lpthw/ex45/cave.py
8,330
3.921875
4
from textwrap import dedent import result as res class Cave(object): """ Main cave class """ def __init__(self, name): """Initialize cave class """ self.name = name # We need an entry scene self.entry_scene = """ """ # We need a description self.description ...
e431fb7ad66da3aeffa593ed688617b5a8f6770a
Hoon94/Algorithm
/Leetcode/20 Valid Parentheses.py
1,251
3.828125
4
class Solution: def isValid(self, s: str) -> bool: """[summary] Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the sam...
4a339cbd56cfcff44ec4838791393ed66e5c1b97
wuchenxi118/lc
/rotate_image.py
1,030
3.984375
4
import copy class Solution: def rotate(self, matrix): """ Do not return anything, modify matrix in-place instead. """ if len(matrix)==0: return matrix temp = copy.deepcopy(matrix) size = len(matrix) for i in range(size): for j in range...
f5f2707a3e6408585157a2d289dd55aa082dc061
framoni/switches
/tree_search.py
2,980
3.609375
4
import copy import itertools def get_groups(size): """ starting from the board size, find all groups of decision variables v_i """ groups = {} for i in range(1, size ** 2 + 1): neig_i = [] neig_i.append(i) if not i % size == 1: neig_i.append(i - 1) if not i % si...
7e44e1cca9699b32e96df998c3583b235f0ad330
eujc21/AlgPy
/algpy/core/basic.py
1,514
3.734375
4
######### Basic - A class for basic mathematical calculations ######### class AlgPyBasic(object): #---------------------------------------------------------------------- """docstring for Basic.""" def __init__(self, arg): super(AlgPyBasic, self).__init__() self.arg = arg self.functi...
65fc639d6bf8f93c56a12bea87ec1337382c702d
ArifSanaullah/Python_codes
/74.print vs return - Python tutorial 71.py
304
3.890625
4
# 74.print vs return - Python tutorial 71 def add_three(a,b,c): return (a+b+c) add_three(5,5,5) print(add_three(6,6,6)) # both are same but in case of fuinctions return is better bcz # often we use such functions that dont have to print anything # we just use thier value in return in the code
7fcda50ff779e39172bdf5db47d7b6174effe223
liyu10000/leetcode
/linked-list/#24.py
1,066
3.890625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None # recursive solution class Solution: def swapPairs(self, head: ListNode) -> ListNode: if head is None or head.next is None: return head curr = head ...
69a99983c318f8d332ca7577bef301ea20c7c2bc
Christopher-Cannon/python-docs
/Example code/16 - rectangle.py
432
4.1875
4
def rectangle_area(width, height): return width * height def rectangle_perimeter(width, height): return (width * 2) + (height * 2) width = int(input("Width of rectangle?: ")) height = int(input("Height of rectangle?: ")) area = rectangle_area(width, height) perimeter = rectangle_perimeter(width, height) pri...
a52891764e501c650c1e94d4dd69c00d5296d0ea
Gablooblue/CS11-PS2
/src/vector_sum.py
791
3.921875
4
def findQuadrant(x,y): if x > 0 and y > 0: return "I" elif x >0 and y < 0: return "IV" elif x < 0 and y > 0: return "II" else: return "III" def getNumber(s): num = "" for c in s: #for characters in string s if(c != '[' and c != ']'): num +...
de83847ea244027d4f35204093512451480e3642
cheezypuff/GameEngine
/World.py
1,264
3.609375
4
import pygame from Sprite import * class World: def __init__(self,size,rm): self.player = None self.rm=rm self.size=size self.s = size self.reset() def reset(self): self.sprites=[] #for x in range (20): # self.sprites.append(Sprite(self.rm.ge...
98a96d8ce203446d038edeffc6b617ba0349114d
rodsom22/lwf_polyps
/retinanet/utils/colors.py
1,018
3.875
4
import warnings def label_color(label): """ Return a color from a set of predefined colors. Contains 80 colors in total. Args label: The label to get the color for. Returns A list of three values representing a RGB color. If no color is defined for a certain label, the color green ...
78e49f73474a97a0fd0a93d3a654c2a0ebf73ec8
Mi7ai/A
/E4/power.py
1,027
3.546875
4
import sys from algoritmia.schemes.divideandconquer import IDivideAndConquerProblem, DivideAndConquerSolver class PowerSolver(IDivideAndConquerProblem): def __init__(self, a, b): self.a = a self.b = b def is_simple(self) -> "bool": return self.b == 1 def trivial_solution(self) -...
fde20c4a8fb14d053f5d2fc2407ba3b9b1a6dd66
ndpark/PythonScripts
/RPS.py
2,147
4.28125
4
#! python3 import random """ Let's make a game of Rock, Paper, Scissors, where the user will play against the computer. """ # Ask the user their name and store it in a variable called name. name = input('Hello! What\'s your name?') print ('Okay ' + name + '! Let\'s play Rock, Paper, Scissors.') print('Rock breaks s...
06fc84e3b4bb4e4ab114a95957fd1f0eb4b0a5b2
mrlaska/Students_List
/Students_List.py
1,936
4.21875
4
students = [] def get_student_titlecase(): for student in students: return student def print_students_titlecase(): for student in students: print(student) def add_student(name): student = name.title() students.append(student) def save_file(student): try: f = open("stu...
b8d7f20b5d3ff5d32238d27a886aa210c3cdc414
Ian100/Curso_em_Video-exercicios-
/desafio_20.py
471
3.953125
4
# O mesmo professor do desafio 019 quer sortear a # ordem de apresentação de trabalhos dos alunos. # Faça um programa que leia o nome dos quatro # alunos e mostre a ordem sorteada. from random import shuffle # shuffle significa embaralhar a = input('Primeiro aluno: ') b = input('Segundo aluno: ') c = input(...
f60cffe6c45632e5a4c02596ac19a710ad8c1f75
milenacudak96/python_fundamentals
/labs/02_basic_datatypes/1_numbers/02_06_invest.py
500
4.15625
4
''' Take in the following three values from the user: - investment amount - interest rate in percentage - number of years to invest Print the future values to the console. ''' i_amount = float(input('Provide investment amount: ')) interest_rate = float(input('Provide interest rate in percentage: ')) years...
9b1e5f2ef83dbd9f65b85fc9b139012400b94ddc
tkaderr/python_fundamentals
/product.py
1,054
3.671875
4
class product(object): def __init__(self,price,item_name,weight,cost,brand): self.price=price self.item_name=item_name self.weight=weight self.cost=cost self.brand=brand self.status="For Sale" self.box="New" def sell(self): self.status="Sold" ...
37bc2fa863d2fcc5b653482865aa9c10fba81dc8
michael-kaldawi/Prime-Number-Multiprocessing
/PipeTest.py
4,103
3.828125
4
__author__ = 'Michael Kaldawi' """ Programmer: Michael Kaldawi Class: CE 4348.501 Assignment: P01 (Program 1) Program Description: This program implements a prime number finder utilizing the sieve of Eratosthenes, multiprocessing, and communication via pipes. """ # Note: we are using numpy for our array processing t...
10571b55754d87c161a5d6a7859395d1a635250e
ADeeley/batch-file-updater
/file_updater.py
593
3.546875
4
from os import listdir from os.path import isfile, join mypath = "F:\\mystuff\\projects\\file_updater\\testfiles" files = [mypath + "\\" + f for f in listdir(mypath) if isfile(join(mypath, f))] # generates a list of file names def write_to_files(files): '''Pre: text must be string files must be list ...
1f3fc3a27533c52ab0adc6e7b89fb13787c89bb7
hawkinsbl/04-TheAccumulatorPattern
/src/m4_more_summing_and_counting.py
15,176
4.28125
4
""" This module lets you practice the ACCUMULATOR pattern in several classic forms: SUMMING: total = total + number COUNTING: count = count + 1 AVERAGING: summing and counting combined and FACTORIAL: x = x * k Subsequent modules let you practice the ACCUMULATOR pattern in its "in graphics" form: ...
3df67b34dd5e7677529c77330bae435e19f95b7d
persocom01/TestAnaconda
/pandas/12_pd_stat_functions_test.py
1,918
3.515625
4
import pandas as pd import seaborn as sb import matplotlib.pyplot as plt # Use this command if using Jupyter notebook to plot graphs inline. # %matplotlib inline import_path = r'.\datasets\drinks.csv' # Necessary in this case since 'NA'='North America' in this dataset. data = pd.read_csv(import_path, na_filter=False)...
d403e637e0eaeae86236f476a6a51ac70443fe82
IsaacDVM/main
/python/prueba.py
68
3.515625
4
pata = 0 pata += 1 print(pata) print("hello world","estúpido")
5eba8c2a989c0e8b4dbb40305b03bfd7f0cfa29f
filip-michalsky/Algorithms_and_Data_Structures
/Interview_problems_solutions/Tree_problems (BFS,DFS)/right_side_view_BST.py
1,140
3.625
4
class Solution: def rightSideView(self, root): """ :type root: TreeNode :rtype: List[int] O(n) time - each node visit only once O(n) space -dictionary stores the entire tree NOTE: it is possible to construct O(1) space if we keep track of the last elem visited in a le...
0be0ee08b0e356b25bd97a163eefae420de23902
calpa/Algorithm
/LeetCode/389_Find_the_Difference.py
376
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ __author__ = 'calpa' __mtime__ = '2/11/2016' """ def find_the_difference(s, t): # Create an empty set first char_set = set() for char in set(t): if char in char_set: continue # Difference: if s.count(char) != t.count(cha...
599876a7515625abb250cf60bdf8e108b854661c
adee-dev/Demo_Repo_1
/Datatypes.py
641
3.96875
4
#Datatypes By xyz '''var='Hello World' print(var) var='Hi Guys' print(var) name='John' print('hello', name, 'How are you?') print(name.upper()) print(name.lower()) print(name.title()) ''' #Famous_Quote='''Albert Einstein once said, “A person who never made a #mistake never tried anything new.”''' #pri...
03592e4b2187ad637a552a2c747e4d7932fbdf64
JacobOrner/USAFA
/CS_210 (Introduction to Programming)/Labs/Lab32_Objects.py
11,903
4.15625
4
"""CS 210, Introduction to Programming, Fall 2015, _YOUR_NAME_HERE_. Instructor: Dr. Bower / Col Gibson / LtCol Harder / LtCol (Ret) Christman Documentation: None required; cooperation on labs is highly encouraged! ======================================================================= """ def main(): """Main p...
c5d7dd44f402c052625bd949c8ec6ad98af22f5c
roman-kachanovsky/checkio-python
/solutions/scientific_expedition/the_best_number_ever.py
1,262
4.34375
4
""" --- The best number ever --- Elementary It was Sheldon's version and his best number. But you have the coding skills to prove that there is a better number, or prove Sheldon sheldon right. You can return any number, but use the code to prove your number is the best! This mission is pretty simple to solve. You are...
bac2334a0bb43eedb8e35410b5758034965cd1af
victorsnms/reclip
/resizeclip.py
7,455
4.03125
4
#test commit #import tkinter as tk #import library of gui #window = tk.Tk() #creating window object #intro = tk.Label(text="Welcome!") #creating label #intro.pack() #incorporando os elementos #widgets: Label, Button, Entry, Text, Frame #entry widgets: get(), delete(), insert() ex:name = entry.get() #get() in texts ne...
0c1ee09363c998143d6bc8cba73dfe3b119a04af
Kaue-Romero/Python_Repository
/Exercícios/exerc_27.py
198
3.890625
4
nome = str(input('Qual é o seu nome? ')).strip() primeiro_nome = nome.split() print('Primeiro nome {}'.format(primeiro_nome[0])) print('Ultimo nome {}'.format(primeiro_nome[len(primeiro_nome)-1]))
a999fda705b946a95fc7afa0b2ba7ddd72fb0bea
masonwang96/LeetCode
/0167两数之和(2)输入有序数组/solution1.py
460
3.609375
4
class Solution: def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ dic = {} for index, num in enumerate(numbers): if num in dic: return [dic[num] + 1, index + 1] dic[t...
b188e006d6738a1879271eff42bfbdc9a2331172
Rushi21-kesh/30DayOfPython
/Day-9/Day9-by-ShubbhRMewada.py
273
3.796875
4
def begineer(n): return n%10 def advance(n): if len(str(n))%2==0: return -1 return (int(n/(10**(len(str(n))//2))))%10 n=int(input("Enter a Number: ")) print(f'The last digit of {n} is',begineer(n)) print(f'The Middle digit of {n} is',advance(n))
b39ab9f30ca7dd5438155d7d564348525600a314
DrewDaddio/Automate-Python
/saveFiles.py
1,613
4.5
4
# Reading and Writing Plain Text Files print("""Steps to reading and writing text files in Python: Open 1. open() function: open's the file helloFile = open('<file name.txt>') helloFile.read() helloFile.close() Read 2. readlines() method: returns all of the lines as strings inside of a list. helloFile ...
b3d8d27086127b83b98f8a89f0c0ecb702681dae
n158/experimental-python3
/prime_fastest.py
1,223
3.796875
4
# -*- coding: UTF-8 -*- from itertools import compress import numpy as np def rwh_primes1v1(n): """ Returns a list of primes < n for n > 2 """ sieve = bytearray([True]) * (n // 2) for i in range(3, int(n ** 0.5) + 1, 2): if sieve[i // 2]: sieve[i * i // 2::i] = bytearray((n - i * i -...
204de2c376ae0b8c1d2b0f943722d271a9290e50
TT0101/nyc-zcta-data-helpers
/ZipToZCTA/FileHelper.py
3,123
3.515625
4
# -*- coding: utf-8 -*- """ @author: Theresa Thomaier """ import csv import re import pandas as pd #file reader def readInCSVDicData(fileName, processFunction): fileReader = None data = [] try: with open(fileName) as fileReader: fileList = csv.DictReader(fileReader) ...
12a69cff545d5a6029342300ebd772cc28ce745a
navyasree1011/CRT-BATCH
/#3.py
4,648
4.3125
4
#!/usr/bin/env python # coding: utf-8 # # every variable in python is acts like object and object has 3 characteristics # # identity # # type # #value # In[1]: a=10 print(id(a)) print(type(a)) print(a) # In[2]: b=10 b # In[3]: print(id(b)) # In[5]: a=10 b=24.5 c="gitam" d=2+4j print(a,b,c,d) print(type(...
ae4547023682a6f202bf1f01f1dea097c0cd7a1b
ishaansharma/blind-75-python
/tests/test_problem26.py
651
3.859375
4
import unittest from problems.problem26 import solution, TreeNode class Test(unittest.TestCase): def test(self): root1 = TreeNode(1) root1.left = TreeNode(2) root1.right = TreeNode(3) root2 = TreeNode(1) root2.left = TreeNode(2) root2.right = TreeNode(3) self.assertTrue(solution(root1, root2)) root1 ...
481b01a7035876cb2d86ef94149201ebaeb057a5
saviobobick/luminarsavio
/flowcontrols/import_modules/functions.py
153
3.625
4
#def add(num1,num2): # res=num1+num2 # print(res) #add(50,60) #add(50,65) #add(55,65) def cube(num): res=num*num*num print(res) cube(10)
d66a1a984d593e61a291a5ac090c3413d29662a2
Shoyee/learngit
/time_calendar_model01.py
1,294
3.515625
4
#!/usr/bin/env python3 #coding:utf-8 ''' import time local_time = time.localtime() print(local_time) print(type(local_time)) gm_time = time.gmtime() print(gm_time) print(type(gm_time)) asc_time = time.asctime() print(asc_time) print(type(asc_time)) c_time = time.ctime() print(c_time) print(type(c_...
9bccb8126f896060b32f6d569e9e61b9f60c5fd3
KonstantinosNakas/ProjectEuler-Python-Solutions
/27.py
467
3.5625
4
def isPrime(a): i = 2; if (a<2): return False; while (a%i != 0): i = i + 1; if (i == a): return True; else: return False; max_num_of_cons = 0; max_a = 0; max_b = 0; for a in range(-1000,1000): for b in range(-1000,1000): n = 0; num_of_cons = 0; while (isPrime(n*n+a*n+b)): num_of_cons = num_of_co...
d636fe313bbd8b836447b5955f5c4f487ed94dd3
akhandsingh17/assignments
/boilerplates/Facebook/nlargestElement.py
409
4.28125
4
# Given a ´dictionary, print the key for nth highest value present in the dict. # If there are more than 1 record present for nth highest value then sort the key and # print the first one. input = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 3, 'f': 4, 'g': 5} def nHighestVal(input, k): input = sorted(input.items(), k...
85b1400b0b1fed1291476a35529e569857049603
algorithmic-dynamics-lab/pybdm
/bdm/encoding.py
6,217
4
4
"""Encoding and decoding of arrays with fixed number of unique symbols. While computing BDM dataset parts have to be encoded into simple hashable objects such as strings or integers for efficient lookup of CTM values from reference datasets. In case of CTM dataset containing objects with several different dimensional...
10e3028e017e09119ac98f2f1525ec31f3068d6f
presian/HackBulgaria
/Programming0-1/Week_2/1-Basic-List-Operations/problem2.py
557
3.625
4
languages = ['Python', 'Ruby'] languages.append('C++') languages.append('Java') languages.append('C#') languages.insert(0, 'Haskell') languages.append('Go') print(languages[0]) print(languages[1]) print(languages[4]) index = languages.index('C#') languages[index] = 'F#' print(languages) print(languages[len(languages)-1...
13bd11ca5c821abe9d675ca1a7c226da6cb231e7
rofernan42/Bootcamp_Python
/day04/ex00/FileLoader.py
441
3.609375
4
import pandas class FileLoader: def load(self, path): file = pandas.read_csv(path, sep=",") print(f"Loading dataset of dimensions {file.shape[0]} x {file.shape[1]}") return file def display(self, df, n): if n > 0: print(df.head(n)) elif n < 0: pri...
e3cfe9b29e732d1d361c6d18fb4831ae557144d2
pflun/advancedAlgorithms
/Amazon-lunchRecommandation.py
1,308
3.53125
4
# -*- coding: utf-8 -*- class Solution(object): def lunchRecommandation(self, menu, person): dicm = {} dicp = {} tmp = set() res = [] # Italian => Pizza for item in menu: food = item[0] style = item[1] if style in dicm: ...
8793bc0e33cf04f064b05bec3c0b7b5b4e576621
thec4iocesar/python3
/pythyon_old/modulos/modulo.py
274
3.734375
4
#!/usr/bin/python3.7 print('Usando Modulos') def contagem(): a = 0 while a <= 10: print (a) a = a + 1 contagem() def somar(x, y): print("somando") return x + y def boas_vindas(nome): return 'Seja bem vindo, {}!'\ .format(nome)
ebf018566fa8c7096abac7bfd99faa890cf50fc4
lostdatum/Python3-Tutorial
/c02_scope.py
5,339
4.28125
4
# ============================================================================= # SCOPE OF OBJECTS # ============================================================================= # This tutorial is about the scope of objects in Python. # Basicly, the scope of an object is the domain in wh...
deb235de612f63cf50cde3ee1ddf390e21743fe4
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/42_12.py
1,795
4.65625
5
Python – Split String on all punctuations Given a String, Split the String on all the punctuations. > **Input** : test_str = ‘geeksforgeeks! is-best’ > **Output** : [‘geeksforgeeks’, ‘!’, ‘is’, ‘-‘, ‘best’] > **Explanation** : Splits on ‘!’ and ‘-‘. > > **Input** : test_str = ‘geek-sfo, rgeeks! is...
96e58815ee2ebc178532b77c4f24a3bdb8976a2e
AymanM92/PID_Python_Assignment_NanoDegree
/4_Implement_PID_controller.py
5,049
4.09375
4
# ----------- # User Instructions # # Implement a P controller by running 100 iterations # of robot motion. The desired trajectory for the # robot is the x-axis. The steering angle should be set # by the parameter tau so that: # # steering = -tau * crosstrack_error # # You'll only need to modify the `run` function at ...
cfa6ee5a4ff6161144261d9493dad84bcd94f02b
nn98/Python
/Python-19_2/lab7_4_T.py
1,206
3.609375
4
# -*- coding: ms949 -*- """ Էϴ ܾ Ͻÿ. ҹ ʰ ó϶. '.,!?()/ ܾ ƴϴ. Է¿) : While The Python Language Reference describes the exact syntax and semantics of the Python language, this library reference manual describes the standard library that is distributed with Python. It also describes some of the optional compone...
d5ae0defc00d608ac05694bd4811c33182710df0
macbeth-byui/MathShower_Arcade
/mathshower.py
5,411
3.5
4
from abc import abstractmethod import arcade import random from PIL import Image from PIL import ImageDraw from PIL import ImageFont WIN_WIDTH = 800 WIN_HEIGHT = 800 class Problem: def __init__(self): self.problem_text = "" self.points_right = 0 self.points_wrong = 0 @abstractmethod ...
a39293ee97c5d2c47ca63e991bfcfab945fb7fb8
NewtonFractal/Project-Euler-6
/Project Euler #6.py
177
3.65625
4
import time start = time.time() def squared(y): x = sum(x**2 for x in range(1,y+1)) print(abs((x-(((1+y)*y)/2)**2))) squared(100) end = time.time() print(end - start)
8e176c3f7830ceb14681aad8115873cb8b61e4b9
Deodatuss/DevOps_online_Kyiv_2021Q2
/m9/task9.1/py_files/fizzbuzz.py
235
3.53125
4
def get_reply(number): if (not number % 5) and (not number % 3): return 'FizzBuzz' elif not number % 3: return 'Fizz' elif not number % 5: return 'Buzz' else: return f'{number}'
39403ee450bdb0d3c0ad736213f504290aee45e5
Ceasar1978/NewCeasar
/d3_exercise_calculator.py
392
3.59375
4
a = int(input(""" 1:加法 2:减法 3:乘法 4:除法 请输入您要进行的计算:""")) i = int(input("请输入第一个数字:")) j = int(input("请输入第二个数字:")) if a == 1: print(i ,'+',j,'=',i+j) elif a == 2: print(i,"-",j,'=', i-j) elif a == 3: print(i,'*',j,'=',i*j) elif a== 4: print(i,'/',j,'=',i/j) else: print("输入错误!")
c946b407657c3aa3b1d14a83e7fdcc10c509bb8e
JustinDoghouse/LeetcodeAnswer
/twoSum.py
400
3.515625
4
__author__ = 'burger' class Solution: # @return a tuple, (index1, index2) def twoSum(self, num, target): ht = {} for i in range(len(num)): if ht.__contains__(target - num[i]): return (ht[target - num[i]] + 1, i + 1) else: ht[num[i]] = i ...
a0a5a772477096941c72c9a6c41082caea05a2a9
ryanbrown358/PythonStuff
/python list and loops/listAndLoops.py
443
4.125
4
Ryan = "Where is ryan at today?" for names in Ryan: print(names) list_of_list = ["String1", "String1", ["Second list of sting2", "Second2"], ["Third list of string3", "And so on!"]] for list in list_of_list: print(list) for i in range(1,101): if i % 3 == 0: print("zip") elif i ...
b5d261bfdb148403ed9e72cbd1d275880aa5df4a
suniljarad/unity
/Assignment1_2.py
1,398
4.28125
4
# #Step 1 : Understand the problem statement #step 2 : Write the Algorithm #Step 3 : Decide the programming language #Step 4 : Write the Program #Step 5 : Test the Written Program #program statement: # Take one function named as ChkNum() which accept one parameter as number. # If number is even then ...
0796081988a74f745fc0764ac554f723bf924a4a
lytl890/DailyQuestion
/jinhao/jinhao_q2.py
867
4.0625
4
''' 第2题:设计一个猜数字的游戏 系统随机生成一个1~100之间的整数,玩家有5次机会,每猜一次系统就会提示玩家该数字是偏大还是偏小,如果猜中了,则告知玩家并提前结束游戏,如果5次都没猜中,结束游戏并告知正确答案。 ''' import random low = 1 high = 100 times = 5 #随机生成一个数字 goal = random.randrange(low, high) print('数字已选好,游戏开始。你只有{0}次机会!'.format(times)) while times > 0: number = int(input('请输入你猜的数字:')) times = times -...
e1db0d5909ebf5a0139230d684948d04b435ea72
alishakundert/codewars-kata
/5kyu/[5kyu]Best_travel.py
595
3.65625
4
''' Best travel https://www.codewars.com/kata/55e7280b40e1c4a06d0000aa/python ''' import numpy as np from itertools import combinations def choose_best_sum(t, k, ls): # all possible combinations comb = combinations(ls, k) # compute sum of all combinations sum_comb = np.array(list(set([sum(p) fo...
fac759b547e390011bc424472aa9b2d0cab60aa3
ahmed100553/Problem-List
/minimalMultiplet.py
407
4.25
4
''' Find the smallest multiple of the given number that's not less than a specified lower bound. ''' def minimalMultiple(divisor, lowerBound): if lowerBound%divisor == 0: return lowerBound return (lowerBound / divisor + 1) * divisor ''' Example For divisor = 5 and lowerBoun...
909dc0a0da64c71de6371205b33a04c07ef43cb0
krixstin/python-enhance
/oop/visibility.py
400
3.578125
4
class Product(object): pass #__items : private type class Inventroy(object): def __init__(self): self.__items = [] def add_new_item(self, product): if type(product) == Product: self.__items.append(product) print("New item added") else: print("Inv...
248d1776c7c38ce015b8e218c4cff839f899e655
mikoim/funstuff
/codecheck/codecheck-3538/app/calendar.py
2,225
3.875
4
import string class Calender: def __init__(self, days_year: int, days_month: int, days_week: int): if not (days_year > 0 and days_month > 0 and days_week > 0): raise ValueError('all arguments must be natural number') if days_week > 26: raise ValueError('days_week must be a...
04172f603871e3de71afebfe906e6ac8dfe621cd
Iron-Maiden-19/MapReduce
/reducerx.py
2,662
3.5625
4
#!/usr/bin/env python3.6 import sys #Variables that keep track of the keys. current_key_being_processed = None #Do not add anything above this line. The one #exception is that you can add import statements. #You can create any global variables you want here that you will use per key. #For example, we can create a...
3f87fcaeffe026d1366e9dcc784eb51e95067a13
alexmasucci/geocoding-helpers
/google-maps-api/init_pickle.py
1,079
3.59375
4
'''This program creates a dataframe from the address data, creates fields for the new variables we want, then saves the dataframe as a pickle. The address data is assumed to be saved as a CSV file called addresses.csv with the following variables: addressid - An integer uniquely identifying each address addressline1 ...
3bdbb73da108ab01e100d8fdff38cc5bbc2698ea
saurabhsarage/Python
/Task1_Assignment1.py
406
3.78125
4
""" Created on Mon Dec 23 22:20:42 2019 @author: saurabh """ """ Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. """ l = [] for i in ra...
1f83437583e03ed89d00374cddc0acb4579017ce
nsotiriou88/Machine_Learning
/10 - Model Selection & Boosting/XGBoost/xgboost.py
1,920
3.6875
4
# XGBoost - Gradient Boost Model with decision trees # High performance: speed, quality, results # Install xgboost following the instructions on this link: http://xgboost.readthedocs.io/en/latest/build.html# # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # ...
15e590cd6035572aa042c5a03b18e60c0433ce62
shaon11579/Exploration-of-Learner-Data-with-VAEs
/Replication_main.py
5,359
3.5
4
# -*- coding: utf-8 -*- """ Replication __main__ This function creates a NN as described in Autoencoders for Education Assessment, and creates the graphs just like that paper. Specifically, we replicate table 1, figure 3, figure 4, table 2, and figure 5. @author: andre """ import pandas as pd import numpy as np im...
2e75b03dc287d1bc53754b508a84c9d4e049fa0d
zhangshv123/superjump
/interview/dp/hard/LC97. Interleaving String.py
2,275
3.625
4
""" Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: s1 = "aabcc", s2 = "dbbca", When s3 = "aadbbcbcac", return true. When s3 = "aadbbbaccc", return false. """ """ 首先,这道题的大前提是字符串s1和s2的长度和必须等于s3的长度,如果不等于,肯定返回false。那么当s1和s2是空串的时候,s3必然是空串,则返回true。 所以直接给dp[0][0]赋值true,然后若s...
b944ed5368bac10834feb5d606c8055c8c830c56
StepanSZhuk/PythonCore377
/ClassWork/ClassWork1.py
329
4.125
4
a=int(input("Input the number a=")) b=int(input("Input the number b=")) if a <= b: min, max = a, b print("The number a={0} is minimal number,the number b={1} is maximum number".format(min, max)) else: min, max = b, a print("The number b={0} is minimal number,the number a={1} is maximum number".format(mi...
9f93f4422a6d3eba4cf21199effd138e1d0df5b2
ChuhanXu/LeetCode
/Cisco/countBit.py
225
3.703125
4
# 统计一个整数的二进制式里有多少个1 def countBit(n): count = 0 while n: n &= (n-1) count += 1 return(count) print(countBit(10)) # 10 1010 2 # 10 &= 9 1010 &= 1001 = 1000
b9a21a5e45c4e11d928cace1619b8ead872fa1aa
radatelyukova/pfk
/pfk/07/01_functions.py
1,255
3.71875
4
#!/usr/bin/env python3 ################################################################################ # 01_functions.py # # <Executable Module Purpose> # # 18.07.2017 Created by: rada ################################################################################ def show_name(name): print("hello %s" % ...
48c3d7debc79400e5684a772b1b4273c17715f8d
Rshcaroline/FDU-Data-Visualization
/Final Project/reference/Python_FFD/NewtonSolver.py
3,140
3.890625
4
import numpy """ A method that will be used to solve a nonlinear system of equations using the Newton Raphson method. So, F(x) is a vector with the follwing components [f1(X), f2(X), ...] , where X is the vector of variables. Using Taylor's theorem, the following statement can be obtained: F(X) = F(X0) + DF(X0)*(del...
0ded5e54231c63676059cdc0a117ce590f96febb
gwg118/Python-Play-Time
/for_loop.py
95
3.53125
4
foods = ["Tuna", "bacon", "peanut", "butter"] for f in foods: print(f) print(len(f))
8645a88f5594f292d9d8914453c01749b2d1fe09
samuelzq/Learn-Python-with-kids
/part1/check_prime.py
462
4.3125
4
''' Program to check whether a number is a prime ''' number = int(input('Please input an integer: ')) if number == 1: print('1 is neither a prime nor a composite number.\n') exit() remainder = 1 for factor in range(2, number): remainder = number % factor if remainder == 0: break...
964efdda8212de93a50e9c180fe1616691c3e9b5
tonyxiahua/CIS-40-Python
/Quizs/Quiz-9-Part-2.py
355
4.15625
4
inStr = input("Enter a sentence for pangram-checking:") inStr = inStr.strip() word = [] letters = [] for i in range(len(inStr)): if inStr[i].isalpha(): if inStr[i] not in letters: letters.append(inStr[i]) if len(letters) == 26: print("\"",inStr,"\" is a pangram") else: prin...
b2cc8b69dcb61dff6fcfcef042ffb73c4ab58d1a
programiranje3/2020
/main.py
2,630
4.28125
4
# # Hello world: the print() built-in function and the + operator # print("John Lennon") # print('John Lennon ' + 'was born in 1940.') # print('John Lennon', 'was born in 1940.') # print('John Lennon', 'was born in', 1940, '.') # print('John Lennon', 'was born in', str(1940) + '.') # print() # print('John Lennon', '\nw...
08be94dc59fb70dee4ec27e08eec3e7384139e27
Raffayet/CustomSearchEngine
/nonblocking_proccess.py
947
3.71875
4
import threading import time start_time = time.time() current_time = None stop = False class KeyboardThread(threading.Thread): def __init__(self, input_cbk=None, name='keyboard-input-thread'): self.input_cbk = input_cbk super(KeyboardThread, self).__init__(name=name) self.start() de...
bea704b6ebe787f26a7939f6dfdc6bf083b02e5f
chars32/edx_python
/Quizes/Quiz5/construct_dictionary_from_lists.py
1,540
4.375
4
#Write a function named construct_dictionary_from_lists that accepts 3 one dimensional lists and #constructs and returns a dictionary as specified below. # The first one dimensional list will have n strings which will be the names of some people. # The second one dimensional list will have n integers which will be ...
90be92859732d2a3f3fbfd207bc7f4ab8cdb7ede
PR850/LeetCode---Algorithms
/HowManyNumbersAreSmallerThantheCurrentNumber/test_How_Many_Numbers_Are_Smaller_Than_the_Current_Number.py
880
3.78125
4
import unittest import pytest from How_Many_Numbers_Are_Smaller_Than_the_Current_Number import smallerNumbersThanCurrent # python -m unittest test_How_Many_Numbers_Are_Smaller_Than_the_Current_Number.py class TestHowManySmaller(unittest.TestCase): def check_if_list_contain_only_integers(self): with self...
df877335e12653465f920c796b0539dfd640a015
ojenksdev/python_crash_course
/chapt_10/remember_me.py
1,052
3.96875
4
import json def get_stored_username(): """Retrieves the username from a file""" filename = 'username.json' try: with open(filename) as f_obj: username = json.load(f_obj) except FileNotFoundError: return None else: return username def get_new_username(): ""...
517f962e1117511ea4c41baf5e9af4f131bf191c
Frederik-N/projecteuler
/problem23.py
2,476
4.09375
4
# Problem 23 - Non-abundant sums # A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. # For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. # A number n is called deficient if the sum of its pro...
01c2161cbe02c4057c9d9ad7dc0702148d06122e
Pedropostigo/ml
/dataframe.py
3,555
3.625
4
""" functions to manipulate data frames """ import numpy as np import pandas as pd from tqdm import tqdm_notebook as tqdm def feature_inspection(data, unique_vals = 5): """ Function to inspect features of a data frame. Returns a data frame with feature names, type of feature and unique values Paramet...
79359f5e1a291b5c276f5520886b84fb78802e8e
JGeun/BOJ_Python
/Python_workspace/2900/2908.py
310
3.78125
4
import sys def get_bigger(nums): for i in range(2, -1, -1): if int(nums[0][i]) > int(nums[1][i]): return nums[0] elif int(nums[0][i]) < int(nums[1][i]): return nums[1] return nums[0] nums = sys.stdin.readline().rstrip().split() print(get_bigger(nums)[::-1])
004ba34d4f068c69c32d085326f15274d462ee29
Ponkiruthika112/codeset6
/str_word_rev.py
205
3.609375
4
s=input() j=0 for i in range(0,len(s)): if s[i]==" ": k=s[j:i] j=i+1 print(k[::-1],end=" ") elif i==len(s)-1: k=s[j:i+1] print(k[::-1]) #to print a string
9251527f2636ff1727596fa36d4016a86142facb
davray/lpthw-exercises
/ex11.py
850
4.3125
4
print "How old are you? ", age = raw_input() print "How tall are you? ", height = raw_input() print "How much do you weigh? ", weight = raw_input() print "So, you're %s old, %s tall and you weigh %s." % ( age, height, weight) # Study Drills # 1. Go online and find out what Python's raw_input does. # - raw_input...
9ef06c9ec5ffd97e669336bd761199436b2c3e7b
isakaaby/fys3150
/read_sol_plot.py
779
3.59375
4
import numpy as np import matplotlib.pyplot as plt infile = open("solution.txt", 'r') N = int(infile.readline()) #Filling the start boundaries x = [0] #grid points v = [0] #tridiagonal solutions u = [0] #analytic solutions for line in infile: numbers = line.split() x.append(float(numbers[0])) v....
1b35e0f18f0127e576a99c2cd524f715328b2256
MayuriTambe/Programs
/Programs/DataStructures/Tuples/RepeatedElements.py
188
3.65625
4
Data=(22,54,11,66,4,8,55,22,54,8,4) print("The tuple is:",Data) for i in range(0,len(Data)): for j in range(i+1,len(Data)): if Data[i]==Data[j]: print(Data[i])
b02332acc4534dbfc6d15b5d0d0ac796a32a8996
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/rna-transcription/91c3aec13b2e4f059be9b1bfc3b5da54.py
334
3.828125
4
class DNA(): def __init__(self, dna): self.dna = dna def to_rna(self): rna = '' for nucleotide in self.dna: if nucleotide == 'C': rna += 'C' elif nucleotide == 'G': rna += 'G' elif nucleotide == 'A': rna += 'A' elif nucleotide == 'T': rna += 'U' else: return 'Not a nucleotide'...
40d2beeb87e714f73d75fb67d998173538adc157
mmcelroy75/snippets
/class_objects/dice.py
406
3.65625
4
from random import randint class Die: def __init__(self, sides=6): self.sides = sides def roll_die(self): self.die_roll = randint(1, self.sides) print(self.die_roll) d4 = Die(4) d6 = Die() d8 = Die(8) d10 = Die(10) d12 = Die(12) d20 = Die(20) ''' for i in range(10): d6.roll_di...
ed6ffe0f8e7632854bf1e1af19a1dbcc8ecf7b0e
bpafoshizle/Small-Projects-and-Utils
/TRAGeocoder/TRAGeocoder/GoogleGeocoder.py
1,888
3.671875
4
""" http://www.pythonforbeginners.com/cheatsheet/python-mechanize-cheat-sheet http://stackoverflow.com/questions/5035390/submit-without-the-use-of-a-submit-button-mechanize/6894179#6894179 """ from . import * import requests import json class GoogleGeocoder(object): """ Default init method takes an API key. If no...
81368d92d8fecb20780fe5a61e9878e12899b5dc
chipmonkey/adventofcode2020
/day1part2/runme.py
3,314
3.71875
4
DEBUG = False class filethingy: values = [] def __init__(self): self.values = [] f = open('input.txt', 'r') for line in f: self.values.append(int(line)) print("input: ", self.values) # class find2020s: # mydata = filethingy() # def getfirstresult(self)...
7c83675e9dfe82255ee9a469facc82a7d6864e3d
NJonas184/CS_portfolio
/CSC 356 Machine Learning/multiclassClassifier.py
2,531
3.78125
4
import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np from sklearn.datasets import fetch_openml from sklearn.svm import SVC import pickle #Training a multiclass classifier to #recognize numbers from the mnist dataset. def main(): print("Hello World!") #fetching the information mn...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
47

Collection including LocalResearchGroup/split-avelina-python-edu-decontaminated