blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b21cdeeb67581bbf29ddc2ef1aec3e1e8ac0d802
Ttibsi/AutomateTheBoringStuff
/Ch.07 - Pattern Matching with Regular Expressions/FindPhoneNumberUsingRegex.py
333
4.25
4
# Finding Patterns of Text with Regular Expressions #import regex module import re #What to search for phoneNumRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') #String to search though mo = phoneNumRegex.search('my number is 415-555-4242') #Result comes as an object with a .group() method print('phone number found: ' ...
4b2448a39ac25e131b9b8bb257d1a4f5cbfbae47
thaus03/Exercicios-Python
/Aula09/Desafio027.py
332
4.1875
4
# Faça um programa que leia o nome completo de uma pessoa, mostrando em seguida o primeiro e o ultimo nome separadamente # Ex: Ana Maria de Souza # primeiro: Ana # ultimo: Souza nome = str(input('Digite o nome completo: ')) print(f'Primeiro: {nome.split()[0].capitalize()}') print(f'Ultimo: {nome.split()[-1].capitalize...
8ac5b19e03aafd149f181f8c12fb7f02c527c226
xavigu/Blockchain_management
/utils/hash_util.py
696
3.671875
4
"""Provides hash generator helper methods""" import hashlib import json def hash_string_256(string): return hashlib.sha256(string).hexdigest() # ---------------------------------------------------- # function to create hashed block def create_hash_block(block): # hash the block and convert to string with json ...
5b86aaaec105ef7fb0018d84eb73318f0c953f4b
mayanksoni052/substraction
/substraction.py
122
3.578125
4
a, b = map(int, input("Enter numbers for substraction ").split()) print("The substraction of", a, "and", b, "is = ", a-b)
81d4d41664f6692db685b50475007e615c7e3b15
udhayprakash/PythonMaterial
/python3/07_Functions/029_closures_ex.py
1,817
4.8125
5
#!/usr/bin/python3 """ Purpose: closures in python - Closures can avoid the use of global values. - It provides some form of data hiding. - When there are few methods (one method in most cases) to be implemented in a class, closures can provide a better solution. But when the number of attributes ...
4f6d66f754fb19fdfeaba874749812a98c86e6db
john-odonnell/csc_212
/labs/lab4.py
3,204
4.0625
4
import unittest import time def sum(n: int) -> int: """ Sum of Numbers. Returns the sum of all integers in the range [0, 10] """ if n == 0: return 0 else: return n + sum(n - 1) def running_time_sum(): values = [10, 100, 250, 500] run_times = [] for value in values: ...
da58a577253b61aa0281faa1974c1356fb660733
domengabrovsek/academic-fri
/programming-1/Vaje/Vaje 0/trikotnik.py
570
3.703125
4
import math stranica1 = float(input('Vnesi prvo stranico: ')) stranica2 = float(input('Vnesi drugo stranico: ')) stranica3 = float(input('Vnesi tretjo stranico: ')) s = float((stranica1 + stranica2 + stranica3) / 2) p = float(math.sqrt(s*(s-stranica1)*(s-stranica2)*(s-stranica3))) r = float(p/s) r2 = float((stra...
9a9848cdccdea87c952eb3078584663bd62a52cf
JPTIZ/the-pragmatic-programmer
/exercises/077-plain-text/pre/addrbook.py
1,617
3.5625
4
'''Address book database management.''' from struct import pack, iter_unpack from typing import NamedTuple class Address(NamedTuple): name: str phone: str address: str number: int def save(data, filename='book.db'): with open(filename, 'wb') as f: for item in data: _data = [e...
b14717066dffe23c694cfa8d2fa4a863cb88d071
jiwonjulietyoon/Algorithm
/Tasks/1_IM/190228.py
607
3.890625
4
# 1974. 스도쿠 검증 def sudoku(arr): # 9x9 sudoku for i in range(9): # search each row and column col = [arr[j][i] for j in range(9)] if len(set(arr[i])) != 9 or len(set(col)) != 9: return 0 for i in [0, 3, 6]: # search each 3x3 section for k in [0, 3, 6]: sub = [] ...
cd5b63885aa8cfea1d12df64193ab16542327443
rupesh1219/python
/leet_code/daily/move_zeros.py
884
3.828125
4
############################################################################### # given a list move all zeros to the end of the list # dont change the order of elements in list # dont use extra data structures # try to minimize your operations ############################################################################...
3efc51a371e7f25cc11c39c9f798e707c0d8d79d
codeLovingYogi/Algorithms
/binarysearch.py
513
4.03125
4
def binary_search(data, target, low, high): """Return true if target found in data. Search only considers portion from data[low] to data[high]. """ # interval empty, no match if low > high: return False else: mid = (low + high) // 2 # match found if target == data[mid]: return True elif target < dat...
afa953a39e3f71aec770002bb2b04d341aafc75b
LinoSun/LeetCodeByPython
/daily/2.两数之和.py
1,657
3.765625
4
''' 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 示例: 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) 输出:7 -> 0 -> 8 原因:342 + 465 = 807 ''' class ListNode: def __init__(self, x): self.val = x self.next = None class Solution...
02ef1e44f1273cc07d688be8c257bb3954534fb5
Yogini824/NameError
/PartB_q3b.py
1,213
4.1875
4
'''Develop a Python Program which prints factorial of a given number (Number should be User defined)''' def factorial(n): # defining function to calculate factorial of a number if n<0: # condition to check the number is negative or not print("Enter ...
d6d130a41913d0027cd9c34d9901c11b88da621d
romildodcm/learning_python
/python_for_Beginners/aula28_demoLoops.py
502
4.09375
4
people = ['Ro', 'Ka', 'Li', 'Ma'] print('-----------------------------------') print(f'Numero de nomes: {str(len(people))}') index = 0 while index < len(people): print(people[index]) index += 1 print('-----------------------------------') print(people) people.sort() print(people) print('------------------------...
16c529ebe518eaa13b8b6128dd7143d482f2c607
Skolekode/Introduksjon
/Skolekoding/introduksjon/4_3kodeflyt.py
512
3.625
4
""" I denne oppgaven lager vi en bankkonto. Kjøp på Vinslottet gjør at penger går ut. Utprinter gjør at vi stadig får et innblikk i hvordan bankkontoen ser ut. del 1 Beskriv med en tegning hva som skjer i dette programmet og hva utprintene blir total_sum = int(input("Skriv en fiktiv sum på din bankkonto i heltall\n"...
79b25550187bb9298a68762a48fd1835447a2004
matxa/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
214
3.921875
4
#!/usr/bin/python3 """function read_file()""" def read_file(filename=""): """read from a filename """ with open(filename, encoding="utf-8") as file: text = file.read() print(text, end="")
31f50660ed1df085e1347d96cc3537508dc8bb92
ardavast/hackerrank
/python/08_date_and_time/p02.py
428
3.53125
4
#!/usr/bin/env python3 # coding: utf-8 """ Time Delta https://www.hackerrank.com/challenges/python-time-delta """ import datetime if __name__ == '__main__': n = int(input()) for _ in range(n): ts1 = datetime.datetime.strptime(input(), "%a %d %b %Y %H:%M:%S %z") ts2 = datetime.datetime.strpti...
a6dfdcb34df09eb475bd477d2ce01aa43e9bad3c
decayedcross/shaunlearnpython
/basic_string_operations.py
1,369
3.96875
4
class Basic_String: def __init__(self): pass def printer(self, message, s): print(message, s) return def form_printer(self, message, a): print(message.format(s.count(a))) s = "Hey there! what should this string be?" p = Basic_String() # Length should be 20 p.printer("Length of s =", len(s)) # First o...
67b365c7779a1b03373ffb475a3e8d96a2767867
verma-shivani/DSA-Library
/Project_Euler/1-Multiple_Of_3_And_5/1-Multiple_Of_3_And_5.py
171
4.09375
4
sum0 = 0 # If i is divisible by 3 or 5, add to sum for i in range(100): if (i%3 == 0 or i%5==0): sum0 += i # Print answer print('The sum is: ' + str(sum0))
d9da437cd7e1865a36df8b03b18e06d73b8c09f9
HARICHANDANAKARUMUDI/chandu
/amstrng17.py
140
3.6875
4
c=int(input("")) temp=c sum=0 while(c>0): rem=c%10 sum=rem**3+sum c=c//10 if(temp==sum): print("yes") else: print("no")
2fce8ef6f2f4da6b5ec27373e15a5ba6d4632783
jazibahmed333/Mini-projects
/AI/lab1/lab1/part 2/Lab1_Agents_Task2_PokerPlayer.py
14,820
3.859375
4
import random # identify if there is one or more pairs in the hand Rank = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] Suit = ['s', 'h', 'd', 'c'] # 2 example poker hands # CurrentHand1 = ['Ad', '2d', '2c'] # CurrentHand2 = ['5s', '5c', '5d'] # Randomly generate two hands of n cards # def generat...
1af63bcd9f63bfdbada541c2f8b4b4b18bfd827f
devopsvj/PythonAndMe
/simple-programs/distance_traveled.py
321
4.28125
4
print "Distance Travelled by a Car" print "--------------------------" speed=input("Enter speed of the Car per hour in miles :") hr=input("Enter the hours to calculate the distance : ") distance=speed*hr print "The Distance traveled by the car at "+str(speed)+" miles per hour in "+str(hr)+" hours is : "+str(distance)...
858021018578e7e6231336d94c21f4c92a4a01fb
NehaFarkya/PythonLearning
/ExNumber.py
140
4.21875
4
import math r=float(input("enter the radius")) areaofcircle=math.pi*(r**2) areaofcircum=2*math.pi*r print(areaofcircle) print(areaofcircum)
080961659666148c500ccc608b9e60154b3e8371
michelgalle/hackerrank
/CrackingTheCodingInterview/16-TimeComplexity-Primality.py
507
4.15625
4
def is_prime(a): if a < 2: return False if a == 2 or a == 3: return True # manually test 2 and 3 if n & 1 == 0 or a % 3 == 0: return False # exclude multiples of 2 and 3 maxDivisor = a ** 0.5 d, i = 5, 2 while d <= maxDivisor: if a % d == 0: return False d += i i = 6 -...
a599d5da58c615b922ff9e1c310c2f37ceac907f
sharvilshah1994/LeetCode
/LinkedLists/HasCycle.py
684
3.640625
4
class ListNode(object): def __init__(self, x): self.val = x self.next = None def build_linked_list(): l = ListNode(1) l1 = ListNode(2) l2 = ListNode(3) l3 = ListNode(4) l4 = ListNode(5) l.next = l1 l1.next = l2 l2.next = l3 l3.next = l4 l4.next = l retur...
eed9447e7faf3a8dec6faf38be751b83981b4ac8
aishtiks/LearnPython
/ConditionalStatements.py
249
4.03125
4
num_Value1 = 23 if num_Value1 < 21: print("You cannot marry now.") elif num_Value1 is 21: print("You just reached marriage age, wait and enjoy life. What is the hurry?") else: print("You are in perfectly valid age for marriage.")
dd6c05b3e7f2e0eaaab325c2704261315e54041e
MAPLE-Robot-Subgoaling/IPT
/data/HW5/hw5_066.py
569
4.15625
4
def main(): width = int(input("Please enter the width of the box:")) height = int(input("Please enter the height of the box:")) symbol = input("Please enter a symbol for the box outline:") fill = input("Please enter a symbol for the box to fill:") newHeight = 1 for s in symbol: print(s*w...
9d47324ba4d2e37c4ddfe6e2d190b2f29a6192aa
amtfbky/git_py
/dg/base/09-2匿名函数扩展.py
245
3.546875
4
def tst(a,b,func): #res = a+b res = func(a,b) return res #func_new = input("请输入一个匿名函数:") func_new = 'lambda x,y:x*y+100' # 这里要字符串才行 func_new = eval(func_new) num = tst(11,22,func_new) print(num)
10ff22e857f7f81195c6c93afc03a956f3c8f58a
FarsBein/Maze_A_Star
/Maze_A_Star.py
8,366
3.546875
4
import pygame import random from queue import PriorityQueue pygame.init() WIDTH = 800 SCREEN = pygame.display.set_mode((WIDTH,WIDTH)) pygame.display.set_caption("A* Maze generator") BLACK = (0, 0, 0) WHITE = (250, 250, 250) RED = (255,0,0) BLUE = (0,0,255) LIGHT_BLUE = (173, 216, 230) GREEN =(0,255,0) GRAY = (220,220...
5bef7ff469e99ac96e2f2f675e3e7b95e425e25e
ck7up/ccnb-python
/Exercice4/exercice4.py
1,231
4.1875
4
from math import sqrt print("# Faire un programme qui demande à un utilisateur d'entrer les 3 coefficients d'un équation quadratique, soient a, b, c. => y = ax^2 + bx + c #") run = 0 while run != 1: a = float(input("Entrez la valeur de a = ")) b = float(input("Entrez la valeur de b = ")) c = float(input("E...
fa86ce2391094972d3fec275b68f6ccfede1ce3f
imranali18/RPA4
/source/class_code/Lec16_imdb.py
506
3.828125
4
imdb_file = input("Enter the name of the IMDB file ==> ").strip() count_list = [] for line in open(imdb_file, encoding="utf-8"): words = line.strip().split('|') name = words[0].strip() found = False for pair in count_list: if pair[0] == name: pair[1] += 1 found = True ...
422aa38bd83af5af23cde23d9652c7ece323c96a
Lethons/PythonExercises
/PythonProgram/chapter_10/10-04/10-04.py
223
3.625
4
while True: name = input("Please input your name: ") if name == 'quit': break print("Nice to meet you %s." % name.title()) with open('guest_book.txt', 'a') as f: f.write(name.title() + '\n')
c022b6576b66950f41641b403df5a24009a266e3
jespel2013/Python-Programs
/linked_list.py
1,327
3.5625
4
''' Name: Jesse Pelletier Description: This file contains the class LinkedList that represents the data structure of the same name. It was taken from the practice problems for CSC 120. FileName: linked_list.py ''' class LinkedList: def __init__(self): self._head = None def getHead(self): ...
13096ed1a1cf7762d3c50f559025c68780f0ba16
aizhan00000/game
/lection10.py
1,312
3.984375
4
# def user_num(): # num = int(input("enter a num: ")) # return num # # # def main(a): # for i in range(1, a+1): # print(i) # # # main(user_num()) # def user_num(): # num = int(input("enter a num: ")) # return num # # # def main(a): # print([i for i in range(1, a+1)]) # # # main(user_n...
fea04496f5f6c2557f4ad468a69e7f098a60a54c
nicksim1/learning
/test.py
244
4.09375
4
program_loop = True while program_loop: box = raw_input("what number? ") if box == "exit": program_loop = False else: try: box = int(box) for x in range(13): print box * x except Exception as e: print "Thats not a Number!"
b35a65b5e0f824cc894a5a98c5635103fcd594e7
nsakki55/AtCoder
/python_basic/abc028_a.py
132
3.65625
4
n=int(input()) if n<=59:print('Bad') elif 60<=n and n<=89:print('Good') elif 90<=n and n<=99:print('Great') else: print('Perfect')
a6705c45cad7a51729a9d8e9f0d1a50a6b1cac04
scottwedge/Python-4
/module_1/ExceptionHandling/exceptions.py
1,490
4.53125
5
#!/usr/bin/python ## handling exception in python using try block ## if there is an exception in the try block ## the except block will execute, and if there is no exception ## else block is executed ## finally block will be executed no matter what try: a = 0/0 except: print "Exception handled" else: print "no...
2e933a022d33f4c77bf43cee528c37e0d41f5382
ertugrulMustafa/Tetris-2048
/game_grid.py
17,301
3.578125
4
import pygame import stddraw # the stddraw module is used as a basic graphics library from color import Color # used for coloring the game grid import numpy as np from tile import Tile from point import Point # fundamental Python module for scientific computing import point import math import copy from plays...
789ee70da6706f78561b2aec3e8cd48dcf85dc99
ademaas/python-ex
/studyplanProject/student.py
1,189
4.0625
4
import course class Student: #initialization of the class with #student name, student id and list of courses the student is taking. def __init__(self,name,student_no): self.__name = name self.__id = student_no self.__courseList = [] # returns the name of the student def g...
0ff22db30c427ab029037c4baf842aca22137e02
RuningBird/pythonL
/day01/wordgame.py
174
3.828125
4
print("-------------------") temp = input("心中数字:") guess = int(temp) if guess == 8: print("right") else: print("wrong") print("game over") # print(type(temp))
dcdfe25a7d298f3d369584bfa3d54b9c8eca2c4c
marianesc/LP1
/miniteste_while.py
184
3.765625
4
contador = 0.0 auxiliar = 0 soma = 0 p = float(input()) print(contador) while 2 - soma > p: contador += 1 / 2 ** auxiliar auxiliar += 1 soma = contador print(contador)
69ec364ec6ed6b82e67d70fb03abecd4e6073f98
JeeHwan21/CS550
/Fibonacci_binary.py
314
3.671875
4
import sys import math def fib(a): if a == 1: return 1 elif a == 2: return 1 else: return fib(a-1) + fib(a-2) print(fib(int(sys.argv[1]))) def bin(a): sum = 0 for x in range(len(str(a))): # print(sum, x, a[-x-1]) sum = sum + math.pow(2, x) * int(a[-x-1]) return sum print(int(bin(sys.argv[2])))
d9caddbea257bb1abb4664a5b39c8ebbecdcc17a
suryandpl/UberPreparationPrograms
/alok-tripathi-workplace/set3/p11.py
325
4.1875
4
''' Problem : # Get all substrings of string # Using list comprehension + string slicing Author : Alok Tripathi ''' test_str = "Alok" print("The original string is : " + str(test_str)) for i in range(len(test_str)): for j in range(i + 1, len(test_str) + 1): #from 1 to str(len+1) print(list(test_str...
4cad2268990c9e58b0ae2677f7c68f657bbf1d74
johanarangel/condicionales_python
/ejercicios_practica.py
9,993
4.125
4
#!/usr/bin/env python ''' Condicionales [Python] Ejercicios de práctica --------------------------- Autor: Johana Rangel Version: 1.3 Descripcion: Programa creado para que practiquen los conocimietos adquiridos durante la semana ''' __author__ = "Johana Rangel" __email__ = "johanarang@hotmail.com" __ver...
94dbf6e69a2f41864a6e73af49879f57c51913db
Punsach/Coding-Interview-Questions
/CTCI-Chapter1/CTCI-Chapter1-Problem1.py
1,608
4
4
#Determine if a string has all unique characters. #Assume ASCII characters, so max of 128 distinct characters import sys #Using another Data Structure def Solution1(someString): #By pigeonhole if the string has more than 128 characters, there must be some repeat if(len(someString) > 128): return True #Put ch...
0e4ca0c383db411f748144478e50521af41292ce
srikanthpragada/PYTHON_06_APR_2020
/demo/ex/string_with_digits.py
224
4.1875
4
# Count strings with at least one digit count = 0 for i in range(5): s = input("Enter a string :") for c in s: if c.isdigit(): count += 1 break print("Strings with digits :", count)
deb608c8e93805fb1ac47d6624f188cf63432e27
Sidhijain/Algo-Tree
/Code/Python/Kth_Minimum_in_array.py
908
4.40625
4
# Python3 program to find k'th smallest element # Function to return k'th smallest element in a given array def kthSmallest(arr, n, k): # Sort the given array arr.sort() # Return k'th element in the return arr[k-1] # Driver code if __name__=='__main__': arr = [] n = int(input("Enter numb...
b49bdba2224574ee1e9451c79e86fb1bed0baba0
AnuragAnalog/project_euler
/Python/euler034.py
603
3.84375
4
#!/usr/bin/python3 """ 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as 1! = 1 and 2! = 2 are not sums they are not included. """ def fact(n): if n == 0 or n == 1: return 1 else: ...
736b0dc4271de3e183edec65b85f33e05648ddf2
af-orozcog/Python3Programming
/Python functions,files and dictionaries/assesment1_1.py
240
3.9375
4
""" The textfile, travel_plans.txt, contains the summer travel plans for someone with some commentary. Find the total number of characters in the file and save to the variable num. """ f = open("travel_plans.txt","r") num = len(f.read())
6b689e114e7a069fbfa51301d8c7cbdc0f1519e2
duheng18/python-study
/programQuick/chapterEight/demo1.py
426
4.125
4
import re path=input('请输入路径:') with open(path,'r') as f: file=f.read() regex=re.compile('ADJECTIVE|NOUN|ADVERB|VERB') while 1: if regex.search(file): x=regex.search(file).group().lower() print('Enter an %s',x) word=input() file=regex.sub(word,file,count=1) else: brea...
2e891d87430890bacd0c35e202a85609f498f656
Mrwang19960102/work
/model/machine_learning/sklearn/k_近邻.py
756
3.59375
4
# -*- coding: utf-8 -*- # @File: | k_近邻.py # @Date: | 2020/8/5 16:57 # @Author: | ThinkPad # @Desc: | import numpy as np import pandas as pd from pandas import DataFrame, Series # k邻近算法模型 from sklearn.neighbors import KNeighborsClassifier # 手动创建训练数据集 feature = np.array([[170, 65, 41], [1...
19b0bd7054859746ac3fa9454a04761669d42234
MYMCO117/CFERUTAS
/NE-221-2-UNIVA/python/functions.py
600
3.90625
4
''' def say_hello(): return "Hello" print(say_hello) def say_hello_user(name): print("Hello " + name) name = "Jafet" say_hello_user(name) def user_year_old(actual_year, born_year): years_old =actual_year - born_year return years_old print(user_year_old(2021, 1998)) ...
e52c22317ff25d514fb4dcba51ed0a7576450b6d
here0009/LeetCode
/Python/499_TheMazeIII.py
4,932
4.125
4
""" There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r), but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. There is also a hole in this maze. The ball will drop into the hole...
115a29ace09db47a8bc56b90b40f02127f551860
ropable/udacity
/utils.py
2,045
3.59375
4
from __future__ import division import time from functools import update_wrapper def decorator(d): "Make function d a decorator: d wraps a function fn." def _d(fn): return update_wrapper(d(fn), fn) update_wrapper(_d, d) return _d @decorator def trace(f): indent = ' ' de...
f9dd9f4efd7c047afe6d72ecc42a759a503b7f2e
GustavoGajdeczka/IPOO
/aula5/ex9.py
162
3.9375
4
print("== Aumento ==") salario = float(input("= Informe o seu salario: R$")) print("## O seu salario com aumento é igual a : R$", (salario / 100) * 37 + salario)
7bee50a946906ff59bba3b5d02e2f8b29252f94a
cbayonao/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
241
3.859375
4
#!/usr/bin/python3 def search_replace(my_list, search, replace): cpy = [] for a in range(len(my_list)): if my_list[a] != search: cpy.append(my_list[a]) else: cpy.append(replace) return cpy
5058f856415bee6698719729ad01c1f12732495f
asgore-undertale/ATCEE-Asgore-Text-Converter-Extractor-and-Enteror
/ConvertingScripts/Sort_lines.py
209
3.703125
4
def Sort(text, case = True): lines_list = text.split('\n') lines_list.sort(key=len) if case == False: lines_list = lines_list[::-1] text = '\n'.join(lines_list) return text
125b59275dba01b9ce4f8546fed08b5ee3a081e6
sajan777/ML_Begins
/DUCAT/Armstrong.py
206
3.8125
4
result = 0 n= int(input('Enter your number :')) temp = n while(temp>0): temp1 = temp%10 temp = temp// 10 result = result+temp1**3 if(result == n): print('Hell yeah') else: print('Nope')
1404b226df4e033b97d51b3a8ff00f6c7921475f
bgoonz/UsefulResourceRepo2.0
/_RESOURCES/awesome-git-user/ThinkComplexity2/code/Cell2D.py
3,945
3.6875
4
""" Code example from Complexity and Computation, a book about exploring complexity science with Python. Available free from http://greenteapress.com/complexity Copyright 2016 Allen Downey MIT License: http://opensource.org/licenses/MIT """ from __future__ import print_function, division import sys import numpy as...
318777dd3cc975123076862176311e73349b817c
rohanaurora/daily-coding-challenges
/Problems/detect_capital.py
640
3.796875
4
# Detect Capital # Source - https://leetcode.com/problems/detect-capital/ # 1. All letters in this word are capitals, like "USA". # 2. All letters in this word are not capitals, like "leetcode". # 3. Only the first letter in this word is capital, like "Google". # class Solution: def detectCapitalUse(self, word): ...
7dc9ffb485d94e7bb586b9716c092ffdc9391a5f
apterek/python_lesson_TMS
/lesson_10/homework/solution_home_01.py
2,098
3.734375
4
import math from math import pi class Point: def __init__(self, axis_x, axis_y): self.axis_x = axis_x self.axis_y = axis_y self.point_axis = [self.axis_x, self.axis_y] class Figure: def __init__(self): self.second_point = None self.first_point = None def line_le...
5521d9fb61ca6791eab0bff38dd80ee8be94518e
sashadroid/homework
/007_lists/007_homework_1_2_3.py
1,472
3.765625
4
# Задание 1 list = [8, 16, 0, 4, -23, 9] ma = max(list[0::]) print(" Наибольший элемент списка = ", ma) mi = min(list[0::]) print(" Наименьший элемент списка = ", mi) x = sum(list[0::]) print(" Сумма всех элементов списка = ", x) y = x/len(list) print(" Средняя арифметическая элементов списка = ", y) # Задание 2 stu...
62066d70d2b86f4f207ba74689d380d9266a110e
shiv-konar/Python-Projects
/warriors_battle.py
1,895
3.59375
4
''' Credit: Derek Banas https://www.youtube.com/watch?v=1AGyBuVCTeE&index=9&list=PLGLfVvz_LVvTn3cK5e6LjhgGiSeVlIRwt ''' import random import math class Warrior: def __init__(self, name="warrior", health = 0, attkMax = 0, blockMax = 0): self.name = name self.health = health self.attkMax = a...
fb22fe19e70c1da9ef53038b6446a9cdd5a48f68
FangyangJz/Python_Cookbook_Practice_Code
/C1_数据结构和算法/c5_有关heap的测试.py
219
3.859375
4
import heapq def HeapSort(list): heapq.heapify(list) heap = [] print(list) while list: heap.append(heapq.heappop(list)) list[:] = heap return list print(HeapSort([1,3,5,7,9,2,4,6,8,0]))
178c5a9b39ee90226796232466a166996c00174c
Kashish24/hackerEarthCodingSolutions
/Efficient Huffman Coding for Sorted Input.py
1,430
3.71875
4
# Link to the Problem:- https://www.geeksforgeeks.org/efficient-huffman-coding-for-sorted-input-greedy-algo-4/ class createNode: def __init__(self, freq, symb, left = None, right = None): self.freq = freq; self.symb = symb; self.left = left; self.right = right; self.huff = '...
6eac2ab6429dc948341693d84bd48458e254d3d4
AnalyticsCal/AnalyticsCal-Classroom
/anova_class.py
1,920
3.796875
4
# How to use..? # 1. import anova # 2. Pass y_list=y vaues, y_cap_list=y predected values, degree_of_freedom= number of parameters to class import scipy.stats as stats import stats_team3 as common # Structure of the dictionary we deal with # This same dictionary will be returned with updated values once the computati...
3e1230f951e90e560eb3bfc4d42b454bec1f9176
TheRea1AB/Python
/HighestValue.py
541
4.1875
4
# Which of the two numbers is greater def greatestNumber(Number1,Number2): if Number1 > Number2: print('Number 1 is the bigger number') return Number1 elif Number2 > Number1: print('Number 2 is the bigger number') return Number2 else: print('These two numbers are the ...
fcd7d551a7803f90770ae13b0a5b991bfeac40b3
KADEEJASAFEER/python_test_2
/employeefile.py
761
3.875
4
#create class and employee objects class Employee: def __init__(self,eid,name,desig,mail,sal): self.eid=eid self.name=name self.desig=desig self.mail=mail self.sal=sal def printEmp(self): print(self.eid,",",self.name,",",self.desig,",",self.mail,",",self.sal) ...
790ea4bd6b55427677264ceef12cf76fd5460976
lydia-tango/E27FinalProject
/clothes-net.py
3,251
3.96875
4
""" clothes-net.py uses the ANN libraries newConx to create a new class DeepFashion which is a BackpropNetwork to classify inputs data based on the target set. After getting a good training result, we will store the weights used in the network to evaluate novel inputs. """ from newConx import * from defClothes impor...
65d2add97318d1cdca06f2909a3d5b18b7262127
Eternally1/web
/python/fullstacks/week4/day1/卡牌问题2.py
1,506
3.8125
4
# @author: "QiuJunan" # @date: 2018/3/28 15:12 # 2017年机试题目,这里可以输出所有结果为13的组合,之后在寻找一个卡牌数目最多的情况即可 # 目前能做到的是按照顺序将牌一次计算进来,但是不能做到 如不要1,直接从3开始的一些卡牌组合。 def opera(a, b, op): if op == '+': return a + b elif op == '-': return a - b elif op == '*': return a * b elif op == '/': return...
d846fdc1ad1f0505a661a9e43b44480ff7170bc7
thecodingsophist/leetcode
/array_form_of_integer.py
264
3.625
4
''' For a non-negative integer X, the array-form of X is an array of its digits in left to right order. For example, if X = 1231, then the array form is [1,2,3,1]. Given the array-form A of a non-negative integer X, return the array-form of the integer X+K. '''
63d47c63efdf63f33035f0a7e01667e87c9c4b8a
katiemthom/word-counter
/wordcount.py
554
3.5
4
import sys import string dict_words_counts = {} file_to_count = open(sys.argv[1]) for line in file_to_count: line_list = line.split() for word in line_list: word = string.strip(word, ",.?/;:\'\"[]{}-()&%$#!`") word = word.lower() dict_words_counts[word] = dict_words_counts.get(word, 0) + 1 unsorted_list = ...
b14b989b06090f93f64d89d41ae9df9a4183c146
panas-zinchenko/zinchenko_lab
/Lab6(1).py
1,088
3.90625
4
from re import * name = input('inter you name:') address = input('inter you email address:') phone = input('inter you phone:') def validateAddress(address): pattern = compile('(^|\s)[-a-z0-9_.]+@([-a-z0-9]+\.)+[a-z]{2,6}(\s|$)') is_valid = pattern.match(address) if is_valid: print('правильний em...
e93d2df0395c95a088ee849ae85a8a7ac6cef374
A-Alexander-code/150-Python-Challenges--Solutions
/Ejercicio_N017.py
250
3.890625
4
edad = int(input("Ingresa tu edad: ")) if edad>=18: print("Puedes votar") elif edad==17: print("Puedes aprender a conducir") elif edad==16: print("Puedes comprar un billete de lotería") else: print("Puedes pedir dulces en Halloween")
adb65030bc65ddc260bc84a50ef731d510b05a7e
AShar97/Interpreter
/toy.py
19,588
3.625
4
""" Toy Language Interpreter """ """ Grammar : compound_statement : statement_list statement_list : statement | statement SEMI statement_list statement : compound_statement | assignment_statement | loop_statement | conditional_statement | print_statement | println_statement |...
954f174a56381fe2736abfb4166f594fd597d1a5
alexartwww/geekbrains-python
/lesson_03/03.py
423
3.75
4
task = ''' Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов. ''' def my_func(var1, var2, var3): vars = [var1, var2, var3] vars.sort(reverse=True) return sum(vars[0:2]) if __name__ == '__main__': print(task) print(my_func(1, 2...
3881ff21671bb9468767d6cab3770b2c572bd0a4
daniel-reich/turbo-robot
/NWR5BK4BYqDkumNiB_4.py
2,076
4.1875
4
""" In this challenge, you have to verify if a number is exactly divisible by a combination of its digits. There are three possible conditions to test: * The given number is exactly divisible by **each of its digits excluding the zeros**. * The given number is exactly divisible by the **sum of its digits**. *...
8267909d103e212e448b2422fa09faaed78efe58
maryna-hankevich/test_repo
/game.py
2,731
3.59375
4
# Быки и Коровы import random def calculate_bulls_and_cows(player_n, secret_n): bulls = 0 cows = 0 for index in range(len(player_n)): if player_n[index] == secret_n[index]: bulls += 1 for index in range(len(player_n)): for j in range(len(secret_n)): if index != ...
676971970b5bf39b2be55f91b35451d401074bad
rulaothman/AdvancedDataStorageRetrieval
/climateapp2.py
4,890
3.609375
4
#Routes #/api/v1.0/precipitation #Query for the dates and temperature observations from the last year. #Convert the query results to a Dictionary using date as the key and tobs as the value. #Return the JSON representation of your dictionary. #/api/v1.0/stations #Return a JSON list of stations from the dataset. #/api/v...
ee32adabd68222a70ea542fbedc0414966f252d7
petardmnv/SoftwareDevelopment
/Turtle/solution/turtle.py
3,553
3.734375
4
from typing import List # KISS class Turtle: canvas: List[List[int]] x: int y: int is_spawned: bool orientation: str def __init__(self, x: int, y: int): if x <= 0 or y <= 0: raise IndexError self.row = x self.column = y self.canvas = [[0] * y for i ...
823714a1999e34aa22dd5d7a754f3d1636c941f2
kaparker/tutorials
/penguin-analysis/getting_started.py
2,032
4.34375
4
#!/usr/bin/env python3 import pandas as pd """ Data Analysis in python: Getting started with pandas Exploring Palmer Penguins Walk through of code in article: https://medium.com/@_kaparker/data-analysis-in-python-getting-started-with-pandas """ df = pd.read_csv('https://raw.githubusercontent.com/allisonhorst/palmerpe...
748fd364026cc32dad1622ee8ca7e87017396ade
parky83/python0209
/st01.Python기초/0301수업/py08반복문/py08_06_2단가로출력.py
478
4.15625
4
# 2단의 구구단을 가로 출력하는 프로그램을 만드시오. 끝날 때는 마침표를 붙인다. # 힌트. 출력할 문자열을 변수에 저장하고 마지막 한번만 변수값을 print()를 사용하야 출력해야 한다. for x in range(1, 10, 1): str = "2 * %d = %2d" % (x, 2*x ) # x가 9이면 마침표를 찍고 # 아니면 콤마를 찍어라. if(x == 9): print( str, "." ) else: print( str, "," ) print()
f1140d277c54cc6af29e854370e135e2e2ec2809
yeonhodev/python_lecture
/lecture47.py
1,091
4
4
class Student: def __str__(self): return "{} {}살".format(self.name, self.age) def __init__(self, name, age): print("객체가 생성되었습니다.") self.name = name self.age = age def __del__(self): print("객체가 소멸되었습니다.") def 출력(self): print(student.name, student.age) student = Student("윤인성", 3) student....
9a1d6610edb77da0d1c96e7eef66ac15d891313a
MohnishShridhar/C100-project
/ATM.py
416
3.734375
4
class Card(object): def __init__(self, name, number, pin, amount): self.name=name self.number=number self.pin=pin self.amount=amount def withdraw(self): amt= input("How much do you want to withdraw: ") print("withdrawn " + amt) def know(self): ...
9790184d9c894d8a364dd4de235cd57116bfcc96
pato0301/cs50
/pset6/dna/dna.py
1,465
3.5
4
# Import library from cs50 import get_string import re import sys import csv # Get files file_db = sys.argv[1] file_sq = sys.argv[2] # Open sequence sq = open("{}".format(file_sq), "r") sq_str = sq.read() # Open Database reader = csv.reader(open(file_db, 'r')) db_dic = {} # Read each line of db for row in reader: ...
ff5263c06aee8fe38eb46144721f503a80b1897e
NipunSaha/C-106
/Ice_cream_vs_temp.py
963
3.515625
4
import csv import plotly.express as px import numpy as np def plot_fig(data_path): with open(data_path) as f: df = csv.DictReader(f) fig = px.scatter(df,x="Temperature",y="Ice-cream Sales") fig.show() def get_data_source(data_path): temp = [] ice_cream_sales = [] w...
529a397ac3dde8a9373cd0ae151e6398859f6cd0
shenchuang006/python
/Kitchen/Fridge.py
1,744
4.125
4
#coding=utf-8 class Fridge: """ This class implements a fridge where ingredients can be added and removed individually , or in groups. The fridge will retain a count of every ingredient added or removed, and will raise an error if a sufficient quantity of an ingredient isn't present. ...
45e7a9010b5dd5c64c2806a33cac78e7892519bc
pascal19821003/python
/study/tutorial/if.py
105
4.03125
4
x=1 if x<1: print("greater than 1") elif x==1: print("equal to 1") else: print("less than 1")
043e99fe5c5c38f11d55e170be19446ab70df4d0
niki4/leetcode_py3
/easy/443_string_compression.py
4,193
4
4
""" Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the original array. Every element of the array should be a character (not int) of length 1. After you are done modifying the input array in-place, return the new length of the array. Follow up:...
4b8ebcacdeba688f66c21c77c022d7393c9b288c
naimucar/8.hafta_odevler-Fonksiyonlar
/sayiokuma fonk.py
3,225
4.03125
4
#Kullanıcıdan 2 basamaklı bir sayı alın ve bu sayının okunuşunu bulan bir fonksiyon yazın. # Örnek: 97 ---------> Doksan Yedi def sayi_oku(rakam=(input('1.yol en cok 3 basamakli sayiyi giriniz :'))): if rakam.isdigit()==False: print('lutfen 3 basamakli sayi giriniz') return birler =['','bir','...
b8041320ef62fadfc8f1657299cea4864d301187
choicoding1026/data
/python/python09_문장2_반복문3_dict_comprehension.py
1,116
3.703125
4
''' dict Comprehension 형태: for문 + 조건문 혼합형태 for key,value in mm.items(): # [ (key,value), (key,value)...] print(key,value) 용도: 제공된 딕셔너리를 반복해서 조건 지정 및 임의의 연산을 적용해서 다시 딕셔너리로 반환하는 기능. 문법1: result = { k:v for k,v in dict.items()} 문법2: 단일 if 문 result = { k:v for k,v in dict.it...
2a03972f4c213faba1a592a70171d6ebf7e0aa75
chenjingtongxue/python
/13/copy_file/猜数字.py
354
3.703125
4
import random randnum=int(random.uniform(1,10))#光是random.uniform是返回带有小数的随机数 guessnum=int(input('请你猜一个1到10之间的整数:')) if randnum>guessnum: print('您猜小了,随机数是:',randnum) elif randnum==guessnum: print('恭喜,您猜中了') else: print('您猜大了,随机数是:',randnum)
a80562d9a9b5e22dc09942fd25e84635bbf5b5a9
jatin2504/Machine-Learning
/Part 1 - Data Preprocessing/data_preprocessing.py
833
3.71875
4
# Data Preprocessing #Importing the library import numpy as np import matplotlib.pyplot as plt import pandas as pd #Importing the dataset dataset = pd.read_csv('Data.csv') X = dataset.iloc[:,:-1].values y = dataset.iloc[: , 3].values #Taking care of missing values from sklearn.preprocessing import SimpleImputer miss...
a4f14ecdbcb335af275ed267324668264054d26b
adebayo5131/Python
/ReverseLinkedList.py
275
3.765625
4
#O(n) time and O(1) space where n is the number of nodes in the linkedlist def reverseLinkedList(head): current1 = None current2 = head while current2: current3 = current2.next current2.next = current1 current1 = current2 current2 = current3 return current1
011622bd8e0ee4d16bb0d9f1acfaed6d4fb1f0e8
VectorTensor/Mathematical_tools
/RK_4.PY
687
3.9375
4
# Solution of first order differential equation using RK-4 method. import math import matplotlib.pyplot as plt #function dy/dx=f(x,y) def f(x,y): return (1+x**2)*y h=0.02 #Step size x0=0 #initial value f(x0)=y0 y0=1 a=[x0] b=[y0] def y(x0,y0): #RK-4 Iteration function m1=f(x0,y0) m2=f(x0+(h/2),y0+(h/2)*m1...
52ffe7537bc56f62df2db3c3f742763ebf37a05f
wenwenbbyy/python
/grade.py
353
3.984375
4
def computegrade(score): if score>=0.9 and score<=1.0: print 'A' elif score>=0.8 and score<0.9: print 'B' elif score>=0.7 and score<0.8: print 'C' elif score>=0.6 and score<0.7: print 'D' elif score<0.6 and score>0: print 'F' else: print 'Bad score' try: s=raw_input('Enter score:') computegrade(flo...
b99ada75d53844a69a19d7a38ea84b8d28cd0a5a
Aayushi-Mittal/Udayan-Coding-BootCamp
/session8/Markdown-Table-Generator.py
1,507
3.75
4
rows=int(input("Enter number of rows: ")) cols=int(input("Enter number of columns: ")) center=input("Do you want items to be centered? (true/false): ") headings=[] print("\nEnter the data for each cell respectively!") file = open("table.md", "w") print("Let's Generate a Table in Markdown Syntax:\n") for i in r...
9062c1ae5bb22b1b3885c2c66aaa9bc90732b5f3
lemonnader/LeetCode-Solution-Well-Formed
/string/Python/0005-longest-palindromic-substring(马拉车算法-pre).py
1,440
3.765625
4
class Solution: # Manacher 算法 def longestPalindrome(self, s: str) -> str: # 特判 size = len(s) if size < 2: return s # 得到预处理字符串 t = "#" for i in range(size): t += s[i] t += "#" # 新字符串的长度 t_len = 2 * size + 1 ...
e4219692d4e2ff0a9c4cb092d930d9cd4800df74
TravisLeeWolf/ATBS
/Chapter_9/osWalk.py
407
3.765625
4
#! python3 # osWalk.py - Learning how to walk a directory tree import os for folderName, subFolders, fileNames in os.walk('S:\\Documents\\GitHub\\ATBS'): print('The current folder is ' + folderName) for subFolder in subFolders: print('SUBFOLER OF ' + folderName + ': ' + subFolder) for fileName in...
eec920ddc92606a08179b834067f6085da2fe715
Shammy0786/Python-learning
/glob.py
470
3.75
4
# i=10 #global scoe vRIble # def function1(n): # i=5 #local # m=6 #local # global i # i=i+7 # print(i,m) # print(n,"yes it is") # # function1("really") # print(m) x=76 def shammy(): x=3 def azad(): global x # it cannot be global becouse we didnt define outside the ...