blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7dbda26bbf64ec43bc3fd0e34f3f75a91a0c4da3
vinhlee95/hacker_rank_python
/validate_email.py
1,064
4.375
4
""" You are given an integer followed by email addresses. Your task is to print a list containing only valid email addresses in lexicographical order. Valid email addresses must follow these rules: It must have the username@websitename.extension format type. The username can only contain letters, digits, dashes an...
88f2e7ad524e50e464f24df75b3198ac11865077
stinovlas/Turnaj
/Testing.py
1,907
3.640625
4
from Player import Move import importlib import sys def pick_next(): while True: pick = input("Pick your next move: ") for m in Move: if m.value[0].lower() == pick.lower(): return m print("pick options: A,B,C,D") def print_result(res, sc1, sc2): print("Yo...
30b21bd9b7009ad6413fb98386e8126cb707006f
abhimita/udacity-algorithms
/array_digits/test/test_array_digits.py
2,743
4.21875
4
import unittest from array_digits import ArrayDigits class TestArrayDigits(unittest.TestCase): # Test when there are odd number of digits in the given array def test_rearrange_digits_when_odd_number_of_elements(self): array = [1, 2, 3, 4, 5] self.assertEqual(ArrayDigits.rearrange_digits(array),...
8f4bc422ac9dcd175eda8803a6cb2bcc797865b4
sresis/practice-problems
/validate-bst/validate-bst.py
504
3.640625
4
# This is an input class. Do not edit. class BST: def __init__(self, value): self.value = value self.left = None self.right = None def validateBst(tree): def helper(tree, min_val, max_val): if tree is None: return True if tree.value < min_val or tree.value >= max_val: return Fal...
5bf7e428099098f2e02b8a45deb0be6a210aa902
jctrotter/algorithms
/hw1/problem4/mergeTime.py
2,344
3.78125
4
# merge logic import random, time def merge(array, left, right): i = 0 # left array ptr j = 0 # right array ptr k = 0 # merged array ptr while i < len(left) and j < len(right): # iterate through both l and r arrays if left[i] < right[j]: # if left value smaller ...
a496c348b183aa89cee2d9e4619ff51d7ab05574
slumflower/kata_mastery
/sum-of-list-values/solution.py
92
3.515625
4
def sum_list(lst): num = 0 for i in lst: num = i + num return num
ef96390796d2684622d45ec3232398479f9f5f8d
nerdjerry/python-programming
/library/search/binarysearch.py
855
3.875
4
def binarySearch(input, value): return search(input,value,0,len(input)) def search(input, value, start, end): midpoint = (start + end) // 2 if start >= end : return -1 if input[midpoint] == value: return midpoint elif input[midpoint] > value : return search(input,value,star...
ddec9e37cbf553056a2dfd2970c4f9ce206a3507
CS-UTEC/tarea1-github-ZzAZz4
/primo.py
2,043
4.1875
4
import math ''' Checking for primality by using a deterministic variant of the Miller-Rabin test in O((lg(n))^4) ''' # class definition defines a controlled exception to continue outer loops form inner loops, which is # really useful in this context class Continue(Exception): pass def is_prime(number: int): ...
ad97eb08a3163e835785e580536ac3c6fefda645
kshintaku/100DaysOfCode
/Algo_Practice/Grokking-Algorithms/divide_n_conquer.py
1,141
4.0625
4
''' Chapter 4 - Quicksort Exercies: 4.1 - Write out the code for the earlier sum function ''' def recursive_sum(arr): x = 0 if len(arr) > 0: x = arr.pop() return x + recursive_sum(arr) else: return x print('This is recursive sum: ', recursive_sum([1, 2, 3])) ''' 4.2 - Write a r...
a221ea538c71c6c90c5350ee61cfdc604953137a
Kitrinos/Ch.11_Classes
/11.1_Classy_Boats.py
2,679
4.40625
4
''' CLASSY BOATS ----------------- Use the following Pseudocode to create this program: 1.) Create a class called Boat( ) 2.) Use a constructor that sets two attibutes: name and isDocked. 3.) The name should be entered as an argument when the object is created. 4.) The isDocked attribute is a Boolean v...
fe24cc394fcdecaeba3e02c1338bb8f8484f9e63
pragya16/AssignmentPython
/program20.py
433
4.46875
4
# Question 20: Ask the user for a string and print out whether this string is a palindrome or not word= 'madam' word_rev = reversed(word) def is_palindrome(word): if list(word) == list(word_rev): print'True, it is a palindrome' else: print'False, this is''t a plindro...
a3808b6e305797174cef203933e640f90e1a91fb
tommywei110/machine-leanring-implementation
/traditional ml/Perceptron.py
830
3.53125
4
import numpy as np # Perceptron from sklearn.linear_model import Perceptron # Get data from datasets from sklearn.datasets import make_classification # plt import matplotlib.pyplot as plt X, y = make_classification(n_features=2, n_redundant=0, n_informative=2, ...
728cb10c468e23925a88f3ccddf71fa8334bef1b
andrefcordeiro/Aprendendo-Python
/Uri/iniciante/3047.py
179
4.03125
4
# Idade da Dona Mônica m = int(input()) a = int(input()) b = int(input()) if m - (a+b) > a and m - (a+b) > b: print(m - (a+b)) elif a > b: print(a) else: print(b)
38942b0942d0ba382b0bc7033c4bc8d148db80f2
khans/ProgrammingAndDataStructures
/python/repr_class.py
279
3.859375
4
class Point3D(object): def __init__(self,x,y,z): self.x = x self.y = y self.z = z def __repr__(self): # to print in a different style, this is over-riding repr print str((self.x,self.y,self.z)) myPoint = Point3D(1,2,3) myPoint.__repr__()
cc7c5fa3d9be376d043f0d2382f3e004df4b75d1
less1226/learningpython
/leetcode/1.twoSum.py
325
3.671875
4
from typing import List def twoSum(nums: List[int], target: int) -> List[int]: dic = {} for i in range(len(nums)): if target - nums[i] in dic: return [dic[target - nums[i]], i] dic[nums[i]] = i return [] if __name__ == "__main__": result = twoSum([-3,1,3], 0) print(re...
72b8f95ba17f1f8a3f68a1fdccdd642ba7480805
ryuo07/C4TB
/session9/minihacklist_part_VIII/sort_and_select.py
548
3.671875
4
highscore = [45, 67, 56, 78] for i in range(2): highscore.sort(reverse=True) l = len(highscore) print("high score:") if l<=5: l = l elif l>5: l = 5 for i in range(l): print(i+1,highscore[i], sep=".") c = int(input("enter your new highscore:")) high...
73a3efa24893d8c888abb09f66b1a6b05e2d319b
agrawalshivam66/python
/lab3/q6.py
416
3.875
4
def fib_range(x): print("First fibonacci numbers in range 1-1000 are") a=0 b=1 c=0 while c<x: print(c,end=', ') c=a+b a=b b=c def fib_first(): print("First 25 fibonacci numbers are") a=0 b=1 c=0 count=0 while count<25: print(c,end=',...
90565e042b953ba58c4ef08595f453827a4ef65d
BKKajita/User_registration
/Agenda.py
7,007
4.125
4
# Este programa possui funções do Python 3.10 # Poderá não funcionar em versões anteriores do Python # Nenhum arquivo externo será gerado durante a execução deste programa info_contato = {} def menu_programa(): # Menu inicial do programa print('*='*30) print('Digite uma das Opções a seguir:') print('1: ...
91228313f8bdd02978fc15cc2a85f97a652d546e
sam-littlefield/EulerProject
/project/problem1/bruteSolution.py
116
3.875
4
total = 0 for i in range(1000): if ((i % 3) == 0) or ((i % 5) == 0): total += i print('Total: ', total)
dc643b6440db3dac84378c3277b1b91a11642332
DanielSoaresFranco/Aulas.py
/exercícios/ex007.py
305
3.578125
4
n1 = float(input('primeira nota do aluno: ')) n2 = float(input('segunda nota do aluno: ')) m = (n1+n2)/2 limpa = '\033[m' roxo = '\033[1;35m' ciano = '\033[1;36m' cinza = '\033[1;37m' print('a média entre {}{:.1f}{} e {}{:.1f}{} é {}{:.1f}{}'.format(roxo, n1, limpa, ciano, n2, limpa, cinza, m, limpa))
d88761b9467282797e713a351de8700f1bfbeacc
KateZi/Advent_of_Code
/Day 6 (Unused).py
1,363
4
4
class Planet: def __init__(self, name): self.name = name self.moons = list() self.star = None def add_moon(self, moon): self.moons.append(moon) def add_star(self, star): self.star = star class Universe: def __init__(self): self.planets = list() d...
c720aa5fbedb00ea2d6bd7cad5b29eff90f790e2
kalehub/tuntas-hacker-rank
/designer-pdf.py
714
3.78125
4
from string import ascii_lowercase def design_pdf_viewer(char_height, word): word = word.lower() list_of_words = list() # dictionary to know the alphabet ALPHABET = {letter: str(index) for index, letter in enumerate(ascii_lowercase, start=0)} numbers = [ALPHABET[w] for w in word if w in ALPHABET] ...
b4a482cec0058b92a7087ba4f8a8e57f69db22cf
Fazlur9/PBO
/PBO_19188/Latihan_13_angkaterbilang.py
762
3.765625
4
def Terbilang(bil): angka=["","Satu","Dua","Tiga","Empat","Lima","Enam","Tujuh","Delapan","Sembilan","Sepuluh","Sebelas"] Hasil =" " n = int(bil) if n >= 0 and n <= 11: Hasil = Hasil + angka[n] elif n < 20: Hasil = Terbilang(n % 10) + " Belas" elif n < 100: Hasil...
1cf70bfde362453b958964f621871458ea548e5e
rafal3008/Pong_old
/pong.py
1,206
3.59375
4
from objects import * from utility import * # pyGame essentials pygame.init() clock = pygame.time.Clock() # main window WINDOW = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption('Pong:The Game') # creating game obj ball = Ball(WIDTH / 2 - 15, HEIGHT / 2 - 15, 30, 30, white) player = Player(WIDTH ...
055c2488bc740b7dd3226686b1a420617f8d86d0
chanjun2005/ChemistryCalculators
/lussaclaw.py
1,664
3.59375
4
class Conversion: def __init__(self): self.atmconst = 1.01325 self.mmhgconst = 0.0013332239 self.kconst = 273.15 def atm_to_bar(self, atm): nBar = atm * self.atmconst return nBar def mmhg_to_bar(self, mmhg): nBar = mmhg * self.mmhgconst ret...
2b01debca0710e0eac38863d3a0fa2008f773225
Maryam-ask/Python_Tutorial
/Lambda/LambdaPython.py
654
3.96875
4
# Add 10 to argument a, and return the result. x = lambda a: a + 10 print(x(5)) # **************************************************************************** # Multiply argument a with argument b and return the result. y = lambda a, b: a * b print(y(4, 6)) # **********************************************************...
ef67266ecc27d6a73f52e8a22942930cc50a1516
PepSalehi/algorithms
/ML/nlp/language_identification.py
2,259
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Identify a language, given some text.""" from nltk import wordpunct_tokenize from nltk.corpus import stopwords def _nltk_to_iso369_3(name): """ Map a country name to an ISO 369-3 code. See https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for an over...
adb8d7af9c6c9ea2182b9a4d9be652eb78996bc5
ishandutta2007/ProjectEuler-2
/eu56.py
1,581
3.90625
4
# ------------------------------------------------------------- Powerful digit sum ------------------------------------------------------------ # # # # A googol (10^100) is...
1166b0013ef7a289787ae59f49aa40967f2e80a2
marythought/sea-c34-python
/students/MaryDickson/session02/fibnotes.py
402
3.703125
4
# anna's code def fibonacci(n): F1 = 0 F2 = 1 F = 0 for i in range(1,(n+1)): F1 = F2 F2 = F F = F2 + F1 return F def lucas(m): F1 = 2 F2 = 1 F = 2 if m == 0: F = 2 elif m == 1: F = 1 else: for i in range(1,m): F1...
489446c52475b54abd6a2350b0abad07ea11f2c7
lucas72466/algorithm008-class01
/Week_02/graph/无权图/Stack.py
444
3.6875
4
class Stack: def __init__(self): self.data = [] def is_empty(self): return len(self.data) == 0 def push(self, element): return self.data.append(element) def pop(self): ret = self.data.pop() return ret def peek(self): return self.data[0] def...
d50bb6c976fedf9061e84efcdf518af81d6da47d
vtyagiAggies/artificialIntelligence
/blockGame/report.py
2,129
3.578125
4
#!/usr/bin/python class Report: def __init__(self, filename="report.html"): self.obj = open(filename, "w") self.obj.write( "<html><head><Title>AI Homework 2 Report</Title><style>table, th, td {border: 1px solid black;border-collapse: collapse;}th, td {padding: 5px;text-align: center;}</...
6bfb01d4998d9ba703156a93a9f4dff434c41161
wyfapril/CS6112017
/PythonExercises/exercise7.py
187
3.984375
4
def print_list(list): for i in list: print(i) def print_reversed_list(list): for i in reversed(list): print(i) def len(list): count = 0 for i in list: count += 1 return count
2dc6e7d3a331e4e9b3054f51bace71010c6024f1
kaiwensun/leetcode
/1001-1500/1496.Path Crossing.py
460
3.578125
4
class Solution: def isPathCrossing(self, path: str) -> bool: cur = (0, 0) seen = {cur} deltamap = { "N": (0, 1), "S": (0, -1), "E": (1, 0), "W": (-1, 0) } for step in path: delta = deltamap[step] cur = (c...
43dc9a88b62080a2e7667dbd1610fdaaded67586
Rrrapture/python-the-hard-way
/ex/ex19.py
1,268
4.1875
4
#Python the Hard Way exercise 19 #this function takes two arguments, and prints the first argument value, #then the second argument value, then an exclamation sentence, then a command #sentence followd by an extra line break #I forget what the "d" is. def cheese_and_crackers(cheese_count, boxes_of_crackers): print "Yo...
e21995056e7e7295ca596e645dfeabf3879c35ba
minotaur423/Python3
/Python-Scripts/prob8.py
955
4.21875
4
# Arithmetic Progression # You are to calculate the sum of first members of arithmetic sequence. # Input data: first line contains the number of test-cases. Other lines # contain test-cases in form of triplets of values A B N where A is the first # value of the sequence, B is the step size and N is the number of first...
764520c900f7650e5fe1cb181bf9cb31d645eebc
VCloser/CodingInterviewChinese2-python
/11_MinNumberInRotatedArray.py
685
3.859375
4
def find_in_order(arr, start, end): min_ = arr[start] for i in range(start+1,end+1): if min_ > arr[i]: min_ = arr[i] return min_ def find_min_in_rotate_arr(arr): p1 = 0 p2 = len(arr)-1 while arr[p1]>=arr[p2]: if p2-p1==1: return arr[p2] mid = (...
e0fe6db28befd4ea87ca7f707b283ce5acb05fb2
jfs-coder/learn-py
/comprehensions.py
870
3.9375
4
# comprehensions - populate a list in declaration. # populates a list with numbers 0 to 99 x = [x for x in range(100)] print(x) # adds 2 to the start of the range x = [x + 2 for x in range(10)] print(x) # puts 100 zeroes in a list x = [0 for x in range(100)] print(x) # puts 100 'a' in a list z = ['a' for x in range(100...
95fcf8f3a85d7fdde140eac606554cf6cefcb241
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4428/codes/1595_842.py
313
3.84375
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. num = int(input("Digite um numero: ")) soma = 0 while(num > 0): resto = num % 10 num = num//10 soma = soma+resto print(soma)
04c1c3bf32fcc18284b4a19e022db81aa77128f2
youkidearitai/Arduino_LED_on_Python
/section3/hundred_push.py
596
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class HundredPush(object): def __init__(self): self.count = 0 def push(self, line): if (self.count % 100 == 9): print("Lチカ!!: {0}".format(line.strip())) self.count = self.count + 1 return True print("{0}...
5a56d27dc11c0289d00ac654f0d7737d8422e84f
almamuncsit/Data-Structures-and-Algorithms
/Data-Structure/09-linked-lists-03-remove.py
2,065
3.921875
4
class Node: def __init__(self, data=None): self.data = data self.next = None class SLinkedList: def __init__(self): self.head = None def print_list(self): print_val = self.head while print_val is not None: print(print_val.data) print_val = p...
76d77c32fbd94a1dff999f894dcf26a7aa208691
amesy/golang_note
/数组练习/数组练习.py
341
3.71875
4
import math def for_(num_half, res): for i in range(num_half): res.append(i) res.append(-i) return res def array(num, res=[]): num_half = math.ceil(num/2) # num为偶数 if num % 2 == 0: return for_(num_half, res) # num为奇数 L = for_(num_half, res) return L[1:] print(...
c501ca8f0ece9587841ef244f7fad0dacc710915
yovanycunha/P1
/opbancarias/opbancarias.py
500
3.8125
4
#coding: utf-8 # Operações Bancárias # (C) 2016, Yovany Cunha/UFCG, Programaçao I cliente,saldo = raw_input('').split() saldo = float(saldo) while True: entrada = raw_input('') if entrada == '3': break operacao,quantia = entrada.split() operacao = int(operacao) quantia = float(quantia) if operacao == 1: #qu...
c4536d6b936c0e27d31cfcdb12162ac8edb4a10b
Nanofication/MultinomialBayes
/MultinomialBayesTutorial.py
6,220
3.640625
4
""" Following NLTK tutorial on classifying sentences and intents """ import nltk from nltk.stem.lancaster import LancasterStemmer #Word Stemmer. Reduce words to the root forms. Better for classifying stemmer = LancasterStemmer() # 3 classes of training data. Play around with this training_data = [] training_data.a...
68d8544b3bfa8c86377dd60ff99350f7e4447161
learnables/learn2learn
/learn2learn/nn/misc.py
3,226
3.65625
4
#!/usr/bin/env python3 import torch class Lambda(torch.nn.Module): """ [[Source]](https://github.com/learnables/learn2learn/blob/master/learn2learn/nn/misc.py) **Description** Utility class to create a wrapper based on a lambda function. **Arguments** * **lmb** (callable) - The function t...
75b51c3849d56dd249e2ca7b8a4a7dac2f6059a9
balupawar/python-code
/faultyCalculator.py
900
4.21875
4
# create faulty calculator # balu pawar # 25/6 = 44 # 88+44 = 0 #10-10 =12 print("Enter first number:") number1= int(input()) print("choose operation on number , + ,- / , *") operator = input() print("Enter Second Number") number2 = int(input()) if number1 == 26 and operator == '/' and number2== 6: print("44") eli...
603bba57b53d042242bad85209c65b350b96353c
bikendra-kc/pythonProject512
/set/number6.py
139
4.0625
4
'''6. Write a Python program to create an intersection of sets''' a={1,2,3,4,5,6} b={4,5,7,8,9} print(f'the intersection of sets is :',a&b)
b4986bbe06c38b2228672d5ecaf22a26c10a2a6e
BeginnerA234/codewars
/задача_7_8kyu.py
155
3.5625
4
def positive_sum(arr): return sum(i for i in arr if i>0) print(positive_sum([1,2,3,4,5])) # https://www.codewars.com/kata/5715eaedb436cf5606000381
8fd467a3620217d72043e9ec6857404c5d82a310
wickedkat/KatsLair
/user_verification.py
1,025
3.5
4
import password_handler from database import data_handler def check_user_in_database(username): ''' Function calls database query, that returns user data by username given. If there is no username in database, it returns False :argument username - dictionary :returns user_exists - dictionary or False ''' us...
93cb47db4f8c827d1e835b3589b7c42c806bb5f9
ericgarig/daily-coding-problem
/192-crawl-list-to-end.py
802
4.03125
4
""" Daily Coding Problem - 2019-04-18. You are given an array of nonnegative integers. Let's say you start at the beginning of the array and are trying to advance to the end. You can advance at most, the number of steps that you're currently on. Determine whether you can get to the end of the array. For example, give...
ed57a10b6e3b4208cdb14a413302da3c0871588e
sunamya/Data-Structures-in-Python
/Interview Questions/LinkedList/FlattenALinkedList.py
2,112
3.828125
4
#User function Template for python3 ''' class Node: def __init__(self, d): self.data=d self.next=None self.bottom=None ''' def sortedMerge(a,b): if a is None: return b elif b is None: return a if a.data <= b.data: result = a result.bott...
d57870a7a45b520062d60b7fa34930a480212e3a
DAVIDMIGWI/python
/Bill.py
777
4.09375
4
units = float(input("Enter your units:-")) if units < 50: total = units * 0.5 print("Kindly pay",total,"Rs") print("Inc. surcharge", total + 10) elif units > 50 and units <=150: pay1 = 50 * 0.5 pay2 = units - 50 * 1 total = pay1 + pay2 print("pay",total) print("Inc. surch...
2daf6d39f903b9e208ce1e56129dd5672cfcc678
mylgood/myl_good_demo
/new_word.py
416
3.625
4
import math class my_math(object): def __init__(self,name): self.name = name def my_sum(self,a): s = 0 for i in a: s += i return s def add(self,a,b): return a+b def cos(self,a): return math.cos(a) def __repr__(self): return self.na...
272751e04480a014a0369d2c24d936b39b415c9a
rajlath/rkl_codes
/code-signal/maxTeam.py
1,025
3.59375
4
players = [[88, 47, 42, 21], [40, 76, 21, 22], [45, 92, 1, 1], [22, 23, 10, 11], [1, 100, 1, 0], [40, 70, 90, 80], [40, 12, 45, 12], [40, 80, 81, 80], [40, 50, 60, 70], [0, 0, 0, 99], [12, 54, 44, 55]] ''' he best team ...
b6a1972792e3a1c97360aab77a7ffd96ac1a32a6
nicholas-babcock1995/mycode
/iceAndFire04.py
1,811
3.75
4
#!/usr/bin/python3 """Alta3 Research - Exploring OpenAPIs with requests""" # documentation for this API is at # https://anapioficeandfire.com/Documentation import requests import pprint AOIF_CHAR = "https://www.anapioficeandfire.com/api/characters/" AOIF_HOUSES = "https://www.anapioficeandfire.com/api/houses/" def ma...
bb6d644b15d64855dedf07978397a2fb7751a142
Ameyg1/Pythonbasics
/time and dates/timing1.py
534
4.25
4
from datetime import date, time, datetime def main(): today= date.today() print("Today's date is ",today) #todays date print("Date componenents:",today.day,today.month,today.year)#notice the comma print("Today's weekday is :",today.weekday()) days=["mon","tue","wed","thurs","fri","sat","sun"] ...
bdfd90db7d56b98a6be6ab63ce65e57da7397923
Griffinw15/Data-Structures
/binary_search_tree/alt_part2_bst.py
3,652
4.09375
4
def in_order_print(self, node): # Base case if node is None: return else: # Start printing from the far left(lowest # always furthest to the left) # Recursively print from low to high, left to right # (Print order not node values) #...
57d5566f750f28cf151dbfab9bda87156d2ca308
cnzau/self_learning_clinic_xii_oop
/student.py
1,199
3.890625
4
#!/usr/bin/env python3 from datetime import date class Person(object): """ This is the super class """ def __init__(self, f_name, l_name): self.f_name = f_name self.l_name = l_name class Instructor(Person): """ Inherits from Person class """ def __init__(self, f_na...
a61c6aad2d30356987a373d7768ca6cf5fb8a819
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#192 Find the Remainder.py
615
4.25
4
# Task: # Write a function that accepts two integers and returns the remainder of # dividing the larger value by the smaller value. # # Division by zero should return an empty value. # # Examples: # n = 17 # m = 5 # result = 2 (remainder of `17 / 5`) # # n = 13 # m = 72 # result = 7 (remainder of `72 / 13`) # # n = 0 #...
0618cb5f3bdf03d8d637e7626921259cff05eac4
akrivko/learn_python
/tuple.py
1,700
3.796875
4
# tuple t = 123, 'fdsf' r = 4234, '34234sdfs', 'sdfsdf' print (t) t = t,r print (t) print (t[1][2]) l = 'lonely', print (l) a, b = t print(a,'\n',b) from math import pow x = int(625) #int(input('Enter the Number:')) y = 5 #int(input('Enter the root:')) #write down your logic here print (x,y) p = float(p...
1c1a67e6a62237a7e4c2dd1f3b1868f57db74d4e
zevstravitz/Personal-projects-in-Python
/Computer Algebra and Calculus System/3Dgrapher.py
2,575
3.65625
4
#Zev Stravitz #11/6/16 #3D grapher import math from Tkinter import * print 'Welcome to the 3D point grapher' x_comp = int(raw_input('X component: ')) y_comp = int(raw_input('Y component: ')) z_comp = int(raw_input('Z component: ')) def graphAxis(): canvas.create_line(250, 0, 250, 250, fill="red", width=5) ...
46a41a3a16a7603087674ea4e4c2c5faa51023c4
jonasclaes/TM_Python_Sem_1
/C2/EX1/triple_test.py
158
4.3125
4
number = int(input("Enter a number: ")) if (number % 3 > 0): print(str(number) + " is not divisible by 3") else: print(str(number) + " is a triple")
f0a566d675c699cfa08d55fdfb4aabdfee7076d6
kelseyMcCutcheon/OUR_Assessment
/TestAdaptationAlgorithm.py
2,325
3.734375
4
DIFFICULTY = 1 EASY_WRONG = 3 EASY_RIGHT = 2 MED_WRONG = 2 MED_RIGHT = 2 HARD_WRONG = 2 HARD_LIMIT = 3 class adaptAlgo: section = 0 difficulty = DIFFICULTY easyWrong = EASY_WRONG easyRight = EASY_RIGHT medWrong = MED_WRONG medRight = MED_RIGHT hardWrong = HARD_WRONG hardLimit = HARD_LI...
4121a6247197fe56af9802ae3ade79b6a3cecff1
ametthapa/python
/snakegame_next.py
3,623
3.671875
4
import pygame import time import random pygame.init() white = (255, 255, 255) yellow = (255, 255, 102) black = (0, 0, 0) blue = (0, 0, 255) green = (0, 255, 255) red = (255, 0, 0) dis_width = 600 dis_height = 400 dis = pygame.display.set_mode((dis_width, dis_height)) pygame.display.set_caption("snake...
1ce39356f926f14e2e00e86b127ef1ad1a51a480
gcdsss/Python_Script
/book_example/Section7.py
775
4.25
4
#! python3 # Section7.py practice on regex import re # Use regex to check whether input is strong string cmd len_re = re.compile(r'.{8,}') # length at least 8 a_re = re.compile(r'[a-zA-Z]+') # must contain upper or lower chara num_re = re.compile(r'[0-9]+') # must contain at least 1 number. def StrongcmdCh...
5896d1e657a4da4da654957e1161032ec147ea68
whiterg1/Python_Stack
/Fundamentals/oop/BankAccount/BankAccount.py
1,087
3.8125
4
class BankAccount: bank_name = "The National Bank of Roy" all_accounts = [] def __init__(self,int_rate,balance): self.int_rate = int_rate self.balance = balance BankAccount.all_accounts.append(self) def deposit(self, amount): self.balance += amount return sel...
70f61132574e106c2c3953948f3c88acb8532849
bopopescu/Daily
/calendar_test.py
411
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import datetime import calendar def increase_year(year, source=None): ''' 根据给定的source date, 获得增加一定天数的时间 ''' source = source if source else datetime.datetime.now() _y = source.year + year _m = source.month _d = min(source.day, calendar.monthrange...
5c52a94ab7eb5074859079c53032aca1b2cd05e7
Habibur-Rahman0927/1_months_Python_Crouse
/Python All Day Work/29-04-2021 Days Work/string.py
1,407
4.40625
4
# String in python are surround by ether single quotation marks or double quotation marks "Hello" is the same as 'Hello' print("Hello python") #string print('Hello python') #There are same a= 'this line show string method' print(len(a)) print(a.capitalize()) # this method uppercase first letter a sentance print(a.ca...
61c1cb509a88a4014e8ca1da95404fbc93a7f7ac
malikyilmaz/Class4-PythonModule-Week3
/3-alphabetical_order.py
674
4.59375
5
""" Write a function that takes an input of different words with hyphen (-) in between them and then: sorts the words in alphabetical order, adds hyphen icon (-) between them, gives the output of the sorted words. Example: Input >>> green-red-yellow-black-white Output >>> black-green-red-white-yellow """ ...
59a06d7389e876cf651c98b35a6e3649b94e54db
aganpython/laopo3.5
/python/Error&Exception/Try_Except.py
1,365
4.03125
4
# -*- coding: UTF-8 -*- #1 未加异常处理 # def loop(l): # # print(l[6]) # # loop([1,2]) # print("结束了") #2 加了异常处理 # def loop(l): # try: # print(l[6]) # except Exception as e: # print("发生了错误") # # loop([1,2]) # print("结束了") #3 # age = input("请输入年龄") # int_age = int(age) # print(int_age) # print('...
3c30dc82bbc56080764e8feebf3315f73395d0dc
lynnpepin/socket-examples
/test_server.py
1,585
3.578125
4
""" test_server.py Instantiates a SimplestServer, sends 100 pieces of data over it, and repeats the procedure 100 times. The data is generated deterministically using random.seed, so the client can verify that the server sends the correct data. """ from simplest import SimplestServer import random if __name__ == ...
3a238b7ed7c61a741c98283480109238d4b94969
clivejan/python_fundamental
/data_types/alien_no_points.py
226
3.5
4
alien_0 = {'color': 'green', 'speend': 'slow'} # access a key that does not exist in a dictionary #print(alien_0['points']) # usgin get() to set a defaut retuen value print(alien_0.get('points', 'No point value assigned.'))
e3c20174ef965ece3cdbe5c2b441c875dd79dbf3
simu217/AllCode
/EffectiveDateTypeTrial.py
33,468
3.59375
4
import sys import csv import re import time import datetime def convert_month_to_num(mm): if (mm == 'jan') or (mm == 'january'): new_mm = '01' elif (mm == 'feb') or (mm == 'february'): new_mm = '02' elif (mm == 'mar') or (mm == 'march'): new_mm = '03' elif (mm == 'apr') or (m...
4108102b9f68e6a1e5411e6c79d26072a044820f
SeanMitchell1994/cryptography
/src/caesar/caesar_driver.py
263
3.734375
4
from caesar import * word = "defend the east wall of the castle!./" print("Original word: " + word) encrpyted_word = Encrypt(word, 3) print("Encrypted word: " + encrpyted_word) decrpyted_word = Decrypt(encrpyted_word,3) print("Decrypted word: " + decrpyted_word)
a0312034db463adc7665f997b6f790195df2cf6d
okrek6/Smallest-Multiple
/Smallest-Multiple.py
140
3.796875
4
def gcd(x,y): return y and gcd(y, x % y) or x def lcm(x,y): return x * y / gcd(x,y) n = 1 for i in range(1,21): n = lcm(n,i) print(n)
3eba1e89c457a689f8bfe92936b662177ff74960
abhisek08/python-lists
/list shuffle.py
176
3.890625
4
''' Write a Python program to shuffle and print a specified list. ''' import random lst=[2,1,5,4,6,7,84,5,6,77,96,14,32,23,56,233,12,54,59,71,24] random.shuffle(lst) print(lst)
ace070749d3e0550b30f032e474b1eec9c8897c3
vasavi-test/python
/task1.py
525
3.65625
4
#age 18-60 entires=int(raw_input("number of entires:")) file_out = open("details.csv","w") header = "name,age,salary\n" file_out.write(header) for x in range(entires): name=raw_input("enter name:") age=int(raw_input("enter age:")) if age>60 or age<18: print "please enter valid age." ...
fc1af0f41353976435e115c9627943eed1cf72b3
dwaq/advent-of-code-solutions
/2016/05/2-md5.py
1,067
3.5
4
import hashlib door_id = "ojvtpuvg" m = hashlib.md5() integer = 0 digits = 0 # 8 character password password = [0, 1, 2, 3, 4, 5, 6, 7] # digits we haven't found yet available = [0, 1, 2, 3, 4, 5, 6, 7] # find all digits while (len(available) > 0): # concatenate ID and integer seed = door_id + str(intege...
47fba03517a23e9aebe24adfa2a3f875244dbe64
yvettecook/TicTacToe
/tictactoe_tests.py
2,249
3.890625
4
import tictactoe game = tictactoe.Tictactoe() def test_game_has_board(): assert game.board != None print "passed: game has a board" def test_board_has_3_rows(): assert len(game.board) == 3 print "passed: board has 3 rows" def test_row_has_3_squares(): assert len(game.board[0]) == 3 print "pa...
5933b4ff2c85a039fa6508e15315c3516afff285
fgirardin/worldtour
/src/analyzer.py
1,610
3.546875
4
"""Analyzer module: utilities to manipulate list of cities.""" import pandas as pd def normalize(x): """Normalize longitude.""" if x < -0.2: x += 360 return x class Analyzer(): """Class to analyze and manipulate list of cities.""" def __init__(self, file): """Init class.""" ...
c955d0a944ce3240017d8e89d12c56c604a76a50
madeibao/PythonAlgorithm
/PartC/Py移除重复的节点.py
806
3.9375
4
class ListNode(object): def __init__(self,x): self.val = x self.next = None class Solution: def removeDuplicateNodes(self, head: ListNode) -> ListNode: if not head: return head set2 = set() set2.add(head.val) res= head while res.next: if res.ne...
5ad73c07356baf4446dc5a8384e735e89d3ca858
cuongnb14/python-design-pattern
/sourcecode/data_structure/linked_list.py
1,091
4.09375
4
class Node: def __init__(self, data=None, next=None): self.data = data self.next = next def __str__(self): return self.data class LinkedList: def __init__(self): self.length = 0 self.head = None def add_head(self, data): node = Node(data) node....
59eddd29763b4ae13119b4f273c03d7155aad2c7
iakonk/MyHomeRepos
/python/examples/leetcode/amazon/favorite-genres.py
2,648
3.953125
4
""" https://leetcode.com/discuss/interview-question/373006 Given a map Map<String, List<String>> userSongs with user names as keys and a list of all the songs that the user has listened to as values. Also given a map Map<String, List<String>> songGenres, with song genre as keys and a list of all the songs within that...
32bc5f13c687c0b1dded2708ef26e3db5a60db36
PhDpwnerer/Escape
/Maze.py
4,850
3.796875
4
import random import copy from Wall import * from Floor import * from Hatch import * #the maze algorithm is Recursive Backtracking, which is inspired from http://weblog.jamisbuck.org/2010/12/27/maze-generation-recursive-backtracking class MazeRecursive(object): def __init__(self, rows, cols): #(...
79e749b618ceb5fde3f82e241ca7e075fb374734
hulaba/GeeksForGeeksPython
/Greedy/WWP.py
564
3.625
4
class WWP: @staticmethod def run_wwp(input_sequence, maximum=6): line = "" words = input_sequence.split(" ") for word in words: if len(line + word) < maximum: line += "{0} ".format(word) elif len(line + word) == maximum: line += wor...
20540138558f6e01bdde498451d54750943586ba
miguel8998/pipeline
/app/src/weather/main.py
3,365
3.703125
4
#!/usr/bin/python """WeatherApp Uses the weather openapi to display the weather in any location. Underneath the hood this application uses an openapi library to connect and obtain data. The Flask framework is used to host a website that exposes the weather when a location is typed in. """ # flask framework imports f...
86ab530aae5c21a6a0de602d8192a464f2b78479
rafaelperazzo/programacao-web
/moodledata/vpl_data/88/usersdata/179/59422/submittedfiles/listas.py
421
3.59375
4
# -*- coding: utf-8 -*- def alturas(a): diferença=0 for i in range(0,len(a),1): diferença=diferença+((a[i])-(a[i+1])) if diferença<0: diferença=diferença*(-1) else: diferença=diferença return (diferença) b=[] n=int(input('digite o valor de n :')) for i in range(0,n,1): va...
1164a4aed9cb23f61f94d4088f702e595e779537
kp1zzle/leetcode
/findDuplicateFileInSystem.py
824
3.625
4
import collections from typing import List class Solution: def findDuplicate(self, paths: List[str]) -> List[List[str]]: map = collections.defaultdict(list) for path in paths: files = path.split(' ') directory_path = files[0] for file in files[1:]: ...
f922f93055b3bbcdfcec5e39e75a2aa1a83e52da
tianyuan23/Network-Security
/ecb.py
2,443
3.609375
4
# Import AES symmetric encryption cipher from Crypto.Cipher import AES # Immport class for hexadecimal string process import binascii # support command-line arguments import sys # define block size of AES encryption BLOCK_SIZE = 16 # The 128-bit AES key key = binascii.unhexlify('00112233445566778899aabbccddeeff') ...
fc62cc0aaee2d43fc5dee049b94213f652db370d
sishtiaq/aoc
/2020/12/12a.py
1,469
3.65625
4
from input import t0, t1 # "R90 would cause the ship to turn right by 90 degrees" # but in the test case, the ship E,R90 -> S ?! def new_dir(cur_dir, direction, angle): if direction == 'R': new_dir = (cur_dir - angle) % 360 else: new_dir = (cur_dir + angle) % 360 return new_dir def fwd(c...
d1a51e4159137959b3427adbe1afecb60403ed4e
nogicoder/BasicFlow
/codeacademy/factorial.py
178
3.984375
4
def factorial(x): result = 1 for i in range (1, x+1): result *= i return result def factorial(x): result = x while x > 1: result *= x-1 x -= 1 return result
d14cd7dc1d209c486bf4c4951cda066a87f27547
jemg2030/Retos-Python-CheckIO
/INCINERATOR/OOP5ParentChild.py
2,565
4.53125
5
""" 5.1. Create an ElectricCar class that inherits properties from the Car class. 5.2. Modify the __init__ method of the ElectricCar class so that it uses super() to call the __init__ method of the Car class. 5.3. Add a new attribute battery_capacity of type int to the ElectricCar class __init__ method. This attribut...
de592dbfb86308ea0f08016701ce14baa31017f4
DanieleMagalhaes/Exercicios-Python
/Mundo2/somaPAR.py
281
3.703125
4
print('-'*60) soma = 0 #inicialize fora do FOR cont = 0 for c in range(1,7): valor = int(input('Digite um valor: ')) if (valor % 2 == 0): soma += valor cont +=1 print('\nVocê informou {} número(s) PARES e a soma é: {} '.format(cont, soma)) print('-'*60)
a81b4e692c20d7cbe9caf7f24fd1f778322ce9a4
esinkarahan/python_projects
/tictactoe_ai/tictactoe_ai_functions.py
4,970
3.875
4
# useful auxiliary functions and 3 simple AIs # for tictactoe game # December. 2020 import random width = 3 height = 3 def new_board(): # returns an empty w x h board board = [[None for i in range(0, width)] for j in range(0, height)] return board def render(board): # print board on screen with co...
bc63da75094b1b05d4578362562dfb0785b368c0
Annamalai1995/websitecreated
/Accessset.py
148
4.09375
4
a={"sam","pk","anu","sathish"} for i in a: print(i) #check the set is present or not a={"sam","pk","anu","sathish"} print("sam" in a)
f09534568ea2172bc506971f0c04afb2ea6b2ef0
Anupalsi/guvi
/upper_to_lower_to_upper.py
150
3.796875
4
n=input() for i in range(len(n)): if n[i]>='a' and n[i]<='z': print(n[i].upper(),end='') if n[i]>='A' and n[i]<='Z': print(n[i].lower(),end='')
01a47308e05fe648ab65668e8cd50ac8661414b3
alexanderdavide/advent-of-code-2020
/day9/9a.py
752
3.515625
4
from functools import reduce PREAMBEL = 25 def get_possible_sums(numbers): sums = [] for idx, numb in enumerate(numbers[:-1]): for addend in numbers[idx + 1 :]: if numb != addend: sums.append(numb + addend) return sums def find_invalid_number(numbers): for idx, ...
0989662fcba1b2f0290b50f71981cdf5cde5e4ae
iagsav/AS
/T2/SemenovaDS/2.1.py
248
3.671875
4
def is_prime(var): for i in range(2,var+1): a=0 for j in range(2,i): if i%j==0: a=1 break if a==0: print(i); b=int(input("Введите число:")) is_prime(b)
12f8dc64d4e7742264fa79654a0962a215132fdb
georgetao/comp-programming
/dualpal.py
791
3.796875
4
""" ID: georget2 LANG: PYTHON3 TASK: dualpal """ def isPalindrome(s): if len(s) < 2: return True if s[0] != s[-1]: return False return isPalindrome(s[1:-1]) def num_in_base(num, base): if num < base: return str(num) prefix = num_in_base(int(num / base), base) if prefix[0] == "0": prefix = prefix[1:] ...
75b9091f34c258c64cd1c2da5d95768d4a5525a9
Icetalon21/Data-Science
/scikitlearn/std.py
1,523
3.5625
4
import sklearn import numpy as np import sklearn.datasets as skdata from matplotlib import pyplot as plt boston_housing_data = skdata.load_boston() print(boston_housing_data) x = boston_housing_data.data feat_names = boston_housing_data.feature_names print(feat_names) #print(boston_housing_data.DESCR) y = boston_...
f72a269aba401f9db56226320b3744115f233101
csuzll/python_DS_Algorithm
/3、基本数据结构/reverstr.py
433
3.828125
4
# 使用stack实现字符串反转 from stack import Stack def revstring(mystr): s = Stack() revstr = "" for c in mystr: s.push(c) while not s.isEmpty(): revstr = revstr + s.pop() return revstr if __name__ == '__main__': # 测试 assert revstring("apple") == "elppa", "apple Error" assert r...