blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
54aafe26e9d3f45903d0034fc1acf73af72b25e0
gfcharles/euler
/python/euler002.py
624
3.734375
4
""" Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Find the sum of all the even-valued terms in the sequence which do not exceed four million. """ from common.euler_lib import fibonacci...
6466c540fe3fde11e8f4a646c6dcc5b5fb2d749a
lakshmick96/python-practice-book
/chapter_5/problem3.py
392
3.796875
4
#Write a function findfiles that recursively descends the directory tree for the specified directory and generates paths of all the files in the tree. import os def findfiles(dir_name): for root, directories, filenames in os.walk(dir_name): for filename in filenames: print os.path...
9495ea5606cf06c11b83ca8e3887549a61ba44e8
josemorenodf/ejerciciospython
/Bucle for/BucleFor7.py
208
3.6875
4
''' En vez de una lista, se puede escribir una cadena, en cuyo caso la variable de control va tomando como valor cada uno de los caracteres ''' for i in "AMIGO": print(f"Dame una {i}") print("¡AMIGO!")
32d194c845a0f20fbd6e23f8bf977aae51173a30
TigerKing-Cser/Person-Learning
/bicycles.py
874
4.21875
4
bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) # 访问列表元素 print(bicycles[0]) print(bicycles[0].title()) # 修改元素列表 bicycles[0] = bicycles[0].title() print(bicycles) # 在列表中添加元素 ## 在列表尾部添加元素 bicycles.append('ducati') print(bicycles) ## 在列表插入元素 bicycles.insert(0, 'ducati') print(bicycles) # 从...
95df35be127e3dabcaffd48320970ff72b7491bb
Yihang-Chen/data-structure-and-algorithm-in-python
/ch5栈和队列/后缀表达式求值.py
813
3.546875
4
from sstack import SStack def suffix_exp_evaluation(line): exp = line.split(' ') operators = '+-*/' st = SStack() for x in exp: if x not in operators: st.push(float(x)) continue if st.depth() < 2: raise SyntaxError('操作数错误!') b = st.pop() ...
370dcf1952b70c037d0d50bfdb2b91cc51be4559
chandraharsha4807/PYTHON--CODING-PROBLEMS
/ORDER-MATRIX.py
683
3.78125
4
n = input().split(" ") rows = int(n[0]) col = int(n[1]) matrix = [] for i in range(0, rows): matrix.append(sorted([int(col) for col in input().split()])) #print((matrix)) # Create an empty list to store matrix values temp = [] for i in range (rows): for j in range(col): temp.append(matrix[i][j]) #...
0d494812b22df4244b0623c32e146a01063fdf8f
kayyali18/Python
/Python 31 Programs/Ch 10/Simple_GUI.py
303
3.609375
4
# Simple GUI # Demonstrates creating a window from tkinter import * # create a root window root = Tk () # modify the window root.title ("Simple GUI") # sets the name of the title root.geometry ("300x200") # sets the size in pixels # kick off the window's event loop root.mainloop ()
31d6ba8177c826d677088e31fb9bbcc34e70ae42
mila-orishchuk/pythoncourse
/Lesson4/task6.py
1,182
3.859375
4
''' tasks ''' number = int(input('Enter number: ')) for i in range(number): if not i % 18 == 0 and not (50 <= i <= 80): if i == 42: print('Потому что') else: print(i) ''' ''' attempts = 0 max_number = None while attempts != 5: user_input = input('Enter numbers: ') ...
0334565f8ffd638b8a6e551c58247cdbbc8ff163
mike6321/dataStructure_algorithm
/Homework04/Problem05.py
1,305
3.734375
4
class ArrayQueue: def __init__(self): self.data = [] def size(self): return len(self.data) def isEmpty(self): return self.size() == 0 def enqueue(self, item): self.data.append(item) def dequeue(self): return self.data.pop(0) def peek(self): r...
71aeae28f1a7fcc850f4e2ceff800eade8918c01
aayushipriya03/Hacktober20fest21
/Python/01_variable.py
261
3.5625
4
a_122 = '''harry''' # a = 'harry' # a = "harry" b = 345 c = 45.32 d = True # d = None # Printing the variables print(a) print(b) print(c) print(d) # Printing the type of variables print(type(a)) print(type(b)) print(type(c)) print(type(d))
2953b7a18f8fee8ec3ca2b0bf7b5bb15ee5b4a29
Tebazil12/advent-of-code2020
/day6.py
539
3.578125
4
with open("input-day6", 'r') as f: num_yeses = 0 current_answer = '' for i, line in enumerate(f): # print(i) if line == '\n': #stop and prcoess list_answer = list(current_answer) set_answer = set(list_answer) num_yeses = num_yeses + len(set_ans...
7260c27e17c2decc78c8f6c3cd09b021a3ecf7b6
rajagoah/Python-Importing-From-Web
/ImportingFromWebExercise8.py
520
3.625
4
import requests from bs4 import BeautifulSoup #storing url in variable url = 'https://www.python.org/~guido/' #packaging, sending and receiving the response r = requests.get(url) #html_doc storing the html in text html_doc = r.text #converting to beauitfulsoup object soup = BeautifulSoup(html_doc) #finding all the...
04653c5b85ddf440a2af9f4e475231f4715de36a
guoyuantao/Data_Structure_and_Algorithm
/Stack/括号匹配.py
1,341
4.125
4
""" 在数学运算中,括号需要是匹配的。编写程序判断括号是否匹配。 思路: 1. 初始化一个空栈 2. 遍历括号,如果是左括号,入栈 3. 如果是右括号,如果栈顶元素是左括号,则出栈,消去。 4. 当右括号仍存在,栈以空。或者栈不空,右括号扔存在。则不匹配。 """ from Stack.stack import Stack def parChecker(symbolString): """ 简单括号是否匹配 :param symbolString: 括号字符串 :return: bool型,匹配:True,不匹配:False """ # 初始化一个栈 s = Stack(...
c6329ee5c657d050856c8ae5e9e642f3084e56be
TobiasDemoor/LeetCode
/leet.932.py
499
3.5
4
from typing import List class Solution(object): def beautifulArray(self, n: int) -> List[int]: ans = [1] while len(ans) < n: tmp1 = [] tmp2 = [] for i in ans: aux = i*2-1 if aux <= n: tmp1.append(aux) ...
2c94cc3fd735f8a01cf08b39e27cf3278c6e06cb
hbagaria4998/Forsk2019
/Day1/handson.py
160
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue May 7 18:18:13 2019 @author: hbagaria """ num = 1 while num<1: print(num) num += 1
7e9f5c4c7cdd5987533b98ceeee635891ad05406
woskar/automation
/gui/mouseNow.py
1,782
4.3125
4
#! usr/bin/env python3 # mouseNow.py - Displays the mouse cursor's current position. ''' Project: Where is the mouse right now? Being able to determine the mouse position is an important part of setting up your GUI automation scripts. But it’s almost impossible to figure out the exact coordinates of a pixel just by l...
aea2dc100c814bfe2fec5828286a59c8ece4efa6
tawanchaiii/01204111_63
/ELAB06/lab06_05.py
629
3.90625
4
def mul_matrix(A,B) : result = list() m = len(A) n = len(B[0]) for i in range(m): b = [] for j in range(n): b.append(0) result.append(b) for i in range(len(A)): for j in range(len(B[0])): for k in range(len(B)): resu...
4b3bf86aac25fb535b63c6a5871a55476eb3d991
sutt/ppd
/scratch/scratch4.py
3,164
3.734375
4
""" ================== Animated histogram ================== This example shows how to use a path patch to draw a bunch of rectangles for an animated histogram. """ import numpy as np import matplotlib.pyplot as plt import matplotlib.patches as patches import matplotlib.path as path import matplotlib.animation as an...
4429334f3bd2d9236096b12d7048d6a13f9637da
DinaShaim/GB_Algorithms_data_structures
/Les_1_HomeWork/les_1_task_1.py
500
4.25
4
#Найти сумму и произведение цифр трехзначного числа, которое вводит пользователь. print('Введите целое трехзначное число') x = int(input('Число = ')) S = x % 10 + x // 10 % 10 + x // 100 P = (x % 10) * ((x // 10) % 10) * (x // 100) print(f'Сумма чисел введенного числа = {S}') print(f'Произведение чисел вве...
4cd5d9c893f28033e15b34b4d09e3e0660ee3dd8
JoseJunior23/Iniciando-Python
/aprendendo_python/ex012.py
394
3.625
4
# leia o preço de um produto e mostre seu novo preço com 5% de desconto i = (' Calcula desconto ') print('{:-^175}'.format(i)) pr = float(input(' Entre com o valor do poduto : ')) des = pr * 0.05 vf = pr - des print(' O valor inicial do produto é de ${}, com o descconto de 5% você pagará ${}.'.format(pr,vf)...
db671c189b475b57cc425436c6f0850a7ac50b6a
shieh08/projeuler
/p003_largest_prime_factor.py
698
3.984375
4
# projecteuler.net/problem=3 # What is the largest prime factor of the number 600851475143 # Function to figure out prime or not. def is_prime(n): if n < 2: return False # Eliminate even numbers. if not n & 1: return False # Check for each odd number up to sqrt of n. for x in range(3, int(n**0.5)+1...
5c736dcb9f246efb06097f218bec5bedf72334f9
RaghavNitish/Unscramble-Computer-Science-Problems
/Task4.py
1,340
4.25
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 4: The telephone company want to i...
386a47aebb998286008f42e0ea90f79789f1ad07
Yengwa/PiPractice-
/dim.py
893
3.5
4
from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) button1=16 button2=12 LED1=22 LED2=18 GPIO.setup(button1,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(button2,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(LED1,GPIO.OUT) GPIO.setup(LED2,GPIO.OUT) pwm1=GPIO.PWM(LED1,1000) pwm2=GPIO.PWM(L...
f697903eb75f728ebc9622ab8abe89234caf765a
cjb5799/DSC510Fall2020
/THEOBALD_DSC510/THEOBALD_DSC510_Assignment 6.1.py
1,434
4.4375
4
#DSC510 #Week 6 #Programming Assignment Week 6 #Author Ammy Theobald #10/11/2020 #Change#:1 #Change(s) Made: Initial Program #Date of Change: 10/11/2020 #Author: Ammy Theobald #Change Approved by: N/A #Date Moved to Production: 10/11/2020 #Initial Greeting name = input('What is your Name? \n') print('H...
6a368d826715b3d9ce69d0b9484abd57c1076a0d
lyvius2/python-dataAnalytics
/util.py
167
3.578125
4
# -*- coding: utf-8 -*- def sum_func(*args): sum =0 for i in args: sum += 1 return sum def echo_func(say): return "You said {0}".format(say)
eeeb9f609eac475e12358c06d008dec07dec0073
santoshjoshigithub/spark
/rdd/average_friends_by_age/average_friends_by_age.py
2,204
3.65625
4
# Problem: There is a file having fields as <id, name, age, num_of_friends). Write a spark program to find the averge number of friends for any given age. # following modules are used to run spark in local windows. import findspark findspark.init() findspark.find() import pyspark # import required modules for Spark t...
2e8b138685cb7f1359ade25633553e09bc1805d1
freelifedev/Course_Module1
/drawing.py
2,496
3.796875
4
# import the necessary packages import numpy as np import cv2 # initialize our canvas as a 300*300 with 3 channels, Red, Green, # and Blue, with a black background canvas = np.zeros((800,1300,3), dtype="uint8") #draw a gren line from the top-left corner of our canvas to the # bottom-right green = (0,255,0) cv2.line(c...
4ec3bf7422420cbdef2184c20c35a66196421ca6
leyap/python3-tutorial
/Python3Tutorial/digit.py
93
3.8125
4
a = 2 b = 3 print(a+b) print(a*b) #a^3 print(a**b) print("0.1 + 0.2 = ") print(0.1+0.2)
b4d635fea395532940c9b15530794d91195cb5d7
AshBesada/Grocery-List
/IT-140-grocery_list.py
1,956
4.1875
4
# Create a dictionary grocery_item = {} # Create a list grocery_history = [] # Variable used to check if the while loop condition is met stop = False # A while loop # Initializes the list and asks the user for commands until he/she types 'q'. while not stop: # Accept input of the name of the grocery item purcha...
3327157790815fc578cbfadf18c07c6a0f19b917
jnhro1/CS_python
/민성,지훈/p57.py
479
3.890625
4
""" p57.py 정수 2개를 입력받아서 큰 수와 작은 수를 출력하는 프로그램 정수를 입력하세요 : 5 정수를 입력하세요 : 10 큰 수 : 10 작은 수 : 5 """ num1 = int(input("정수를 입력하세요")) num2 = int(input("정수를 입력하세요")) if num1 == num2: print("두 수가 같습니다") elif num1 > num2: print("큰 수 : %d 작은 수 : %d" %(num1,num2)) elif num1 < num2: print("큰 수 : %d 작은 수 : %d" %(num2,num...
037c65f101fd66bd312ab2283d77b7b5414edd5b
EuroPython/ep-tools
/eptools/finaid/fetch.py
1,755
3.5625
4
""" Functions to get the data Financial Aid submissions. """ from .data import finaid_submission_hdr from ..gspread_utils import get_ws_data, find_one_row def get_finaid_ws_data(api_key_file, doc_key, file_header=finaid_submission_hdr): """ Return the content of the Google Drive spreadsheet indicated by `doc...
510a5e9411d40ed05f1c344d34fd02fdd539ffaf
anjoy92/TwitterDataAnalytics
/Chapter4/centrality/SimpleGraph.py
2,924
3.765625
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ Creates a simple retweeted graph network from the json file provided. __author__ = "Shobhit Sharma" __copyright__ = "TweetTracker. Copyright (c) Arizona Board of Regents on behalf of Arizona State University" """ import argparse from os import sys, path sys.path.append(pa...
ec029bd51cab77fd7f4ba6393825ed5f2aac2564
preetiduhan/DataStructuresInPython
/ConstructUniqueBSTs.py
1,000
3.546875
4
class Solution(object): def generateTrees(self, n): if n==0: return [] nums = [i for i in range(1,n+1)] #given a list of nodes, gives UBST list for it def treeList(L): res = [] if L==[]: return [None] if len(L)==1: ...
f86f9259027249afabeec3bd43803eb45914d4bd
saurabhgupta2104/Coding_solutions
/LeetCode/Delete_Nodes_And_Return_Forest.py
1,970
4.03125
4
# https://leetcode.com/problems/delete-nodes-and-return-forest/ """ Given the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees). Return the roots of the trees in the remaining forest. You may r...
8eefae95b9d0ace2c0adc9f8d69f9030c168d62c
xhaatemx/py4e-my-solutions
/file extract/extractCommonHours.py
470
3.59375
4
hours = [] common = {} name = input("Enter file:") if len(name) < 1 : name = "1.txt" file = open(name) # extract Senders Data for line in file: if not line.startswith('From '): continue line = line.strip('From ').split() # add each hour into a list hours.append(line[4][: line[4].index(':')]) for h in hours: if...
93763cea8dcaf62a26d630652dca25e078cd8de6
ronething/python-async
/async_overview/06/an_error.py
522
4.125
4
# -*- coding:utf-8 _*- __author__ = 'ronething' """ 尽量不要传可变参数 list 可以被改变 因为是指针 """ def add(a, b): """ +=背后的魔法方法是__iadd__ +背后的魔法方法是__add__ a = a + b 两者不同 += 直接修改本身 + 则是新声明一个 左边 a 和右边 a 无直接联系 """ a += b return a a = 1 b = 2 c = add(a, b) print(c) # 3 print(a, b) # 1 2 a = [1, 2, 3] b ...
b2b24e7a88647b7b7fd39867e0e8f516a69a545b
cleo-guerra/Curso-Python-Essentials-C6
/15_except_taller_GuerraCleopatra.py
560
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Aug 6 19:12:54 2021 @author: DELL """ def validarNumero(prompt, min, max): while(True): try: print("ingrese un valor entre",min,"y",max) x = int(input(prompt)) assert x >= min and x <=max return x ...
056ee794f68bdca3418da1347b3c1f2ad87ee65e
gregschmit/django-impression
/impression/tests/test_email_address.py
914
3.515625
4
""" This module is for testing the email address model. """ from django.test import TestCase from ..models import EmailAddress class EmailAddressTestCase(TestCase): def test_constructor_properties(self): """ Test the custom constructor classmethod, ``get_or_create``. """ email = ...
67f1f5108aa05777390f11328fd1acfa0079930c
yangzongwu/leetcode
/archives/interview-prepare/amazon/The Maze.py
3,428
4.4375
4
''' There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. Given the ball's start position, the destination and the maze, determine whether t...
28fc25b20f33bba1664f0186c2a8abfed0bcabda
Kanaderu/CircuitPython
/bundle/circuitpython-community-bundle-examples-20200224/examples/example3_crazy_color.py
1,668
3.6875
4
# This is example is for the SparkFun Qwiic Single Twist. # SparkFun sells these at its website: www.sparkfun.com # Do you like this library? Help support SparkFun. Buy a board! # https://www.sparkfun.com/products/15083 """ Qwiic Twist Example 3 - example3_crazy_color.py Written by Gaston Williams, June 2...
30c8c565d3da751b692faaddb3e42d3648dcff9c
Mike-Marble/Learning-Python
/EX/py4e_tutorials/ex_080.py
1,099
4.34375
4
# this program loops through the lines of the text file # finds lines that start with 'from' # splits those lines into a list # and prints the word at associated list position # opens file fOpen = open('ex_071_text.txt') # *** added after *** emailList = [] # loops for each line in the file for line in fOpen: # s...
6a521b5e3c8a38b2db7748d8f172fb1fbdc37c4d
SeregaPro1/hello-world
/Lessons/scope.py
419
3.65625
4
# scope = the region that a variable is recognized # A variable is only available from inside the region it is created. # A global and lacally scope versions of a variable can be created. name = 'Bro' # global scope(avaible inside and outside functions) def display_name(): name = 'Code' ...
fd521e551db925236cbf815c7999b44383d16b83
weddy3/TPP
/21_tictactoe/tictactoe.py
4,002
3.9375
4
#!/usr/bin/env python3 """ Author : wil <wil@localhost> Date : 2021-06-03 Purpose: Tic Tac Toe """ import argparse import re # -------------------------------------------------- def get_args(): """Get command-line arguments""" parser = argparse.ArgumentParser( description='Tic Tac Toe', for...
e13a8046bf822fcb07b4d263cec597fe1aaccbd0
DiasVitoria/Python_para_Zumbis
/Lista de Exercícios I Python_para_Zumbis/Exercicio5.py
246
3.8125
4
prod = float(input("Informe o valor total da compra: ")) desc = float(input("Informe a porcentagem do desconto: ")) porcprod = desc / 100 valordesc = prod * porcprod valortotal = prod - valordesc print('Valor total a pagar: ',valortotal)
d123186b69b0b3b66cff4522ebdc15109c29282f
BTS-413/1.Hafta
/16701042/kimlikoperatoru.py
268
3.71875
4
#is isleci a=5 b=5 """ if a is b: print("aynı") is isleci a ve b'nin id numaralarını kontrol eder. """ """ if a==b: print("aynı") ==(eşit eşit) a ve b nin değerlerini kontrol eder. """ #id fonksiyonu a=5 b=5 print(id(a)) print(id(b)) print(id(5))
3d7945af557b78b1d95a882700db093705617e19
jguecaimburu/euler
/ex46e.py
2,450
3.71875
4
""" It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 2×12 15 = 7 + 2×22 21 = 3 + 2×32 25 = 7 + 2×32 27 = 19 + 2×22 33 = 31 + 2×12 It turns out that the conjecture was false. What is the smallest odd composite that cannot be written a...
9313877802c897ccdbe07808ebe20c00822a1e3d
cuimin07/cm_offer
/11.旋转数组的最小数字.py
691
4.0625
4
''' 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。例如,数组 [3,4,5,1,2] 为 [1,2,3,4,5] 的一个旋转,该数组的最小值为1。   示例 1: 输入:[3,4,5,1,2] 输出:1 示例 2: 输入:[2,2,2,0,1] 输出:0 ''' #答: class Solution: def minArray(self, numbers: List[int]) -> int: i, j = 0, len(numbers) - 1 while i < j: m = ...
645e43ca3dfb7b9de7d12738804177bf3e114bb5
Virjanand/LearnPython
/022_partialFunctions.py
559
4.40625
4
# Partial functions # Derive a function to a function with fewer parameters and fixed values from functools import partial def multiply(x, y): return x * y # create a new function that multiplies by 2 dbl = partial(multiply, 2) print(dbl(4)) # values will be replaced from left # Exercise: replace first 3 variab...
4cb000ddb86bc5cace90a9f2525bc0e759c903fe
dmitrii1991/Python-my-works
/basic_algorithm/Fibonacci/recursuon_decor.py
325
3.515625
4
def memo(f): cache = {} def inner(x): if x not in cache: cache[x] = f(x) return cache[x] return inner @memo def fib(x): assert x >= 0 return x if x <= 1 else fib(x - 1) + fib(x - 2) def main(): n = int(input()) print(fib(n)) if __name__ == "__main__": ma...
1ac417e5fb0a373b46364624d1b5e3b8f04b4f92
SakyaSumedh/eulerProblem
/10001_prime_number.py
545
4.0625
4
''' By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? ''' from math import sqrt number = 10001 prime_list = [2] def check_prime(prim_list, value): sqrt_value = sqrt(value) for prime in prim_list: if prime > sqrt_value: brea...
712bf738d2fabdab5849c9485dd90ea11e353d95
Sonima-S/work-work-python-
/names.py
172
3.734375
4
names = ['sonee','niku','puru','santu','anu','prateek','arunema','omu','sudeep','ram'] names_with_e = [x for x in names if 'e' in x] print 'names with e are:', names_with_e
a01a780602bafb1dff4d99da46805ea269363c3c
jlopezh/PythonLearning
/co/com/test/scopeExamples.py
1,175
4.34375
4
"""Explain LEGB rule""" """Local and Global scopes""" a_var = 'global value' def a_func(): a_var = 'local value' print(a_var, '[ a_var inside a_func() ]') a_func() print(a_var, '[ a_var outside a_func() ]') print("=" * 20) """concept of the enclosed (E) scope. Following the order 'Local -> Enclosed -> Globa...
55021d0744a53dd0e23dd44406d27bfa8b822b1a
astreltsov/firstproject
/Eric_Matthes_BOOK/DICTIONARY/6_9_Favorite_places.py
315
3.765625
4
favorite_places = { 'oleg': ['crete', 'santa cruz', 'snegiri'], 'anna': ['zug', 'miami', 'samara'], 'nick': ['spb', 'kiev', 'varshava'] } for name, locations in favorite_places.items(): print(f"\n{name.title()}'s favorite places are: ") for location in locations: print(f"\t{location}")
39c9f0c7ddc4c54b7f31b0212ae5696a865d94b4
silkyg/python-practice
/Assignment_1_input_output_operators_data_type/Calculate_area_of_a_circle.py
179
4.34375
4
#program to find area of a circle , where Radius is taken from user import math r=int(input("Enter radius of the circle :")) Area= math.pi *r*r print("Area of circle is ->",Area )
03c2725edb4560c5a91a85c54b2e092d01bcc134
digoreis/code-interview
/hash-array-string/1.3-urlify/main.py
478
4.1875
4
# Write a method to replace all spaces in a string with %20. You may assume that the string has # sufficient space at the end to hold the addictional characters, and that you are given the `true` # length of the string.( Note: if implementing in Java, please use a character array so that you # can perfom this operat...
f50281e664b9aa21bf11b86fbc3d9b5085d07efd
MahadiRahman262523/Python_Code_Part-1
/practice_problem-21.py
511
3.953125
4
# Create an empty dictionary. Allow 4 friends to enter their # favourite languages as values and use keys as their names. Assume that # the name are unique. favlang = {} a = input("Enter your favourite language Sharthok : ") b = input("Enter your favourite language Auddry : ") c = input("Enter your favourite...
a5f4b44259e649e7094354067e9c97687a568937
arnabs542/BigO-Coding-material
/review/beverages_topo_sort.py
1,671
3.765625
4
from queue import PriorityQueue def dfs(src): visited[src] = True for u in graph[src]: if not visited[u]: dfs(u) result.append(beverages_ls[src]) # print('Intermediate result: ', result) def topological_sort(graph, result): for i in range(n): if not visited[i]: dfs(i) result.reve...
1b5f4f53ee9869f1c1cbceaeedd6b6c2d5a19261
MartyVos/V2ALDS_Week1
/2-getNumbers.py
805
4.03125
4
# getNumbers(s) # This function returns all the numbers in a string # Parameters: # s: str # A string with numbers # # Return: # lst: list of ints # A list with the extracted numbers def getNumbers(s): st = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') lst = [] tmp = "...
17548a1b587f96448eb701a7ee4f47f693c8a9da
cavandervoort/Udemy-Python-Course
/Milestone Project 1 (Tic Tac Toe)/TicTacToe_2_Player.py
3,073
3.8125
4
import time import IPython def did_player_win(board, letter): for row in range(3): if board[row][0] == board[row][1] == board[row][2] == letter: return True for column in range(3): if board[0][column] == board[1][column] == board[2][column] == letter: return True if ...
a0ad460471c4924633611ad7a04e213ef6b74f23
radhika5208/Elevator
/dynamic.py
1,540
3.75
4
#import Adafruit_BBIO.GPIO as g import sys import time as t dp=0 max1=5 def upward(dp,tp): for i in range(tp+1): pin="P9_"+str(11+dp+i) print "Floor No: "+str(dp+i) #g.setup(pin,g.OUT) #g.output(pin,g.HIGH) t.sleep(1) #g.setup(pin,g.OUT) #g.output(pin,g.LOW) #g.setup(pin...
839b62e12e2601922082e799cd555edd9d3a7a3a
sidneyarcidiacono/interview_prep_2
/linked_list.py
668
4.09375
4
"""Implement our linked list.""" class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.tail = None def append(self, item): new_node = Node(item) if self.head is None: ...
bafc86a5ed3cdebf0369eb590dca091254b1f0fe
zhouchengrui/COMS4701_AI
/hw1_search/treeNode.py
2,937
4.1875
4
#!/usr/bin/env python3 class TreeNode(object): """ This class represents the search tree node """ def __init__(self, state, parent_move = None, parent = None): self.state = state self.parent_move = parent_move self.parent = parent self.cost = parent.cost + 1 if parent els...
f2afd53886e8c277e9f49847e8bd69fad9b0d420
peqadev/python
/doc/practices/12.data_types_strings_modifiers.py
518
4.21875
4
# Modificadores de cadenas a =" Hello, World! " print(a.upper()) # HELLO, WORLD! print(a.lower()) # hello, world! print(a.strip()) # Hello, World! (Elimina todos los espacios en blanco) print(a.lstrip()) # Hello, World! (Elimina los espacios en blanco a la izquierda) print(a.rstrip()) # Hello, World! (Elimina ...
4a6d2bf606de9327bf53dbb408df1027ea5e9c59
Sunqk5665/Python_projects
/算法练习/PTA/python蓝桥/第1周/04-输出10个不重复的英文字母.py
796
4.21875
4
# 要求:随机输入一个字符串,把最左边的10个不重复的英文字母(不区分大小写)挑选出来。 # 如没有10个英文字母,显示信息“not found” # String模块 ascii_letters 和 digits 方法:ascii_letters是生成所有字母, # 从a-z和A-Z,digits是生成所有数字0-9 from string import digits # 所有数字 from string import ascii_letters as al #所有字母 def prt(s): # 筛选函数 re='' # for i in s: if i in al and i.lower() ...
d2d95e4c1af0668a79b4229494a020ddf92af7ab
mzivi/elgoog
/leetcode/001_two_sum.py
1,109
3.90625
4
# Given an array of integers, return indices of the two numbers such that they add up to a specific target. # # You may assume that each input would have exactly one solution, and you may not use the same element twice. # # Example: # # Given nums = [2, 7, 11, 15], target = 9, # # Because nums[0] + nums[1] = 2 + 7 = 9,...
a43187a9a5ff3986c89f835ccf4e390ecbe51aa8
MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video
/Ex063-Fibonacci.py
228
3.828125
4
n = int(input('Digite quantos termos da Sequência de Fibonacci você deseja ver: ')) x = 0 a = 0 b = 1 print(f'{a} {b} ', end='') while x != n+1: soma = a + b print(f'{soma} ', end='') a = b b = soma x += 1
de9b81bb4b9d4245a4f947452713301cedcf17e3
eidgahadi/Homework2
/Time_conversion.py
399
3.859375
4
time = input().split(":") hours = int(time[0]) minutes = time[1] seconds = time[2][:2] ap = time[2][2:] if ap == "PM" and hours != 12: hours += 12 elif ap == "PM" and hours == 12: hours = 12 elif ap == "AM" and hours == 12: hours = 0 if hours < 10: hourString = "0" + str(hours) else: ...
f91d53cdf044934f5a131ef37ff875734bf53155
armanshafiee/allback
/math henese.py
4,639
3.65625
4
print("num2=1=>edame,,,num2=0=>by by") for z in range(999): print("1)+") print("2)-") print("3)*") print("4)/") print("5)mokeab") print("6)mokeab mostatil") print("7)heram kaf moraba") print("8)kore") print("9)heram kaf mosalas") print("10)makhrot") print("11)ostovane") p...
808603a128dba73cdaa9165e08b983b482a1e501
kleyow/webapp2_boilerplate
/forms/custom_validators.py
768
3.53125
4
import decimal import re from wtforms import ValidationError class DecimalPlaces(object): """Validates the number of decimal places entered in a field.""" def __init__(self, min=2, max=2, message=None): self.min = min self.max = max self.message = message def __call__(self, form, field): if n...
cb59c684d88f5c2fcdccb067370357bdfe127af6
clopez5313/PythonCode
/Lists/Middle.py
154
3.703125
4
def middle(theList): length = len(theList) return theList[1:length-1] tList = ['a','b','c','d'] nList = middle(tList) print(nList) #print(tList)
50b58fbfdc1ee9be5a5ab0780e6f7d39daae8057
SalmaFarghaly/cross-word
/util.py
841
3.5625
4
import heapq class Node(): def __init__(self, state,cost): self.state = state self.cost=cost def __lt__(self, other): return self def __le__(self,other): return self def __gt__(self, other): return self def __ge__(self, other): return self ...
f75b6a117749ce635dedb6f6c2b24fa419cfb72e
ByketPoe/gmitPandS
/week10-objects/timesheetentry.py
493
3.65625
4
# timesheetentry.py # The purpose of this program is to enter data into time sheets. # author: Emma Farrell import datetime as dt class Timesheetentry: def __init__(self, project, start, duration): self.project = project self.start = start self.duration = duration def __str__(self):...
435608237a4c2b9ba79eb7cb73d1bb3754ca2c69
erauner12/python-scripting
/Linux/Python_Crash_Course/chapter_code/chapter_06_dictionaries/reference/aliens.py
546
4.1875
4
# we will be putting a dictionary inside of a list # Make an empty list for storing aliens. aliens = [] # Make 30 green aliens. for alien_number in range(30): new_alien = {'color': 'green', 'points': 5, 'speed': 'slow'} aliens.append(new_alien) # change the properties of the first 3 aliens for alien in alie...
e32e4c511f1940ee10a702f87df6a3da9b8184af
sreenidhimohan/sreenidhi
/number.py
123
3.984375
4
i=int(input("enter the number")) if(i>0): print("positive number") elif(i<0): print("negative number") else: print("zero")
e8f42fe26b8fee2cdefff69d9ee05e6fa9c8a18e
AnneOkk/Alien_Game
/settings.py
1,075
3.859375
4
class Settings: """A class to store all the settings for the game""" def __init__(self): """Initialize the game's settings""" #Screen settings # create a display window on which we'll draw graphical ship self.screen_width = 1200 self.screen_height = 800 # (1200, ...
21e3eba7f84540c0ce018a3c5379fce687fe65f7
zhazhijibaba/zhazhijibaba_programming_lessons
/programming_lesson2/compute_pi_monte_carlo.py
660
3.890625
4
# Compute pi value by Monte Carlo sampling # circle area within a square with unit length # pi = Area / r^2 # Area = Area of the square * number of points within circle / total number of points # Area of the square = 4 * r^2 # pi = 4.0 * number of points within circle / total number of points import random import math...
71bb53b624ce1940d037468920c1e77e809b068b
ThistleBlue22/CountAndLength
/main.py
2,446
3.765625
4
from wordCount import wordcount from lineCount import linecount from meanWordLength import meanwordlen import argparse def main(doc, calctype): try: # the below code checks the if calctype == "wordcount": wc = wordcount(doc=doc) print("Word Count:", wc, "\n") elif c...
6ba66782689daf236d285102ede6aaf270ec512f
Javierzs/Algoritmosyprogramacion-Grupo2Ciclo4
/Semana6/1332.py
325
3.609375
4
n=int(input())#casos de prueba c=0#contador while True: if(c==n): break c=c+1 palabra=input("") tamaño=len(palabra) if(tamaño==5): print("3") elif(palabra[0]=="t" and palabra[1]=="w" or palabra[0]=="t" and palabra[2]=="o"or palabra[1]=="w" and palabra[2]=="o"): print("2") else: print("1"...
e407972e07cefd0a1ed3ede24f796d6adb3327ac
amidoge/Python-2
/ex092.py
611
4.4375
4
#Is a number prime? ''' -Greater than 1 -Only divisible by one and itself -Return True if prime, False if not -Only runs in the main file ''' def prime_or_not(number): #loop that runs until half the number if number > 1: if number == 2: return True else: for i in range(...
07a4f9a0fd0ce8af74f527a4a1c970d89c820fdf
BreadSocks/adventofcode2017-python
/day01/Day 1 Challenge 1.py
398
3.515625
4
data = open("input.txt").read() example1 = "1122" example2 = "1111" example3 = "1234" example4 = "91212129" total = 0 input = data for index, character in enumerate(input): if index == len(input) - 1: if character == input[0]: total += int(character) else: continue el...
c459325e7faf43e5e3e9e06fa08fe05e8799c8cc
Gzigithub/markup
/Python/algorithm/quick_sort(快速排序).py
709
3.765625
4
# 快速排序法 # 递归思想,sum()函数即是如此思想计算 # 计算速度的快慢取决于基准值的选取 def quick_sort(array): # 基线条件:为空或者只包含一个元素的数组是‘有序’的 if len(array) < 2: return array # 递归条件 else: # 设定基准值 pivot = array[0] # 由所有小于等于基准值的元素构成的子数组 less = [i for i in array[1:] if i <= pivot] # 由所有大鱼基准值的匀速构成的子数组...
459f902d7c79b669b70ba73a8f42c6a12301732d
th9195/PythonDemo01
/MyFuncation.py
1,297
3.9375
4
#空方法 def fun(): pass def my_abs(number): ''' 自定义abs :param number: int 或者 float :return: abs 绝对值 ''' #参数判断 #函数出错友好提示 if not isinstance(number,(int,float)): raise TypeError("只能输入int 和 float 类型") if number >= 0: return number else: return -number def...
32e75a5aa8da2e030edbc33c8d99eb2c90dd493f
shahpriyesh/PracticeCode
/GrpahQuestions/CourseSchedule2.py
403
3.59375
4
from collections import defaultdict class CourseSchedule2: def courseSchedule2(self, numCourses, prerequisites): # map course -> list of prerequisites hmap = defaultdict(list) for prereq in prerequisites: hmap[prereq[0]].append(prereq[1]) # keep a list of taken classes ...
4c39b92209937c3ca1f7b6102c9b5a71d7484772
ccmb501/Code-Rev
/CodeRev.py
764
3.921875
4
BuildingDict = { "mosher":{"spider man": "066", "doctor strange": "123", "peter quill": "234", "iron man": "066", "incredible hulk": "456", "black widow": "090", "hawk eye": "270" } } userNameInput = input("Please enter your name: ") userRoomInput =...
5afe76de8a5e48ff3ce956f934d00a2ac004c435
harshitaJhavar/Neural-Networks-and-its-Applications-Deep-Learning-
/Question2_5.py
1,484
4.15625
4
##Solution for Question 2.5 ##Source code for stopping criterion ## Let us solve it for exercise 2.3- Gradient Descent ##Question 2.3 Gradient Descent Source Code from math import pow ## Initiating number of iterations to 0. Number_of_Iterations = 0 ## Defining the value of precision precision = 1/1000000 ## Limiti...
1bd20857eba027790b118f02f8eaa81dc321adce
PeterSharp-dot/dot-files
/python-projects/primes-generator/p_gen.py
845
3.984375
4
#!/usr/bin/env python def primesGen(max): primes = [] l = 3 # Lista nieparzystych aż do max while l <= max: if (l % 2 == 1): primes.append(l) l += 1 # import pdb; pdb.set_trace() # Odsiewamy te z dzielnikiem for i in primes: if i > 3: ...
2881ca279c67790a2d67ebbd9d67a94a402a2e42
Labs17-RVNav/rvnav-ds
/Rv_Flask/utils/geometry.py
933
4
4
from math import radians, cos, sin, asin, sqrt class Geometry: def __init__(self): self.init() def get_med_coordinate(lon1, lat1, lon2, lat2): lat_med = (lat1+lat2) / 2 lon_med = (lon1+lon2) / 2 return lat_med, lon_med def haversine(lon1, lat1, lon2, lat2): """ ...
fe877605ead1810bedaad9ba24cbc29217af1cc3
rishabh0071/JUMBLED_WORD_GAME
/jumbled_word_game.py
1,739
3.640625
4
import tkinter from tkinter import * import random from tkinter import messagebox answers = [ "python", "java", "swift", "canada", "india", "mexico", "legend", "dragon", "well", "king" ] words = [ "nptoyh", "avja", "wfsit", "cdanaa", ...
97ed0e9e7cb9aa35b933c8c72e9fbb146a8a71ec
mnizhadali-afg/PythonCourse
/ch05/GeneratorExpression.py
123
3.78125
4
numbers = [10, 3, 7, 1, 9, 4, 2, 8, 5, 6] for value in (x ** 2 for x in numbers if x % 2 != 0): print(value, end=' ')
71ba3be9cdb1fb1a5288c001716fd2278c1325e0
iamnst19/python-advanced
/Fundamentals_First/Functions/return.py
1,351
4.1875
4
cars = [ {'make': 'AUDI', 'model': 'Q2 Dsl', 'mileage': 19896, 'price': 17800}, {'make': 'AUDI', 'model': 'A6 SW Dsl', 'mileage': 87354,'price': 52000}, {'make': 'SKODA', 'model': 'Fabia', 'mileage': 90613, 'price': 11000}, {'make': 'AUDI', 'model': 'A4 SW Dsl', 'mileage': 47402, 'price': 93000}, {'make': 'V...
82110073b33ca9e06b82ac93bbcb966ee8f6bd0d
Super-Rookie/testproject
/practice projects/Somelikeithoth CYOA.py
3,956
4.03125
4
import random player_hp = 50 enemy_hp = 10 boss_hp = 15 loot = 0 name = input("Enter a name: ") print("You have been given a bow and some arrows and have been tasked with one goal: Defeat the boss in the cave.") print("You enter the cave and find footprints that leads to a path going to the right.") choice_one = inp...
47295c61a44cfd497988c0ab9265732b3fc7a8ad
tony-x-lin/susd_search
/susd_lqr/plotting_tools/plot.py
865
3.515625
4
import matplotlib.pyplot as plt import numpy as np def cost_plot(z, names): """ plot training improvement """ plt.figure() plt.grid() for i in range(len(z)): plt.plot(z[i]) plt.legend(names) plt.title("Cost during Training") def plot(x, x_lqr, dt): """ plot th...
6abadf8bb1200db2ad353e542a3140cd53ad77b3
jjshanks/project-euler
/007/solution.py
1,096
3.6875
4
# https://projecteuler.net/problem=7 # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. # What is the 10,001st prime number? # DEV NOTES # brute force solution took ~90 seconds # only checking odds dropped the solution down to ~45 seconds # only checking known primes...
d58289b8eec582ac627e8d36ba2d669ac84386a4
Mykola-L/PythonBaseITEA
/Lesson3/3_2.py
268
3.765625
4
def two_numbers(a, b): if a == b: print('a дорівнює b') elif (a - b) and 5: print('a - b = 5') elif (b - a) and 5: print('b - a = 5') elif (a + b) and 5: print('b + a = 5') return True two_numbers(2, 3)
1576ef3c15f969fb484cb8258ab2574ab72ed86e
Berrio2411/Algoritmos2021-01
/talleres/tallerfuncionesmap.py
1,079
4.25
4
#Crear una función map que haga lo siguiente: # Devuelva el cuadrado de cada elemento de la lista potenciador = lambda valor : valor ** 2 lista = [8,4,23,42,15,33,21] listaCuadrados = list (map(potenciador, lista)) print (listaCuadrados) #• Divida a todos los elementos de la lista por el mayor número de la misma list...
0b9a35e5ad81d0639e7fe01557ed3765cfd91f7d
Taoge123/OptimizedLeetcode
/DailyChallenge/LC_505.py
928
3.703125
4
import collections import heapq class Solution: def shortestDistance(self, maze, start, destination) -> int: m, n = len(maze), len(maze[0]) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] heap = [(0, start[0], start[1])] distance = collections.defaultdict(int) while heap:...
c1b16b56afbfd3f4cc9119b2cfb6cc2a35e9ea5e
Leevimseppala/python
/beginner/exercise6_6.py
1,310
3.921875
4
# Kysytään käyttäjältä rajat lowpoint = int(input("Anna alueen alaraja:\n")) highpoint = int(input("Anna alueen yläraja:\n")) # Luodaan kaksi boolean muuttujaa, cont ja found cont = True found = False # Mennään looppiin jossa pysytään niin kauan kunnos cont = False while cont: # Käydään läpi jokainen luku rajojen s...
9d3273a5bf924ab227d281fd835a9bdfca338c51
zeruken117/UWM-WD
/WD/zadanie5.py
292
3.671875
4
a = int(input("Podaj liczbe a: ")) b = int(input("Podaj liczbe b: ")) c = int(input("Podaj liczbe c: ")) if (0<a<=10) and (a>b or b>c): print('a zawiera sie w przedziale od 0 do 10, oraz a jest wieksze od b lub b jest wieksze od c') else: print('warunek nie zostal spelniony')
3583855ac0b0c578226ad4bbfc007d938d0ac6b3
navyaramyasirisha/PYTHON2018FALL
/PYTHON/LAB/LAB1/Source/nonrepeat.py
249
3.84375
4
s = input("enter a string of your choice: ") while s != "": string_len = len(s) ch = s[0] s = s.replace(ch, "") string_len1 = len(s) if string_len1 == string_len-1: print(ch) break else: print("invalid input")
b8fbffb4370fd7ce91f06b440ce5d18b92c0ad2c
sullivantobias/POO-LG
/Python POO/test.py
2,186
3.6875
4
class Caracter(): def __init__ (self, pseudo, age): self.pseudo = pseudo self.age = age self.race = "" self.weapons = "" self.heal = "" pass def getRace (self): return self.race def setRace (self, race): self.race = race def setWeapons...