blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
bd03a0c12dc5cfc0f06ec975cb2b07502e4f0097
Fay321/leetcode-exercise
/solution/problem 91.py
1,291
3.5625
4
# -*- coding: utf-8 -*- """ https://leetcode.com/problems/next-permutation/ next permutation 题意理解:https://blog.csdn.net/qq_29600137/article/details/86628763 """ class Solution(object): def nextPermutation(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, ...
c052ef76f089630e83fcf06dc115daf78eda5eb6
purushottamkaushik/DataStructuresUsingPython
/LinkedList/additionofdifferentnumberofdigits.py
2,694
3.984375
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def display(self): if self.head is None: return temp = self.head while temp: print(temp.data, end=" ") ...
e602e13cb88156ece3ee9ce364fa77c3d76a3af4
khinthandarkyaw98/Leetcode
/061_sumNumbers.py
982
3.578125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def sumNumbers(self, root: TreeNode) -> int: self.tempStr = "" array = [] def _helper(root): if root ...
9600ee6234cff1831cc7ac2c062fedb3828e1df0
pytorch/tutorials
/intermediate_source/char_rnn_generation_tutorial.py
13,740
3.625
4
# -*- coding: utf-8 -*- """ NLP From Scratch: Generating Names with a Character-Level RNN ************************************************************* **Author**: `Sean Robertson <https://github.com/spro>`_ This is our second of three tutorials on "NLP From Scratch". In the `first tutorial </intermediate/char_rnn_cla...
b09893b287253b70fd593ab8dd675eeb4d29bdde
douglas9314/CursoPython
/desafio004.py
592
4.15625
4
# Faça um programa que leia algo pelo teclado e mostre na tela # o seu tipo primitivo e todas as informações possiveis sobre ele. print('--== Desafio 004 ==--') a = input('Digite algo: ') print('O tipo primitivo de valor é {}'.format(type(a))) print('So tem espaço ? {}'.format(a.isspace())) print('É um numero ? {}'.fo...
44d3412aa6ee08179179b1e0f02ac308d9c543a4
C193231-Lujain/Python-SD1
/continue statement.py
160
3.71875
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 25 22:17:21 2021 @author: Lujain """ i=0 while i <6: i+=1 if i==3: continue print(i)
6b3e5a77b83a686c7b566d4ffdf9acb5655b26c2
meganesu/advent-of-code-2017
/day8/part1.py
3,748
3.84375
4
import operator class Condition: def __init__(self, register_name, comparison_operator, amount): self.register = register_name self.comparison_operator = comparison_operator self.amount = amount def evaluate(self, registers): ''' import operator add = {"+": oper...
726764c2e638c9e96b5738a0850da1e2457421c9
robE357/web-vigenere
/vigenere.py
3,223
4.03125
4
import caesar def alphabet_position(letter): alphabet = 'abcdefghijklmnopqrstuvwxyz' if letter.isalpha(): letter = letter.lower() return alphabet.index(letter) elif letter.isdigit(): return int(letter) % 26 else: return 0 def rotate_character(char, rot): ...
008c30d3824854ddec55ae5d78e40c121dc1f4aa
ivanlyon/exercises
/test/test_k_bijele.py
740
3.59375
4
import unittest from kattis import k_bijele ############################################################################### class SampleInput(unittest.TestCase): '''Problem statement sample inputs and outputs''' def test_sample_input_1(self): '''Run and assert problem statement sample 1 input and out...
f4acc93cc866364a0eeaec376872790c9dec410f
gyurel/Python-Advanced-Course
/exercise_stacks_queues_tuples_and_sets_2/santas_present_factory.py
1,900
3.59375
4
# import sys # from io import StringIO from collections import deque # # test_input1 = """10 -5 20 15 -30 10 # 40 60 10 4 10 0 # """ # # test_input2 = """30 5 15 60 0 30 # -15 10 5 -15 25 # """ # # sys.stdin = StringIO(test_input1) # sys.stdin = StringIO(test_input2) toys_nomenclature = { 150: 'Doll', 250: 'W...
c64befe475a7729ede26465032d95f959a99affc
arthurpbarros/URI
/Iniciante/1132.py
223
3.515625
4
a = int(input()) b = int(input()) soma = 0 if (a <= b): for i in range (a,b+1): if (i%13 != 0): soma += i else: for i in range(b,a+1): if (i%13 != 0): soma += i print (soma)
fc9679bebe0a8d0410c587a08d288939d995f069
chasingbob/deep-learning-talk
/02_linear_regression.py
2,121
3.875
4
''' A linear regression example implemented using TensorFlow ''' from __future__ import print_function import tensorflow as tf import numpy as np import matplotlib.pyplot as plt rnd = np.random plt.ion() plt.show() learning_rate = 0.01 training_epochs = 1000 display_step = 50 # Training Data train_X = np.asarray([...
ce5c639596236ffcc5af737095929f25e5085d81
akimi-yano/algorithm-practice
/lc/200.NumberOfIslands.py
1,453
3.78125
4
# 200. Number of Islands # Medium # 16021 # 373 # Add to List # Share # Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. # An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume a...
bda3873801dcdb946d78ac6c1df6e9225a66f45d
yonicarver/ece203
/Lab/Lab 3/preditorprey.py
1,066
3.828125
4
import math print 'Enter the rate at which prey birth exceeds natural death >', defaultA = 0.1 A = float(raw_input() or defaultA) print 'Enter the rate of predation >', defaultB = 0.01 B = float(raw_input() or defaultB) print 'Enter the rate at which predator deaths exceeds births without food >', defaultC = 0.01 C...
2a74e625036220952780694421fa956cfbed26e5
ArtakSukiasyan/TheBisectionMethod
/The_Bisection_Method/The_Bisection_Method.py
271
3.8125
4
def F(x): return pow(x,3)-x-1; def X(a,b): return (a+b)/2 a=1; b=2; E=1e-2; x=X(a,b) k=0 while abs(F(x))>E: if ((F(a)*F(x))<0): b=x else: a=x k+=1 x=X(a,b) print ("x = ", x) print ("step is equal ", k)
dce4419554da1689f65c5ef8705b34cb24bf0860
hassoonsy2/AI-Group-project-
/business rules/hybrid_Recommendation.py
3,172
3.5625
4
import psycopg2 from psycopg2 import Error def connect(): """This function is the connection with the postgres db""" connection = psycopg2.connect(host='localhost', database='huwebshop', user='postgres', password='Xplod_555') return connection c = connect() def disconnect(): """This function disco...
f3cbf426adbf9a8870c972974f9d69b31b270fcc
sahasatvik/Competitive
/smith.py
736
4.0625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Displays the Smith numbers within a given range. # A number 'n' is a Smith number if the sum of its digits is equal # to the sum of the sums of the digits of its prime factorization. # For simplicity, prime numbers will be ignored. # Usage : ./smith,py [upper limit [low...
26938c1833a3468068b8fb2d4b26299df5bd5dc6
yaHaart/hometasks
/Module23/01_names_2/main.py
700
3.578125
4
with open('log.txt', 'w', encoding='UTF-8') as log: pass with open('people.txt', 'r', ) as pfile: summ = 0 for line in pfile: try: length = len(line) if line.endswith('\n'): length -= 1 if length > 2: summ += length els...
e942e5b6fdb2c88f23e9fc1d30afe76da89e9612
navin089/Sample-python-code
/ex9.py
646
4.25
4
ipfile = input("Enter file name with extension : ") top = ipfile.split('.') print("Given file extension is : ",top[-1])## To PRINT THE GIVEN FILE EXTENSION exam_st_date = (11, 12, 2014) print("Converted Date format is : %i/%i/%i "%exam_st_date) ## To convert date format as " 11/12/2014 " #-------------------...
12a81d4c1e2b63f7889b19bf7a42e5178edbbc1d
BrayanCastro/PaydayLoans
/payday.py
5,268
4.4375
4
# Author: Brayan Castro # Project: PaydayLoans # Description: For this program I have developed a program that calculates the APR of a payday loan in the two scenarios listed below. # (1) I know the total loan amount or amount the borrower will receive , the total fee or cost of the loan, and the length of the loan (...
40e132991c5d7fc1074f5923548ecb5d391ac990
Edkiri/BoringStuff
/walkingTree.py
312
3.859375
4
import os for folderName, subfolders, filesnames in os.walk('delicius'): print('The current folder is ' + folderName) for subfolder in subfolders: print('SUBFOLDER OF ' + folderName + ': ' + subfolder) for filename in filesnames: print('FILE INSIDE ' + folderName + ': ' + filename) print('')
2f765e6f42fa7850d26e7274223fac7b595bfe3a
Edark94/init.el
/file-backups/!home!emil!Kurser!ad2!2assignment!updateddifference.py.~1~
6,261
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Assignment 2, Problem 1: Search String Replacement Team Number: Student Names: ''' ''' Copyright: justin.pearson@it.uu.se and his teaching assistants, 2020. This file is part of course 1DL231 at Uppsala University, Sweden. Permission is hereby granted only to the r...
35bafa92cc7c71c9422eb6c93cbf23c3b308ba32
miaopei/MachineLearning
/LeetCode/github_leetcode/Python/k-inverse-pairs-array.py
1,322
3.734375
4
# Time: O(n * k) # Space: O(k) # Given two integers n and k, find how many different arrays consist of numbers # from 1 to n such that there are exactly k inverse pairs. # # We define an inverse pair as following: For ith and jth element in the array, # if i < j and a[i] > a[j] then it's an inverse pair; Otherwis...
d93054dd6ee885c34811f7f97eeec9dc7f4468fb
ashirwadsangwan/HackerRankProblems
/Algorithms/Easy/mini-maxSum.py
637
4.0625
4
''' Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. ''' def miniMaxSum(arr): min_sum = 0 max_sum = 0 for i in a...
3f3554f5e47961d2adac498a85611b1b5a37cd6b
lucaslmrs/Cluster-Studies
/Visualization/dataVisualization.py
3,026
3.890625
4
# Initializing studies in data visualization for clustering # Data handling import numpy as np import pandas as pd from sklearn import preprocessing # Data visualization from matplotlib import pyplot as plt import seaborn as sns import plotly.express as px # Clustering from sklearn.cluster import KMeans # Dimensiona...
b683f760cdc424bc6bc3e7479da5f462a969416a
tariere/python-challenge
/PyBank/main.py
5,587
4.0625
4
#to start, I'll import the modules that I will need to access the data in the file and manipulate the data in the CSV. import os import csv #I'll place the path the the CSV in a variable so that it can be referenced budget_csv = os.path.join("Resources", "budget_data.csv") #check this #print(budget_csv) #acc...
f077071e5e651ecdb84f3218c54e82c54fb2b011
DebabrataH/Central-GIt
/passfail.py
489
3.953125
4
s1 = "Math" s2 = "Eng" s3 = "Beng" subject1 = int(input("Enter the 1st mark: ")) subject2 = int(input("Enter the 2nd mark: ")) subject3 = int(input("Enter the 2nd mark: ")) subject4 = int(input("Enter the 4th mark: ")) if (subject1 or subject2 or subject3 or subject4) < 30: print("You are failled due to lessthan ...
9b6a18a5252a5211879e27734d19e8d3142eba0a
AgsKarlsson/day2-bestpractices-1
/matmult.py
1,264
4.15625
4
# Program to multiply two matrices using nested loops import random def generate_matrix(N): # NxN matrix X = [] for i in range(N): X.append([random.randint(0,100) for r in range(N)]) # Nx(N+1) matrix Y = [] for i in range(N): Y.append([random.randint(0,100) for r in range(N...
20bac2cc4bd3463167a9581c07b395f3a698a992
adammorton11/Parser
/exprgram.py
10,294
3.609375
4
import re, sys, string import keyword syntaxDebug = False tokens = "" # Expression class and its subclasses class Expression( object ): def __str__(self): return "" class BinaryExpr( Expression ): def __init__(self, op, left, right): self.op = op self.left = left self.righ...
c634a2b0552baf5d8555814995951c9b504a1760
makeTaller/Crash_Course_Excercises
/city_functions.py
395
3.890625
4
def city_country(city, country, population=0): """Return a string representing a city-country pair.""" output_string = city.title() + ", " + country.title() if population: output_string += ' - population ' + str(population) return output_string #describe_city("Moscow", "Ru...
36109e8fd8eb9f1141a3881f500edc309f9d5d6b
ShrutiBhawsar/practice-work
/FunctionAlias.py
613
3.96875
4
def function1(): print("Inside Function 1") def function2(func): print("Inside Function 2 ") func() print(type(func)) # aliasFunc = function1 #it creates the alias of function1 # function2(aliasFunc) def add(num1, num2): print(num1+num2) def sub(num1, num2): print(num1-num2) def mul(n...
696cecc070d760e12ae722e58e7a2cb3bc6dc154
jerryrong/MITx6.00x_ProblemSets
/ProblemSet5/ps5_recursion.py
3,291
4.25
4
# 6.00x Problem Set 5 # # Part 2 - RECURSION # # Problem 3: Recursive String Reversal # def reverseString(aStr): """ Given a string, recursively returns a reversed copy of the string. For example, if the string is 'abc', the function returns 'cba'. The only string operations you are allowed to use are ...
2789b5c21b20434360a4204f333bc5b79ff35ca1
bespontoff/checkio
/solutions/Alice In Wonderland/zigzag_array.py
1,545
4.125
4
#!/home/bespontoff/PycharmProjects/checkio/venv/bin/checkio --domain=py run zigzag-array # This function creates an List of lists. that represents a two-dimensional grid with the given number of rows and cols. This grid should contain the integers fromstarttostart + rows * cols - 1in ascending order, but the elements...
5b844744bed7cbb67f9234cea0966dd908ab03b2
farmani60/coding_practice
/topic1_arrays/SparseArray.py
1,868
4.1875
4
""" There is a collection of input strings and a collection of query strings. For each query string, determine how many times it occurs in the list of input strings. For example, given input strings = ['ab', 'ab', 'abc'] and queries = ['ab', 'abc', 'bc'], we find 2 instances of 'ab', 1 of 'abc' and 0 of 'bc'. For each...
d28728e04ad0bcbd7c767c053ffb30c732a13b80
Nod17/IFRN_Python
/atv5.py
112
3.703125
4
n1 = int(input("Converter cm em m, digite o valor: ")) result = n1/100 print ("O valor e metros é:", result)
9f5d1c6ded25ba07e4f0491876aa25d1c8c3e161
cerver1/Python-Sprint
/valueComputed.py
155
3.5625
4
sample = input("Please enter an integer: ") a = int(sample) b = int(sample + sample) c = int(sample + sample + sample) result = a + b + c print(result)
b22d3d69ddc0d73131b1fcc523bf7b3e39ab53f2
dekamiron/my_first_attempt
/homeWork08/task00_func_decor.py
2,120
3.953125
4
# декоратор, позволяющий вместе с результатом функции возвращать время ее работы; import time, inspect def timer(fun): def tmp(*args, **kwargs): t = time.time() res = fun(*args, **kwargs) print("Время выполнения функции: %f" % (time.time()-t)) return res return tmp @ti...
de4b5f1b33c8e6f34bceee6b1fb772f5b4070e69
dilyanatanasov/python-library
/change.py
812
3.734375
4
def changePassword(rowOfUser): accFile = open('accounts.txt', 'r') fileContent = accFile.readlines() rowList = fileContent[rowOfUser].split() # checks if the password is same as the old one, if its right then the new password is added in the text file instead the old one while 1: oldPa...
e0b6bafaedd13270913a754a8ea3ef770006a96c
victorchu/algorithms
/python3/sorting_and_search/find-first-and-last-position-of-element-in-sorted-array.py
2,766
4.125
4
#!/usr/bin/env python3 """ Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. Follow up: Could you write an algorithm with O(log n) runtime complexity? Example 1: Input: nums = [5,7,7,8,8...
41a95c43d6fe1f5009d51a44d702eeca9e205d3a
yurulin1113/Python
/function/Decorator2.py
1,255
3.703125
4
def fn(): print("我是fn") def add(a, b): r = a+b return r def mul(a, b): r = a*b return r # ------------------------------------------------------------ def begin_end(old): def new_fun(): print('fun start~~~') old() print('fun end~~~') return new_fun f = begin...
a44ddc8d1a03217fe9d597550318a56e24b062f2
mam288/bioinformatics-VI
/wk2_01_suffix_array_construction.py
1,245
4.375
4
""" Solution to Suffix Array Construction Problem. Finding Mutations in DNA and Proteins (Bioinformatics VI) on Coursera.org Week 2, code challenge #1 https://stepik.org/lesson/Suffix-Arrays-310/step/2?course=Stepic-Interactive-Text-for-Week-2&unit=8998 """ def generate_suffix_array(seq): ''' Construct the suf...
ea59eee0bbc84698973a6b3f444130a5f1d2f2e3
mrshakirov/LeetCode
/30-Day LeetCoding Challenge/Week 3/Search in Rotated Sorted Array.py
1,016
3.890625
4
#https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/530/week-3/3304/ from typing import List class LeetCode: def search(self, nums: List[int], target: int) -> int: if not nums: return -1 start, end = 0, len(nums) - 1 while start + 1 < end: mid =...
8fbe8f31c78d38bc0af868d827f953f03d8dd629
shahwar9/algorithms-diaries
/grokking/misc.py
3,448
3.875
4
def is_palindrome(arr): for i in range(len(arr)//2): if arr[i] != arr[~i]: return False return True # Find if a number is palindrome or not. # 69396 def is_num_palindrome(num): num = abs(num) while num >= 10: digits = int(math.log(num, 10)) first = num // (10**di...
561f3180466fd919d31a38bf03366facc24d5537
zwcoop/guttag_intro_comp_ed3
/ch3/pg49-fe.py
539
4.25
4
# Change the code in fig3-2.py so that it returns the largest # rather than the smallest divisor. # Hint: if y*z = x and y is the smallest divisor of x, z is the # largest divisor. x = int(input('Enter an integer greater than 2: ')) smallest_divisor = None largest_divisor = None for guess in range(2, x): if x % g...
a2ad6038f03054b3a836ed874e27f9665f890d02
simaminghui/ImageSegmentation
/Segnet/test/__init__.py
1,463
3.578125
4
# ----------------开发者信息--------------------------------# # 开发人员:司马明辉 # 开发日期:2020-10-19 20:28 # 文件名称:__init__.py # 开发工具:PyCharm import numpy as np from keras import Model from keras.layers import * import keras.backend as K from PIL import Image # w = np.array([5, 6, 7, 8, -1]) # w = w.reshape(1,5) # x = Input(shape=...
32acc4d3b09d573d866d811b647a8eef61e4c9a4
octaviaisom/Python-Challenge
/PyBank/main.py
2,529
4
4
#!/usr/bin/env python # coding: utf-8 # In[19]: import pandas as pd # In[20]: #Read CSV file budgetDataDF = pd.read_csv("Resources/budget_data.csv") budgetDataDF.head() # In[21]: #Confirm there are no incomplete rows budgetDataDF.count() # In[22]: #The total number of months included in the dataset total...
432736118d1728c98b380fa347c449dbf8908b7e
RachelMurt/Python
/Area.py
505
4.1875
4
#code for calculating the area of a room #imports the time component import time #prints the questions for user input print ("Calculating the area of a room") length = int(input("What is the length of the room in metres? ")) width = int(input("What is the width of the room in metres? ")) #calulates the area ...
a3d3e6575033c1de2bae4a534009474653333ad4
JoseVictorAmorim/CursoEmVideoPython
/cursoemvideo/ex051.py
181
3.75
4
a1 = int(input('Qual o primeiro termo da PA (A1)? ')) r = int(input('Qual a razão da PA? ')) for c in range(1, 11): an = a1+((c-1)*r) print(('A{} = {}'.format(c, an)))
831205f9a2fd6aee4f6275e1da3903b49abcbe56
AlexandervVugt/DarkTimesMississippi
/gui/logic/Boat.py
1,884
3.953125
4
class Boat: def __init__(self, load = 0, capacity = 10, sellPrice = 2): if load > capacity: raise ValueError self.__load = load self.__capacity = capacity self.__sellPrice = sellPrice def load(self, amount): """ Adds an amount to the load of this Boat...
02885555972bd9b1b436a1442fe4dc225692c683
caionaweb/numb
/14/uri-master/solutions/1 - Iniciante/1044.py
184
3.625
4
a, b = input().split() a, b = (int(a), int(b)) if a < b: temp = a a = b b = temp if divmod(a, b)[1] == 0: print('Sao Multiplos') else: print('Nao sao Multiplos')
f0657e2faeff2a3eb7b7f33ef48dec5ad0ad0efb
atul1503/curve-fitting
/Custom_Function_Graph_Plotter_without_curve_fit.py
907
3.84375
4
# fit a second degree polynomial to the economic data from numpy import arange,sin,log,tan from pandas import read_csv from scipy.optimize import curve_fit from matplotlib import pyplot # define the true objective function def objective(x): return 0.01006304431397636*sin(0.009997006528342673*x+0.010000006129223197)+0...
018ae7344856af52e97d2ec702c94ed20a7e4d6f
DMRobertson/euler
/python/src/euler22.py
1,034
4.0625
4
"""Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For example,...
2db620d43ac772beb1b24427e8db239059a196ca
sparkle6596/python-base
/pythonProject/function/vowels count.py
96
3.71875
4
a="hello" vowels="aeiou" count=0 for i in a: if(i in vowels): count+=1 print(count)
a16028c673157d839c490f2dabdea65470aa21b7
nrojas1/dice_game
/game.py
10,958
3.671875
4
""" The famous dice game in command line format using classes """ import random; import time; import sys TOPSCORE = 1000 class Game: """ Game class""" def __init__(self, n_players): self.n_players = n_players self.n_round = 1 self.top_score = 0 self.scoreboard = list() ...
b9bd495e302f76857bc84c58af12aa9a34ab4aea
igorverse/CC8210-programacao-avancada-I
/aulas_de_lab/aula3/ex2.py
682
4.25
4
''' Crie um programa que leia números inteiros do usuário até que o número 0 seja inserido. Uma vez que todos os números inteiros tenham sido lidos, seu programa deve exibir todos os números negativos, seguidos por todos os números positivos. Dentro de cada grupo, os números devem ser exibidos na mesma ordem em que for...
2124ae018076b8ed8a380ac613ded46ba9c50ed1
tingleshao/leetcode
/interleaving_string/main.py
1,200
3.765625
4
class Solution: # @return a boolean def isInterleave(self, s1, s2, s3): # print len(s1) # print len(s2) #s print len(s3) if len(s3) != (len(s1) + len(s2)): return False table = [[False for i in range(len(s2)+1)] for j in range(len(s1)+1)] # print table ...
ccdcc817056c986555b4262bba5cc332f31317d9
ruirodriguessjr/Python
/Tuplas/ex3MaiorEMenorValoresEmTupla.py
342
3.84375
4
#MaiorEMenorValoresEmTupla from random import randint valor = (randint(1, 10), randint(1, 10), randint(1, 10), randint(1, 10), randint(1, 10)) print(f'Eu sorteei os valores {valor}') maior = menor = 0 for c in valor: print(f'{c} ', end='') print(f'\nO maior valor sorteado foi {max(valor)}') print(f'O maior valor sorte...
77ab03c4d23e212eb8e1d4f9be69e164b8fa4326
allensunbo/python_playground
/product.py
547
4.34375
4
def product(a, b): """ Implement a function product to multiply 2 numbers recursively using + and - operators only. """ if b == 1: return a else: return a + product(a, b - 1) print(product(2, 3)) def product3(a, b, c): """ Implement a function product to mu...
8274a29951d2294dbeb9506d6238105fea38ec37
ehoffmann/skills
/euler19.py
2,248
4.28125
4
#!/usr/bin/python def is_leap(year): """ Return true if year is leap """ if (year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0): return True else: return False def day_in_year(year): """ Return day count for a given year """ if is_leap(year): return 366 else: ...
03eac2947b93b1d1f52a819e5a06c1c971f6e754
PongDev/2110101-COMP-PROG
/Grader/12_Class_33/12_Class_33.py
822
3.796875
4
class piggybank: def __init__(self): self.c1=0 self.c2=0 self.c5=0 self.c10=0 self.money=0 def add1(self,n): self.c1+=n self.money+=n def add2(self,n): self.c2+=n self.money+=n*2 def add5(self,n): self.c5+=n self....
87a1c2fcc8d92c3d226ebfd360d4c9a9620f2a86
S4T3R/NEW-STUFF
/Session 5/k.py
186
3.65625
4
from random import randint i = randint(1, 101) print ("It is") if i < 31: print ("cloudy") elif 30 <= i and i <= 60: print ("rainy") elif i > 60: print ("sunny")
9634246f4f7bf0791c1b7e610584d7769b2696da
MitchellDan/Ch.04_Conditionals
/4.3_Quiz_Master.py
4,731
3.578125
4
''' QUIZ MASTER PROJECT ------------------- The criteria for the project are on the website. Make sure you test this quiz with two of your student colleagues before you run it by your instructor. ''' print(" _____ _____ _ __ ______ _____ ________ ___ _") print("/ ___| ...
8ab486cd6c0ee8f67a264cef087fa7d9cb670c17
borinjrjose/FIAP-Nano-Course-Python
/Capitulo2-Repeticoes/tabuada_for.py
165
3.859375
4
tabuada = int(input("Qual tabuada quer ver?")) print("Tabuada do", tabuada) for numero in range(1, 11, 1): print("\t", numero, "x", tabuada, "=", numero*tabuada)
74d22345771e50dd1d83fcc28345f5f04fd20826
Ru0ch3n/MOOCs
/Udacity/MachineLearning/ud120-projects/decision_tree/dt_author_id.py
1,359
3.671875
4
#!/usr/bin/env python """ This is the code to accompany the Lesson 3 (decision tree) mini-project. Use a Decision Tree to identify emails from the Enron corpus by author: Sara has label 0 Chris has label 1 """ import sys from time import time sys.path.append("../tools/") from email_preproces...
d0c57f42b9ec8f193db62bab4889924cdc5819bf
dadailisan/python-program-exercises
/program_6_collatz_sequence.py
360
4.1875
4
#The Collatz Sequence number = 0 def collatz(number): if number % 2 == 0: print(number//2) elif number % 2 == 1: print(3*number + 1) while number < 100: try: print('Enter a number: ') number = int(input()) collatz(number) except ValueError: ...
902e35d5f86e0631bcb8b1f30d7c1aba1d9da5e3
mike100111/IS211_Assignment6
/conversions.py
667
3.5625
4
# Converts Celcius to Kelvin def convertCelsiusToKelvin(value): return round(value + 273.15,2) #Converts Celcius to Fahrenheit def convertCelsiusToFahrenheit(value): return round(value * 9.0/5.0 + 32.0,2) # COnverts Fahrenheit to Celcius def convertFahrenheitToCelcius(value): return round((value - 32) * ...
37f794a000069dceb951b7d7928fa2f3facfc2ae
rlauture1/1st-Code-project
/BMIdocument.py
116
3.53125
4
weight = float(weight) height= float(height) bmi = weight/(height * height) if bmi <= 18.5: print(your )
7cae23007e2d7dd1c77eba5063934f0b7a6c70d0
jbgoonucdavis/Portfolio_sample
/ECS32B_3.py
4,349
3.65625
4
# Jack Goon # 914628387 # ECS 32B A06 # TA Jackson # Homework Assignment 3 # Problem 1 -------------------------------------------------------------------------------------- def kleinfeldt(n): if n == 1: # base case return 1 else: return 1/(n**2) + kleinfeldt(n-1) # reduction + recursion steps...
d4408ff6925fc527fa785ead3db07eb5c9f8e959
susu9655/python_test
/day0518/ex14_if.py
363
3.609375
4
sang=input("상품명을 입력하세요") su=input("수량을 입력하세요") su=int(su) dan=input("단가를 입력하세요") dan=int(dan) sum=0 if su>=5: print("5개 이상은 10% 할인됩니다.") sum=su*dan*0.9 else: print("5개 미만이라 할인이 안 됩니다.") sum=su*dan print(sang,"상품 ",su,"개는 총",sum,"원 입니다.")
d03515a9e3a7a0afa1915a5b0ca429978c0c4c03
DarshanDEV1/SecurityCalculator
/SecurityCalculator.py
615
4.15625
4
password="HELLO_OPEN_WORLD@123" enter = " " while password != enter : enter=input("Enter PASSWORD::- ") if enter != password: print("WRONG PASSWORD ENTER AGAIN") enter=input("Enter PASSWORD::- ") else: print("WELCOME TO THE PYTHON CALCULATOR:::-- ") number1=float(input("enter your first number: ")) op=input("ente...
7aaaf6507b77388ae30a7325fad51eda47dfb722
welcomesoftware/python-tutorial
/wordcount.py
460
3.65625
4
nombre = input('Ingrese un archivo: ') manejador = open(nombre, 'r') contador = dict() for linea in manejador: palabras = linea.split() for palabra in palabras: contador[palabra] = contador.get(palabra, 0) + 1 grancuenta = None granpalabra = None for palabra, contador in list(contador.items()): if...
99f87e9924d7d28ca3b29d898e17815086e69e41
786930/python-basics
/sumAverage.py
1,970
4.03125
4
# Program name: sumAverage.py # Your Name: Aerin Schmall # Python Version: 3.7.8 # Date Started - Date Finished: 9/2/2020 - 9/2/2020 # Description: takes a user designated amount of numbers and finds their doubles, sum, minimum and maximum def cont(): con = input('add new numbers? (y/n): ') ...
023a78b67ad3c8ae2d95da863f11b73e449c7a64
wuikhan/Learn-Py
/numbers.py
281
3.546875
4
# Author: Waqas Khan # Date:May 09,2017 # Email: wuikhan@gmail.com #Number type & Math operators int_num = 10 float_num = 20.0 print(int_num) print(float_num) a = 10 b = 20 add = a + b print(add) subtract = b - a print(subtract) multi = a * b print(multi) division = b / a print(division)
8bc231c76a10a2286ef2a023e6aa81197dfcdb2c
JonathanMF2020/practocasphyton
/tortuga/tortuga.py
462
3.703125
4
import turtle def main(): window = turtle.Screen() tortuga = turtle.Turtle() tortuga.shape('turtle') make_square(tortuga) turtle.mainloop() def make_square(param): length = int(input('Tamaño de cuadrado: ')) for i in range(4): crear_linea_gire(param,length) def crear_linea_gire(p...
5fa57bd6c8a684f786426ee85cda2ed431a31bae
brandonrobson/Learning
/Python/stringcompressor.py
567
3.9375
4
# This function compresses strings by converting repeating characters to characters and numbers # eg AAAABBBBCCCC becomes A4B4C4 def compress(string): r = "" length = len(string) # Edge Case 1 if length == 0: return "" # Edge Case 2 if length == 1: return string + "1" las...
5e8196d567da32380febdf6d28d21ddd1a676cf1
rossjjennings/crypto
/frieder_luk.py
5,309
3.625
4
from primitive_polynomials import all_factors import sympy def to_fl(n): ''' Calculate the (ternary) Frieder-Luk encoding of a positive integer `n`. This consists of a pair of integers: one whose set bits correspond to the ones in the ternary expansion of `n`, and another whose set bits correspond ...
011dabb9a0d535492788c499321d9d6158611983
vishnuster/python
/rolling_the_dice.py
658
3.96875
4
import random counter=0 while True: input("Hit enter to roll the dice ") a=random.randint(1,6) if(a==6): print('you hit six') counter=counter+1 print('You have hit a six in your',counter,'attempt.') break elif(a!=6): print('Hard luck, no six. You got',a,'.',end=" ...
ac44afef6bf95be5446502047c2bbc94fcbcf112
simrit1/asimo
/Chap 7/7.26.10 Exercise.py
800
3.640625
4
# Exercise 7.26.10 import sys def is_prime(n): """Checkout if the integer is prime or not""" if n < 2: return None else: for i in range(2, n): if n % i == 0: return None else: return True def test(did_pass): """Prin...
75da9bd277a723b5c7f7ef0b91c7ed16b0bc1fa0
Sahu-Ayush/Data_Structure_and_Algorithms_450_Target
/string/reverse_string_iterative.py
607
3.703125
4
# Write a program to reverse an string ''' Input : pythonstring Output : gnirtsnohtyp Input : hannah Output : hannah Approach: (Iterative way) 1) Initialize start and end indexes as start = 0, end = n-1 2) In a loop, swap arr[start] with arr[end] and change start and end as follows: start = start +1, end = end –...
2a3dc03d3b4abd4805ee4d179e1f68b549ce614c
ElliottBarbeau/Leetcode
/Problems/Merge Intervalss.py
720
3.546875
4
class Solution: def merge(self, intervals): if not intervals: return [] intervals.sort(key = lambda x: x[0]) result = [] start = intervals[0][0] end = intervals[0][1] for interval in intervals: new_start = interval[0] new_end = in...
598f37ae1287b3f9b872993a81dc36289ef0a9d5
vishalsingh8989/karumanchi_algo_solutions_python
/Chapter 3 linklist/removeDupDlist.py
910
3.875
4
"""https://www.geeksforgeeks.org/remove-duplicates-sorted-doubly-linked-list/ """ from linklist import DoubleNode as Node, printlist from random import randint from mergesortdoublelinklist import mergesort def removeDup(head): new_head = Node(head.data, None, None) tail = new_head head = head....
372b5ebcc69c9185a0aca38991f4bd30a135257b
rmount96/Digital-Crafts-Classes
/programming-101/Exercises/Small/5.py
104
4.03125
4
day = int(input("Day (0-6)? ")) if day < 1 or day > 5: print("Sleep in") else: print("Work day")
c7baa23ba2fd6e56497ad367bd336c2fab0b10de
raulgranja/Python-Course
/PythonExercicios/ex063.py
218
3.90625
4
n = int(input('Digite um número inteiro: ')) n0 = contador = 0 n1 = 1 print('{} {}'.format(n0, n1), end=' ') while contador < (n - 2): n2 = n0 + n1 print(n2, end=' ') n0 = n1 n1 = n2 contador += 1
6777032ba126d3199e47d4e23ddbce4dd71378cc
Irlet/Python_SelfTraining
/Fun_with_numbers.py
4,238
4.0625
4
""" no imports, no list comprehensions, no lambdas, no enumerate! """ def get_odd_elements(x, start): """ Return a list containing first 'x' odd elements starting from 'start'""" list_x_odd_elemets = [] element = start if x <= 0: raise ValueError('Numbers count parameter must be greater than ...
7ae849f28bd684e9cab3944a325f962698fd1b34
fjucs/107-VideoProcessing
/w1/guess.py
463
3.9375
4
import random, os def main(): random.seed('I\'m a random seed') cnt = 0 guess = int(random.randint(1, 100)) while True: cnt += 1 n = int(input('Please input a number: ')) if n > guess: print('Your number is greater than the secret number') elif n < guess: print('Your number is lesser than the secret...
6238af50277a624264479d2344ba52c8cd743dcd
6democratickim9/python_basic
/mycode/pythonic/python.py
357
3.65625
4
my_str = [] my_str = 'java python kotlin' my_list = my_str.split() print(type(my_list), my_list) print(type(my_str)) my_str2=[] my_str2 = '.'.join(my_list) print(type(my_str2)) my_str = 'java python kotlin' my_list = my_str.split(',') print(type(my_list), my_list) my_str2 = ",".join(my_list) print(my_str2) result = ...
e47fb0e81df1498cd30bd16c175d4e76dbd7eeeb
nbawane/Hobby_Python
/PythonPrac/custom_exception_class.py
788
3.609375
4
#minimum balance class class OpenAccount: def __init__(self,starting_balance): self.current = starting_balance def deposit(self,amount): self.amount=amount self.current += self.amount return self.current def withdraw(self,amount): self.amount = amount ...
f92a192c02a618c5479e26b7d74e34399eb7b5ee
yemgunter/inscrutable
/lab3a_yolanda_gunter.py
4,094
4.4375
4
############################################################### # Yolanda Gunter # Lab 3 # My program uses decisions, repetition and functions that will ask # for User's name, birth month and birth year to run program that # greet User with what season they were born in and if they were # born in a leap year or not. T...
c29374a9ff783c0b4c67e1a1ea98e8b0834e919e
theoctober19th/ds-algorithms
/data_structures/linked_list.py
6,259
4.4375
4
class Node: '''A node in the linked list''' def __init__(self, item): """ Args: item: The item to be inserted """ self.data = item self.next = None # string representation of this node def __str__(self): return self.data class LinkedList: ...
7be03b220ac3326c11c7f5ae680f29c8a2dd4de6
beerfleet/udemy_tutorial
/Oefeningen/uDemy/bootcamp/lots_of_exercises/mode.py
738
4
4
""" This is another trickier exercise. Don't feel bad if you get stuck or need to move on and come back later on! Write a function called mode. This function accepts a list of numbers and returns the most frequent number in the list of numbers. You can assume that the mode will be unique. """ def mode(lijst: list)...
ccf4182a0ae82f6b8d3269510230eee825988fca
htl1126/leetcode
/549.py
1,237
3.90625
4
# Ref: https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii/discuss/101520/DFS-C%2B%2B-Python-solutions # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object):...
c6b3ccc982bdde455afe8566e6d967caa08e88e2
subodhss23/python_small_problems
/markdown_formatting.py
765
4.1875
4
''' Given a string and a style character, return the newly formatted string. Style characters are single letters that represent the differenet types of formatting. For the purposes of this challenge, the style characters are as follows: "b" is for bold "i" is for italics "c" i...
551916be6f9155a156f88a9a08ea8171d5cb0a03
changlongG/Algorithms
/leetcode/MinimumTimeDifference.py
920
3.65625
4
#find minimum time difference in a list of time, eg:["hh:mm","hh:mm"], first covert #string of time to minutes(int), sort the coverted array and then the problem will be #find the minimum different of integer in a sorted array import datetime class Solution: def findMinDifference(self, timePoints): """ ...
be0c03dd165d30c7a8fe1337d65be18b9316eaf6
codeBlooded1997/SMTP
/send_emails.py
2,785
3.703125
4
# import the SMTP library. SMTP = simple main transfer protocol. its a protocol we must follow to send emails import smtplib # Import MIME test format library. MIME = Multipurpose Internet Mail Extensions. Its an internet standard we follow to encode email contents, like attachements, pictures, links, text, etc... fro...
98177ce13e8ee12d25b923922ec457e79ca5da6d
annezats/practice-problems
/advent-of-code-20/aoc20-2.py
1,253
3.703125
4
def validity(info): min=info[0] max=info[1] char=info[2] password=info[3] c = 0 for letter in password: if (letter == char): c=c+1 if (int(min)<=c<=int(max)): return True else: return False def unpack(line): dividers=['-',' ',':',' '] info=[] i=0...
9de0ee350fae20213ef66791e5f8ad494433a5b2
tuanpn93/tuanpham
/Final HW/HW04.py
625
3.5625
4
import numpy as np import pandas as pd str = "Ah meta descriptions… the last bastion of traditional marketing! The only cross-over point between marketing and search engine optimisation! The knife edge between beautiful branding and an online suicide note!" print(str.split()) s = pd.Series(str.split()) def check_vo...
9f11f204293b3737f0864b591e911458ee60a06e
genos/online_problems
/prog_praxis/same_five_digits.py
854
3.59375
4
#!/usr/bin/env python from collections import Counter from itertools import combinations def histogram(triple): return Counter(int(d) for d in ''.join(str(x) for x in triple)) def meets_criteria(triple): hist = histogram(triple) digits, counts = set(hist.keys()), set(hist.values()) return digits ==...
966abf41007687d81288b0632a7b9e1b78bc79df
spradeepv/dive-into-python
/hackerrank/domain/python/collections/ordered-dict.py
1,458
4.0625
4
""" Task You are the manager of a supermarket. You have a list of N items together with their prices that consumers bought on a particular day. Your task is to print each item_name and net_price in order of its first occurrence. item_name = Name of the item. net_price = Quantity of the item sold multiplied by the pri...
249583f58e01da5987e5dc2d54ac260cb61fddb1
OPL94/Game-Station
/Password Generator.py
2,152
4.09375
4
#The code below is used to generate strong passwords. #the dictionaries word_dict and numb_dict below associates a letter with a number. from random import * word_dict = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, ...
7c074e6ab02514f03b3d9b036adb6a8ab52ea092
efajunk/specialist
/Python 1/Day 1/Example/first.py
2,165
3.734375
4
# print('hello, students') # print('second string') # # example_value_read = 5 # print(example_value_read) # example_value_read = 'hello' # print(example_value_read) # example_value_read = 455 # # ## Пример_константы # LANG = "Python" ## Пример_константы # # ## Создание строк # first_method = 'Hello' # second_met...