blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
9561851f923a17ac51f4717ab4146370544c8448 | VimalJana/guvi | /g9.py | 63 | 3.5 | 4 | n=int(input())
s=0
for i in range(0,n+1):
s+=i
print(s) |
7ed83fe6f8377042b427f1199ec43e7db69bd496 | eswinpalacios/challenges | /easy/increment_by_number_original.py | 681 | 3.59375 | 4 | # Increment a number from [1] => [2]
# [1, 9] => [2, 0]
# [0] => [1, 0]
def increment_by_x(numbers=[], number=1):
index = len(numbers) - 1
carry = number
while carry > 0 and index > -1:
current_number = numbers[index] + carry
numbers[index] = current_number % 10
index = index - 1
... |
0f3be19877bfc0161aca7dd6fffd78a5efb4ee4f | PPL-IIITA/ppl-assignment-newage-newton | /submission1/couple_maker.py | 4,282 | 3.546875 | 4 | #!/usr/bin/env python3
"""Module to make couples."""
from girl_choosy import GirlChoosy
from girl_desparate import GirlDesperate
from girl_normal import GirlNormal
from boy_generous import BoyGenerous
from boy_geek import BoyGeek
from boy_miser import BoyMiser
from utility import Utility
from couple import Couple
fro... |
46253b8e777025059b89ce08e9e4b0ff33645552 | PPL-IIITA/ppl-assignment-newage-newton | /submission1/logger.py | 1,350 | 3.65625 | 4 | #!/usr/bin/env python3
"""Module containing class for logging."""
import csv
import os
from datetime import datetime
class Logger:
"""Class for logging.
Methods:
couple_logger : Log information about couples in csv file format.
gift_logger : Log details of gift exchanges in csv file format.... |
0144f125dcb9c8ddec82cd5dad5aa1a65cae390b | PPL-IIITA/ppl-assignment-newage-newton | /submission2/reader.py | 699 | 3.90625 | 4 | #!/usr/bin/env python3
"""Module containing class to read data from csv files."""
import csv
class Reader:
"""Class for reading data from csv files.
Methods:
readfile : Read a csv file.
"""
@staticmethod
def readfile(name):
"""Read csv file and return list of dictionaries contain... |
1626dbd53b6611f87c1c418f3f3d6d630a9104c7 | ASchneidman/AWAPCMU2018 | /Algo2018/awap2018-competition/src/player_one.py | 12,160 | 3.515625 | 4 | from base_player import BasePlayer
import networkx as nx
import operator
import random
import copy
import inspect
class Player(BasePlayer):
"""
You will implement this class for the competition.
You can add any additional variables / methods in this file.
Do not modify the class name or t... |
2a8ea1f95001015fba07fc2130024b5c6a8375c7 | aashishah/LocalHackDay-Challenges | /EncryptPassword.py | 702 | 4.28125 | 4 | #Using Vignere Cipher to encrpt password of a user using a key that is private to the user.
def encrypt(password, key):
n = len(password)
#Generate key
if len(key) > n:
key = key[0:n]
else:
key = list(key)
for i in range(n - len(key)):
key.append(key[i % len(key)... |
6d8fb9e005a826f3054480c89022a945dfbaabde | octopuschai/algorithms-study | /dijkstra.py | 3,731 | 3.65625 | 4 | graph = {
'start': {
'a': 6,
'b': 2
},
'a': {
'fin': 1
},
'b': {
'a': 3,
'fin': 5
},
'fin': {},
}
graph2 = {
'start': {
'a': 5,
'b': 0
},
'a': {
'c': 15,
'd': 20
},
'b': {
'c': 30,
'd... |
f67808d6a6139427a3992093bad4e1bdd9320cf3 | octopuschai/algorithms-study | /binary_search.py | 373 | 3.75 | 4 | def binary_search(seq, item) -> bool:
low, high = 0, len(seq)
if high == 0:
raise ValueError('Original Seq is empty!')
seq = sorted(seq)
while low < high:
idx = (low + high) // 2
if seq[idx] < item:
low = idx + 1
elif seq[idx] > item:
high = idx
... |
aa82bfaf7cf371753ccd2f10edd1df38b0626357 | RadiumScriptTang/Onmyoji | /test.py | 314 | 3.515625 | 4 | import numpy as np
a = np.array([
[1,2,3,4],
[5,6,7,8],
[9,10,11,12]
])
print(a[[0,2]][:,[1,3]])
miwenList = ["红叶","妖刀","河童","雨女","荒川","大天狗","姑获鸟","镰鼬","小鹿男","海坊主","青行灯","吸血姬","妖狐","清姬","雪童子"]
print(len(miwenList)) |
dc5d39496d290dc624d8bc993d26a672b9ee31a9 | jtagaca/AlgoPractice | /insertionsort.py | 624 | 4.09375 | 4 | def insertionSort():
arr = list(map(int, input().split())) # inputting the number in an array on a single line
for i in range(0, n):
print("enter number: ")
ele = int(input())
arr.append(ele)
count = 0
print("Original array"+str(arr))
for i in range(... |
11fe0af4cf20916b0d666c9e7040c0fbb45fa005 | ThornInJonsSide/puzzling | /wordsearch.py | 4,326 | 3.71875 | 4 | #!/usr/bin/python
# Usage: script -f <grid_file> -l <min_string_length>
"""
Searches the grid for all words of length min_string_length or longer.
Output coordinates use 0,0 at the top left.
The grid file format is:
ABCDEFG
HIGHEED
...
The grid is assumed to be rectangular.
Any non-alphanumeric characters will be stri... |
23ac8865271e2a83d12afcfb5d1938dc471f6c7d | mightybeast11/Python-100-Days | /Day01-15/code/Day02/Exercises_day02.py | 677 | 3.703125 | 4 | # -*- coding:utf-8 -*-
# Author: Zihang
# 1. centigrade
# f = float(input('请输入华氏度:'))
# c = (f - 32) / 1.8
# print('%f 华氏度等于 %f 摄氏度' % (f, c))
# print('%.2f 华氏度等于 %.2f 摄氏度' % (f, c))
# 2. circle
# import math
# r = float(input('Input the radius: '))
# perimeter = 2 * r * math.pi
# area = math.pi * r ** 2
# print('周长... |
f061b607cc08200f55da5e84064c2a8f4ea8b5cb | scotthadzik/ATTC3260 | /Lab4/Lab4.1.4.py | 3,219 | 3.53125 | 4 | #!/usr/bin/env python
import RPi.GPIO as GPIO
import time
PIN_R = 11
PIN_G = 12
PIN_B = 13
GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location
colorOptions = 256 # The number of colors available in an 8 bit number
redColorDefault = colorOptions
blueColorDefault = colorOptions
greenColorDefault = colorOp... |
815566f8ae63dea0e9eba2f781806478c99eafea | Dhana-Sunil-Yalampalepu/driveready | /GCD with recursion.py | 147 | 3.71875 | 4 | def gcd(a,b):
if b==0:
return a
if a>b:
a,b=b,a
return gcd(a,b%2)
a,b=map(int,input().split())
print(gcd(a,b))
|
1e99e669c978889b630a9531d07385cfb5ffe7f7 | wangxf108/Python_basics | /11-25.py | 3,030 | 3.90625 | 4 | # 挺多不会的,主要是根本不知道,还有就是基础的数据类型,各种括号,双引号。要记住。
# # 注意,两个井号的例子,是自己比较不擅长的。
#12 两种方法获得一个10,20,。。200的列表
# my_range = range(10,210,10)
# print(list(my_range))
# my_range = range(1,21)
# print([10 * i for i in my_range])
##13 输出1到21的字符串形式,将str放在my_range前面,定义输出类型。
# my_range = range(1, 21)
# print(list(map(str, my_range)))
... |
dca21c4b07aa505db986dc443ea5682e08edf5fa | JoseRodriguez-CR/Assignment_Dojo_Pets | /Ninja.py | 1,057 | 3.875 | 4 | from Pet import Pet
class Ninja:
# implement __init__( first_name , last_name , treats , pet_food , pet )
def __init__( self, first_name, last_name, pet, treats, pet_food ):
self.first_name = first_name
self.last_name = last_name
self.pet = pet
self.treats = treats
self.... |
bb37b936d120f9ee321a3093e0890f7c164b7544 | Akulinabu/DS_2 | /4.tuple.py | 771 | 3.921875 | 4 | # *** Кортеж (tuple) ***
# неизменяемый (immutable) тип коллекции (структур данных)
my_tuple = (10, 20, 30)
# чтение данных из кортежи
num = my_tuple[-1]
# нельзя менять значения
# my_tuple[0] = 100
# нельзя удалять значения
# del my_tuple[0]
# *** методы ***
# метод который возвращает кол-во элементов опреде... |
15c76b453894e5eb09fcaa195a0a8a66351b1048 | Karlo5o/rosalind_problems | /RNA.py | 700 | 4.1875 | 4 | """
An RNA string is a string formed from the alphabet containing 'A', 'C', 'G', and 'U'.
Given a DNA string t corresponding to a coding strand, its transcribed RNA string u is formed by replacing all occurrences of 'T' in t with 'U' in u.
Given: A DNA string t having length at most 1000 nt.
Return: The transcribed RNA... |
754f597e75b13f141131676d6b87dcf7d5da7639 | jon-chun/undergrad-project | /data/load.py | 347 | 3.71875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 28 15:30:01 2017
@author: finbrown1
"""
import pandas as pd
# define the column names we want and read the data from csv to a panda df
names = ("ID", "Sex", "DoB", "Event", "Distance", "Time", "Date")
data = pd.read_csv("events_best3.csv", heade... |
4823eee1240c2dea4ba46ea13ce7d77579eeb1c5 | ushadevipatturaj/HyperSkillProjects | /Problems/Palindrome/task.py | 165 | 4.03125 | 4 | str_input = input()
str_temp = ''
for x in str_input:
str_temp = x + str_temp
if str_temp == str_input:
print("Palindrome")
else:
print("Not palindrome") |
a2d8eb1fdbaf7d9142e714096c61d533abdda077 | chengdg/Lib | /site-packages/eaglet/utils/string_util.py | 2,142 | 3.78125 | 4 | # -*- coding: utf-8 -*-
__author__ = 'chuter'
import binascii
def __is_hex_char(char):
assert (char is not None)
char = char.upper()
return (ord(char) >= ord('0') and ord(char) <= ord('9')) or\
(ord(char) >= ord('A') and ord(char) <= ord('F'))
def is_hax_str(hex_str):
if hex_str is None or... |
24ba976ed34048272c992c6a8ed0878cefa7ea94 | mustafadag525/python | /quiz 1.py | 445 | 3.546875 | 4 | import random
min_fark = 101
s2 = 201
while True:
s1 = random.randint(1,100)
print("{} ".format(s1))
gecici = s2 - s1
if gecici < 0:
gecici = gecici * -1
if gecici <= min_fark:
min_fark = gecici
min1 = s1
min2 = s2
s2 = s1
if (s1 >= 70 and s1 ... |
d6c9481fd67e920623b9c3ac06f98d0051db1c95 | SaulAlekss/clienteservidor | /listas.py | 1,328 | 4.5625 | 5 | def main():
# Una lista es una estructura de datos en python
# # La ventaja aceptan datos de tipos distintos
# # Creamos una lista
lista = [1,23.01, False, "hola lista", "A",[-1,-5, "hola", 0.0], -12,"A"]
# Lista Vacia
listaVacia = []
# Accesando a elementos de la lista
for elemento in l... |
e2d244bf8f2e314a835e2ab6972a0fb6cd7b4b24 | DasHache/LearnProgramming | /timer.py | 941 | 3.609375 | 4 | from threading import Timer
# class InfiniteLoopTimer:
# def __init__(self, w, obj, obj_method_name, dt=1):
# self.stopped = False
# self.o = obj
# self.omn = obj_method_name
# self.dt = dt
# def start(self):
# self.t = Timer(self.dt, self.callback)
# self.t.st... |
30d8f36f830653c2ba102e94f89598b57cebc046 | DasHache/LearnProgramming | /create.py | 697 | 3.84375 | 4 | import Tkinter as Tk
print "which color do you want for the background?"
color = raw_input("blue, red, brown, white, black?")
canvas = Tk.Canvas(width=300, height=300, bg=color)
canvas.pack()
ground = canvas.create_rectangle(300, 300, 0, 250, fill='brown')
figure = raw_input("what figure do you want to create?")
col... |
899fca92b68c6528da4c8b776ec589ff6c6c4e54 | abdoun-206/Booking-Quote-System | /src/booking_quote_system/Menu.py | 5,314 | 3.65625 | 4 | import sys
import csv
from datetime import datetime
from booking_quote_system.Package import Package
from booking_quote_system.PackageManager import PackageManager
from booking_quote_system.Rules import determine_shipping
class Menu:
"""Displays a list of options on the terminal for the user to run"""
def _... |
08bb415e8ea413298a029be6d66dc11559ee2643 | sjmirmoeini/python-_traning | /recursive-functions/string_permutation.py | 580 | 3.75 | 4 |
class Permutation:
def __init__(self,text):
self.result = []
self.text = text
self.permutation(self.text)
def __call__(self):
return self.result
def permutation(self,text,step=0):
if step==len(text):
self.result.append(''.join(text))
... |
d97a61166687dfe757ac15ad8f0a9096359f304a | ChrisBarnes2000-MS-DU/SPD-2.31-Testing-and-Architecture | /lab/refactoring/Refactoring_Simplifying_Conditional_Expressions/consolidate_conditional.py | 742 | 3.59375 | 4 | # by Kami Bigdely
# Consolidate conditional expressions
def dice(ingredients):
print("diced all ingredients.")
def mix_all(diced_ingredients):
print("mixed all.")
def add_salt():
print('added salt.')
def pour(liquid):
print('poured', liquid + '.',)
def make_shirazi_salad(ingredients):
if (... |
4a4b022cfa3c06d2406ee0c1a6340771fd65e399 | ChrisBarnes2000-MS-DU/SPD-2.31-Testing-and-Architecture | /final-exam/tic_tac_toe_messy.py | 7,578 | 3.875 | 4 | # Tic Tac Toe
# Reference: With modification from http://inventwithpython.com/chapter10.html.
import random
import sys
NUMBER_SPACES = 10
PLAYER_LETTER = ''
COMPUTER_LETTER = ''
NEXT_MOVE = 0
VERBOSE = False
BORDER = False
# !! Board Functionality
def drawBoard(board):
"""This function prints out the board that... |
b99e0dbe26ae32591aa438669c0e6efa88f29baa | vijayarohini/Vijaya-Rohini | /digits.py | 77 | 3.640625 | 4 | num=int(input())
count=0
while(num>0)
count=count+1
num=num//10
print(count)
|
026dc1b18a137b56dd4e9047a119527f35d16433 | marcusiq/w_python | /pythagorean_tree.py | 1,097 | 4 | 4 | import numpy as np
# Define the column vector (3, 4, 5).T which will be the root of our ternary tree.
# The T denotes transpose.
print "Explore the tree of primitive Pythagorean triples.\n".title()
x = np.matrix([[3, 4, 5]]).T # The T gives us the transpose.
print "The vector x containing the root of the pythagorean... |
d516d08d9c1af9bce8e845f69552a45377b6696b | marcusiq/w_python | /greeting.py | 1,570 | 4.4375 | 4 |
"""
Generally. There is no method overloading in python.
Overloading in other languages occurs when two methods have the same name, but different numbers of arguments.
In python, if you give more than one definition using the same name,
the last one entered rules, and any previous definitions are ignored.
"""
# Her... |
7c3e75e6fdaddead4b3b3d00f10da680ea031b12 | carlalopxz/Ejercicios-de-DFD | /1. Ejercicios de diagrama de flujo/Ciclos y Bucles/39_suma_n_numeros.py | 135 | 3.921875 | 4 | num = int(input('Digite un número \n'))
suma = 0
for i in range(num+1):
suma = suma + i
print(f'La suma total es de: {suma}') |
2d660501e4438242b74a3a4ff106d65e12c13fe4 | carlalopxz/Ejercicios-de-DFD | /1. Ejercicios de diagrama de flujo/Operadores/16_volumen_area_esfera.py | 287 | 3.78125 | 4 | #EJERCICIO 16
radioEsfera = 0
print('Digite el valor del radio de la esfera')
radioEsfera = int(input())
area = 4 * 3.14 * radioEsfera**2
volumen = (4/3) * 3.14 * radioEsfera**3
print('El area de la esfera es de: ' + str(area))
print('El volumen de la esfera es de: ' + str(volumen)) |
08a65aed72b814f99c18cddcf34e87642b248b7f | carlalopxz/Ejercicios-de-DFD | /1. Ejercicios de diagrama de flujo/Operadores/13_porcentaje_alumnos.py | 534 | 3.84375 | 4 | #EJERCICIO 13
cantidadMujeres = 0
cantidadVarones = 0
print('Digite la cantidad de alumnas mujeres y alumnos varones')
cantidadMujeres = int(input())
cantidadVarones = int(input())
cantidadTotalAlumnos = cantidadMujeres + cantidadVarones
porcentajeMujeres = (cantidadMujeres*100) / cantidadTotalAlumnos
porcentajeV... |
98dc231e567433d4a6a16523dcc1f602adb97059 | carlalopxz/Ejercicios-de-DFD | /1. Ejercicios de diagrama de flujo/Ciclos y Bucles/43_suma_pares_e_impares.py | 256 | 3.8125 | 4 | num = int(input('Digite un número \n'))
sumaA = 0
sumaB = 0
for i in range(1,num+1):
if i % 2 == 0:
n = i * (-1)
sumaA = sumaA + n
else:
sumaB = sumaB + i
sumaTotal = sumaA + sumaB
print(f'La suma total es de {sumaTotal}') |
4847bf84c91506784831788cf43a24e76e38e035 | carlalopxz/Ejercicios-de-DFD | /1. Ejercicios de diagrama de flujo/Ciclos y Bucles/49_num_pares.py | 246 | 3.828125 | 4 | num = int(input('Ingrese un número \n'))
suma = 0
cont = 0
i = 0
while i <= num:
i = i + 1
if i % 2 == 0:
suma = suma + i
cont = cont + 1
print(f'La suma de los números pares es de {suma} y son {cont} números pares') |
ba792e273deaaac9a690f6663a9d7ddb02df37c1 | carlalopxz/Ejercicios-de-DFD | /1. Ejercicios de diagrama de flujo/Ciclos y Bucles/46_factorial.py | 201 | 4.0625 | 4 | num = int(input('Digite un número para sacar su factorial \n'))
i = 1
factorial = 1
while i <= num:
factorial = factorial * i
i = i + 1
print(f'El factorial del número {num} es {factorial}')
|
4fd7d7d3fdf45e210e092fdbfabc2a75cf5d11d2 | carlalopxz/Ejercicios-de-DFD | /1. Ejercicios de diagrama de flujo/Condicionales/35_suma_3numeros.py | 258 | 3.9375 | 4 | x = int(input('Ingrese un número X \n'))
y = int(input('Ingrese un número Y \n'))
z = int(input('Ingrese un número Z \n'))
if x + y == z:
print(f'La suma de {x} + {y} es = {z}')
else:
print(f'{z} no es el resultado de la suma entre {x} y {y}')
|
d0bbee89f7522a28ca4eef2fc007b6d2fa446acf | SurendraTamang/eulerProblems | /q7.py | 854 | 3.765625 | 4 | #!/usr/bin/env python
"""
q7.py - Project Euler Question No. 7- 10001st prime
By listing the first six prime numbers: 2, 3, 5,
7, 11, and 13,
we can see that the 6th prime is 13.
What is the 10 001st prime number?
Question Link:- https://projecteuler.net/problem=7
Program Written By :- Surendra Tamang
"""
def solv... |
d87a412e176c92b6ba8799d5d0ef124273e21a4c | gansell/python | /python examples/decorators/argcheck.py | 878 | 3.8125 | 4 | """Check function arguments for given type.
"""
import functools
def check(*argtypes):
"""Function argument type checker.
"""
def _check(func):
"""Takes the function.
"""
@functools.wraps(func)
def __check(*args):
"""Takes the arguments
"""
... |
a967ce911478c70450a2df49825d76d980b64992 | adamelliott1982/1359_Python_Benavides | /playground/sandbox.py | 193 | 4 | 4 | foods = ['lasagna', 'spaghetti', 'ravioli', 'manicotti']
for food in foods:
print(food)
for food in foods:
print('I love ' + food)
for x in (range(len(foods))):
print(x) |
0db7eaa487bf54eb30f885b7baf11d93dfd6eabd | adamelliott1982/1359_Python_Benavides | /lab_04/1359-lab_04/drop_grade.py | 1,549 | 4.34375 | 4 | # Program: drop_grade.py
# Programmer: Adam Elliott
# Date: 02/26/2021
# Description: lab 4 - lists and for statements
########################################################
# create list of 5 grades and initialize
grades = [100, 80, 70, 60, 90]
# print report name – DROP LOWEST GRADE PROGRAM
print('DRO... |
90aebac8a06199b3da4b53c1792b34b6be97c7c3 | giodamelio/git-shell-info | /scripts/char-list-to-string.py | 265 | 3.9375 | 4 | #!/usr/bin/env python
import sys
if (len(sys.argv) != 2):
print("You MUST pass in a comma seperated list of ascii chars in decimal format")
sys.exit(1);
chars = sys.argv[1]
chars = chars.split(",")
print(''.join(chr(int(charcode)) for charcode in chars))
|
602ad097fb31bc2db048fbc35576252a4f945ad4 | pseeej/BackEnd | /Python/1. python_basic/section05-2.py | 2,238 | 4.0625 | 4 | # section 05-2
# python 흐름제어 (반복문)
# 반복문 실습
# 코딩의 핵심 -> 조건 해결 중요
# 기본 반복문 : for, while
v1 = 1
while v1<11:
print("v1 is :", v1)
v1 += 1
print()
for v2 in range(10): #0부터 9까지
print("v2 is :", v2)
print()
for v3 in range(1, 11): #1부터 10까지
print("v3 is :", v3)
print()
# 1~100 합
sum1 = 0
cnt1 =... |
ee5a69761807f45f69cda371e3a6e7b092ece02e | AldoRastrelli/SVG-Image-Creator | /pila.py | 648 | 3.9375 | 4 | class Pila:
"""define una clase Pila"""
def __init__(self):
"""constructor de la clase"""
self.items = []
def esta_vacia(self):
"""indica si la pila está vacía"""
if not self.items:
return True
return False
def apilar(self,item):
... |
3f1cbefa03d75462895a7b7d1803e5ad9684b60b | shiney5213/Study-Programming | /python/SBA_bigdata_python/1.python_basic/0813 data type.py | 932 | 3.84375 | 4 | # 논리형
x = 4
y = 9
print("x == y", x == y)
print('x !=y', x !=y)
print('x<y', x<y)
print('x>y', x>y)
print('int(True)=', int(True)) # 1
print('int(False=)', int(False)) # 0
print(True or False) # True
print('x or y', x or y) #4
print('x and y', x and y) #9
print('not x', not x) # False
# is, is not
print(1 =... |
11772f37a4885f1b240c1ed419d621fb14391f77 | shiney5213/Study-Programming | /python/SBA_bigdata_python/1.python_basic/modules/fibo.py | 439 | 3.859375 | 4 | def fib(n):
'''
n까지의 피보나치 수열을 출력하는 함수
:param n: Integer
:return: None
'''
a, b = 0, 1
while b < n:
print(b, end='')
a, b = b, a + b
print()
def fib2(n):
'''
n까지의 피보나치 수열을 반환하는 함수
:param n: Integer
:return: List
'''
result = []
a, b= 0, 1
w... |
7f0dff5bb913022f1f7962886a8eb755708ebaa7 | shiney5213/Study-Programming | /python/SBA_bigdata_python/1.python_basic/0813_datastructure_set.py | 543 | 3.78125 | 4 | # set
# set형 집합 연산자
a = set('abracadabra')
b = set('alacazam')
print('집합 a =', a)
print('집합 b =', b)
print('합집합 a | b =',a | b)
print('교집합 a & b =', a & b)
print('차집합 a - b =', a - b)
print('여집합, a ^ b =', a ^ b)
# 중복 제거 및 정렬
beast = ['lion','tiger','wolf','tiger','lion','bear','lion']
print('beast =', beast)
uniq... |
09a686fa553e9e94b734a57c84286a01452d4737 | Mahima1199/258382_daily_commit | /third.py | 145 | 3.671875 | 4 | x = 12
if(x>5):
print("Number greater than 5")
if x > 47:
pass
else:
print("Number greater than 5 and less than 4")
|
d2925f49653c748c9d713595e99f1f4084b6fab9 | Mahima1199/258382_daily_commit | /Dictionaries.py | 253 | 3.59375 | 4 | primary = {"red":[255,0,0],"green":[0,255,0],"blue":[0,0,255]}
print(primary["red"])
print(primary["blue"])
primes = {1:2,2:3,4:7,7:17}
print(primes[primes[4]])
nums = {1:"one",2:"two",3:"three"}
print(1 in nums)
print(2 in nums)
print(4 not in nums)
|
3253b50172bad91f99374be912d905485611ab9e | iFreet1/skillfactory-module-B6.10.4-Egorov | /guest.py | 695 | 3.765625 | 4 | class Person:
def __init__(self, name, city):
self.name = name
self.city = city
def get_person_data(self):
return f'{self.name}, {self.city}'
class Guest(Person):
STATUS = '"Гость"'
def __init__(self, name, city):
self.name = name
self.city = cit... |
8aae644945e9d329181679c4edb7a31192212500 | thatothupudi/thatothupudi-Animal-Part1OOP | /dog.py | 368 | 3.6875 | 4 | from animal import Animal
class Dog(Animal):
def __init__(self,petname,sound,eats):
super().__init__(petname,sound,eats)
def eat(self):
print(self.eats)
return "{0}".format(self.eats)
def sounds(self):
print(self.sound)
return "{0}".format(self.sound)
dog1 = Dog(... |
982717fe70d36ae712eb70a9018098a237f25fa8 | hiramf/MovieTrailerWebsite | /best_picture_nominations.py | 3,526 | 3.578125 | 4 | import fresh_tomatoes # fresh_tomatoes contains the website structure
import webbrowser
# tmdbsimple is an API for retrieving information about movies
import tmdbsimple as tmdb
tmdb.API_KEY = "[your key here]"
class Movie():
def __init__(self, movie_title, poster_url, youtube_url, tmdb_id):
self.movie_ti... |
a47cf0347668bb09dee994258efb0e104d6646fc | AiramL/Python-Exercicios | /fatorial.py | 442 | 4.03125 | 4 | '''
Aluno: Lucas Airam Castro de Souza
Programa para calcular fatorial de um numero n
'''
def fatorial(numero):
if (numero == 0) or (numero == 1):
return numero
elif (((type(numero)!=long) or (type(numero)!=int)) and (numero<0)):
return "Operacao definida apenas para o conjunto dos numeros in... |
9c884bca9341c9819dd4aa506de9e0c318d268b4 | rockgarden/python_demo | /code/test.py | 3,302 | 4.03125 | 4 | import unittest
from name_function import get_formatted_name
# 测试方法
# 在 PyCharm 中必须通过 Run File in Console 执行,因为 PyCharm 有自带的 Unittests 模块
# 也可在环境中将默认测试unittest框架改为py.test
# File->setting->Tools->Python Intergrated Tools->Default test runner->py.test
# test_ 开头的方法都将自动运行
class NamesTestCase(unittest.TestCase):
"""... |
178776fb6b78e69855f8e07bbc5dfe6f1f45e522 | rockgarden/python_demo | /code/模块.py | 12,022 | 3.796875 | 4 | '''
Python 提供了一个办法,把这些定义存放在文件中,为一些脚本或者交互式的解释器实例使用,这个文件被称为模块。
模块是一个包含所有你定义的函数和变量的文件,其后缀名是.py。模块可以被别的程序引入,以使用该模块中的函数等功能。这也是使用 python 标准库的方法。
$ python using_sys.py 参数1 参数2
命令行参数如下:
using_sys.py
参数1
参数2
'''
# 1、import sys 引入 python 标准库中的 sys.py 模块;这是引入某一模块的方法。
# 2、sys.argv 是一个包含命令行参数的列表。
# 3、sys.path 包含了一个 Python 解释器自动查找所... |
f42eae6e132785e1d525f852cfc8843df4e3129a | rockgarden/python_demo | /code/file.py | 3,169 | 3.90625 | 4 | # IMPORT: 由于 python work directory 为 /Volumes/Data/GitHub/python_demo/code
# 所以 相对路径不能包含 code
filename = 'assets/pi_million_digits.txt'
with open(filename) as file_object:
lines = file_object.readlines()
pi_string = ''
for line in lines:
pi_string += line.rstrip()
print(pi_string + "\n" + str(len(pi_string)))
b... |
8b78ce5023f9a09242249424cec8a1acac108b75 | afrlv1/Algorithms | /TS_01.py | 4,690 | 3.921875 | 4 | from typing import Optional, List
class Matrix:
"""
Код нашего коллеги аналитика очень медленный и тяжелый для восприятия. Ваша задача сделать его быстрее и проще.
"""
def __init__(self):
self.matrix = [[None]]
def matrix_scale(self, matrix: List[List[Optional[object]]], scale_up: bool) -... |
ad88813e80a73228b67bab94e90dc9ae2186344e | kashython/wiki_mining | /wiki_speak.py | 324 | 3.578125 | 4 | '''
Will take query from user and reply appropriate answer from wikipedia
'''
import sys
import wiki_mining as wm
query = sys.argv[1:]
query = "when is Anil Kapoor's b'day"
print('Query :', query)
wm_object = wm.WikiMining(query=query)
# wm_object.get_wiki_bday("Anil Kapoor")
# wm_object.get_wiki_def("neural ne... |
d0ef50ff24d8cbfa77224bc3615fd2bba4744268 | stefano54321/aaa | /untitled2.py | 1,788 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 24 15:14:41 2018
@author: stefa
"""
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 21 17:48:19 2018
@author: stefa
"""
import numpy as np
def swap(mat, i, j):
mat[i], mat[j] = mat[j], mat[i]
#eliminare swap
def find_pivot(mat, start, col):
... |
463175dc0170b56d92304e9dad4884da6b62bdd4 | Marcfeitosa/Cursoemvideo-Python | /ex000.py | 176 | 3.78125 | 4 | print('Olá Mundo!!!')
x_str=input('Primeiro número: ')
y_str=input('Segundo número: ')
x_int = int(x_str)
y_int = int(y_str)
soma = x_int + y_int
print ('A soma é', soma) |
fca12342901e0000da4aac85ae4dbda923a67c78 | Marcfeitosa/Cursoemvideo-Python | /aula15.py | 1,833 | 3.71875 | 4 | n = s = c = 0
while True:
n = int(input("Digite um número: "))
if n == 999:
break
c += 1
s += n
print(f'A soma dos {c} valores é {s}.')
"""Desafio 066
Crie um programa que leia vários números inteiros pelo teclado. O programa só vai parar quando o usuário digitar o valor
999, que é a... |
46087c7fb3aa69ffc6f67238d07e5b9fd1602edc | camamu/BloGAE | /samples/in_op.py | 212 | 3.890625 | 4 | # El operador in
numeros = [1,2,3,4]
3 in numeros #returns True
5 in numeros #returns False
cadena "abcde"
"a" in cadena #returns True
"vsb" in cadena #returns False
for numero in numeros:
print str(numero) |
0716dea37f8df26e54ffaae7bb69b36026739986 | amitmorag/Shopping-cart---python-OOP | /item.py | 763 | 3.65625 | 4 | class Item:
def __init__(self, item_name: str, item_price: int, item_hashtags: list, item_description: str):
self.name = item_name
self.price = item_price
self.hashtags = item_hashtags
self.description = item_description
'''function to compare between two items
params:
... |
8c2a6954dbcdb20dba141975559470e8b04ad921 | BenjaminLivingstone/fundamentos-python | /Otros/ejerciciopython1.py | 1,116 | 4.1875 | 4 | # GRUPO 2:
# Crea una funcion que dado una palabra diga si es palindroma o no.
def palindroma(palabra):
if ("hola"[::-1]==palabra):
print("La palabra",palabra,"es palindroma")
else:
print("La palabra",palabra,"NO es palindroma")
palabra="hola";
palindroma(palabra)
palabra="python"
print(palab... |
f371184ca3169f6fffe54319969f8ed2cf8ef2d6 | DishT/Python100- | /ex2.py | 297 | 4.1875 | 4 | def factorial(num):
number = 1
for i in range(int(num)):
number = (i+1)*number
print (number)
# 8! = 8 * 7!....... , 0! = 1
def factorial_2(num):
if num == 0 :
return 1
else:
return num * factorial_2(num-1)
def factorial_3(num):
num = input()
factorial(num)
print (factorial_2(num)) |
eb85f65ab6ec3ce4111fc10d12ee42deee4d992e | DishT/Python100- | /python_100_ex4.py | 233 | 3.8125 | 4 | # from structshape import structshape
value = input("Input your number")
store_list = value.split(",")
store_tuple = tuple(value.split(","))
print (store_list, structshape(store_list))
print (store_tuple, structshape(store_tuple))
|
c00b2a4ab9e2f3e147a84d521140457c7cbad59b | DishT/Python100- | /python_100_ex23.py | 505 | 3.765625 | 4 | def caculate(num):
''' Return the square value of the input number.
The input number must be integer.
'''
return num**2
print (caculate(3))
print (abs.__doc__)
print (int.__doc__)
print (input.__doc__)
print (caculate.__doc__)
class Person:
name = "Person"
def __init__(self, name = Non... |
bc4221e253e08010368f9a20d3cb70d9abd6458f | DishT/Python100- | /python_100_ex25.py | 466 | 3.734375 | 4 | class American:
@staticmethod
def printNationality():
print("America")
class NewYorker(American):
def OK(self):
print("GOGO")
class Circle:
radius = 0
def __init__(self,r):
self.radius = r
def area(self):
return self.radius**2*3.14
anAmerican = American()
print("Object A")
anAmerican.printNationalit... |
743a8fd4673bbd7e8730ba0ce7a289ee3135b9ed | marc-p-greenfield/tutor_sessions | /minimum_input.py | 180 | 3.6875 | 4 | def min2(value1, value2=0):
return min(x, z)
input1 = int(input("Gvie a value:"))
input2 = int(input("Give another value:"))
print (min2(input1))
print (min2(input1,input2))
|
37ac60fa04dbaed484d77e43317c6069a26ad777 | marc-p-greenfield/tutor_sessions | /payment_system.py | 602 | 4.21875 | 4 | number_of_employees = int(input("How many employees do you want to enter:"))
total_payment = 0
for i in range(number_of_employees):
name = input('Please enter name: ')
hours = float(input('How many hours did you work this week? '))
rate = float(input('What is your hourly rate?'))
payment = 0
overt... |
94a8bf4906c88a2d708ba4fb9ac84eaf452af1aa | Sdoof/Trapyng | /libs/BBBLSTM/tf_general_model1.py | 9,819 | 3.90625 | 4 | """
In this document we will perform a basic Linear Regression including TensorBoard.
It is a very simple manual program with no proper naming of the variables.
We will:
- Use the conditional in the huber loss.
- We can also save the model parameters.
"""
from __future__ import absolute_import
from __future__ ... |
c5dea7448fd96e7db1483ef2f64f4653849507fb | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch08/lab_8_4.py | 798 | 3.9375 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# LAB 8-4 파일에서 중복되지 않은 단어의 개수 구하기, 212쪽
#
# 단어에서 구두점을 제거하고 소문자로 만든다.
def process(w):
output =""
for ch in w:
if ch.isalpha() :
output += ch
return output.lower()
words = set() # 중복을 방지하기 위해 집합 자료형에 단어를 넣자
fname = input("입력 파일 이름: ")
file = o... |
34389df6a6f342bb5d57ca08ddbc83368f4f71a5 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch11/lab_11_2.py | 362 | 3.6875 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# LAB 11-2 삼각함수의 기본인 사인 그래프 그리기, 289쪽
#
import math
import matplotlib.pyplot as plt
x = []
y = []
for angle in range(360):
x.append(angle)
y.append(math.sin(math.radians(angle)))
plt.plot(x, y)
plt.title("SINE WAVE")
plt.show() |
6669e316fceb73aa26b4e54dbfbb2bee2d81f001 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch04/lab_4_6.py | 335 | 3.765625 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# LAB 4-6 원의 내부에 있는 점일까 외부에 있는 점일까, 106쪽
#
x, y = map(float, input('점의 좌표 x, y를 입력하시오 : ').split())
if x*x + y*y > 5*5:
print('원의 외부에 있음')
else:
print('원의 내부에 있음') |
3fb6661084689aa95cc51353f940077099a3f548 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch11/code_11_15_1.py | 473 | 3.796875 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 11.15 한 화면에 여러 그래프 그리기 : subplots(), 299쪽
#
import matplotlib.pyplot as plt
# 갯수가 2 x 2개, 크기가 (5, 5) 인치
fig, ax = plt.subplots(2, 2, figsize=(5, 5))
ax[0, 0].plot(range(10), 'r') # row=0, col=0
ax[1, 0].plot(range(10), 'b') # row=1, col=0
ax[0, 1].plot(range(10), 'g') # row... |
3cb34750e6584271f74494e7b7b9c574f37207b4 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch10/code_10_5.py | 458 | 4 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 10.5 강력한 넘파이 배열의 연산을 알아보자, 255쪽
#
import numpy as np
salary = np.array([220, 250, 230])
salary = salary + 100
print(salary)
##################################
salary = np.array([220, 250, 230])
salary = salary * 2
print(salary)
#################################
salary = np... |
175704e317c0b6ea47276da8f7df047918501ad8 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch08/code_8_10_3.py | 506 | 3.734375 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 8.10 두 수의 약수와 최대공약수 그리고 프로그래밍적인 사고, 213쪽
#
def get_divisors(num): # num의 약수를 집합형으로 반환함
divisors = set()
for i in range(2, num):
if num % i == 0:
divisors.add(i)
return divisors
x = 48
y = 60
A = get_divisors(x)
B = get_divisors(y)
print(A.inte... |
b83f1a5f105c8f6baaf149f1282e81aa57074dd9 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch03/code_3_4.py | 470 | 3.953125 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 3.4 컴퓨터 과학에서 아주 중요한 나머지 연산자 : %, 73쪽
#
p = int(input("분자를 입력하시오: "))
q = int(input("분모를 입력하시오: "))
print("나눗셈의 몫 =", p // q)
print("나눗셈의 나머지 =", p % q)
number = int(input("정수를 입력하시오: "))
print(number % 2) # 나머지로 연산의 결과가 0이면 짝수, 1이면 홀수이다 |
2b56edd29e6fcb81e5bb17a04b25a983651caed2 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch06/lab_6_6.py | 468 | 3.8125 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# LAB 6-6 거북이에게 이차함수를 그리게 하자, 162쪽
#
import turtle
t = turtle.Turtle()
t.shape("turtle")
t.speed(0) # 터틀 그래픽의 그리기 속도를 가장 빠르게 한다
def f(x): # 2차 함수를 만든다
return x ** 2 + 1
t.goto(200, 0)
t.goto(0, 0)
t.goto(0, 200)
t.goto(0, 0)
for x in range(150):
t.goto(x, int(0.01 * f(x... |
a9f5a386203fe02efc9f289408744aef6e326c57 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch08/code_8_6.py | 392 | 4.125 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 8.6 집합의 항목에 접근하는 연산, 207쪽
#
numbers = {2, 1, 3}
if 1 in numbers: # 1이라는 항목이 numbers 집합에 있는가 검사
print("집합 안에 1이 있습니다.")
numbers = {2, 1, 3}
for x in numbers:
print(x, end=" ")
for x in sorted(numbers):
print(x, end=" ") |
3223bec557c82c376ec80a151ecacad098cf229c | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch03/code_3_5.py | 416 | 4.0625 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 3.5 거듭제곱 연산자 : **, 74쪽
#
a = 1000
r = 0.05
n = 10
print(a * (1 + r) ** n)
bottom = float(input('직각삼각형의 밑변의 길이를 입력하시오: '))
height = float(input('직각삼각형의 높이를 입력하시오: '))
hypotenuse = (bottom ** 2 + height ** 2) ** 0.5
print('빗변은', hypotenuse, '입니다') |
3c3163f151a9fab4b15e55bdf209d62df7c02326 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch07/lab_7_6.py | 855 | 3.828125 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# LAB 7-6 도시의 이름과 인구를 튜플로 묶어보자, 192쪽
#
# 다음과 같은 리스트가 생성되어 있다.
city_info = [('서울', 9765), ('부산', 3441), ('인천', 2954),
('광주', 1501), ('대전', 1531)]
max_pop = 0
min_pop = 999999999999999999
total_pop = 0
max_city = None
min_city = None
for city in city_info:
total_po... |
f55269d68528514d821361658050722dacf8e29e | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch02/lab_2_4.py | 348 | 3.625 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# LAB 2-4 복리 이자 계산하기, 52쪽
#
principal = 10000000
years = 5
interest_rate = 0.03
money = principal * (1.0 + interest_rate) ** years
print('원금: ', principal)
print('이율: ', interest_rate)
print('기간: ', years)
print('수령금액: ', money) |
c5c66f2969c93fe22b3833f48eec1eba8c9b23df | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch12/code_12_5_1.py | 392 | 3.859375 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 12.5 CSV에서 원하는 데이터를 뽑아 보자, 310쪽
#
import csv
f = open('d:/data/weather.csv') # CSV 파일을 열어서 f에 저장한다.
data = csv.reader(f) # reader() 함수를 이용하여 읽는다.
header = next(data)
for row in data:
print(row[3], end=',')
f.close() |
1e330033a702ac1eff3b96cf58d7158692401275 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch05/lab_5_4.py | 365 | 3.84375 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# LAB 5-4 술에 취한 거북이를 그리는 랜덤 함수, 125쪽
#
import turtle
import random
t = turtle.Turtle()
t.shape("turtle")
for i in range(30):
length = random.randint(1, 100)
t.forward(length)
angle = random.randint(-180, 180)
t.right(angle)
turtle.done() |
01c44d23930540810b62756b5bfa61d5a599bed5 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch05/lab_5_7.py | 263 | 3.671875 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# LAB 5-7 입력받은 수를 사용하는 구구단 출력, 130쪽
#
dan = int(input("원하는 단은: "))
i = 1
while i <= 9:
print("%s*%s=%s" % (dan, i, dan * i))
i = i + 1 |
9ab0e069f0e078fde005840a8085c05f696ff9a9 | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch07/code_7_14.py | 249 | 3.5625 | 4 | #
# 따라하며 배우는 파이썬과 데이터과학(생능출판사 2020)
# 7.14 조건이 붙는 리스트 함축 표현도 가능하다, 189쪽
#
s = ["Hello", "12345", "World", "67890"]
numbers = [x for x in s if x.isdigit()]
print(numbers) |
3a0ef9a34871283e22aa125eee7597adf67b974a | jinseoo/DataSciPy | /src/파이썬코드(py)/Ch06/code_6_10.py | 453 | 3.5 | 4 | def order(num, pickle, onion):
print('햄버거 {0} 개 - 피클 {1}, 양파 {2}'.format(num, pickle, onion))
order(1, False, True)
######################################################################
def order(num, pickle=True, onion=True):
print('햄버거 {0} 개 - 피클 {1}, 양파 {2}'.format(num, pickle, onion))
order(1, pickl... |
9aa3f37b8c778f8834c946a86e8cd2e067b4454d | camorazrushimoe/projecteuler | /10done.py | 683 | 3.953125 | 4 | #Сумма простых чисел меньше 10 равна 2 + 3 + 5 + 7 = 17.
#Найдите сумму всех простых чисел меньше двух миллионов.
def get_primes(n):
numbers = set(range(n, 1, -1))
primes = []
while numbers:
p = numbers.pop()
primes.append(p)
numbers.difference_update(set(range(p*2, n+1, p)))
re... |
f26e9e6bc1103c6c72fbe0fc72ed2435b62281ad | KishoreMayank/CodingChallenges | /Cracking the Coding Interview/Arrays and Strings/StringRotation.py | 349 | 4.1875 | 4 | '''
String Rotation:
Check if s2 is a rotation of s1 using only one call to isSubstring
'''
def is_substring(string, sub):
return string.find(sub) != -1
def string_rotation(s1, s2):
if len(s1) == len(s2) and len(s1) != 0:
return is_substring(s1 + s1, s2) # adds the two strings together and calls ... |
83a5cf777c580996e4c02f49f41d0cca5e1c4d0f | KishoreMayank/CodingChallenges | /Interview Cake/Linked Lists/FindRepeat.py | 1,480 | 4 | 4 | '''
Find Repeat:
We can find a duplicate integer in O(n) time while keeping our space cost at O(1).
'''
def find_duplicate(int_list):
n = len(int_list) - 1
# STEP 1: GET INSIDE A CYCLE
# Start at position n+1 and walk n steps to
# find a position guaranteed to be in a cycle
curr = n + 1
fo... |
01be02c1dc7f758cb026de11b2bece1878bc9345 | KishoreMayank/CodingChallenges | /Interview Cake/Greedy/MaxProfit.py | 738 | 3.734375 | 4 | '''
Max Profit:
Write an efficient function that takes stock_prices and returns the best profit
I could have made from one purchase and one sale of one share of Apple stock yesterday.
Input: [10, 7, 5, 8, 11, 9]
Output: 6
'''
def get_max_profit(stock_prices):
if len(stock_prices) < 2:
rais... |
b5d3beb20cc86479f91f35db74f4f4a87bd54dc4 | KishoreMayank/CodingChallenges | /Interview Cake/Stacks and Queues/MaxStack.py | 821 | 4.3125 | 4 | '''
Max Stack:
Use your Stack class to implement a new class MaxStack with a
method get_max() that returns the largest element in the stack.
'''
class MaxStack(object):
def __init__(self):
self.stack = []
self.max = []
def push(self, item):
"""Add a new item to the top o... |
e707b179164af07c59e45c2810e343344220996c | KishoreMayank/CodingChallenges | /Cracking the Coding Interview/Recursion and Dynamic Programming/TripleStep.py | 440 | 3.90625 | 4 | '''
Triple Step:
A child can run up and hop 1, 2, or 3 steps at a time. How many ways can it make it up the stairs
'''
# DYNAMIC PROGRAMMING (TOP - DOWN)
memo = {0:1, 1:1, 2:2}
def triple_step(n):
if n in memo:
return memo[n]
memo[n] = triple_step(n - 1) + triple_step(n - 2) + triple_step(n - 3) #... |
c61156ce91081f2f2a4521efb6280ddb9c8d3c45 | KishoreMayank/CodingChallenges | /Interview Cake/Recursion and Dynamic Programming/CoinChange.py | 510 | 3.984375 | 4 | '''
Coin Change:
Find the number of ways to make change for a certain amount
'''
def coin_change(amount, coins):
combos = [0] * (amount + 1) # create an array of size amount + 1
combos[0] = 1 # initialize the number of ways to get 0 coins (1 way)
for coin in coins:
for i in range(coin, am... |
7e498a26ca8743db5184643dc698628d413fb55b | Lord-Chronos/SpaceSheep | /gui.py | 1,282 | 3.796875 | 4 | from tkinter import *
import tweet
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.e2 = Entry()
self.e1 = Entry()
self.master = master
self.init_window()
textFile = open("score.txt", "r")
self.score = tex... |
4e269b06b7585e075014926b85fcedfa1140b1d8 | j-n4m4573/Leetcodez | /binary_treez.py | 1,583 | 3.953125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class BinarySearchTree:
def __init__(self, items=[]):
self.root = None
for item in items:
self.append(item)
def append(self, item):
node = Node(item)
if self.root == None:
self.ro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.