blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
56750ae64953539679a3ff2698c9740706272510
wmvanstone/RPiShakeCode
/wmv_utils.py
725
3.6875
4
from datetime import datetime def date2nthDay(date_string, format='%Y%m%d'): date_object = datetime.strptime(date_string, format) newYearDay = datetime(year=date_object.year, month = 1, day = 1) return(date_object - newYearDay).days + 1 def pad(num): out = str(num) while len(out) < 3: ...
2bc63ad5ed4f3dcc9b1ad9dd03c77cedf2c891cb
shelibenm/processingsheli
/lesson_4/lesson4_algoFunctions.pyde
923
4.1875
4
""" * Functions. * * The drawTarget() function makes it easy to draw many distinct targets. * Each call to drawTarget() specifies the position, size, and number of * rings for each target. """ #TODO-run the code-see what is the outcome of the code? def setup(): size(640, 360) background(51) ...
8c203390e7dddd3f1862c341d380cc075ce9b00b
court-jus/Mijnlieff
/game.py
1,763
3.671875
4
from colorama import * from board import Board from player import Player class MijnlieffGame: def __init__(self): self.board = Board(4, 4) self._p1 = Player("Player 1", Fore.RED) self._p2 = Player("Player 2", Fore.BLUE) self._next_player = self._p1 def next_player(self): ...
a16b9cf08c55e4d18de9342ab7aa58e7dca40c55
Mayur-Nagdive/let-s-upgrade-python-assignment
/pilot_navigation_system.py
1,349
4.53125
5
#Pilot navigation system #you are the pilot and your plane is at the altitude of 3000ft which is safe for landing if the plane is above 3000ft and 6000ft atleast allow the pilot to try for landing #if your plane is above 6000ft din't allow the pilot to land the plane and ask to go around #user will enter the altitu...
2493373c95004f5d108354bb7137ed2e722e4f60
aiqbal-hhs/python-programming--91883-patrick-setu
/python_quiz_base.py
9,645
3.78125
4
import time import sys try: colour = sys.stdout.shell except AttributeError: raise RuntimeError("Use IDLE") #BUILTIN = purple text #SYNC = black text #STRING = green text #console = brown text #COMMENT = red text #KEYWORD = orange text #stdout = blue text #hit = white text, black background #ERROR = black tex...
a555d38973b24f53c3c35ec88b9d65e8dc167dc4
justinwlin/Python-Data-Structure
/Archive/MSC/1003Testing.py
1,322
3.828125
4
import sys ''' [<term (var)> for <var> in <interable-collections] [<term(var)> for <var> in <iterable collections> if (cond (var)>)] ex. of conditional list res_lst[] for <var> in interable_collections>: if(<cond(var)>): res_lst.append(<term(var)>) return res_lst ''' #=============...
8f43dfa0f0a60bfd297b6f92f3dbd1accd21da6e
AprilLJX/LJX-also-needs-to-earn-big-money
/code-offer/no29printMatrix.py
1,947
4.03125
4
def printMatrix(matrix): # # matrix类型为二维列表,需要返回列表 #*matrix 将返回值其作为一个元组保存 #[::-1],即将列表第一个至最后一个复制,并且倒序 # zip x = [1,2] # y = [3,4] # zip(xy) # x = [1,3] # y = [2,4] return matrix and list(matrix.pop(0)) + printMatrix(zip(*matrix)[::-1]) # matrix and [*matrix.pop(0)]是为了防止matrix为空时...
218e4f41dcd236a9891697be5ab114137b0db6c4
layshidani/learning-python
/lista-de-exercicios/Livro Curso Intensivo de Python/CIP-6.7-pessoas.py
663
3.953125
4
# coding: UTF-8 print('----' * 30) print('Dados sobre uma pessoa') print('----' * 30) pessoas = [] pessoa = { 'first_name': 'June', 'last_name': 'Hidani', 'age': '7', 'city': 'Ferraz de Vasconcelos' } pessoas.append(pessoa) pessoa = { 'first_name': 'Lays', 'last_name': 'Hidani', 'age...
9b70f76d15d891af8db75c27adb7c1c1e048a7c2
nawealvarez/frro-soporte-2018-13
/Practico-04/Ejercicio-04.py
2,935
3.640625
4
import tkinter from tkinter import ttk class Formulario(tkinter.Frame): def __init__(self, parent): tkinter.Frame.__init__(self, parent) self.parent = parent self.initialize_user_interface() def initialize_user_interface(self): """ Dibuja una interfaz de usuario, donde...
69a89fc7a8d50d75dc1cdba38813a10aff2f1830
khizra-ali/Python-Practice
/8.py
159
4.25
4
any_string=input("Enter any string: ") string="is" if (any_string[:2] == string): print("string remains unchanged") else: print("is" + any_string)
ce29da91cef76c8a5f097579a1f7cb3bea072f94
jgartsu12/my_python_learning
/python_data_structures/tuples/lists_nested_n_tuples.py
711
4.34375
4
# Working with Lists Nested in Tuples # add new element that is a list inside of the tuple # tuples are immutable ... lists are mutable !! post = ('Python Basics', 'Intro guide to Python', 'Some cool python content') # tuple tags = ['python', 'coding', 'tutorial'] # list w/ 'strs' post += (tags,) # performed reassi...
0edc629b726022d8a0696b4a5f4ab1f3d14f47c0
kgracki/SmartCityBuses
/map_data/distance_compute.py
1,149
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # File : distance_compute.py # Author : Kacper Gracki <kacpergracki@gmail.com> # Date : 29.11.2018 # Last Modified Date: 30.11.2018 # Last Modified By : Kacper Gracki <kacpergracki@gmail.com> from math import hypot from bus_test_map i...
facf39822b091175e3c8e15c584bd5d9e273b971
rogeriolaguilar/python
/lessons/handling_errors.py
10,226
4.40625
4
""" Examples of common errors in Python """ # Remember you can use ctrl+k to comment a block of code and # ctrl+shift+k to uncomment a block of code # Syntax errors correspond to problems where your code doesn't follow the rules # for writing valid Python programs. Note that these errors arise # before Python trie...
4fc32a62c27e16211bf73555355ed9d6f38445ba
garderobin/Leetcode
/leetcode_python2/lc349_intersection_of_two_arrays.py
431
3.765625
4
class IntersectionOfTwoArrays(object): def intersection(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ if not nums1 or not nums2: return [] set1 = set(nums1) intersection = set() for num...
fd5767eb97984dfc072488d0432da5666103cf85
OptimusOO/pydatadc_2018-tidy-master
/pydatadc_2018-tidy-master/data/exercise.py
2,907
3.578125
4
import pandas as pd from pandas.io.clipboards import read_clipboard from pandas.io.parsers import read_csv df= pd.read_csv('../data/gapminder.tsv',sep='\t') df.columns df.index df.values type(df) df.shape df.info() df['country'] country_df=df['country'] print(df.head()) subset=df[['countr...
cf80c71d55c3242304250d1ef116553396a0c485
EdersonLuiz/lista_estudo_dirigido2
/Exe 4.py
512
3.84375
4
#F.U.P. que peça um número inteiro e determine se ele é ou não um número primo. #Um número primo é aquele que é divisível somente por ele mesmo e por 1. num = int(input("\nInforme um número inteiro: ")) cont = 0 div = [] for i in range(num): if num % (i + 1) == 0: cont += 1 div.append(...
99a91b7f871953e64ac0263503e3aacbaee0cfe2
taoranzhishang/Python_codes_for_learning
/study_code/Day_10/21生成器函数.py
1,033
3.671875
4
# -*-coding:utf-8-*- # @Author: 陶然至上 # @Email: taoranzhishang@hotmail.com # @File: 21生成器函数.py # @Time: 2020/12/12 18:12 # @Software:PyCharm """ def creatList(): myList=[x for x in range(1000)]#一次性全部生成,费内存 return myList print(creatList())#不带yield可以直接调用 """ def creatList2(): for i in range(1000):...
821b62163098ac04002f7d13c77b4153367af8c7
rutujar/practice
/Fork Python/Contest/Module 4/Fibonacci Objects.py
2,307
4.21875
4
Fibonacci Objects ''' # You are given two objects. Each object has data members x,y, and z. You need to find the nth fibonacci object. The nth fibonacci object is given by F(n)=F(n-1)+F(n-2); n>2 You need to sum the corresponding values of obj1 and obj2 to get obj3. # Input Format: The first line of input conta...
07f2724a6dd1e8aa8d38d693322351a9960259e7
katunold/Andela_Palindrome_Assignment
/main.py
466
3.828125
4
from palindrome import check_palindrome words = [] def main(): global run run = True while run: user_input = input("Insert word to test : ") if user_input.lower() == "exit": # global run run = False return words.insert(0, user_input) if ...
f7ae05698a55c5ea61ebbc32f009f625b604362d
noahlwest/leetcode
/python/easy/125_Valid_Palindrome.py
627
3.5
4
class Solution: def isPalindrome(self, s: str) -> bool: #first: isolate s to only alphanumeric new_str = "" if not s.isalnum(): for char in s: if str(char).isalnum(): new_str += char else: new_str = s new_s...
43f89dd957f03616beaa00cab09dae72efee1631
Cadu12/UFF
/exercicio2.py
283
3.9375
4
print("Fibonacci: ") vezes = int(input()) + 1 f1 = 0 f2 = 1 f3 = 0 fStr = None while vezes != 0: if fStr is None: fStr = str(f1) else: fStr = fStr + ", " + str(f1) f3 = f1 + f2 f2 = f1 f1 = f3 vezes = vezes - 1 print(fStr)
27263bb70f08a0132a0d1c157e2b7fb39a4c2a9e
ramon-master/CodigosPythonTurmaDSI
/Exercicio (lista e tuplas)/exer remover numeros pares.py
376
3.578125
4
valores = list() pares =[] for cont in range(0,10): valores.append(int(input(f"Informe o valor {cont+1}: "))) if valores[cont] % 2==0: pares.append(valores[cont]) for cont in range(0,len(pares)): if pares[cont] in valores: valores.remove(pares[cont]) del(pares) print(f"Lista sem os val...
98dc5bc64cd50bd4b98b1a0c814584a31f5fce87
billm79/COOP2018
/Chapter03/U03_Ex06_Slope.py
1,111
4.6875
5
# U03_Ex06_Slope.py # # Author: Bill Montana # Course: Coding for OOP # Section: A3 # Date: 14 Sep 2017 # IDE: PyCharm Community Edition # # Assignment Info # Exercise: 6 # Source: Python Programming # Chapter: 3 # # Program Description # Calculates the slope of a line, given two points entered by u...
07ba7a06514b5016521275d546dcdb793e59845d
MCLACS/Python-Public
/Module3/3E-BuildString.py
486
3.953125
4
start = input("Enter starting letter: \n") startLen = int(input("Enter number of starting letters: \n")) mid = input("Enter middle letter: \n") midLen = int(input("Enter number of middle letters: \n")) end = input("Enter ending letter: \n") endLen = int(input("Enter number of ending letters: \n")) s = "" for i in r...
1e07d0350944ad95fc3dbd78a521f40c3aeed995
df413/leetcode
/product_of_array_except_self/solution.py
1,034
3.796875
4
class Solution(object): """ Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O(n). For example, given [1,2,3,4], return [24,12,8,6]. Follow up: C...
2c33fd47438118287df5aec81c37e3731490dae2
humorliang/cookbook
/threading/多线程2.py
754
3.59375
4
# coding:utf-8 import threading from time import sleep, ctime # 主线程等所有的子线程结束以后才结束 def sing(): for i in range(3): print('正在唱歌%d' % i) sleep(1) def dance(): for i in range(3): print('正在跳舞%d' % i) sleep(1) if __name__ == '__main__': print('开始:', ctime()) # 定义线程 t1...
a02a8630b3a5ce0702965fd27d684c04d250b71f
Bmbonu/google-python-solutions
/google-python-solution/string1/mixup.py
651
4
4
# D. MixUp # Given strings a and b, return a single string with a and b separated # by a space '<a> <b>', except swap the first 2 chars of each string. # e.g. # 'mix', pod' -> 'pox mid' # 'dog', 'dinner' -> 'dig donner' # Assume a and b are length 2 or more. def mix_up(a, b): if len(a) >= 2 and len(b) >= 2: ...
71999167c68950713b3f0a1c784c183f2af2f0e6
Zantiki/PyScripts
/turtlecircle.py
4,040
4.09375
4
# Sebastian Ikin, 23/09-19 import turtle import math from _tkinter import TclError # Method to reset the screen, write the drawing-type and prep the turtle def set_up(r, main_func): # Reset the window for a new drawing wnd.resetscreen() trt.penup() trt.goto(-250, 250) trt.pendown() # Write w...
beb45267f99fe74c987a59cc9ce6767ef4228b14
Zak-Olyarnik/CS-260
/week4/post.py
1,631
3.875
4
#!/usr/bin/env python import node # contains Node class from lexer import * # contains input & tokenizing functions def infix(T): # left, me, right if T: infix(T.left) print str(T.data), infix(T.right) else: return def prefix(T): # me, left, right if T: print str(T.data), prefix(T.left) ...
d500cbea1d840b7f51bdacf293beec652d425444
GuangyaoZhang/code-Introduction_to_algorithms
/Insert sort.py
278
3.734375
4
def insertSort(A:list): for j in range(2,len(A)): for i in range(j-1,0,-1): if(A[i]>A[i+1]): t = A[i] A[i] = A[i+1] A[i+1] = t return A A = [4,5,5,7,8,234,746,23425,352345,3] A = insertSort(A) print(A)
4e24bc41b66c8474e1b23579b25d747ae401d6fc
OptimalBPM/qal
/qal/common/strings.py
3,624
3.9375
4
""" Contains miscellaneous string functions. :copyright: Copyright 2010-2014 by Nicklas Boerjesson :license: BSD, see LICENSE for details. """ import os def parse_balanced_delimiters(_input, _d_left, _d_right, _text_qualifier): """Removes all balanced delimiters. Handles multiple levels and ign...
eb503cd66cde74a371954f9057b1324bde9cb3ef
LooiXIV/UVM_Repo
/data_science_ii/HW05_Alooi/comms.py
33,570
4
4
#!/usr/bin/env python # comms.py # Alexander Looi # Last Modified: March 26rd, 2017 """COMMS This module has all the components to create, manipulate and analyze communities for a graph. In addition to manipulating and analyzing communities this module builds graphs. to associate with communities the user wishes to a...
d90e2dbcad7f361bad16280f12d90c5b38171489
brianlechthaler/FizzBuzzPython
/tests/test_DivisibilityCheck.py
919
3.578125
4
from unittest import TestCase as __tc__ from fizzbuzzpurepython import DivisibilityCheck as __divcheck__ class TestDivisibilityCheck(__tc__): def test_euclidian_quotient(self): # Create a new DivisibilityCheck object divcheck = __divcheck__(3,1) # Get the DivisibilityCheck object's Euclidi...
c1e0993722488e329ebd63543bc5171cf55c04c2
Joph25/ATI-Experiment
/stepper_motor.py
2,500
3.59375
4
import random CLOCKWISE = 1 COUNTERCLOCKWISE = 0 class StepperMotor: # ----------------------------------------------------------------------------------------------------- def __init__(self): self.counter_A = 0 self.counter_B = 0 self.counter_I = 0 self.cur_rel_pos = 0 # per...
581ac6249c143d15ff59d7f83616a3f3bfb33774
15988108363/Github
/2020.07.11-数据结构2.py
1,986
4.03125
4
#创建结点类 class Node(object): def __init__(self,val,next=None): self.val = val #有用数据 self.next = next #链表的操作 class Linklist(object): def __init__(self): self.head =None def init_list(self,date): self.head = Node(None) p =self.head for i in date: p.nex...
895312090103e0dbb2fb900038c6af350f54391c
JoseOtavioVidal/CES_22
/Cap 8/Cap8-Ex10.py
813
3.953125
4
import sys def reverse(s): """Returns a string who is a reverse of s""" r = "" for x in s: r = x+r return r def is_palindrome(s): """Analyse if s is a palindrome""" r = reverse(s) if r == s: return True else: return False def test(is_ok): """Print is the test is ok or not""" linenum = sys._getfra...
6b804e1a0110314141995ddd2ecd5426941e1380
adri-gonzalez/python-multithreading
/03_multi_threading_use_case/threading_imp.py
856
3.640625
4
import threading import queue import time def worker(): while True: item = q.get() with thread_lock: print(f'Working on {item}') print(f'Finished {item}') time.sleep(1) q.task_done() # Definimos un lock thread_lock = threading.Lock() # Creamos nuestro Que...
e6fb49134ff864293720d5d60cb3c87c53ffecd4
AbhiAgarwal/python
/data structures/graph/graph_path.py
2,392
3.65625
4
# Personal re-write of a combination of code from the following: # http://www.python.org/doc/essays/graphs/ # https://github.com/faif/python-patterns/blob/master/graph_search.py class Graph: def __init__(self, graph): self.graph = graph def findSinglePath(self, start, end, path = []): self.sta...
50d78af70434aea63293cc0913c2fd6ad5072df2
pyeng/edu_py_net
/cl6_ex2_list_to_dict.py
580
4.03125
4
#!/usr/bin/env python """ def convert_list_dict(data): a_dict = {} x = 0 for i in data: if x <= len(data): a_dict[x] = data[x] x += 1 return a_dict a_list = [1, 2, 3, "hello", "world"] new_dict = convert_list_dict(a_list) print print "List: %s" % a_list print "Dict: %s" % new_dict print """ def convert_...
3b1117fc6fa9bc01516f2749047e0d1528143bea
shankar7791/MI-10-DevOps
/Personel/Avdhoot/Python/Mar 15/prog4.py
523
3.875
4
'''Given a string, find all the duplicate characters which are similar to each others. Input : hello Output : l Input : geeksforgeeeks Output : e g k s ''' string = "Great responsibility" for i in range(0, len(string)): count = 1 for j in range(i+1, len(string)): if(...
2d08561fa9fdb38ba031a24c8819d88fa40d46b6
Mornrain/leetcode
/301-600/435.py
1,066
3.640625
4
# 435. 无重叠区间 # 给定一个区间的集合,找到需要移除区间的最小数量,使剩余区间互不重叠。 # # 注意: # # 可以认为区间的终点总是大于它的起点。 # 区间 [1,2] 和 [2,3] 的边界相互“接触”,但没有相互重叠。 # 示例 1: # # 输入: [ [1,2], [2,3], [3,4], [1,3] ] # # 输出: 1 # # 解释: 移除 [1,3] 后,剩下的区间没有重叠。 class Solution: def eraseOverlapIntervals(self, intervals): n = len(intervals) num = 0 ...
67f632d0e162966f184849386bbb4f86e9b76555
imvivek71/LearningPython
/Examples/AverageInGivenList.py
238
3.875
4
n=input("Enter the number of elements in given list:") arr=[] #Here we are using long procedure for i in xrange(0,n): arr.append(input("Enter the array elements :")) sum=0 for i in xrange(0,n): sum=sum+arr[i] avg=sum/n print avg
8b11387bc5e6d721b9ff6b5892c15e04f388acb5
naimbob95/my_adventofcode2020_answers
/day1/python/solution.py
1,279
3.703125
4
import os from random import sample def readfromtxt(): files = open('input.txt', 'r') all_num = [int(x.strip()) for x in files.readlines()] # print(all_num) return all_num ##Part1 def findtwonum(all_num): # print(all_num) arr = [] samp = sample(all_num,2) get_arr ...
874a15ae23ea3ce67eeb8bddae6c1fadeb34c414
ErrorCode51/ProjectEuler
/Euler_56.py
220
3.75
4
highest = 0 for x in range(1, 100): for y in range(1, 100): nr = int(x**y) nr = [int(n) for n in list(str(nr))] if sum(nr) > highest: highest = sum(nr) print('highest:', highest)
69b592ab82aea76e366cce59fdfb86bc7f4397f1
ardgz/CodeEval
/Easy/sumOfPrimes/sumOfPrimes.py
718
3.8125
4
import math value = 1 sum = 0 numPrimes = 0 MAX_PRIME_NUMBERS = 1000 while (numPrimes != MAX_PRIME_NUMBERS): if value == 1: # 1 is not a prime value += 1 continue elif value == 2: # 2 is a prime sum += value numPrimes += 1 value += 1 continue if v...
8a955d0c005872f341898995614799f553254d4c
aceri/portfolio
/resources/finance/python_cryptostats/minerpie/minerpie.py
1,696
4
4
""" Make a pie chart - see http://matplotlib.sf.net/matplotlib.pylab.html#-pie for the docstring. This example shows a basic pie chart with labels optional features, like autolabeling the percentage, offsetting a slice with "explode", adding a shadow, and changing the starting angle. """ from pylab import * import j...
a255f7ac9bbc80d5224ae23e6d4cfda3b71defe3
BandaruRajesh/Assignment
/42_problem.py
711
3.953125
4
""" Write a program to find the sum of first 3 digits after the decimal in the Natural Logarithmic value of given positive number. Constraints : 1<=n<=106 Example 1 Input Case 1 : 14 OUTPUT : 18 Explanation : log(14)=>2.639 """ import unittest def LogSum(nums): """ ??? Write what needs to be done ??? ...
95a2e33f52ad46c18fedd1bdf5452da40287aa6a
umairnsr87/Data_Structures_Python
/443A - anton and letters.py
317
3.578125
4
set = input() set = set.replace('{', '') set = set.replace('}', '') set = set.replace(' ', '') list = list(set.split(',')) if '' in list and len(list) == 1: print(0) else: dict = {} for i in list: if i in dict: dict[i] += 1 else: dict[i] = 1 print(len(dict))
517c31d45e4a77a1b0e13c81e32dae09c8100bce
sanjivko/datasc
/Python_WebScraping/webscrapDemo2.py
258
3.53125
4
#python code to implement the BeautifulSoup to read html page from urllib.request import urlopen from bs4 import BeautifulSoup html = urlopen("http://www.pythonscraping.com/exercises/exercise1.html") bsObj = BeautifulSoup(html.read()); print(bsObj.h1)
f82fbb8b273576557fa4ec5effd4c37e9ae080ce
sarahxu087/Intro-Python-I
/src/16_prime.py
415
4.1875
4
num = input('Write a number bigger than 0 to find if it is a prime:') def isPrime(num): if num > 1: for i in range (2,num): if (num % i)==0: print(num,"is not a prime number") print(i,"times",num//i,"is",num) break else: print(...
8aa68f437df711297ebf05f4317530a8fde40329
gnulnx/dynamol
/python_extensions/Iterator_Test/test.py
898
3.65625
4
#!/usr/bin/env python from iterator_ext import * x = list_int() for i in [1, 2, 3, 4, 5]: x.push_back(i) for i in x: print i print "Now starting TestClass" tc = TestClass() print "Testing name" tc.name = "john" print tc.name for i in tc.tcList: print i print "Push_Back test" tc.tcList.push_back(25) tc.tcList...
cb67e8f677db9cf00f21f5e3c1f96fdc12cbb52a
cybelewang/leetcode-python
/code643MaximumAverageSubarrayI.py
960
3.796875
4
""" 643 Maximum Average Subarray I Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value. Example 1: Input: [1,12,-5,-6,50,3], k = 4 Output: 12.75 Explanation: Maximum average is (12-5-6+50)/...
0484dbac8244c5c8f13f953e225e7eaea6e1f2fd
yaolinxia/leetcode_study
/605. 种花问题.py
1,421
4.40625
4
""" 假设你有一个很长的花坛,一部分地块种植了花,另一部分却没有。可是,花卉不能种植在相邻的地块上,它们会争夺水源,两者都会死去。 给定一个花坛(表示为一个数组包含0和1,其中0表示没种植花,1表示种植了花),和一个数 n 。能否在不打破种植规则的情况下种入 n 朵花?能则返回True,不能则返回False。 示例 1: 输入: flowerbed = [1,0,0,0,1], n = 1 输出: True 示例 2: 输入: flowerbed = [1,0,0,0,1], n = 2 输出: False 注意: 数组内已种好的花不会违反种植规则。 输入的数组长度范围为 [1, 20000]。 n 是非负整数,且不会超...
86e0941c445ca290d5b5271536711b43bc924b29
HeekyungKim6424/codeuniv_python
/6day.py
1,741
3.90625
4
#모각코 달콤한 파이썬 난이도 중 print('''==========도형 목록========== 1. 원 2. 삼각형 3. 직사각형 4. 정사각형 ============================''') a=int(input("도형 목록에서 넓이를 계산할 도형의 번호를 입력해주세요: ")) if a == 1: b=int(input("원의 반지름 길이를 입력해주세요: ")) area=(b**2)*3.14 print("반지름의 길이가 {}인 원의 넓이는 약 {}입니다.".format(b,area)) elif a==2: b=int(inpu...
4b1202da25c6f2e0e4027e4f5a5fa93f29a316f7
skandRaturi/competitive-programming
/python/basic of IO/IO/toggle_string.py
191
3.75
4
a='abcdefghijklmnopqrstuvwxyz' b=a.upper() s=list(input()) for i in range(len(s)): if s[i] in a: s[i]=s[i].upper() elif s[i] in b: s[i]=s[i].lower() print(''.join(s))
39b792619bc051d7500dd9296f790287da8ee997
yunieyuna/Solutions-for-Leetcode-Problems
/python_solutions/1207-unique-number-of-occurrences.py
545
3.734375
4
# https://leetcode.com/problems/unique-number-of-occurrences/ import collections class Solution: def uniqueOccurrences(self, arr: List[int]) -> bool: occur = collections.Counter(arr) if len(occur.values()) == len(set(occur.values())): return True else: return False ...
08a6379617063d99f7a24678a1d5003f9a55f574
JenZhen/LC
/lc_ladder/company/gg/Minimum_Height_Tree.py
5,158
3.875
4
#! /usr/local/bin/python3 # https://www.lintcode.com/problem/minimum-height-trees/description?_from=ladder&&fromId=18 # Example # 对于一个树状的无向图,选择任何一个节点作为根。这个图就变成了一个有根树。在所有可能的有根树中,有最小高度的树叫做最小高度树(minimum height trees, MHTs)。 # 给定这样的图,找出所有的MHTs,返回根标记的数组。 # 格式 # 图包含了n个节点,标记从0到n-1。给定n和一个无向边列表edges。每一个边是一组节点标记。 # 假定没有重复的遍。由于所...
775ccd4659d46d8154dadb21c6ba6e6b0ae3c6d2
alancyao/fun-times
/Algorithms/data_structures/trie.py
988
3.890625
4
class TrieNode: def __init__(self, char, is_word=False): self.char = char self.children = {} self.is_word = is_word def insert(self, s): if not s: self.is_word = True return elif s[0] not in self.children: self.children[s[0]] = TrieNode(s[0]) self.children[s[0]].insert(s[1...
f0366f54cca580b5b9e267125d8735aad368aff3
franklingu/leetcode-solutions
/questions/find-the-smallest-divisor-given-a-threshold/Solution.py
1,422
3.640625
4
""" Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold. Each result of the division is rounded to the nearest in...
790472a1130fd1aa11e17dbcffe5b2f2d69c1a40
dibery/UVa
/vol114/11482.py
475
3.515625
4
def tri( pad, qnt, size ): # front, back for i in range( 1, size ): s = ( size - i ) * ' ' + '/' + ( i - 1 ) * 2 * ' ' + '\\' + ' ' * ( size - i ) print( pad + s * ( qnt - 1 ) + s.rstrip() ) print( pad + ( '/' + ( size - 1 ) * 2 * '_' + '\\' ) * qnt ) c = 0 while True: size, layer = map( int, input().split() ) ...
2b63588e14cf77aced600e59f9dd8082d6ac7bf5
CodingPemula-CPu/Kalkulator-sederhana-2-input-python
/kalkulator.py
590
4.09375
4
#KinsProject #input1 number1 = eval(input("Masukkan bilangan pertama : ")) print(float(number1)) #operator operator = input("Masukkan Operator (+,-,*,/): ") print(operator) #input2 number2 = eval(input("Masukkan bilangan kedua : ")) print(float(number2)) if operator == '*': print("Hasil Perkalian...
bb67573a9c6f1f752d8c9bfe9df02fc03a64af2c
spike688023/The-Python-Workbook-Solve-100-Exercises
/all_exercises/60.py
279
4.28125
4
#Create a program that prints Hello repeatedly. while 1 < 2: print("Hello") """ 這次呢, 我寫的比較好, 因為它的條件判斷 是用 1 < 2 , 這要經過比較 ,才能得 出 True, 而我不用。 while True: print("hello") """
6efed5ccf4dbf72fb339229cc3d4b1ef1067443e
gfunk68/python-challenge
/PyBank/main.py
1,729
3.515625
4
import os import csv totalprofit = 0 totalmonths = 0 lastloss = 0 monthofchange = [] maxincreaseprofit = 0 maxdecreaseprofit = 0 profitchange = 0 profitchangelist = [] csvpath = os.path.join('Resources','budget_data.csv') writepath = os.path.join('Output','budget_summary.txt') with open(csvpath, 'r') as csvfile: ...
93a0c4ee693e16489286ad4da5d73d78508e5037
koopa01/pythonlearning
/day05_exercises.py
3,829
3.65625
4
import random import math # 水仙花数也被称为超完全数字不变数、自恋数、自幂数、阿姆斯特朗数,它是一个3位数,该数字每个位上数字的立方之和正好等于它本身, # 例如:$1^3 + 5^3+ 3^3=153$。 l1 = [] for x in range(100,1000): a = (x % 10) ** 3 b = ((x // 10) % 10) ** 3 c = ((x // 10) // 10) ** 3 if a + b + c == x: l1.append(x) print(l1) # 正整数反转,例如:将12345变成54321 # nu...
ac3fb1de569f1e5238a0d261d6246db7b2d88b55
Igor2501-as/Synergy-IT-Academy
/Game_fool (в работе).py
2,787
4.15625
4
С использованием ООП написать программу, которая раздает карты для игры в дурака 1. Реализовать класс карты как масть + значение, метод __repr__ и __str__ для вывода на экран class Card(object): SPADE = 1 HEARTS = 2 CLOVER = 3 DIAMOND = 4 def __init__(self,...
3f9b83ee6bc3d18d528340487942f98d8c40b215
RieLCho/PS_Practice
/Baekjoon/baekjoon/1934.py
172
3.734375
4
from math import gcd def lcm(_a, _b): return _a * _b // gcd(_a, _b) t = int(input()) for _ in range(t): (a, b) = map(int, input().split()) print(lcm(a, b))
29d210bb1581b2008466cac5f503921a482aed9e
EnterNameHere7/python-proxy-test
/ApiApplication/src/utility/utility.py
1,057
3.75
4
import json import collections class JSONSetEncoder(json.JSONEncoder): """Use with json.dumps to allow Python sets to be encoded to JSON Example ------- import json data = dict(aset=set([1,2,3])) encoded = json.dumps(data, cls=JSONSetEncoder) decoded = json.loads(encoded, object_hook=j...
806df3e8fb3bb484fb755d799c0766cdb4e84961
L316645200/_Python
/LeetCode/编程面试题/面试题40. 最小的k个数.py
793
3.765625
4
# 输入整数数组arr ,找出其中最小的k个数。 # 例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。 # 示例1: # 输入:arr = [3, 2, 1], k = 2 # 输出:[1, 2] # 或者[2, 1] # 示例2: # 输入:arr = [0, 1, 2, 1], k = 1 # 输出:[0] # 限制: # # 0 <= k <= arr.length <= 10000 # 0 <= arr[i] <= 10000 from typing import List class Solution: def getLeastNumbers(self, arr: List...
ed3173a7cc7d5c433f13c000012b9889c5a0f26d
beatrizqa/PythonLessons
/exercisesExplanations/Loops/whileLoop.py
1,666
4.375
4
# WHILE Loops: # 1. Executes a block of code a number of times # 2. Instead of determining the number of times before hand # 3. we get until a certain condition is met # 4. SYNTAX: # create a variable and set it to a certain value (i = 0) # while a certain condition is true: # ...
f356b2129b5b787b6588235af7f03e59024773b8
erikliu0801/leetcode
/python3/solved/P844. Backspace String Compare.py
2,813
3.8125
4
# ToDo: """ 844. Backspace String Compare Easy Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Note: 1 <= S.length <= 200 1 <= T.length <= 200 S and T only contain lowercase letters and '#' characters. Follow up: Can you...
3d779eec59f3f6faf99c97cea45657edf678d24e
GiGiGan/Python-Exercise-100
/EX25.py
97
3.546875
4
#make a script from a to z import string for letter in string.ascii_lowercase: print(letter)
ee2607a581695025a831a609c6587953f92ac820
007HarshChaudhary/Google-Coding-Questions
/Special Strings.py
2,429
3.953125
4
# -*- coding: utf-8 -*- """ Created on Fri May 15 16:47:42 2020 @author: Harsh Chaudhary """ ''' A string is said to be a special string if either of two conditions is met: All of the characters are the same, e.g. aaa. All characters except the middle one are the same, e.g. aadaa. A special substring is an...
faf182e1fab4e5ae49e669d12d2d3069220b9665
tielushko/The-Modern-Python-3-Bootcamp
/Section 26 - OOP Part 2/properties.py
1,162
3.8125
4
class Human: def __init__(self, first, last, age): self.first = first self.last = last if age >= 0: self._age = age #private for the class else: self._age = 0 """ def get_age(self): return self._age def set_age(self, new_age): ...
89ba0243308fb1ae04785a89d723627d03adc077
anshayghosh/Ekrishi
/seed.py
2,223
3.953125
4
class seed: lowest_temp =0 highest_temp =0 buying_price = 0 name ="" ideal_altitude = 0 def __init__(self,name): self.name = name if(self.name == "Wheat"): self.buying_price = 18 self.lowest_...
ffcf40a25714cc9b3985a608250ead58f0af3420
steevejoseph/hours
/states/statefind.py
726
4.40625
4
#!usr/bin/env python3 """ Simple python program that returns the US state name that corresponds with a user-submitted abbreviation. """ from US import states def find_state(string): if len(string) != 2: print("Sorry, abbreviations must be two letters!") print("Please try again\n") main() try: retval = s...
895181a1b6bb2e647a727e3a668956788c3ac2d2
Danilocl/Python
/Not in.py
208
3.703125
4
letras = [] i = 0 cont = 0 while i < 5: letras.append(input("Letra: ")) if letras[i] not in 'aeiou': cont += 1 print("testando") i += 1 print("Foi digitado %d consoantes "%cont)
b7f37ba14f1c21b2167a9a02f5f805fe922cbf09
SSaratKS/Python-Projects
/100 Python Exercises/exercise44.py
1,416
4.4375
4
#Question: ''' Create a script that generates a file where all letters of English alphabet are listed three in each line. The inside of the text file would look like: abc def ghi and so on. Hint: This is like the previous exercise, but with a different step. ''' #Answer ''' import string letters = string.ascii_lowe...
a755ce16a6aff69932f5b0c04946e8b901b23739
daniel-reich/turbo-robot
/rBHTZ3HTCZQ6r5XP4_11.py
769
3.84375
4
""" Create a function that expands a decimal number into a string as shown below: 25.24 ➞ "20 + 5 + 2/10 + 4/100" 70701.05 ➞ "70000 + 700 + 1 + 5/100" 685.27 ➞ "600 + 80 + 5 + 2/10 + 7/100" ### Examples expanded_form(87.04) ➞ "80 + 7 + 4/100" expanded_form(123.025) ➞ "100 + 20 + 3 + 2/100...
37c87e9973ccbcff19a22a6db48ac6a41fa258e8
lassi-dev/SpaceWar
/spacecraft/hull.py
2,327
3.625
4
from tkinter import PhotoImage from tkinter import Canvas from tkinter import NW import math #Superclass for all moving objects on Canvas class Hull(): """Hull class used as a superclass for all moving elements in game It is created with 3 requiered arguments: position on ...
f1b0dd2ad11046a9139a03ac059f786a02a10a59
atan59/A01175168_1510_labs
/Lab05/lab05.py
5,509
4.21875
4
"""A module of functions for Lab 5.""" import random import doctest def roll_die(number_of_rolls, number_of_sides): """ Roll a die with a specific number of sides a certain number of times. :param number_of_rolls: a positive int :param number_of_sides: a positive int :precondition: number_of_roll...
7495385b95db106b52f0484c91f4b30bdcef5ab5
JagadeeshMandala/python
/python programms/area of a circle.py
195
4.25
4
import math def area_of_a_circle (r): res=math.pi*r*r return res r=float(input("enter the radius of the circle")) print("The radius of the circle is",area_of_a_circle(4))
54ad48d185d26e495d8cbc081ca2c0db5a936e38
jublanco/datos-de-ip
/datos ip.py
717
3.546875
4
#Importamos las librerias que necesitamos import requests import json #Les asignamos la url donde tiene que consutlar la ip url='http://ip-api.com/json/' #Le damos los parametros que queremos consultar y copi parametros='city,country,countryCode,isp,org,regionName,lat,lon,timezone,zip' data={'fields':p...
9580e35f5841ee81397a795e2c3991ad7c89cdc3
mouseking-sw/CodingTest
/6_4_퀵정렬알고리즘.py
1,037
3.765625
4
array =[5,7,9,0,3,1,6,2,4,8] def quick_sort(array,start,end): if start >=end: return pivot = start # 왼쪽 은 작은수 오른쪽은 큰수 증가 인덱스를 시켜가며 비교 할 값 left = start+1 right =end while left <=right: while left <=end and array[left] <= array[pivot]: # 인덱스를 하나씩 증가시키면서 피봇보다 작은값 ...
0740f65a0a0b0950db3bdc89b6e21cafcc8de6ee
BryanSWong/Python
/ex35sd1.py
951
3.796875
4
print "Map of the game: " print """ start() -> 1. "left" -> bear_room() -> 2. "right" -> cthulhu_room() -> 3. dead(why) bear_room() -> 1. "take honey" -> dead(why) -> 2. "taunt bear" and not bear_moved -> bear moves -> 3. "anything els...
8f8c092cae336a44e28d9ac1da95c8a013edc5d3
kyousuke-s/PythonTraining
/day0202/code4_9.py
443
3.578125
4
ages=[26,50,8,'ひみつ',20,78,25,'無回答',22,10,27,33] num=5 #目標の抽出数 samples=list() #サンプルを格納するリスト for age in ages: # isinstance(a,c) は、aがbの型であるかを判定する if not isinstance(age,int): #notなので[ageがint型でなかったら]になる continue if 20 <= age < 30: samples.append(age) if len(samples) == num: br...
acff9385e7bc72fad83011f70cbedb1c494fca68
safaa-alnabulsi/math-problem-solver
/lambdas/src/exceptions.py
656
3.84375
4
class EmptyInputException(Exception): def __init__(self): self.message = "The value you entered is empty. The number must be a non negative integer" super().__init__(self.message) class NegativeNumberException(Exception): def __init__(self, n): self.message = "The value {}' you entered...
c9ea8b9f5c20f3c4d59a1d25b2c69c2ae00f03f6
anthonyy27/python-begin
/guessing-game.py
500
4.28125
4
secret_word = "apple" guess = "" guess_count = 0 guess_limit = 3 out_of_guesses = False while guess != secret_word and not(out_of_guesses): # != means not equal if guess_count < guess_limit: guess = input("Enter guess: ") guess_count += 1 else: out_of_guesses = True # Repeat...
90af7201610653af0066bcf578e7b400a04b8421
TheShubham-K/Algorithmic_Toolbox
/week3_greedy_algorithms/1_money_change/change.py
287
3.578125
4
# Uses python3 import sys def get_change(m): #write your code here count = int(m/10) remain = m % 10 count += int(remain / 5) remain = remain % 5 count += remain return count if __name__ == '__main__': m = int(sys.stdin.read()) print(get_change(m))
4cec175d2a25a7338567b6a04942c23434d4a7f8
MohanaPriya2537/pythonpracticeexamples
/Comprehension/list comprehension.py
1,033
4
4
# To print even no # # l=[] # for i in range(10): # if(i%2==0): # l.append(i) # print(l) # or # a=[i for i in range(10) if (i%2==0)] # a='developer' # b=list(a) # print(b) # To display in list format # a='developer' # # l=[] # # for i in a: # # l.append(i) # # print(l) ...
daf62b980e0f228d9acd8bc01b2eec5f8c5cdc92
rajajwaliya/Python
/Python Basic Program/2. list.py
1,689
3.765625
4
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> y="raj" >>> len(y) 3 >>> x=123 >>> len(x) Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> len(x) TypeError: object of type 'i...
fa4e10b9d9e3d46c800bffa4ee46180f5ccf2a06
Hijtec/OpenCV-Cernil
/Misc/logic_and_arithmetics (1).py
1,218
3.703125
4
import cv2 import numpy as np img1 = cv2.imread("seacity.jpg"); img2 = cv2.imread("tropcity.jpg"); img3 = cv2.imread("logo.jpg"); #add = img1 + img2; add pixelcolors together #add = cv2.add(img1,img2); add pixelcolors together (limited to 255,255,255) #weighted = cv2.addWeighted(img1, 0.6, img2, 0.4, 0) #add...
909bb3a53b37438316aac29b5694d498f86d2644
AFatWolf/cs_exercise
/Mid-term preparation/Midterm 5/3assignment2.py
392
3.71875
4
def binary_search(x, val): l = 0 r = len(x) - 1 ans = "" while(l <= r): mid = (l + r + 1)//2 ans += str(x[mid]) + "," if (x[mid] > val): r = mid - 1 else: l = mid + 1 return ans print(binary_search([5,8,15,22,24,26,32,42,69,71,81,92,96], 92)) p...
1ed893e9fccc08f99491f10efdb79876af3b3af1
ConnorB0018/INST326_NBA_Project
/nba_project.py
6,682
3.59375
4
"""A module for the nba_project program main functionality. Attributes: None. """ import pandas import matplotlib.pyplot as plt from nba_api.stats.static import teams from nba_api.stats.endpoints import teamgamelog from nba_api.stats.endpoints import boxscoresummaryv2 from nba_api.stats.endpoints impo...
f590b07740c97e552c167a450df8594f3fbac3b6
naveensambandan11/PythonTutorials
/tutorial 65_FileHandling.py
621
4.03125
4
# File Handling -- # Read from another file # Write to another file # Read and Write Image file1 = open('naveen', 'r') # Read from another file print(file1.read()) #print(file1.readline()) f = open('naveen', 'w') # Write to another file #f.write('new line added') f1 = open('naveen', 'w') f1.write('Navee...
e6b1c79e282ecf03bbd4e2cf5655db451cf04208
convoliution/stochastic-sort
/gates.py
1,204
3.6875
4
import numpy as np def sigmoid(x: np.ndarray) -> np.ndarray: '''Performs the sigmoid operation 1/(1 + e^(-x)). Args: x: Input array. Returns: Result of the sigmoid function. ''' return 1.0/(1.0 + np.exp(-x)) def relu(x: np.ndarray) -> np.ndarray: '''Performs the ReLU operati...
6db1180a415041bb4fe30ded9407cb69307e40d3
coderhzy/python
/python书籍阅读/06_函数/06_func_test1.py
661
3.6875
4
# coding:utf-8 # 8-1 消息 :编写一个名为display_message() 的函数,它打印一个句子,指出你在本章学的是什么。调用这个函数,确认显示的消息正确无误。 def display_message(name): print('Hello my name is ' + name) display_message('何梓阳') # 8-2 喜欢的图书 :编写一个名为favorite_book() 的函数,其中包含一个名为title 的形参。这个函数打印一条消息,如One of my favorite books is Alice in Wonderland 。调用这个函数,并将一本图书的名称作为...
3ef932263dde8f52a97222379026983d4a0bf8ee
MikalaiKryvusha/sandbox
/roll
930
3.75
4
#!/usr/bin/python3 import sys, random, re def roll_dice(turns, dice): for i in range(1, turns+1): roll = random.randint(1,dice) print(" Your roll #%s of %sd%s: %s" % (i,turns,dice,roll)) def show_error(): print('''Please, roll something like "roll 1d6 2d8"''') sys.exit(2) def show_error_...
103bae9178a5d6b757991d830df0ed611d923b05
rinisha0112/remote_demo
/Day2/Q1.py
240
4.03125
4
def addition(num1,num2=200): #ex of default function arguments return(num1+num2) n1=input("Enter first number: ") n2=input("Enter second number: ") ans_add=addition(num1=n1, num2=n2) print "Addition of %f and %f is %f"%(n1,n2,ans_add)
6771ad654dd37679924a8d9bf66703d82d66ed6a
V2xray1024/pyHack
/循环练习.py
908
3.8125
4
''' Description: 循环练习 Author: yrwang Date: 2021-08-30 19:19:41 LastEditTime: 2021-09-02 21:39:30 LastEditors: yrwang ''' # 1 打印1-100的奇偶数 for i in range(100): if i % 2 == 0: print(f"{i} 是偶数") # 2 循环打印楼层 循环嵌套 for i in range(1, 6): print(f"----------第{i}层----------") for j in range(10): print(...
864717daa2619931a469928bdb82d2bad6744537
andradaioanabogoi/katas
/k_sorted_lists.py
1,043
3.625
4
class KSortedLists: def mergeKLists(self, lists): interval = 1 while (interval < len(lists)): for i in range(0, len(lists)-interval, interval*2): lists[i] = self.merge2Lists(lists[i], lists[i + interval]) interval *= 2 return lists[0] if len(lists) > 0...