blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b96ae4e7f1acb0878c2f22b576f72761266df319
rutu342/PythonCodes
/basics6.py
247
4.4375
4
#to check weather an alphabet is capital or small alpha=input("enter any alphabet") if(alpha>='a' and alpha<='z'): print(alpha,"is small") elif(alpha>='A' and alpha<='Z'): print(alpha,"is capital") else: print("Unknown value")
78de0f2d21e5a4479ed2de7ba1a5a21ee3ec3c91
hoppfull/Learning-Python
/Advanced/design patterns1/ex08 - facade/main.py
578
3.59375
4
"""Facade Design Pattern (Made in Python 3.4.3) http://en.wikipedia.org/wiki/Facade_pattern Very simple pattern. Already used it many times before. Didn't know it was a common design pattern. """ class Part1: def foo(self): print("foo!") class Part2: def bar(self): print("bar!") class Part3: def baz(self): ...
c562724e98327da303f4c53d5b36eddb2741c8f4
Svastikkka/DS-AND-ALGO
/Stack/Balanced Paranthesis 3.py
1,081
3.890625
4
"Implementation of stack using linked list " class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None self.size=0 def PushLL(self,arr): NewNode=Node(arr) NewNode.next=self.head self.head=...
04540cbfb6e006155afd014dc36a123da1b265c2
juanse962/analisis-numerico
/metodos/rule_false.py
1,391
3.65625
4
from sympy import * import math x = symbols('x') function = (math.e**(3*x-12)) + x*cos(3*x)-x**2+4 xa= input("interval start: ") xb = input("interval end: ") tolerance = input("number of tolerance: ") niter = input("number of iterations: ") xa = float(xa) xb = float(xb) tolerance = float(tolerance) niter = int(nite...
432870120634e1d3c667bca146e26a06ea0a2147
llh911001/leetcode-solutions
/reverse_words.py
242
4.5
4
#!/usr/bin/env python # encoding: utf-8 """ Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". """ def reverseWords(s): return ' '.join(s.strip().split()[::-1])
085a9e058ba2a9a45ce93eea3385fb38b9c8c03f
sk055/Data-Structures-using-python
/Linear Data Structures/Array/02-Insertion.py
260
4.03125
4
from array import * print("Insertion in array") array_1 = array('i', [1,2,3,4,5]) #defining array for k in array_1: print(k) print("\nResult\n") array_1.insert(1,30) for k in array_1: #Traversing array after insertion print(k)
4b01e3d534b8e759950f81764bed268beed4992a
clydemichelle/automateboringstuffwithpython
/Part1_PythonBasics/Chapter4_Lists/commaCode.py
219
4
4
def delimit(someList): for item in range(len(someList)-1): print( someList[item] + ', ' , end = '') print('and ' + someList[-1] + '.') spam = ['apples', 'bananas', 'tofu', 'cats'] delimit(spam)
9d17cc734520ffe36cb94e3711e8c3192a6bc87c
wrapper228/RIP
/RIP_lab2/RIP_lab2/lab_python_oop/square.py
454
3.65625
4
from lab_python_oop.rectangle import Rectangle from lab_python_oop.color import Color class Square(Rectangle): def __init__(self, name, x, color): self.name = name self.x = x self.color = Color(color) def area(self): return self.x * self.x def name(self): ...
7c2d00c9c4b19a1f286a4e982571d3b9c90b69f3
raghurammullapudi44/Mission-RnD
/PythonCourse/unit8_assignment_01.py
2,697
3.75
4
__author__ = 'Kalyan' problem = """ We are going to revisit unit4 assignment2 for this problem. Given an input file of words (mixed case). Group those words into anagram groups and write them into the destination file so that words in larger anagram groups come before words in smaller anagram sets. With ...
399fe939bbcd2536b335a541b3b128ffdfee92d9
romulorm/cev-python
/ex.081.extraindoDadosDeLista.py
483
3.78125
4
lista = [] opcao = 'S' cont = 0 while opcao == 'S': lista.append(int(input('Digite um valor: '))) opcao = str(input('Deseja continuar? ')).upper().strip()[0] cont += 1 lista.sort(reverse=True) print('Você digitou \033[33m{}\033[m elementos.'.format(cont)) print('Os valores em ordem decrescente são: \033[33...
7c059b74297779b7355bee833b987706147cc414
WalczRobert/module-4
/input_validation/validation_with_try.py
794
3.9375
4
class Testscores(): def input(self): score1, score2, score3 = input("what are your 3 scores (comma separated): ").split(',') average(score1, score2, score3) def average(self, score1, score2, score3): NUMBER_TESTS = 3 score = float((score1 + score2 + score3) / NUMBER...
d0d034c5951602144957579283ea58119790469f
ryanmp/cs325
/hw3/algo_mst.py
1,596
3.515625
4
import itertools from tree import * from helpers import * import time #minimum spanning tree #input: list of cities #output: tree representation of edges for MST -> traversal -> route #@profile def algo_mst(cities): all_edges = set() #(cityA,cityB,distance) # setting up our city-set as a set of edges for idx1 ...
66797d257df4a07829848afeb58cbd5694700211
frankzappasmustache/IT121_Python
/assignments/Lab_3a_usingStrings/fuckstrings.py
3,730
3.875
4
""" Project Name: IT121_Python Sub-project: Labs File Name: fuckstrings.py Author: Dustin McClure Lab: Lab 3a - Using Strings Modified Date: 10/10/2020 A program that formats and prints responses from the foaas api (Fuck off as a Service); an api that allows you to very efficiently ...
2cdda1eeae90c75c08b3fc09017b3de853192473
Shivani161992/Leetcode_Practise
/Backtracking/WordSearch.py
1,541
3.578125
4
from typing import List word = "AAB" board =[["C","A","A"],["A","A","A"],["B","C","D"]] class Solution: def exist(self, board: List[List[str]], word: str) -> bool: row=len(board) col=len(board[0]) index=0 hold='' for r in range(0, row): for c in range(0, col): ...
3633a524bdc19fbfc4e83931838f10c995a1a069
DamonLiuTHU/LeetCode_Python
/max_points_on_line.py
2,391
3.53125
4
# Definition for a point. class Point(object): def __init__(self, a=0, b=0): self.x = a self.y = b class Solution(object): def same_line(self, A, B, C): if A[0] == B[0] and A[1] == B[1] or A[0] == C[0] and A[1] == B[1] \ or C[0] == B[0] and C[1] == B[1]: re...
dee05afe21f1e054151d13dc6bedebbcd20b9735
lsylk/practice
/skills.py
13,013
4.75
5
"""Skills Assessment: Lists Edit the function bodies until all of the doctests pass when you run this file. """ def print_list(items): """Print each item in the input list. For example:: >>> print_list([1, 2, 6, 3, 9]) 1 2 6 3 9 """ for item in items...
87ec7684d139e9ade08cc37ae54bf0ffe1546ed1
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/mntdom001/mymath.py
1,386
4.15625
4
# mymath.py # a module that contains the functions get_integer() which prompts the user to # enter numbers and the function calc_factorial which determines the # factorial of the two digits entered by the user # Author: Dominic Manthoko # 13 April 2014 def get_integer(s): """ this function will pro...
6c3b12452a72b7277287b6b55f5318788ac7cb9c
SurajPatil314/Leetcode-problems
/Binary Tree/BST_preorder_iterative.py
680
3.828125
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 preorderTraversal(self, root: TreeNode) -> List[int]: ans = [] if not root: return ans qw = [] ...
06ea8f2e412fc018628f4d1cb75441e1c0ccc85b
ReCir0/UCU_Programming
/Lab5/continuation.py
2,622
3.84375
4
def calculate_expression(expression): ''' >>> calculate_expression("Скільки буде 8 відняти 3?") 5 >>> calculate_expression("Скільки буде 7 додати 3 помножити на 5?") 50 >>> calculate_expression("Скільки буде 10 поділити на -2 додати 11 мінус -3?") 9 >>> calculate_expression("Скільки буде...
7358b9bdbf0bc76efe9304a101aada4e3d9d2d4c
willson310116/ML-Practice
/Neural Network/text_classification_imdb/load_data_pipe.py
2,824
3.984375
4
s = """ These line is just for testing of loading data with different imput forms. For example, content with empty lines, not like others with sentence stick together which is kind of results after processing. As a result, these lines I type are seperate with empty lines. """ def Remove_space(s): """ M...
fb1f2fc82d4dd8a44de4aa798b58b09beab9b55f
syuanivy/ADBS
/board.py
2,086
4.09375
4
from error import Error class Board: """ Representation of ships and their positions on a map. """ def __init__(self, xsize, ysize): """ Create a rectangular board with integer coordinates that range from (0, 0) to (xsize-1, ysize-1). """ xsize = int(xsize) ...
cf1832eab913eb23db959fb17d5ecf75a890d1cb
axelFrias1998/CrashCourseOnPythonExercises
/Fourth week/Lists/Lists and tuples/listsAndTuples.py
375
3.875
4
fullname = ("Grace", "M", "Hopper") def convert_seconds(seconds): hours = seconds // 3600 minutes = (seconds - hours * 3600) // 60 remaining_seconds = seconds - hours * 3600 - minutes * 60 return hours, minutes, remaining_seconds hours, minutes, remaining_seconds = convert_seconds(2000) print(hours, m...
55cd06180a315b6a57eab6148d6c966afec1cd31
paul0920/leetcode
/question_leetcode/200_5.py
1,320
3.5
4
import collections def numIslands(grid): """ :type grid: List[List[str]] :rtype: int """ if not grid or not grid[0]: return 0 m = len(grid) n = len(grid[0]) visited = set() count = 0 for i in range(m): for j in range(n): if not is_valid(i, j, visit...
9621fc0a4ce47d47a143085c99581a10d2f43a23
staypuffinpc/IPT760-F19
/Day6/BS2.py
1,889
4.03125
4
htmlDoc = """<html><head><title>The Dormouse's story</title></head> <body> <p class="title"><b>The Dormouse's story</b></p> <p class="story">Once upon a time there were three little sisters; and their names were <a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>, <a href="http://example.com/lac...
2ad00cbdfec5879cc5a37637677b7c4af2569b85
fore0919/wecode
/test.py
154
3.765625
4
numbers = [] def even(): for num in range(1,51): if num % 2 == 0: numbers.append(num) print(numbers) return numbers even()
1ea3c1c6ca426059b6edb8e1c419c60a71c9694c
ChicksMix/programing
/unit 5/DiamondHicks.py
561
4.03125
4
b=int(input("Enter the number of symbols to be used in the base: ")) b2= b-2 for n in range(1,b+1,2): # counting by two to add the next line space=1 while space <=int((b-n)/2): print " ", space+=1 for x in range (1,n+1): if x < n: print str("*"), else: ...
878946aa603a7765250277475bc3c013451dbb5b
septyanra/labpy03
/Latihan2.py
245
4
4
print("Program Menampilkan Bilangan Terbesar dari Bilangan n") n = 1 max = 0 while n !=0: if n > max: max = n n = int(input("Masukkan bilangan : ")) if n == 0: break print("Nilai terbesar adalah : ", max)
4ba6433cbda78be78d414ba66c42529616a49eec
db2398/nwe
/10.py
72
3.546875
4
num=int(input()) c=0 while(num>0): num=num//10 c=c+1 print("%d"%c)
9e6e69b3d95805c44a3e69332a61db37489064b9
xy2333/Leetcode
/leetcode/PrintFromTopToBottomAsZ.py
784
3.53125
4
# -*- coding:utf-8 -*- class TreeNode: def __init__(self, x,left = None,right = None): self.val = x self.left = left self.right = right class Solution: def __init__(self): self.stack = [] self.res = [[]] def Print(self, pRoot): # write code here if pRoot is not None: self.stack....
87711c6b969a6ce41564dcb43d4ee333eed9be2f
udoyen/andela-homestead
/andela-homestd/monkey.py
2,252
3.859375
4
import random import string # produces random string of type ascii # s = string.ascii_lowercase # # # def generate(): # """Generates random letters""" # # word creation # w1 = ''.join(random.sample(s, 8)) # w2 = ''.join(random.sample(s, 2)) # w3 = ''.join(random.sample(s, 2)) # w4 = ''.join(ran...
a91cc3752a549a7b720a5107fd598b03974aeb28
AIHackerTest/xiewuqi_Py101-004
/Chap0/project/ex29.py
827
4.1875
4
# -*- coding:UTF-8 -*- people = 20 cats = 30 dogs = 15 if people < cats: print("Too many cats! The world is doomend!") if people < cats: print("Not many cats! The world is saved!") if people < dogs: print("The world is dry!") if people > dogs: print("The world is dry!") dogs += 5 if people >...
a0cac161796f36ae80e67be8f84eea9aba0b66bc
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/4490/codes/1590_1016.py
299
3.5
4
# Teste seu codigo aos poucos. # Nao teste tudo no final, pois fica mais dificil de identificar erros. # Nao se intimide com as mensagens de erro. Elas ajudam a corrigir seu codigo. a = float(input()) b = float(input()) c = float(input()) s = (a+b+c)/2 print(round((s*(s-a)*(s-b)*(s-c))**(1/2),5))
00f78fef27d1eb7bce191acfeb7528893d7f910c
Marios1989/Functions
/Functions.py
2,318
4.03125
4
# Functions def spam(): """"Prints 'Eggs!' """ print("Eggs! ") spam() # Call and Response def square(n): """Returns the square of a number.""" squared = n ** 2 print() "%d squared is %d." % (n, squared) return squared # Call the square function on line 10! Make sure to # include the ...
bbc2a07431ea5ff03f9e9e64686beb584805c5df
Viratsoam/Python-DataStructure
/Recursion/pmi.py
171
4.09375
4
def pmi(n): if n == 0 or n == 1: return n return (n*(n+1))//2 n = int(input("Enter the number to find the sum of first natural numbers!!")) print(pmi(n))
ed372c0c143601216eeab41ad9e9bff4b41c4297
penicillin0/atcoder
/vairtual/20210920/c.py
342
3.671875
4
def Base_10_to_n(X, n): if (int(X/n)): return Base_10_to_n(int(X/n), n)+str(X % n) return str(X % n) ans = [] n = int(input()) for i in range(3 ** n): str_i = Base_10_to_n(i, 3).zfill(n) password = str_i.replace('0', 'a').replace('1', 'b').replace('2', 'c') ans.append(password) print(*s...
d5588c22a46697f72fc6fee0ba63389a371d6c48
26sneharoy/programming-lab
/word.py
80
3.734375
4
w=input("enter you word :") print(w[-1]) length=len(w) print(w[1:length-1])
4fdc19e9f53d4dbe37a8b65d9c58c04fd0dac900
GabrielRomanoo/Python
/Aula 7/ex2 com import.py
1,145
3.953125
4
# Crie um programa para calcular as 4 # operações básicas (usando funções). # As opções são 1-somar, 2-subtrair, # 3-multiplar, 4-dividir, 5-sair import funcoes # Tem que estar no mesmo diretório x = 10 while(x != 5): x = int(input("1-somar, 2-subtrair, 3-multiplar, 4-dividir, 5-sair, Opção: ")) ...
725053bee9a114b005159b0d35077368fde1ddc8
CircleZ3791117/CodingPractice
/source_code/329_LongestIncreasingPathInAMatrix.py
937
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = circlezhou ''' Description: Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of the boundary (i.e. wrap-arou...
29dcd5194fd346bc4f0c8f9bbee66226a24d3f67
Megan0145/TK-exercises-1-1
/Graphs/Graphs-I.py
984
4.34375
4
#1 Using the graph shown in the picture above, write python code to represent the graph in an adjacency list. class Graph: def __init__(self): self.vertices = { "A": {"B":1}, "B": {"C": 3, "E": 1, "D": 2}, "C": {"E": 4}, ...
7f27c1aa112fc0453c220c1efb4ed9e8ebedbdfb
mutedalien/PY_algo_interactive
/less_8/hw_8_more/lesson_8_task_3.py
1,040
4.0625
4
# Написать программу, которая обходит не взвешенный ориентированный граф без петель, в котором все вершины связаны, # по алгоритму поиска в глубину (Depth-First Search). # Задача пройти по всем вершинам вглубь один раз. def graph(n): # Функция генерации графа graph = {} for i in range(n): element = []...
12973bad0f24ead0842cd512e8d169309a9e73cb
ANUSHA6696/Python_Demo
/sets.py
1,209
4.15625
4
#collection does not allow duplicates l1=[1,2,2,2,3,3,4,2,5] s=set(l1) print(s) s1=set("hello") print(s1) #empty set s3=set() #else it is either tuple or dict # to add s3.add(1) #delete same as list or dict #union combining two sets without duplication even= {0,2,4,6,8} odd = {1,3,5,7,9} prime={2,3,5,7} u=odd.uni...
eff280e314cb3ab90182af1a70badb34f333a1f5
SickScarecrow8/CYPAmauryFD
/libro/problemas_resueltos/problema2_1.py
172
3.71875
4
N = int ( input ( "Ingrese el numero de sonidos emitidos por el grillo: ")) if N > 0: T = (N / 4) + 40 print(f"La temperatura es {T}.") print("Fin del programa.")
fa6e1efae11dc98d981eab6ca59095eb84ed7533
YMChen95/CMPUT174-Introduction-to-the-Foundations-of-Computation-I
/lab10/lab10-1.py
307
4.03125
4
def reverseDisplay(number): if number!=0: number1=number%10 number=number//10 print(number1,end='') return reverseDisplay(number) def main(): number = int(input("Enter a number: ")) reverseDisplay(number) print(reverseDisplay(number)) main()
82059c7d0a23dbe2991509c454105b17e8d3ab9d
MaximusMalabaev/Test
/generator.py
252
3.78125
4
#example 1 def simple_generator(val): while val > 0: val -= 1 yield 1 gen_iter = simple_generator(5) print(next(gen_iter)) print(next(gen_iter)) print(next(gen_iter)) print(next(gen_iter)) print(next(gen_iter)) print(next(gen_iter))
7b3dc9b5ab9b48b720246b5a1fce99744023140b
Ahmad-Magdy-Osman/JCoCo
/tests/classtest2.py
808
3.84375
4
import disassembler import sys class Dog: # to run this test, step over code with debugger into this __init__ # method and print the operand stack (option "a") to examine contents. # It should attempt to call the __str__ method below when the operand # stack is printed. Then the result will be that a Dog reference...
ed1d88c95fe3cd887c084a121f241eaf98ff1334
JPMonglis/BTS
/stringConverter.py
21,040
3.59375
4
#!/usr/bin/python # coding: utf-8 import sys import os import re import base64 import binascii import urllib # \ # Author: Paul Laîné # Data: Sat Sep, 2016 # Version: 1.0 # / def file_base64_to_text(): try: path = raw_input("\nPlease enter the path of your file: ") try: data = open(pa...
e857d6b485e6ed8c1b16105571dcba45bdc5e52e
vuhonganh/selfStudy
/online_courses/udacity/design_comp_prog/lesson_6/anagrams.py
6,271
4.3125
4
# This homework deals with anagrams. An anagram is a rearrangement # of the letters in a word to form one or more new words. # # Your job is to write a function anagrams(), which takes as input # a phrase and an optional argument, shortest, which is an integer # that specifies the shortest acceptable word. Your functio...
5cd4853e0f813579cdb6716464a761a9026fbfdc
laxbista/Python-Practice
/String_Excercises/q12.py
307
4.09375
4
# Exercise Question 12: Find the last position of a substring “Emma” in a given string # Where in the string is the last occurrence of the substring “Emma”?: str1 = "Emma is a data scientist who knows Python. Emma works at google." search= "Emma" occur = str1.rfind(search) print(occur)
2cc67428472e4826b84fe1f9109c208fa56f91ea
rajasekaran36/GE8151-Problem-Solving-and-Python-Programming
/Lab/Ex 10 Word Count Command Line/E10-Code.py
149
3.78125
4
import sys args = sys.argv count = 0 for command in args: print (command) count+=1 print ("Total number of arguments:",count) input("Thanks")
a0583be35e2818c18b564bf75959acfd016c69fd
truongc2/data-describe
/data_describe/misc/preprocessing.py
2,037
3.609375
4
import pandas as pd import numpy as np from sklearn.preprocessing import LabelEncoder from sklearn.impute import SimpleImputer def preprocess(data, target, impute="simple", encode="label"): """Simple preprocessing pipeline for ML. Args: data: A Pandas dataframe target: Name of the target feat...
5681e1325467397160eaef6875f13251c4bc0cdc
BuglessCoder/algorithm-1
/Lintcode/climbing-stairs.py
407
3.65625
4
class Solution: """ @param n: An integer @return: An integer """ def Solution(self): pass def climbStairs(self, n): # write your code here fibo = [] fibo.append(1) fibo.append(1) fibo.append(2) for i in range(3, 1000): fibo.appe...
ae242434c64028efaa254acf8555b79a0d2cc0e1
strawsyz/straw
/ProgrammingQuestions/牛客/青蛙跳台阶.py
326
3.796875
4
# 青蛙一次跳1或2格台阶,跳完所有台阶有多少种跳法 # 记忆化搜索 def f(n): memo = [-1] * (n + 1) def dp(n): if n == 1 or n == 0: return 1 if memo[n] == -1: memo[n] = (dp(n - 1) + dp(n - 2)) return memo[n] return dp(n) res = f(5) print(res)
255309a0246c3035d254aee6f09cf14020f9e331
Helbros72/targilim
/targilim_page_25_8_9.py
410
3.90625
4
# a - list numbers a = [] print (' For stop insert digits ,enter 0 or negative digit') while True : x = int(input( ' Enter the number :')) if x == 0 or x < 0: print (' Goodbye') break else : number = int(x) a.append(number) #else : #break min_number = min(a) max_...
5d50530b01da6a17fb9c699aaa3037da24ad5aac
stephen-weber/Project_Euler
/Python/Problem0105_SpecialSubsetSums_testing.py/Problem_105_SpecialSubsetSums_testing.py
3,328
3.65625
4
""" Special subset sums: testing Problem 105 Let S(A) represent the sum of elements in set A of size n. We shall call it a special sum set if for any two non-empty disjoint subsets, B and C, the following properties are true: S(B) S(C); that is, sums of subsets cannot be equal. If B contains more elements than ...
59a9b626e1127bc3c35ef212ef6b306023702103
kotouharuto/algorthm-study
/basic-algorithem_1/1-1/median3.py
439
3.984375
4
# 3つの整数値を読み込んで中央値を求めて表示 def med3(a, b, c): if a >= b: if b >= c: return b elif a <= c: return a else: return c elif a > c: return a elif b > c: return c else: return b print('3つの整数の中央値を求めます。') a = int(input('整数aの値:')) b = int(input('整数bの値:')) c = int(input('整数cの値:')) print(f'中央値は{med3(a, b, c...
85911d3d2945e3114d5af04298c8c94c4dc5e51b
eu2004/codecademy_capstone
/capstone_starter/predict_income_knr.py
3,540
3.65625
4
# Predicts income based on education, drugs and sex, using K-Nearest Neighbors Regression model. import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsRegressor from matplotlib import pyplot as plt from time import time def generat...
0f39a75c924be000651b3f1a6a2e8d68c9fa172d
richpsharp/ep
/problem12.py
2,166
3.828125
4
""" The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,...
d0ac50c3f3107ae2e5dbd2acb058ebd9f48f4a01
SwAtz07/HOMOMORPHIC-ENCRYPTION
/Paillier.py
4,114
3.6875
4
import random import ModularArithmetic import RabinMiller class PrivateKey: """ PrivateKey object contains λ and μ in accordance to the Paillier Cryptosystem args: p: a prime number q: another prime number (p and q are of equal length) n: product of p and q ...
6de54992bf50db5fd2ed368145ed529891489ac4
MarkGhebrial/Vigenere-Cipher
/src/cipher.py
1,145
3.890625
4
from alphabet import alphabet, tebahpla class VigenereCypher: def __init__ (self, key: str): self.key = key.lower() def encryptChar (self, char: str, position: str): try: # Get the value of the character, then add the value of the character at key[position] and turn it back into a character re...
28cc85d0c7238df54395fd865c0b0f72e35672f0
duhan9836/Algorithm-learning
/GateCircuitsClass.py
2,818
3.796875
4
class LogicGate: def __init__(self,n): self.label=n self.output=None def getLabel(self): return self.label def getOutput(self): self.output=self.performGateLogic() return self.output #at this point, we'll not implement performGateLogic function, bec...
7ecdf60b480adcfac7b8fef15de047471a479cbc
rosierui/hrank
/py/hackerrank/easy/print.py
397
3.671875
4
''' https://www.hackerrank.com/challenges/python-print/problem 10/01/17 hackos 615 if __name__ == '__main__': n = int(raw_input()) i = 0 while n > 0: print str(i), i += 1 n -= 1 ''' from __future__ import print_function if __name__ == '__main__': n = int(raw_input()) i = 1...
cecbeeb95edfa05010cb7018b7ad2adb66b360e1
KnightKnight27/MiscellaneousCode
/Python/depth_first_search.py
1,423
4.15625
4
""" Simple implementation of depth-first search. """ import unittest class Node(object): def __init__(self, value, neighbours=[]): self.value = value self.neighbours = neighbours def __repr__(self): return str(self.value) def __str__(self): return self.__repr__() def n...
776900f17bb0ef1d712f6ee9496c2c72adda1ecc
saminnewroad/Python_basics
/untitled2.py
420
3.921875
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 20 15:12:30 2020 @author: 18502 """ def count(list,name): count_name=0 for num in list: if num==name: count_name=count_name+1 return count_name a=['samin', 'reena', 'john', 'samin', 'ram', 'reena', 'samin', 'samin', 'reena', '...
785f002df0bdc170f7990d42d7d91853f88b3d64
jaomorro/StanfordCourseraAlgorithms
/Part2/2-sum with hash.py
1,893
3.515625
4
""" Your task is to compute the number of target values tt in the interval [-10000,10000] (inclusive) such that there are distinct numbers x,yx,y in the input file that satisfy x+y=tx+y=t. """ import requests import json def load_data(file_name): """ load data to be used into a file :param file_name: file...
6d80a3b0537819af425306ac9730d73300ef0b07
helmutwecke/QmPy
/qmpy/_interpolation.py
3,596
3.796875
4
"""Uses routines from scipy.interpolate to interpolate given data sets""" from scipy.interpolate import interp1d, CubicSpline, KroghInterpolator from numpy import linspace def _interpolate(xx, yy, xopt, kind='linear'): """ Interpolates two given sets of data points by either linear, natural cubic spline o...
63edbc2e92fa108c1c398d4138abc31737a1fc6f
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/grgtay001/question1.py
323
4.34375
4
#Tayla George #Program to determine if a year is a leap year or not # 7 March 2014 year = eval(input("Enter a year:\n")) def leap(year): if (year%400)==0 or (year%4)==0 and (year%100!=0): print(year,"is a leap year.") elif (year//4) + (year%100)>0: print(year,"is not a leap year.") l...
5ad19f59c8133f8667ed27adb8685f1c16d5cd7a
venkateshmoganti/Python-Programes
/Task3.py
217
4.1875
4
# Add the numbers given in the list which are greater than 0 given_list = [1, 2, -3, 4, -5, 6] total = 0 for element in given_list: if element > 0: total += element else: continue print(total)
9df357df6b3529424470032b4d214948968ad269
sanmesh21/Employee-Management-Salary-Receipt-Generator-System
/DSF.py
1,891
3.953125
4
import pandas data = pandas.read_csv("Employee Data.csv") #print(data) #print(data.shape) while True: op = int(input("press 1 to find data of hr_locations :\n press 2 to find data of gender :\npress 3 to find data of age :\npress 4 to find data of status :\n press 5 to find data of experience :")) if o...
9f45e7cf3f633dc785e22ef63223fc2d3e5e7844
blueExcess/holbertonschool-higher_level_programming
/0x02-python-import_modules/2-args.py
422
3.984375
4
#!/usr/bin/python3 from sys import argv if __name__ == '__main__': count = 0 if len(argv) == 1: print("0 arguments.") exit() narg = len(argv) - 1 if len(argv) == 2: print('{} argument:'.format(narg)) else: print('{} arguments:'.format(narg)) for x in argv: ...
4c79719002ca8c69f788a1ac9b58ca7ff6c4246f
pratap-rajan/SOLID_blogposts
/wrong.py
530
3.71875
4
def percentage_of_word(search, file): search = search.lower() content = open(file, "r").read() words = content.split() number_of_words = len(words) occurrences = 0 for word in words: if word.lower() == search: occurrences += 1 return occurrences/number_of_words def cou...
070a95a373716f37f39bd894b17e9930cf4e58f4
parthi555/pythonProject01
/train ticket project/forin.py
587
3.734375
4
#language = ['python','mysql','java','javascript','html','css'] #for language in language: # print(language) #language = 'python' #for char in language: # print(char) bikes = ['cbr','bmw','ktm','royalenfield'] for bike in bikes: if bike == 'bmw': print(bike.upper()) else: print(bike.title(...
41ba2faa467393e2abe204e2f30e3d33a614a35f
guilevieiram/100_days
/snake_game/snake.py
1,709
3.734375
4
import turtle as t import time SNAKE_COLOR = 'white' SEGMENT_SHAPE = 'square' SEGMENT_SIZE = 20 STEP_SIZE = SEGMENT_SIZE STARTING_POS = (0, 0) STARTING_SNAKE_SIZE = 3 SCREEN_HEIGHT = 600 SCREEN_WIDTH = 600 MAX_X = (SCREEN_WIDTH-SEGMENT_SIZE)//2 MAX_Y = (SCREEN_HEIGHT-SEGMENT_SIZE)//2 COLISION_DISTANCE = SEGMENT_SIZ...
aab0de72e2cee314d56bd7ed249f0f42af082e48
maniofisint/backups
/learn/DS_codes/projects/multy variable polynomial/code8.py
3,833
3.515625
4
class polynomial: class Node: def __init__(self,exp=None, variable=None, coefficient=None, char=None, next=None, updown=None, is_thread=False): self.exp = exp self.variable = variable self.coefficient = coefficient self.next = next self.updown = u...
7f2dcc86275c893fd8cfcc264fe6555722f7987e
eirikurt/sdsort
/test/cases/nested_class.out.py
710
4.03125
4
# create a Color class class Color: # constructor method def __init__(self): # object attributes self.name = 'Green' self.lg = self.Lightgreen() def __repr__(self): self.show() def show(self): print("Name:", self.name) # create Lightgreen class class L...
60a4652b84f77c9dbe7d04aaa170827b5a58a003
jhu97/coding-test
/implementation_2.py
419
3.6875
4
import sys input = sys.stdin.readline N = int(input()) count = 0 for hour in range(N + 1): if '3' in str(hour): count += 60 * 60 else: for minute in range(60): if '3' in str(minute): count += 60 else: for sec in range(60): ...
500851d3e67eac50eb6451daaf8d871ab68c9c83
GarethFunk/stateofthechart
/improc/flowchart/line.py
493
3.5
4
from .small_classes import Connector class Line: """ This class is used to represent lines connecting lines""" startCon = -1 endCon = -1 kinkPoints = [] text = "" def __init__(self, startNode, startFace, endNode, endFace, startPos = -1, endPos = -1, kinkPoints = [], text = ""): self.s...
e2eeb74cc5252403218f5131e41a85dd43443660
Pengineer/Python34-Syntax
/simple/Demo26_magic.py
1,292
4
4
# 魔法方法 ''' 魔法方法总是被双下划线包围,例如__init__。 魔法方法是面向对象的Python的一切,如果你不知道魔法方法,说明你还没能意识到面向对象的Python的强大。 魔法方法的“魔力”体现在它们总能够子啊适当的时候被自动调用。 ''' # __init__(self[,...]) # 对象实例化时被自动调用 # __new__(cls[,...]) # __init__方法并不是对象实例化时被调用的第一个方法,而是__new__(cls[,...])方法 # 第一个参数数class,后面如果有参数则原封不动的传给__init__方法。 # 这个方法执行后会返回一个类的实例化对象,我们一般不会去重写这个...
22c5e33cfe1fea526121f42e024c7e117c76bea4
ding-cat/Python
/some_learning_code/dictionary.py
778
3.53125
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ from collections import defaultdict sentence = "Peter Piper picked a peck of pickled peppers A peck of pickled peppers Peter Piper picked If Peter Piper picked a peck of pickled peppers Wheres the peck of pickled peppers Peter Piper picked...
ccc5e29afa0f9bf4aa4f391a3365ba9c6b6c5499
xdmiodz/hackerrank
/non_divisible_subset/solution.py
792
3.515625
4
#!/bin/python3 import math import os import random import re import sys from collections import Counter # Complete the nonDivisibleSubset function below. def nonDivisibleSubset(k, S): sets = Counter(item % k for item in S) total_len = int(sets[0] > 0) midpoint = k // 2 + 1 if k % 2 == 0 else (k + 1) // 2 ...
75abdf64941f0b76c1ad2926e45ec6d6aad9d747
DennicaN/Python-HWs
/HW1_1.py
363
3.859375
4
a = 3 b = "word" print('Переменная "a" - ', a, 'Переменная "b" слово - ', b) c = int(input('Укажите челочисленную переменную "c" ')) d = str(input('Укажите строковую переменную "d" ')) print('Ваша переменная с - ', c) print('Ваша переменная d - ', d)
b14e421e79f8e3371b2b99973e3a4641ce7eebb9
Tz21/python_basic
/start.py
597
4.125
4
#6/11 class1 #數字 print(21) #字串 print("python字串") #布林值 print(True) #變數 input = 3 print(input) #運算符號 data = 3 + 5 print(data) data = 5 / 2 print(data) data = 5 // 2 #整數除法 print(data) data = 6 * 2 print(data) data = 6**2 #二次方 print(data) print('Hello'+'World') #提示文字 n1 = input("Enter a Number:") n2 = input("Enter another...
592e13bd33d9a6b3715b1ebb61fe7a2a378f86aa
prithviwarrior/Python_Workspace
/Practice/Swap_case.py
114
3.890625
4
s = "AlPhabET__123" s2 = "" for i in s: if(i.isupper): s2.join(i.lower) else: s2.join(i.upper) print(s2)
7e1908b1bdf0e86670547807fc50c1027448da31
LuLu-89/code_practice
/Disemvowel_Trolls/solution.py
191
3.921875
4
def disemvowel(string): vowel = ('a', 'e', 'i', 'o', 'u', 'A', 'I', 'E', 'O', 'U') for x in string: if x in vowel: string = string.replace(x, "") return string
de1ba6341e45162a26f55b806e5ce6607fa59788
twyunting/Algorithms-LeetCode
/Easy/String/0459. Repeated Substring Pattern.py
264
3.828125
4
def repeatedSubstringPattern(s): """ :type s: str :rtype: bool """ return s in (s + s)[1:-1] print(repeatedSubstringPattern("abcabc")) # It's quite evident that if the new string contains the input string, the input string is a repeated pattern string.
4cd2512760895cd28a3dc43e9ee8a26d308eba79
tony-zhu/psapi
/psapi/utils/ipaddress.py
2,725
3.515625
4
""" Helper methods for validating IP addresses, Code borrowed from: http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python """ import re hostname_re = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE) ipv4_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d))...
7460b20590eca8a953618f198007ffdb0f57ce22
SchrodingersGat/reverse-geocachr
/scripts/latlon_distance.py
672
4.125
4
from math import * def distance(p1, p2): lat1,lon1 = p1 lat2,lon2 = p2 lat1 = lat1 * pi / 180 lat2 = lat2 * pi / 180 lon1 = lon1 * pi / 180 lon2 = lon2 * pi / 180 R = 6371.0 dLat = (lat2 - lat1) dLon = (lon2 - lon1) a1 = pow(sin(dLat/2),2) a2 = pow(sin(dLon/2),2) a...
8d397ec33c015d5950b629c2be90afec6d40803b
A01374862/Mison_05
/MisionCinco.py
5,787
3.96875
4
# Mariana Mejía Béjar # Misión 5. El ciclo for y while (menu) import turtle from PIL import Image, ImageDraw from random import randint # Define el menú que le muestra al usuario las opciones a elegir de aquelo que puede realizar el programa def menu(): print("Misión 5. Seleccione qué quiere hacer.") print...
a6cdd9c65fef8eff9116998d4c3ebfff1f2fc1e5
MihaelaGaman/InterviewProblemsSolved
/algorithms_python/longestPalindromicSubstring.py
1,588
4.25
4
""" Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd" Output: "bb" """ def longestPalindrome(s): max_len = 1 start = 0; low = 0; high = 0 ...
6190436ff727f1bfb91b686616c1937e6a4047d6
jcarball/python-programs
/funcion año bisiesto.py
477
3.75
4
def isYearLeap(year): # if (year % 4 == 0) and (year%100 !=0 or year%400 == 0): result = True print(result) else: result = False print(result) return result # coloca tu código aquí # testData = [1900, 2000, 2016, 1987] testResults = [False, True, True, False] for i in range(...
c887e704041221d22aaa322f6dff400242e1bcf4
dzarrr/Project-Euler
/problem7.py
521
3.75
4
## Dzar Bela Hanifa ## Project Euler no 7 ## Written in Python 3.7 def generate_prime_sieve(n): sieve = [] for i in range (0, n + 1): sieve.append(True) prime_sieve = [] for i in range (2, n + 1) : if sieve[i] : prime_sieve.append(i) for j in range (i + i, n + 1, i) : sieve[j] = Fa...
48302d9c32afb7c8e2b33b54eac885ba115ee8a3
rystills/OpSys-Project2
/MemoryStore.py
12,841
3.6875
4
from Process import Process from enum import Enum from Event import Event, EventType import bisect import Simulator """ State is a simple enum containing each of the potential process states """ class MemoryAlgorithm(Enum): nextFit = 1 firstFit = 2 bestFit = 3 """ The MemoryStore class represents an array...
cc05a8a28941b1c4b31ede3631a770479c32e822
Lucas-Severo/python-exercicios
/mundo01/ex005.py
380
4.15625
4
''' Faça um programa que leia um número Inteiro e mostre na tela o seu sucessor e seu antecessor. ''' num = int(input('Digite um número: ')) ant = num - 1 suc = num + 1 print('Analisando o valor {}, seu antecessor é {} e o seu sucessor é {}'.format(num, ant, suc)) # print('Analisando o valor {}, seu antecessor é {} e...
a021cca1d12985ef1dee9a61657950af4dc9780f
SobrancelhaDoDragao/Exercicio-De-Programacao
/Exercicios-Python/Basico/Exercicios/exercicio22.py
643
4.25
4
#Crie um programa que leia o nome completo de uma pessoa e mostre: # O nome com todas as letras maiúsculas # O nome com todas minúsculas. # Quantas letras ao todo(sem considerar espaços) # Quantas letras tem o primeiro nome. nome_completo = input("Digite seu nome completo: ").strip() print("Seu nome com todas as letr...
a7fbe27b49dbdea37643257150886bcacffb1548
snehahegde1999/sneha
/program-string.py
102
3.953125
4
a=[1,2,3,4,5,6] print (a) #adding one string with another string a=[1,2,3] b=a+[4,5,6] a=[1,2,3]*2
85201b899787af938c628561a5f814a02fbdeb90
Lebhoryi/Leetcode123
/73. 矩阵置零.py
1,218
3.5
4
# coding=utf-8 ''' @ Summary: @ Update: @ file: 73. 矩阵置零.py @ version: 1.0.0 @ Author: Lebhoryi@gmail.com @ Date: 2/24/20 9:03 PM ''' def setZeroes(matrix: [[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ # 获取每一行,假如有0 就整行置为0 row = [[0] * len(i) if 0 in ...
205d3aeee7b72035960929c3a7f1120e2b897385
gamejobmob/python
/스무고개놀이.py
586
3.671875
4
import random secretNum = random.randint(1, 100) print("1부터 100까지의 숫자가 있어요") for i in range(20): print("에상하는 숫자를 입력해") guess = int(input("숫자")) if guess < secretNum: print("예상한 숫자가 너무 작아요") elif guess > secretNum : print("예상한 숫자가 너무 커요") else : break if gu...
c70520225cbe1bfd71b84d890bc0dd4a76c1bf25
ibrahim272941/python_projects
/Armstrong_number.py
632
3.984375
4
num = (input('pls enter a number\t:')) digit = str(num) summ = 0 if num.isdigit(): for i in digit : num_1 = int(i) ** len(digit) summ +=num_1 num = int(num) if num == summ : print(f'{num} is Amrstrong number !!!!') else: print(f'{num} is not Armstrong number'...
daa20da55a1c16106bbad4dcae559d6971d48af9
megcrow/code_academy_practice
/grade_calculator.py
1,628
4.28125
4
#!/usr/bin/python # A calculator for grades, student scores are stored in dictionaries lloyd = { "name": "Lloyd", "homework": [90.0, 97.0, 75.0, 92.0], "quizzes": [88.0, 40.0, 94.0], "tests": [75.0, 90.0] } alice = { "name": "Alice", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], ...
a933bce34b2b8d4f6026679898bb7b9d2f7ef6c1
thoma55s/KattisSolutions
/CD.py
333
3.578125
4
index = 0 while True: firstInput = raw_input() if(firstInput == "0 0"): break numOfCds = firstInput.split(" ") jack = int(numOfCds[0]) jill = int(numOfCds[1]) jacks = [] s = set(int(raw_input()) for _ in range(jack)) incommon = 0 for _ in range(jill): if(int(raw_input()) in s): incommon += 1 pr...
782a8dd59cf07883a7e233f9a6711847a283730b
pavi-ninjaac/HackerRank
/Python_challege/counter.py
1,497
3.8125
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 31 16:54:35 2020 @author: ninjaac """ ###################Collections import collections ################################################################################ #defaultdict from collections import defaultdict #it will assign the default value autom...