blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8ffb36f655d70854d0407da65709e1dcfcbc3377
czs108/LeetCode-Solutions
/Medium/310. Minimum Height Trees/solution (1).py
1,617
3.984375
4
# 310. Minimum Height Trees # Runtime: 232 ms, faster than 79.45% of Python3 online submissions for Minimum Height Trees. # Memory Usage: 18.9 MB, less than 46.34% of Python3 online submissions for Minimum Height Trees. class Solution: # Topological Sorting def findMinHeightTrees(self, n: int, edges: list[l...
8f598eddd091efe4fdccb6bc7fd8ae02540c115e
czs108/LeetCode-Solutions
/Easy/94. Binary Tree Inorder Traversal/solution (2).py
776
3.71875
4
# 94. Binary Tree Inorder Traversal # Runtime: 50 ms, faster than 10.24% of Python3 online submissions for Binary Tree Inorder Traversal. # Memory Usage: 14.1 MB, less than 91.45% of Python3 online submissions for Binary Tree Inorder Traversal. # Definition for a binary tree node. # class TreeNode: # def __init...
d7b6b926829ba01d8495a7e70e277ad3d7f994df
czs108/LeetCode-Solutions
/Medium/364. Nested List Weight Sum II/solution (1).py
2,391
4.28125
4
# 364. Nested List Weight Sum II # Runtime: 32 ms, faster than 69.56% of Python3 online submissions for Nested List Weight Sum II. # Memory Usage: 14.5 MB, less than 82.51% of Python3 online submissions for Nested List Weight Sum II. # """ # This is the interface that allows for creating nested lists. # You should ...
156091b727c98aa66c3bc722664364ee3765bd25
czs108/LeetCode-Solutions
/Easy/20. Valid Parentheses/solution (2).py
1,460
3.921875
4
# 20. Valid Parentheses # Runtime: 28 ms, faster than 72.64% of Python3 online submissions for Valid Parentheses. # Memory Usage: 13.9 MB, less than 5.22% of Python3 online submissions for Valid Parentheses. class Solution: # Hash map for keeping track of mappings. This keeps the code very clean. # Also mak...
2164a685c3d550161e49e911fc25e183d9856351
czs108/LeetCode-Solutions
/Easy/268. Missing Number/solution (3).py
391
3.5
4
# 268. Missing Number # Runtime: 132 ms, faster than 76.58% of Python3 online submissions for Missing Number. # Memory Usage: 15.5 MB, less than 51.40% of Python3 online submissions for Missing Number. class Solution: # Gauss' Formula def missingNumber(self, nums: list[int]) -> int: expected_sum = l...
156ffb8d11176a2fc2422ac01b8cc46f6b730c70
czs108/LeetCode-Solutions
/Easy/796. Rotate String/solution (1).py
366
3.78125
4
# 796. Rotate String class Solution: # Brute Force def rotateString(self, A: str, B: str) -> bool: if len(A) != len(B): return False elif len(A) == 0: return True for s in range(len(A)): if all(A[(s + i) % len(A)] == B[i] for i in range(len(A))): ...
41800cbae07e8e5c8aba6f1e40962ddb26530f5c
czs108/LeetCode-Solutions
/Easy/53. Maximum Subarray/solution (3).py
482
3.640625
4
# 53. Maximum Subarray # Runtime: 68 ms, faster than 48.79% of Python3 online submissions for Maximum Subarray. # Memory Usage: 15.1 MB, less than 12.76% of Python3 online submissions for Maximum Subarray. class Solution: # Dynamic programming def maxSubArray(self, nums: list[int]) -> int: sums = [0...
a048507f246c7543e31a7813abb3515359a2afc3
czs108/LeetCode-Solutions
/Medium/189. Rotate Array/solution (4).py
917
4.21875
4
# 189. Rotate Array # Runtime: 60 ms, faster than 82.31% of Python3 online submissions for Rotate Array. # Memory Usage: 15.3 MB, less than 64.16% of Python3 online submissions for Rotate Array. # Using Reverse # Let n = 7 and k = 3 # Original List : 1 2 3 4 5 6 7 # After reversing all numbers ...
6ebceb3a404339eb9ff681911413fe00f8758462
czs108/LeetCode-Solutions
/Easy/744. Find Smallest Letter Greater Than Target/solution (1).py
674
3.734375
4
# 744. Find Smallest Letter Greater Than Target # Runtime: 204 ms, faster than 5.78% of Python3 online submissions for Find Smallest Letter Greater Than Target. # Memory Usage: 14.7 MB, less than 31.28% of Python3 online submissions for Find Smallest Letter Greater Than Target. class Solution: # Binary Search ...
216e6cbd5e1eb185bed1487f83962ccd3ac4bd9d
czs108/LeetCode-Solutions
/Easy/905. Sort Array By Parity/solution (2).py
287
3.65625
4
# 905. Sort Array By Parity class Solution: # Two Pass # Write all the even elements first, then write all the odd elements. def sortArrayByParity(self, A: list[int]) -> list[int]: return ([x for x in A if x % 2 == 0] + [x for x in A if x % 2 == 1])
7a2d40368f147561cf40e77ff295cd17b9e63cb0
czs108/LeetCode-Solutions
/Easy/1137. N-th Tribonacci Number/solution (2).py
817
3.609375
4
# 1137. N-th Tribonacci Number # Runtime: 32 ms, faster than 35.84% of Python3 online submissions for N-th Tribonacci Number. # Memory Usage: 14.2 MB, less than 40.51% of Python3 online submissions for N-th Tribonacci Number. class Solution: _MAX_IDX: int = 38 # Performance Optimisation - Recursion with Me...
fdc23cd37525f57095386991b1736eb21fcf8633
czs108/LeetCode-Solutions
/Easy/733. Flood Fill/solution (1).py
850
3.578125
4
# 733. Flood Fill # Runtime: 80 ms, faster than 38.53% of Python3 online submissions for Flood Fill. # Memory Usage: 14.7 MB, less than 10.35% of Python3 online submissions for Flood Fill. class Solution: # Depth-First Search def floodFill(self, image: list[list[int]], sr: int, sc: int, newColor: int) -> li...
a4f19df209ebbcca13b36801817f5879ac37b928
czs108/LeetCode-Solutions
/Medium/779. K-th Symbol in Grammar/solution (2).py
714
3.5
4
# 779. K-th Symbol in Grammar # Runtime: 28 ms, faster than 83.78% of Python3 online submissions for K-th Symbol in Grammar. # Memory Usage: 14.2 MB, less than 78.55% of Python3 online submissions for K-th Symbol in Grammar. class Solution: # 0 # / \ # 0 ...
aa5ed4f6b8812e3a8f1db34583dee7b300cbd66e
czs108/LeetCode-Solutions
/Easy/350. Intersection of Two Arrays II/solution (2).py
754
3.75
4
# 350. Intersection of Two Arrays II # Runtime: 48 ms, faster than 67.57% of Python3 online submissions for Intersection of Two Arrays II. # Memory Usage: 14.1 MB, less than 99.75% of Python3 online submissions for Intersection of Two Arrays II. class Solution: def intersect(self, nums1: list[int], nums2: list[...
06ef7e4cd22bccd6d02e065aeac4ca8f90ee7fb0
czs108/LeetCode-Solutions
/Easy/509. Fibonacci Number/solution (3).py
554
3.703125
4
# 509. Fibonacci Number # Runtime: 32 ms, faster than 66.63% of Python3 online submissions for Fibonacci Number. # Memory Usage: 14.2 MB, less than 41.38% of Python3 online submissions for Fibonacci Number. class Solution: # Top-Down Approach using Memoization def __init__(self) -> None: self._sums:...
25f2ed7986be8b8894cb0255b4630ff8de56d3c2
czs108/LeetCode-Solutions
/Easy/234. Palindrome Linked List/solution (2).py
904
3.875
4
# 234. Palindrome Linked List # Runtime: 1365 ms, faster than 5.07% of Python3 online submissions for Palindrome Linked List. # Memory Usage: 116.3 MB, less than 5.19% of Python3 online submissions for Palindrome Linked List. # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, nex...
0a03fb8425e96bc5a15638946fbdb433747371b6
czs108/LeetCode-Solutions
/Medium/1244. Design a Leaderboard/solution (1).py
941
3.640625
4
# 1244. Design a Leaderboard # Runtime: 84 ms, faster than 54.73% of Python3 online submissions for Design a Leaderboard. # Memory Usage: 14.7 MB, less than 60.65% of Python3 online submissions for Design a Leaderboard. from collections import defaultdict import heapq class Leaderboard: # Heap def __init__...
1e29b157e649efd4421317e1f22a94256f8792e1
czs108/LeetCode-Solutions
/Medium/113. Path Sum II/solution (1).py
1,007
3.71875
4
# 113. Path Sum II # Runtime: 40 ms, faster than 94.30% of Python3 online submissions for Path Sum II. # Memory Usage: 15.7 MB, less than 63.80% of Python3 online submissions for Path Sum II. # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # sel...
a1a191ddd1bccdd77313ed344b6c2cf6fcf63d09
czs108/LeetCode-Solutions
/Medium/238. Product of Array Except Self/solution (1).py
967
3.5
4
# 238. Product of Array Except Self # Runtime: 318 ms, faster than 22.10% of Python3 online submissions for Product of Array Except Self. # Memory Usage: 22.4 MB, less than 15.83% of Python3 online submissions for Product of Array Except Self. class Solution: # Dynamic Programming | Left and Right Products ...
03dd0ca0b9b6284982a8c81d999b912d35961d4f
czs108/LeetCode-Solutions
/Medium/120. Triangle/solution (2).py
583
3.640625
4
# 120. Triangle # Runtime: 110 ms, faster than 9.82% of Python3 online submissions for Triangle. # Memory Usage: 15.2 MB, less than 46.17% of Python3 online submissions for Triangle. class Solution: # Bottom-up Dynamic Programming (Flip Triangle Upside Down) def minimumTotal(self, triangle: list[list[int]])...
b6cce76ede37c04597e6912e0fed120029b9ee53
czs108/LeetCode-Solutions
/Medium/931. Minimum Falling Path Sum/solution (1).py
743
3.65625
4
# 931. Minimum Falling Path Sum # Runtime: 116 ms, faster than 77.57% of Python3 online submissions for Minimum Falling Path Sum. # Memory Usage: 15.4 MB, less than 28.70% of Python3 online submissions for Minimum Falling Path Sum. class Solution: def minFallingPathSum(self, matrix: list[list[int]]) -> int: ...
5ad7c83a3f8be69392d2ee3e65f52dd3da27e35a
czs108/LeetCode-Solutions
/Easy/1137. N-th Tribonacci Number/solution (1).py
497
3.78125
4
# 1137. N-th Tribonacci Number # Runtime: 32 ms, faster than 35.84% of Python3 online submissions for N-th Tribonacci Number. # Memory Usage: 14.3 MB, less than 15.94% of Python3 online submissions for N-th Tribonacci Number. class Solution: # Space Optimisation - Dynamic Programming def tribonacci(self, n:...
2eb7db0c2cecf84aec6f862068659dee10b4a715
czs108/LeetCode-Solutions
/Easy/566. Reshape the Matrix/solution (2).py
762
4
4
# 566. Reshape the Matrix # Runtime: 182 ms, faster than 5.04% of Python3 online submissions for Reshape the Matrix. # Memory Usage: 14.7 MB, less than 95.87% of Python3 online submissions for Reshape the Matrix. class Solution: # Without Using Extra Space def matrixReshape(self, mat: list[list[int]], r: in...
6d9477ea0ac19fd14a571ead970a39a5e29cd04a
Subarata-Talukder/Python-Logics
/function_with_arbitrary_args.py
431
3.625
4
# @Author Subarata Chandra Talukder def write_multiple_items(file, separator, *args): file.write(separator.join(args)) def zero_or_more_var_agrs(*names): print("All students names are: ") for std in names: print(std) zero_or_more_var_agrs('Rajib','Subarata','Rimpi') print(list(range(...
1a849f6667fbd2f35f748a726e16e2b8298ba8f6
LotteSuz/complex_parttwo
/models/model.py
5,798
3.546875
4
""" In this file model initiation takes place (init function). Then, in the 'step' function, is everything that should occur every timestep. Events at every timestep are now: - ants move one step in a random direction of the Moore neighborhood """ from mesa import Model from mesa.time import RandomActivation from mesa....
935858123165fa1751ce04711f20914a25835f51
etckanikama/StudyPython
/study-06-api/api.py
3,318
3.5625
4
import requests import urllib import pprint import pandas as pd from requests.api import get def get_api(url): result = requests.get(url) return result.json() def main(): keyword = "鬼滅" genreid = "566403" #おそらくゲームかnintendoについてのgenreid search_url = "https://app.rakuten.co.jp/services/api/IchibaI...
91c8699f696905427f16b869aa6ec0b9c0fecb46
attikis/programming
/python/python_threadingTimer.py
2,070
3.703125
4
#!/usr/bin/env python # Script docstrings ''' Usage: ./fileName.py Permissions: chmod +x fileName.py Description: This is simple illustration of how to run a timed execution of a function insed of a thread, by using threading. It take a single argument when executing, which is the time delay of the thread. Usage: ...
df7b139328ebae53c31ab70730030d3dbef44af7
attikis/programming
/python/python_writelines.py
824
3.59375
4
#!/usr/bin/env python # Permissions : chmod +x fileName.py # To launch : python fileName.py OR ./fileName.py # Definition : Alternative way of reading a file: readline (instead of "file.read()") filePath = "/Users/administrator/my_work/programming/python/writelines.txt" nLines = 10 stringList = ["Alexandros"...
d23546e03e249ec3a35e8e609a78037c04ece73d
attikis/programming
/python/python_intToString.py
582
3.828125
4
#!/usr/bin/env python # Permissions : chmod +x fileName.py # To launch : python fileName.py OR ./fileName.py # Definition : Example of how to convert an int list to a string list intList = [] for i in range(20,0,-1): intList.append(i) print "+++ intList = %s " % (intList) print print '+++ Convertin...
10af637384c6a48d0e045448b793187795f11d56
JuanKarlosM/Mi-proyecto
/codigo/retorno.py
232
3.640625
4
def sumar(numero1, numero2): suma = numero1 + numero2 return suma def mulplicar(numero1, numero2): r = 0 for i in range(numero2): r = sumar(r,numero1) respuesta = sumar(4,7) mult = respuesta * 3 print(mult)
29290f5c5fb53d2d8b34eb4dbc700a3f352bff81
SamuelSanthosh/Skillrack-Daily
/ExcludePalindromeWords.py
114
3.59375
4
S=list(map(str,input().strip().split())) for i in S: if(i.lower()!=i[::-1].lower()): print(i,end=" ")
fbf0581b9a472868f5feebdd725c6baf1abfc5d0
kevokvr/PythonPractice
/Assignment2/Assignment2.py
8,780
3.75
4
import unittest ''' Description: Assignment 2 - Dictionary Author: Kevin Valenzuela Version: 2.0 Help provided to: I helped Makda by writing pseudocode of what I did in some methods Help received from: Read some stuff online about dictionaries, lists, hashmaps. ''' ''' Implement a dictionary using chaining. ...
ef20d180b4a2f7c267edfd0a9208c1a2f94be984
carolinajacome/MisionTIC2022
/Clase6/ejercicio7.py
519
3.890625
4
""" Diseñe un algoritmo que permita imprimir un mensaje según un carácter dado por el usuario, independiente que sea ingresado en mayúscula o minúscula, según la Tabla: Carácter Mensaje a imprimir 'a' Android 'i' IOS otro Opcion inválida """ def carac (caracter): if len(caracte...
14c404bc9e14156d90fe888ed6cadc3fefe59a12
carolinajacome/MisionTIC2022
/Clase6/ejercicio11.py
1,612
3.734375
4
"""La oficina de incorporación del ejército necesita un algoritmo que le pueda permitir saber si un aspirante a ingresar a la institución como soldado es apto o no para poder vincularlo. Para que una persona sea apta, debe cumplir los siguientes requisitos: Si es mujer, su estatura debe ser superior a 1.60 mts y su ...
3c51fa56dab7ab485fe3c781dab936d64bbd842f
carolinajacome/MisionTIC2022
/Taller clase 4/ejercicio2.py
410
3.90625
4
"Escribir una función que reciba un número entero positivo y devuelva su factorial." import math def factorial(n): """Función que calcula el factorial de un número entero positivo. Parámetros n: Es un entero positivo. Devuelve el factorial de n. """ f=1 for i in range (1,n...
9ce90ceb92037fa29cc999cd3f64a469a3ecb5ef
ayushsanghavi/Route_pichu
/route_pichu.py
3,897
3.75
4
#!/usr/local/bin/python3 # # route_pichu.py : a maze solver # # Submitted by : Ayush Sanghavi || IU username:sanghavi # # Based on skeleton code provided in CSCI B551, Spring 2021. import sys import json # Parse the map from a given filename def parse_map(filename): with open(filename, "r") as f: # added file...
a1d553bd9ee7a55bcd60264fa11c818ce9349b99
lucasrodriguesabreu/pythoninicial
/aula23.py
849
3.890625
4
#Manipulando arquivos # -*- coding: utf-8 -*- """ r = Somente leitura w = Escrita (caso o arquivo já exista, ele será apagado e um novo arquivo vazio será criado) a = Leitura e escrita (adiciona o novo conteúdo ao fim do arquivo) r+ = Leitura e escrita w+ = Escrita (o modo w+, assim como o w, também apaga o co...
fec9d72e4d33f5dff9a2186d6c1360ef1c2a45ac
lucasrodriguesabreu/pythoninicial
/aula9.py
347
3.59375
4
#Váriaveis # -*- coding: utf-8 -*- minha_variavel = "Olá mundo!" print (minha_variavel) var1 = 1 # Variável inteira var2 = 1.1 # Variável do tipo float var3 = "Eu sou uma String" # Variável string var4 = True # Variável booleana var5 = False # Variável booleana print(var1) print(var2) print(var3) prin...
248cba64c237da5e70b102c7a5471277a471ce2d
harveytriana/QuarticSolver
/cubicEquation.py
2,387
3.984375
4
#=================================== # VISIONARY S.A.S. # harvey.triana@visionary-saas.com #=================================== from math import atan, cos, sqrt, pi class CubicEquation(): """ Cubic Equation Solver """ def Solve(a, b, c, d, display=False): # validate if is cubic equation ...
3b0f32d866ad4d1018540955a498a4cc57338cb5
Sabbah91/text.game
/GAME-1.py
543
3.984375
4
while True: answer= input('Do you wanna play a Game ? (yes/no) ') if answer.lower().strip() == "yes": answer = input("You enter a cave and there 2 paths (left/right) you have to choose one :") if answer=="left": print('Suddenly a DRAGON appear , And you are Fucked up') ...
85ca91640e3baee5d4c62c5df675d096a7334c65
sanjanajha2001/dictionary
/Q3 sum of values .py
221
3.78125
4
# mydict={"x":100,"y":-54,"z":247} # print("dictionary:",mydict) # total=0 # for i in mydict: # total=total+mydict[i] # print("the total sum of values : ",total) a=[2,7,8,6,4,13,27,94]: i=0 max=0 while i<len(a):
e5df10360ba1ad8a3570ae7a8d4654f525f677fa
kokoritaaa7/Algo
/stack/No_42584_Review.py
1,077
3.859375
4
''' 프로그래머스 - 스택/큐 https://programmers.co.kr/learn/courses/30/lessons/42584 주식가격 2021.09.28 ''' ''' 문제 이해하기 prices에 있는 배열을 순서대로 하나씩 빼면서 남아있는 배열과 비교하기 작지 않으면 +1 작으면 break? ''' ### 효율성 실패 -> 시간초과 # enumerate()는 반복 자료형 내 원소를 하나씩 다 봐야하니까 O(n) # range()는 O(1)인 걸로 알고 있습니다 # def solution(prices): # answer = [0] * len(pr...
88553c201e1ef97c2cb423a33fc9e043887acdc7
kokoritaaa7/Algo
/if문/No_9498.py
502
3.953125
4
''' 백준 알고리즘 https://www.acmicpc.net/problem/9498 시험 성적 2021.07.23 ''' def grade(score): '''시험 점수를 입력받아 90 ~ 100점은 A, 80 ~ 89점은 B, 70 ~ 79점은 C, 60 ~ 69점은 D, 나머지 점수는 F를 출력하는 프로그램''' if score >= 90: return 'A' elif score >= 80: return 'B' elif score >= 70: return 'C' elif scor...
a9ee499089ac79912038f89f361141d3e7d51765
kokoritaaa7/Algo
/stack/deque_study.py
535
3.796875
4
## 사용법 ## from collections import deque dq = deque('python') print(dq) # deque(['p', 'y', 't', 'h', 'o', 'n']) # 데이터 삽입 dq.append('x') # 왼쪽에 삽입 print(dq) # deque(['p', 'y', 't', 'h', 'o', 'n', 'x']) dq.appendleft('y') # 오른쪽에 삽입 print(dq) # deque(['y', 'p', 'y', 't', 'h', 'o', 'n', 'x']) print(dq.pop()) # x print(dq...
7a0766b2784d8a42f9777cfa4cf3094479c73ee1
kokoritaaa7/Algo
/WeeklyChallenge/week1.py
722
3.890625
4
''' 프로그래머스 위클리 챌린지 https://programmers.co.kr/learn/courses/30/lessons/82612 1주차 2021.08.21 ''' ''' 문제 이해하기 놀이 기구 이용료 : price 놀이 기구 이용 횟수에 따라 price * n 갖고 있는 돈에서, cnt만큼 탈 때 모자란 돈 계산하기 금액 부족하지 않으면 0 출력 ''' def solution(price, money, count): total_m = 0 for cnt in range(1, count+1): total_m += price *...
2e8cec443793ca21a7a11d1340802d5142d585b3
PanicButtonPressed/xain-fl
/xain_fl/sdk/use_case.py
1,368
3.859375
4
"""Provides abstract base class use_case which provides an interface to the participant runner""" from abc import ABC, abstractmethod from typing import List from numpy import ndarray class UseCase(ABC): def __init__(self, model): self.model = model @abstractmethod def set_weights(self, weights:...
688959e059ed89f247e51c183a9b5e84766a680b
hackatbrown/brown-apis-python
/brown-apis/client.py
1,111
3.5
4
import requests import json class Client(object): ''' A client for interacting with Brown APIs resources ''' prefix = 'https://' host = 'api.students.brown.edu' def __init__(self, client_id): if not client_id: raise TypeError("A client_id must be provided.") self.client_id...
bdb7c98bea4d4892bf657f6d7e9794742952d212
prakhar728/mlh
/Day4/RandomNumber/RandomNumberGenerator.py
452
3.765625
4
import time def random_number(seed,num): rando=seed for i in range(num): rando = (13*rando + 53)%90060 print(rando) t = time.localtime() current_time = time.strftime("%H:%M:%S", t) print(current_time) hours=int(current_time[:2]) minutes=int(current_time[3:5]) seconds=int(current_time[6:])...
36ce4313eedab0101a21c594e1220a929d40956a
maxwell64/PyPractice
/pigLatin.py
203
3.96875
4
#Converts a given string into pig latin def Pig_Latin(thing): thing = thing.lower() thing += thing[0] thing = thing[1::] thing += 'ay' print(thing) test = 'Jeff' Pig_Latin(test)
e25ec35acf01bf01d871ad040b86245801831089
maxwell64/PyPractice
/fizzBuzz.py
422
4.125
4
#Lists the integers from 1 to 100, if divisible by 3 replaces with Fizz, if divisible by 5 replaces with Buzz, #ifdivisible by both replaces with FizzBuzz def FizzBuzz(l): for i in l: if i%3 == 0 and i%5 == 0: l[i] = 'FizzBuzz' elif i%3 == 0: l[i] = 'Fizz' elif i%5 == 0: l[i]...
7c5dd0438bbf189dd4f11b27c59bba8d238a71ae
bsherwood9/Intro-Python-II
/src/player.py
1,856
3.703125
4
# Write a class to hold player information, e.g. what room they are in # currently. class Player: def __init__(self, name, race, power, health, current_room,): self.name = name self.race = race self.power = power self.health = health self.inventory = [] self.current_r...
694de51893d4eb8b6d73546ef311ff4c6b6cc691
thewchan/hackerrank
/the-minion-game/the_minion_game.py
1,663
3.6875
4
"""Kevin and Stuart want to play the 'The Minion Game'. Game Rules Both players are given the same string, s. Both players have to make substrings using the letters of the string . Stuart has to make words starting with consonants. Kevin has to make words starting with vowels. The game ends when both players ...
d1401956659cc1981eb8d600051d2b2a2d2c89aa
AleksandrSarkisov/Wesley-Chan.-Creating-Applications
/Глава 1. Регулярные выражения/1.13.py
1,267
3.703125
4
#Функция type () . Встроенная функция type ( ) возвращает объект типа, который #отображается примерно как следующая строка в формате, принятом #в интерпретаторе Python: #>» type ( O ) #<type ' int ' > #>» type ( . 34 ) #<type ' float ' > #»> type (dir) #<type ' builtin_function_or_method ' > #Создать реrулярно...
377c3fb37911b4316b525a4700a9f9e09a5e4e0e
AleksandrSarkisov/Wesley-Chan.-Creating-Applications
/Глава 1. Регулярные выражения/1.10.py
370
3.625
4
#Обеспечить сопоставление с м ножеством строковых представлений всех комплексных чисел, поддерживаемых языком Python. import re patt = "[-]*\d+ [-+] \d+i" data = ["23 + 12i", "10 - 16i", "-23 + 3i", "-1 - 2i"] for i in data: print(re.match(patt, i).group())
df8d970bda948fef3f9303b3c81948f336fe915e
digitalfabrik/coldaid-backend
/src/cms/utils/mfa_utils.py
646
3.546875
4
""" This module contains helpers for multi-factor-authentication tasks. """ import random import string def generate_challenge(challenge_len): """ This function generates a random challenge of the given length. It consists of ascii letters and digits. Example usage: :class:`cms.views.settings.mfa.mfa.Get...
812ae9f7d7de0950bfd4c782883198f974419541
kurla-sreevalli/Python_MODULEWISE-assgnmt-
/Conditional statements__solutions.py
4,277
4.21875
4
#1 What is the output of the following if statement a, b = 12, 5 if a + b: print('True') else: print('False') #2 Given the nested if-else structure below, what will be the value of x after code execution completes x = 0 a = 0 b = -5 if a > 0: if b < 0: x = x + 5 elif a > 5: ...
95f3575b8fdf1dc53cd4fca9ae5a8ff5b2ec0725
CVanchieri/CS-Unit3-Algorithms
/eating_cookies/eating_cookies.py
2,504
3.984375
4
''' Eating Cookies: Cookie Monster can eat either 1, 2, or 3 cookies at a time. If he were given a jar of cookies with `n` cookies inside of it, how many ways could he eat all `n` cookies in the cookie jar? Implement a function `eating_cookies` that counts the number of possible ways Cookie Monster can eat all of the ...
bc610675541e3a19132ecd77c79b3265498cdd88
gabeb24/Python-Annuity-Search
/fair_value_search_function.py
3,663
3.71875
4
"""P4: Data Translator I project, CPSC 5061, Seattle University This is the second program that finds the amount of the monthly annuity payment using bisection search. """ from math import e # Which test case are we running? test_case = 1 def annuity_value(initial_monthly_payment): # First figure out the bracket:...
07317a470df0d6b0b97a854391b23e6ac4363744
KaitlynStauder1/cmpt120stauder
/calculatorProject5.pyw/calcclass.py
10,223
3.796875
4
# Intro to Programming # Author: Kaitlyn Stauder # Date: April 27, 2018 # Calculator Class from graphics import * from button import Button import math from displayclass import Display operators = ['+', '-', '*', '/', '%', 'sqrt', '+/-', 'x^y', 'sin', 'cos', 'tan', 'x^2', '10^x', 'sin^-1', '...
4deeb6d6e312f9510a0b4e3ee00f5375638cd7d4
KaitlynStauder1/cmpt120stauder
/fibonacci.py
468
4.15625
4
# Introduction to Programming # Author: Kaitlyn Stauder # Date: February 5, 2018 def main(): print ("This program computes the nth Fibonacci number.") n = int(input("Enter a number for n:")) if n <= 0: print("Error") else: previous = 1 current = 1 for i in range(1, n): ...
e137c121fab3baefbd8f0f964fb34ba3cf78025a
jenjade/class-work
/Ch. 9 Exercise 2.py
775
4.1875
4
#Exercise 2: Write a program that categorizes each mail message by which day of #the week the commit was done. To do this look for lines that start with “From”, #then look for the third word and keep a running count of each of the days of the #week. At the end of the program print out the contents of your dictionary (o...
6b46f94434797fc90e019a741bb0194b8fb16eeb
akkikiki/courses
/csci5622/homework/svm/sklearn/svm_report.py
3,004
4.09375
4
import numpy as np from sklearn import svm from sklearn.cross_validation import train_test_split # Import the MNIST dataset # http://scikit-learn.org/stable/modules/svm.html """ 1. Use the Sklearn implementation of support vector machines to train a classifier to distinguish 3's from 8's (using the MNIST data from t...
f795ead20d33af1bbb0bedd45709ce7d2886cd1d
DimitryRakhlei/BTECH
/c7402/a1/decrypt.py
784
3.515625
4
#!/bin/python3 import task1 from sys import argv if __name__ == "__main__": if len(argv) < 2: exit() elif len(argv) == 2: print("* File reqested:", argv[1]) try: txt = task1.read_file(argv[1]) except Exception: print("! File error") else: ...
61b02573d28cdfcc0ce2e05a60e0c9653434314b
Parsultang2020/Python
/Основы/EasyAdvices.py
2,374
4.34375
4
#!/usr/bin/env python3 from collections import Counter # для пункта 3, 6 # 1. Перевернуть строку print("1. Перевернуть строку") a = "Нужная строка" print(a) print(a[::-1]) # 2. Поменять местами 2 переменные print("2. Поменять местами значение двух переменных") x = 13 y = 47 print (x, y) x, y = y, x # - свапаем п...
ee93ef62c33332d95f5a0bfcfb0f300e0e22816b
HyperTK/python_lib
/CsvIo/csv_io.py
1,382
3.546875
4
import csv import traceback ''' CSVのIOを処理するクラス path:CSVファイル保存先フォルダ filename:CSVファイル名 ''' class CsvIo: # コンストラクタ def __init__(self, path, filename): self.path = path self.filename = filename ''' リストからCSVファイルを作成する str_list:CSVに書き出すリスト is_spl...
d119692fcef16e30262b9f95e45ca9949f2c7ad5
EzorHub/PythonCourse
/keywordArguments.py
432
3.9375
4
def say_hello(name,age): return f"Hello {name} you are {age} years old" #f 는 format인데, f를 앞에 붙여주고 {}안에 파라미터 이름 써주면 자동으로 입력받음 # "hello "+name+"you are "+age+" years old" 이거보다 훨씬 간편하네요잉 hello = say_hello("zozo", "00") #hello = say_hello(name="zozo", age="00") keyword argument는 순서와 상관없이 인자를 키워드로 인식함! print(hello)
6df5b5e9d1a1851c62e7af9aa2b9b2763ab82da3
HarshOza36/SEM_8
/DC/exp8/exp8_chandy_misra_haas_algo.py
1,497
3.578125
4
print("------------------Input Process Graph for the Program-------------------") print(" _________ 1 --> 3") print(" | ^") print(" | |") print(" |-> 0 -- > 2 -> 4") print("\n") procs = int(input("Enter the number of processes >>>> ")) print("Enter the resources of each process >>>> ") resource_array...
d4db25e9af7aca15dd8d4752dfa3d799046d202f
G00398275/Pand-problem-sheet
/Week 05/weekday.py
630
4.3125
4
# Week 05: weekday.py, Weekly Task 05 # This program outputs whether the current day is a weekday or not # References: https://www.w3schools.com/python/python_datetime.asp # Author: Ross Downey import datetime # importing datetime function today = datetime.datetime.now() # determining what day it is if (today.strftim...
fa1c0cc924e9fbac14cff1d647edfcab9b4355c2
darshit-rudani/Python-Basic-I
/12.list.py
746
4.09375
4
# using this list, basket = ["Banana", "Apples", "Oranges", "Blueberries"]; # 1. Remove the Banana from the list # 2. Remove "Blueberries" from the list. # 3. Put "Kiwi" at the end of the list. # 4. Add "Apples" at the beginning of the list # 5. Count how many apples in the basket # 6. empty the basket basket....
fc1746c828055678a04d3eec703e56e2996e3d01
darshit-rudani/Python-Basic-I
/19.dictionary.py
588
3.796875
4
dictionary = { 'a' : [1,2,3], 'b' : 'hello', 'c' : True } dictionary1 = { '123' : [1,2,3], True : 'hello', '[100]' : True } my_list = [ { 'a' : [1,2,3], 'b' : 'hello', 'c' : True }, { 'a' : [1,2,3], 'b' : 'hello', 'c' : True } ] print(dictionary['a'...
11bf39fd50e4b850b07d8f31661ed8e2467b6f77
MichaelJamesHart/Python-Shift-Cipher
/Shift Cipher.py
16,321
4.15625
4
# Michael Hart # Shift Cipher Project # This is a helper function to handle upper-case letters. # If the argument is inside of the upper-case alphabet list, # set the variable lowerCharacter to be the element that is in the same position in the lower-case alphabet list. # If the argument is not in the upper-case alpha...
263937bc77649c85337e809d2ee1a3acf5c08c19
pnovais/califa2.0
/control_sample/funcao.py
100
3.875
4
def divisa(a,b): return a/b c,d = int(input('digite dois valores: ')) d = divisa(c,d) print(d)
2370420b6c043a70bc6cdd0845877fdfaa6f69f7
Sonali-Sharma/spychat_project
/spychat_project1.py
2,368
4.0625
4
def new_user_verification(): print "\nWelcome to the spy community" #printing welcome message print "\nWe would like to know some basic details before getting started" spy_salutation=raw_input("Should i call you Mister or Miss?") spy_name=raw_input("Enter your name :") #taking name from u...
2e2771490dfb31781e5cc29741d9d651725c1457
MrTVM/python
/Python_basic/hm_l3_easy.py
1,375
4.25
4
# Задание - 1 # Создайте функцию, принимающую на вход Имя, возраст и город проживания человека # Функция должна возвращать строку вида "Василий, 21 год(а), проживает в городе Москва" def pearson (name, age, city): print("{}, {} год(а), проживает в городе {}".format(name, age, city)) pearson('Василий', 21, 'Моск...
993a323b2a3d3ae23ba1b0588e8329416cb277f9
colemccaulley/MIS407
/c08-flowcontrol_and_strings/sample_code/cf2.py
382
3.953125
4
# NOTE: You would never see such logic in a "real" program. This example # simply illustrates the evaluation of a expression. For any if, or elif # the Boolean expression must evalution to True for the associated block # of code to run. if True: print(True) else: print(False) if (10 == 10) == True: print(True) ...
5c9d16f762381681fcc29b9271bd39a0b402e616
colemccaulley/MIS407
/c18-list_comprehensions/sample_code/lc05.py
95
3.65625
4
numbers = [12,13,234,556,23123,34,567,89] m3s = [x for x in numbers if x % 3 == 0] print(m3s)
9598339567499dd251f958d6ed387b35358e5a88
colemccaulley/MIS407
/c15-modules_and_packages/mymodules4/mymod_2a.py
362
3.53125
4
mymod_2a_str = "Hello, this is mymod_2a" def mymod_2a_fun(): test_str="test string within mymod_2a_fun" print("==========Hello from mymod_2a_fun==========") print("The test_str value here is... " + test_str) print("...and here is the result from calling dir()...") print(dir()) print("==========Hel...
fbe5e80e8e282e49714eca1a1d38c58ffc194c4e
colemccaulley/MIS407
/c16-closures_and_decorators/sample_code/fun03a1.py
384
3.8125
4
def f(x): print(id(x)) # id(x) returns the id of the 10 or 123 object x = 1024 return(x) x=10 print(id(x)) print(id(10)) # note that id(x) and id(10) return the same value print( id( f(10) ) ) # shows the id of the 1024 object x=123 print(id(x)) print(id(123)) # note that id(x) and id(123) return the same ...
673f366dacd56a898e68818eee4cd70d84d3dc1f
colemccaulley/MIS407
/c16-closures_and_decorators/sample_code/nested_functions3.py
174
3.640625
4
def f(x): def g(y): return(y**x) return(g) sqr = f(2) print(sqr(3)) sqrt = f(1/2) print(sqrt(9)) cube = f(3) print(cube(3)) cubert = f(1/3) print(cubert(27))
84d3883c1a1419867914b114f2660147df034a65
colemccaulley/MIS407
/c18-list_comprehensions/sample_code/lc03.py
220
3.765625
4
numbers = [1,2,3,4,5,6,7,8] squares = [number**2 for number in numbers] cubes = [number**3 for number in numbers] quartics = [number**4 for number in numbers] print(numbers) print(squares) print(cubes) print(quartics)
ab63c2269c45b5d6d6832df2e86a92325babbd72
colemccaulley/MIS407
/c08-flowcontrol_and_strings/sample_code/continue.py
134
4.03125
4
num = 1 while num > 0: num = int(input("Input a whole number less than 100: ")) if num > 99: continue print("Num = ", num)
8493a32bae35741020b915fd87aab125545c2d0f
Thundzz/python-tictactoe
/src/menu.py
1,392
3.5625
4
from input import Input import curses import time class MenuScreen: def __init__(self): self.title = "Tic Tac Toe !!" self.subtitle = "Use UP and DOWN keys to navigate the menu!\nEnter a server IP using the number keys and the . key !" self.entries = [ "Local two players game",...
975b85ed39007106928fdd90c45a7d6a722d9003
summerlinrb/assignment-python-chapter-9
/assignment-python-chapter-9-summerlinrb/app_random.py
611
3.765625
4
import random import string # chapter 9.12 - Generating random values print("Chapter 9.12 Generating Random Values" + "-" * 20) print(random.random()) print(random.randint(1, 10)) print(random.choice([1, 2, 3, 4])) print(random.choices([1, 2, 3, 4])) print("".join(random.choices(string.ascii_letters + string....
69b25b10b361bf43dfd45a5281689a0cb61b64c5
ben-meyer/Master_Scraper
/main.py
761
4.40625
4
import scraper_functions # Ask the user if they want to scrape images, text or both print('Hello! I am a web scraping program. I can scrape images and text from a list of urls.') print('Would you like to scrape images, text, or both?\n') operation = int(input('Type:\n1 for text\n2 for images\nor 3 for both\n \n')) ur...
1c43bfa4f4c76cb27e8a03256757775f2e32a6d5
Offliners/ZeroJugde-writeup
/原創不分類題庫/Contents/d807/d807.py
170
3.65625
4
import sys def gcd(a, b): return b if (a % b == 0) else gcd(b, a % b) for temp in sys.stdin: num1, num2 = map(int, temp.split()) print(gcd(num1, num2))
46980fd0f04a061c71df0e80dedaa23af4c32ad5
Offliners/ZeroJugde-writeup
/基礎題庫/Contents/d122/d122.py
158
3.5
4
import sys for n in sys.stdin: n = int(n) count5 = 0 i = 5 while i <= n: count5 += int(n / i) i *= 5 print(count5)
1f888054b8dcee690dcf6a0cfcb3f651b6d4511f
Offliners/ZeroJugde-writeup
/基礎題庫/Contents/a004/a004.py
180
3.578125
4
import sys for line in sys.stdin: year = int(line) if((year%400 == 0) or ((year % 4 == 0) and (year %100 != 0))): print("閏年") else: print("平年")
af76c731f1292f08aa9710fe8bbaa948678fa80a
Offliners/ZeroJugde-writeup
/101-APCS/Contents/c294/c294.py
356
3.609375
4
import sys for temp in sys.stdin: side = map(int, temp.split()) side = sorted(side) print(*side) if side[0] + side[1] <= side[2]: print("No") elif side[0] ** 2 + side[1] ** 2 == side[2] ** 2: print("Right") elif side[0] ** 2 + side[1] ** 2 < side[2] ** 2: print("Obtuse...
b0d6a66d2554ffe861bcd1c76ced7da9ecccce64
Offliners/ZeroJugde-writeup
/UVa/Contents/e612/e612.py
189
3.75
4
import sys for n in sys.stdin: n = int(n) for i in range(n): temp = int(input()) if temp % 3 == 1: print("NO") else: print("YES")
e71feab5dc54677a9700e3c281f8ca170117ce64
dhpitt/math112
/mod3_exploration.py
840
3.625
4
# David Pitt # Module 3 Exploration # and in-class activity Feb.2 # Finds long-term behaviors of the function # h(x) = x^2 - 1 import matplotlib.pyplot as plt import numpy as np def h(x): return x**2 - 1 sweep = list(range(-100,100,1)) sweep = np.divide(sweep,100) h100 = [] ''' for i in sweep: x = i orb...
dcf4e930479479fe3a5a6d936dce81d42e64398d
biglerd7304/CTI110
/P4LAB1_Bigler.py
296
3.6875
4
# CTI-110 # P4LAB1 # Daniel Bigler # 9-2-18 # def main(): import turtle t = turtle.Turtle() t.shape("turtle") wn = turtle.Screen() for i in [0,1,2,3]: t.forward(50) t.left(90) for i in [0,1,2]: t.forward(50) t.right(120) main()
1c208846e0ed946b1419830a1ebc6988fe59c60e
biglerd7304/CTI110
/P4T2_BugCollector_DanielBigler.py
511
3.96875
4
# Calculate amount of bugs collected over five days # 10-4-18 # CTI-110 P4T2 - Bug Collector # Daniel Bigler # def main(): #set total to zero bug_total = 0 #set up how many days, continue to add to total every day for day in range(1,6): print("How many bugs were collected on day", da...
61084d2595483692d28cd5ba192f96826934443c
CharlotteMorrison/PythonTraining
/Turtle/task4-FillShapes.py
426
4.0625
4
import turtle #set the color to fill the shape turtle.fillcolor('purple') turtle.begin_fill() turtle.circle(50) turtle.end_fill() #move the turtle turtle.penup() turtle.goto(100,0) turtle.pendown() #set a new fill color turtle.fillcolor('yellow') turtle.begin_fill() count = 0 while (count < 4): turtle.forward(1...
ab8fd6227937cee716258f3f535eecdd42624d8a
CodeChopper/home
/python/MonsterBattle/mb_subs.py
517
3.6875
4
# ------------------------------------------------------------------------- # File: mb_subs.py # Created: Tue Feb 7 20:46:27 2006 # ------------------------------------------------------------------------- def actions(action_list): return [(action, int(value)) for action, value in action_list] def subtract_...
01e1b860ddbdf610570b7299777355529e3b779a
manusri2430/manasa
/substring3.py
83
3.546875
4
l1,l2=map(str,raw_input().split()) if l2 in l1: print"yes" else: print"no"
2e39940981f7740bf87c0b1c7fb4cba60ed0553c
manusri2430/manasa
/50.py
74
3.625
4
a = int(raw_input()) print("yes" if a != 0 and (a & (a-1) ==0) else "no")
aa84d66d6fb3e1f438207e9e4ab1bbb52f4061e7
manusri2430/manasa
/10.py
236
3.640625
4
def diffOne(p1,p2): diff = 2 for i in range(len(p1)): if p1[i]!=p2[i] and diff: diff-=1 if not diff: return "no" return "yes" p1, p2 = list(raw_input().split()) print(diffOne(p1,p2))
3217c1a549d15c0444133b8256224d6eb4d68749
manusri2430/manasa
/102.py
232
3.59375
4
def do_stuff(input): a = int(input) while a & 1 == 0: a = a >> 1 print(a) while True: try: value = raw_input() do_stuff(value.rstrip()) # next line was found except (EOFError): break #end of file reached
845b9a42e3693e1c84f496eab9b2b75957da9c58
manusri2430/manasa
/36.py
191
3.546875
4
import sys paragraph = sys.stdin.read().rstrip() specialCharCount = 0 for a in paragraph: if not (a.isdigit() or a.isalpha() or a.isspace()): specialCharCount += 1 print(specialCharCount)
931457b3bb1693063ecdca0f5794354aaddf2272
manusri2430/manasa
/1.py
118
3.734375
4
h=int(raw_input()) fact=1 if(h==0): print(1) else: for i in range(1,h+1): fact=fact*i print(fact)