blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a22f2f389b26228790b0f9beb49614d1168faaf5
geodimitrov/Softuniada
/2017/04. snake.py
2,181
3.703125
4
def create_cube(size): result = [] for x in range(size): line = input().split(" | ") result.append([list(el) for el in line]) return result def read_commands(): result = [] while True: command = input() if command.startswith("end"): result.append(co...
919a366b2b6396ac663305abfe73faf8ce4420bc
Max-Zima/geakbrains-python
/lesson_6_task_3.py
967
3.703125
4
class Worker: def __init__(self, name, surname, position, wage, bonus): self.name = name self.surname = surname self.position = position self._income = {"wage": int(wage), "bonus": int(bonus)} class Position(Worker): def __init__(self, name, surname, position, wage...
10eff9cd2ed79f0182744e5e478c135054c91851
jverkoey/12tweet
/examplebot.py
1,427
3.640625
4
#!/usr/bin/python # # 12tweet - tiny little robots that live in the twittersphere # Created by Jeff Verkoeyen @featherless # # The brains of a basic twitter bot. Does little more than print # all tweets for the given twitter user. # import twitterbot import random class Bot(twitterbot.StandardBot): '''A generic t...
09ecb218f49fff8914c95e652de161639d1bb1c1
terrymyy-zz/Python
/numbers.py
3,237
3.953125
4
import math import sys def isPrime(x): ## function that returns whether or not the given number x is prime. ## This funtion returns boolean. counter = 0 for i in range(1,x+1): if x % i == 0: counter += 1 if counter == 2 : return True else: return False def...
cb5a724cc59989222e4535eb92a0f5ae9c7ff7e1
gdh756462786/Leetcode_by_python
/Permutations&Subsets/Combination Sum.py
1,371
3.625
4
# coding: utf-8 ''' Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimited number of times. Note: All numbers (including target) will be positive integers. The solution set must not c...
27c4e72022012cb6ccb76c1f595268b715a181bc
fooelliot/python
/python-base/01variable/09inner_fun.py
860
3.796875
4
# coding:utf-8 """ Python包含了以下内置函数 序号 方法 描述 1 cmp(item1, item2) 比较两个值 2 len(item) 计算容器中元素个数 3 max(item) 返回容器中元素最大值 4 min(item) 返回容器中元素最小值 5 del(item) 删除变量 """ # print(cmp("hello", "itcast")) # print(cmp("itcast", "hello")) # print(cmp("itcast", "itcast")) # print(cmp(...
7f8794dd7b0583597a606806c7f9d889d479b18f
sandeepkumar8713/pythonapps
/26_sixthFolder/08_queue_height.py
1,751
4.15625
4
# https://leetcode.com/problems/queue-reconstruction-by-height/ # Question : You are given an array of people, people, which are the attributes of some people in # a queue (not necessarily in order). Each people[i] = [hi, ki] represents the ith person of height # hi with exactly ki other people in front who have a heig...
1c97be84f7a3f93aa624abcff091bfbea1531859
adamcanray/canrayLearnPython
/03_data_structures/4_in_keyword.py
1,172
3.734375
4
# ----- header # Kata kunci in digunakan untuk memeriksa apakah List atau Dictionary berisi item tertentu # ----- start reading # Perhatikan: # * keyword 'in' biasa digunakan untuk mengecek: # ----- * apakah sebuah nilai itu terkandung didalam sebuah string, list ataupun dictionary. # * in -- akan mengembalikan nilai ...
3bcf614d401f073417102f228ee5815653f303f3
PDG-x/Coffee-Machine
/beverage.py
562
3.5625
4
class Beverage: # We create out beverahe class, we are going to set all the attributes in a dictionary inside the menu class. def __init__(self, name, variant, size, price, milk = None, milk_type = None, sugar = None, decor = None): self.name = name self.variant = variant self.size = s...
6076ee483b228e93487a1972e8a5c84abbeb0233
alagram/Algorithms
/python/math/sieve_eratosthenes.py
319
3.59375
4
def eratosthenes(end, start=2): if start < 2: start = 2 primes = range(start, end) marker = 2 while marker < end: for i in xrange(marker, end + 1): if marker*i in primes: primes.remove(marker*i) marker += 1 return primes print eratosthenes(20)
3bd6a3998eadcd296956b0783baffda8b573034c
renjieliu/leetcode
/0001_0599/540.py
2,134
3.578125
4
class Solution: def singleNonDuplicate(self, nums: 'List[int]') -> int: s = 0 e = len(nums)-1 while s < e: mid = (s+e) // 2 if nums[mid] == nums[mid-1]: if (mid-s+1)%2 == 0: #left part is even length, the number is on the right side ...
bfa39cd9509b1a2cf78548e60f0bad83e3010e52
greganswer/notes
/Interviews/Examples/linked_list.py
11,514
3.96875
4
import unittest class Node(object): """ An item being added to the LinkedList. """ def __init__(self, data, next=None, prev=None): """ :param data: The info being stored in this new node. """ self.data = data self.next = next self.prev = prev def __str__(s...
0d5b207d390f794ea033678a3cee3ece2756b9c4
wanga0104/learn
/homework/score.py
216
3.90625
4
score = int(input('请为《叶问》的电影评分(请输入1-10):')) if score > 10 or score <= 0: print('数字不能大于10或者小于0') else: print('您为《叶问》的电影打分为',score*'⭐')
8335ee529888bb059546ba62a8e613d8f9f644c0
CarlosAntonioITSZ/Curso-Python
/Diccionarios/Exercise3.py
690
4.09375
4
''' We are going to create a python program where we are going to declare a dictionary to save the prices of the different fruits. The program will ask for the name of the fruit and the quantity that has been sold and will show us the final price of the fruit from the data stored in the dictionary. If the fruit ...
d94a235313abae8375ac3f4d77baf76d2e358bcb
sharath28/leetcode
/prob506/relative_banks.py
706
3.515625
4
class Solution(object): def findRelativeRanks(self, nums): """ :type nums: List[int] :rtype: List[str] """ index_dict = {} nums1 = sorted(nums,reverse = True) for i in range(len(nums1)): index_dict[nums1[i]] = i + 1 return_list = [] ...
7759f3831ed2d452aa3112ac474fcacf6f35c4e7
JPDenver/Sudoku-Solver
/Sudokusolver.py
1,126
3.609375
4
grid =[ [4, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 9, 8], [3, 0, 0, 0, 8, 2, 4, 0, 0], [0, 0, 0, 1, 0, 0, 0, 8, 0], [9, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 3, 0, 6, 7, 0], [0, 5, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 2, 0, 0, 9, 0, 7], [6, 4, 0, 3, 0, 0, 0, 0, 0]] def possible(x,y,n): for i in range(0,9): ...
a50f05734cd2e771733dac6adfc02e6eac82be6c
python-romania/hackerrank
/claudiuiova/algorithms/implementation/drawing_book.py
741
3.859375
4
# !/bin/python3 import os import sys # Problem taken from hackerrank # Link: https://www.hackerrank.com/challenges/drawing-book/problem # # Complete the pageCount function below. # def pageCount(n, p): page_turns = 0 if n in [2, 3]: return page_turns page_turns = n // 2 + 1 pt_from_start_un...
10236d116e74f302c641062683bd1e56db4a75dd
SujanMaga/Python-prac-for-ref.
/test/Conditional_Expression/prac_if.py
347
3.984375
4
a = int(input("Enter number 1: ")) b = int(input("Enter number 2: ")) c = int(input("Enter number 3: ")) d = int(input("Enter number 4: ")) if(a>d): f1 = a else: f1 = b if(b>c): f2 = b else: f2 = c if(f1>f2): print(str(f1),"is the greatest") else: print(str(f2),"is greatest") # To find the g...
c28ac962af8e02db09069ea3f118d5e2df4bf90d
syncopika/learningPython
/interview_practice/ctci/4/4-1.py
1,361
4.15625
4
# 4.1 - route between nodes # given a directed graph, find out whether there is a route between 2 nodes """ questions: - can we assume no cycles? can there be a cycle? ideas: 1. dfs or bfs. since we have a graph already, we just need to do a search from one node to the other. since it's directed, source a...
bca4d9d9ae0e98f345b5e959d79fdd40d0747fbb
Zorro30/Udemy-Complete_Python_Masterclass
/Basics/tuples.py
228
4.0625
4
# Similar to lists, but tuples are immutable. # we use paranthesis for tuples. fruits = ("Apple", "Mango", "Grapes", "Banana") print (fruits[1]) fruits[1] = "Peach" # <-- this is not allowed in tuple, hence they are immutable.
b972409148478158b683748c76fae3bef1720a85
AvivSham/LeetCodeQ
/Easy/RomanToInteger.py
841
3.5625
4
def roman_to_int(s: str) -> int: roman = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} i = 0 ans = 0 sub = 0 while i < len(s)-1: if roman[s[i]] < roman[s[i + 1]]: sub += roman[s[i]] else: ans += roman[s[i]] - sub sub =...
29117b0da1219bc675a93582702d67e957dfef4a
venkatesh533/Practice
/numbers_reverse.py
267
3.875
4
## Program to accept numbers untill 0 is given and display one by one in reverse order ## li = [] while True: n = int(input('Enter a Number(0 to stop):')) if n == 0: break li.append(n) li.reverse() print li for i in range(0,len(li)): # del li[i] print li[i]
efee82cbc0049d2c67cd6bd0d099ba5c9f9a05a1
sihota/CS50W
/Python/conditions.py
156
4.0625
4
number = 8 if number > 10: print(f"number is greater than 10") elif number < 10: print(f"number is less than 10") else: print(f"number is 10")
878b5713c65dfb0a3d4ddfcb6f1f320ace9b985a
MrYangShenZhen/pythonstudy
/基础语法数据类型/数据类型学习/字符串.py
7,738
3.5
4
#使用while循环输入 1 2 3 4 5 6 8 9 10 ''' a=0 while a<10: a=a+1 if a!=7: print(a) print('结束') ''' #1-100所有数的和 ''' number=0 zong=0 while number<101: zong=zong+number number=number+1 print(zong) ''' #1-100内的所有奇数 ''' num=1 while num<101: a=num%2 if a==1: print(num) num=num+1 print('结...
1363b8a3c24c6c1cc44699ca68dcd26e88d3eece
Iannikan/LeetCodeQuestions
/subtreeOfAnotherTree/solution.py
694
3.875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isSubtree(self, s: TreeNode, t: TreeNode) -> bool: if s is None: return False if self.helper(s, t): ...
aa35b7a11be81730e2bf86d3669c473bf90ec921
ElenaSat/Python2021
/POO/Leccion02/02-02-00-MetodosGetSet-UP(1).py
634
3.859375
4
class Persona: def __init__(self, nombre, apellido, edad): self._nombre = nombre self.apellido = apellido self.edad = edad @property def nombre(self): print('Llamando método get nombre') return self._nombre @nombre.setter def nombre(self, nombre): pr...
a0a2a15d7ceb246f717597257012762c51014066
MY-Climate-Observatory/myco-data
/CLIMATExScience/rainfall/data-visualisation.py
1,784
4.09375
4
# -*- coding: utf-8 -*- """ 28 July 2020 Author: Xiandi Ooi Simple visuals segmented into two selection, month and year """ import pandas as pd import plotly.graph_objects as go from plotly.offline import plot def by_year(selected_year, df): """ Input: Year value Output: Line plot of average rainfall in ...
5d09cd733f0b92d9c7a15ce4bf3c2e5a0205385f
fernandozoomp/Python_para_Zumbis
/Lista_1/Exercicio_3.py
538
3.96875
4
# Lista de exercícios I #Exercício 3 #Escreva um programa que leia a quantidade de dias, horas, minutos e segundos do usuário. Calcule o total em segundos. # Solicitar o valor do tempo z = float (input ('Digite o valor dos dias: ')) a = float (input ('Digite o valor das horas: ')) b = float (input ('D...
eea30d27f9654918944f100212dffdb43b88f2e9
RodrigoCaya/Algoritmo-y-Complejidad
/Tarea_2/generarHorarios.py
344
3.578125
4
import random def generarHorarios(): n = random.randint(3, 10) print(str(n)) for i in range(n): inicio = random.randint(1, 18) fin = random.randint(inicio+1, 19) print(str(inicio),end='') print(" ",end='') print(str(fin),end='') print("\n",end='') ...
9ad9f5575a091e453af09e34acbfde2eb60ba3ef
SummerLyn/devcamp_2016
/python/day7/warm_up.py
676
4.03125
4
''' 1) Create random generated list with 100 number anywhere from 100 to 100-90 Using a for loop 2) write another for loop to iterate over that list and count the number of even numbers in the list. ''' import random random_list = [] index = 0 for i in range(0,100): random_numbers = random.randint(100,1000) ...
a5f287fad87eda32b6a049d5d16f35e84d05ed79
junque1r4/treino.py
/Py3Guanabara/des052.py
164
3.578125
4
# números primos num = int(input('Primo:\n[*]:')) primator = 0 for contador in range(1, num): if num % contador != 0: primator = + 1 print(primator+1)
ed5df69018ba18ca1a7b3aaa5d6ebdd3ba5c275c
julian-west/sofifa-analysis
/data/process_data.py
4,246
3.921875
4
"""This file is used to convert raw data into clean data to be used for analysis Cleaning steps include: - creating player_id column - creating country_id column - normalising the units of 'value' and 'wage' columns - imputing the average 'value' or 'wage for players with missing data - reordering a...
6febb745dc01d91497a6ce31569ff645bfdef1a3
solareenlo/python_practice
/02_データ構造/dictionary3.py
400
4.3125
4
"""This is a test program.""" x: dict = {'a': 1} y: dict = x # xからyへの参照渡し(xのアドレスをyに渡してる)になっている y['a'] = 100 print(x, y) # {'a': 100} {'a': 100} と表示 なぜなら, y: dict = x が参照渡しになっているため x: dict = {'a': 1} y: dict = x.copy() # xの中身自体をyへ完コピしてる y['a'] = 100 print(x, y) # {'a': 1} {'a': 100}
f493c95c755474f1279b1980004dc734609c36e0
awesome-liuxiao/grad_course
/2017_spring/graph_theory/optimal_assignment/test.py
3,616
3.546875
4
#!/Users/Trucy/anaconda/bin/python # coding: utf-8 import timeit from collections import deque #============================================================================== # 匈牙利算法 #============================================================================== class HungarianAlgorithm(object): def __init__(self,g...
342f63cb663c0bb4f57c52ad64d4f27414a89dde
blueboy1593/algorithm
/SSAFY알고리즘정규시간 Problem Solving/8월 Problem Solving/0828이론/QueueTest.py
295
3.6875
4
myque = [] def enQueue(item): myque.append(item) def deQueue(): return myque.pop(0) print("myque", myque) enQueue(100) enQueue(200) enQueue(300) print("myque", myque) print("deQueue", deQueue()) print("deQueue", deQueue()) print("deQueue", deQueue()) print("myque", myque) print("OK")
40a2ec2d6e681a03d4bbe533f6bebd3af2f5a202
schellenberg/cs-summer-workshop-2018
/microbits/student-exemplars/turtle-dodge.py
3,676
4.5
4
######################################## #Name Redacted #Computer Science 20 #May 1 2018 #Mr. Schellenberg #Purpose: to use functions and the microbit #How to play: Try to catch the falling turtle ######################################### import microbit import time import turtle import random def is_in_screen(the_w...
1b5f079e35644faf75cc6e8749d1e26857dcf296
YihiaAl-Shekly/learningPython
/PID.py
1,799
3.609375
4
""" PID Class a specific class for controlling UAV control_surfaces """ """ how to tune the PID values manually increase the d until the position (error) is stable (not changing a lot) increase the p slowly until the error is almost to 0 (+or- 5ish%) increase the i by relatively very small increment unt...
b64e9598571ff5750af24e7776982ee7dd87184f
piyushiitg/InterviewQuestions
/Trees/diameter.py
350
3.78125
4
import tree import height root = tree.create_tree() def diameter(root): if root is None: return 0 lheight = height.height(root.left) rheight = height.height(root.right) ldiameter = diameter(root.left) rdiameter = diameter(root.right) return max((lheight+rheight+1), max(ldiameter, rdia...
311c7cd0c6c59b06727be996e859b43ea0664bc4
nigelbrennan/Anxiety-App
/programming_2_ca117-master/programming_2_ca117-master/Lab 6.2/circle_62.py
609
4.03125
4
from math import sqrt def overlap(x1=0, y1=0, r1=1, x2=0, y2=0, r2=1): distance = 0 total_radius = r1 + r2 x = x1 - x2 y = y1 - y2 if x < 0: x = x * -1 if y < 0: y = y * -1 distance = sqrt((x ** 2) + (y ** 2)) if distance < total_radius: return...
3b9a19e4bf48e4f47146c1eb4cfa898fbeba6bbe
linlin-SMU/202011_learn-python
/maizi/05/05-exercise.py
2,716
3.84375
4
# print('---1 表示添加名片---') # print('---2 表示修改名片---') # print('---3 表示删除名片---') # print('---4 表示查询名片---') # print('---其他数字 表示退出名片---') # # namecard_dict = {} # while True: # num1 = input('please input a num: ') # num = int(num1) # if num == 1: # name = input('please input a name: ') # ...
90ef8616c0fa2ac5d33c2e8aadfc87295926691d
Charlie-Toro/Python-Projects
/count20.py
97
3.65625
4
#Count20 #Caleb Bell #uses a loop to count to 20 for number in range(1,21): print(number)
d968bcac0f847d48177c2b1915fc93b770b0d14f
Di30an/Project1BlackJack
/BlackJack.py
3,350
3.5625
4
# Create Deck and shuffle import random import time deck =[] player_hand = [] computer_hand = [] total = 0 computer_score = 0 def blackjack_banner(): welcome = "Welcome to Black Jack" stars = '*' * len(welcome) print(f'{stars} \n {stars} \n {welcome} \n {stars} \n {stars}') def create_deck(deck): ...
cac8d2d0b54101261936d93c15e4e40284c71f28
neeti2000/insertion_sort
/insertion.py
309
4.1875
4
def insertionSort(arr): for i in range(1,len(arr)): key=arr[i] j=i-1 while j>=0 and key<arr[j]: arr[j+1]=arr[j] j=j-1 arr[j+1]=key #driver code. arr=[12,19,13,15,6] insertionSort(arr) for i in range(len(arr)): print(arr[i])
6a62bb0f447fc0f0cf5f61193c04d9c8fbd5351d
mauricioZelaya/QETraining_BDT_python
/DaneivaGamboa/main_Practices_to_eval/practice5.py
945
4.34375
4
# Write a function days_in_month which takes the name of a month, # and returns the number of days in the month. # Ignore leap years: # days_in_month("February") == 28 # days_in_month("December") == 31 # If the function is given invalid arguments, # it should return None. print("------------Months ---------...
8a5a0d55f15b621aea8b7cc9d4d1731fa24c5b35
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/clxsip004/question2.py
2,681
4.09375
4
#30 second expert #Siphesihle Cele #17 march 2014 print("Welcome to the 30 Second Rule Expert") #Introduction printed print("------------------------------------") print("Answer the following questions by selecting from among the options.") think=input("Did anyone see you? (yes/no)\n") #decision ...
0e672396e4bbdddcf228b50f838c150d12dbb854
QuentinDuval/PythonExperiments
/arrays/PartitionArrayIntoDisjonitIntervals.py
1,198
4
4
""" https://leetcode.com/problems/partition-array-into-disjoint-intervals/ Given an array A, partition it into two (contiguous) subarrays left and right so that: * Every element in left is less than or equal to every element in right. * left and right are non-empty. * left has the smallest possible size. Return the ...
c779401142435481b8693942c74eee26705760e7
mayank888k/Python
/tupleeee.py
313
4.1875
4
lst=[5,6,7,8,9] #tuple is Immutable like strings tple=(1,2,3,4) #you cant append or remove like list tple2=tuple(lst) tple3=tple + tple2 print(tple3) print(tple3[5:10]) #you can access it by index print(tple3[::-1]) print(max(tple3)) del tple3 #You can delete whole tuple
ee0596e87c8fdcdbb673c25c71a23df4e682faed
nmamano/GraphWatermarking
/src/model.py
1,511
3.671875
4
""" Record for the parameters of a random graph model Currently it can be either erdos renyi or random power law graph the field name indicates the model """ from utils import printts class Model: """ """ def __init__(self): pass def erdos_renyi(self, num_nodes, prob): """ erdos renyi mode...
78d3771469b15645f7f8fc89130b084898ba819d
zhb339/book-learning
/编程语言/Python/Python编程从入门到实践/第一部分_基础知识/第9章_类/9_3.py
430
3.59375
4
class User(): def __init__(self, first_name, last_name): self.first = first_name self.last = last_name def describe_user(self): print("First name: " + self.first) print("Last name: " + self.last) def greet_user(self): print("Welcome " + self.first + " " + self.last + "!") user1 = User("zheng", "hongbo") u...
62193159ba58bc622d277f0a56b4899703738990
hgy9709/p2_20161118
/w4main.py
410
3.78125
4
sides=10 size=10 bigger=10 angle=90 import turtle wn=turtle.Screen() t1=turtle.Turtle() for i in range(0,sides): if(i%2): size=size+bigger def makeSwirlSquare(size,bigger,turns,sides,angle): for i in range(sides): if(i%2): size=size+bigger t1.fd(size) ...
e31857c5f2a37163f2b8561f04ecef7ffc5ea2d3
ChengHsinHan/myOwnPrograms
/CodeWars/Python/8 kyu/#205 Is the date today.py
326
4.40625
4
# Write a simple function that takes a Date as a parameter and returns a Boolean # representing whether the date is today or not. # # Make sure that your function does not return a false positive by only checking # the day. from datetime import datetime def is_today(date): return date.date() == datetime.today().d...
ee481babdda2dad6f51f1065cc8ae898228923ed
utting/blended_learning_dashboard
/blendedlearning/connectors/models/Website.py
5,346
4.0625
4
""" @author: B.Clark """ from .Course import Course from abc import ABC, abstractmethod from selenium import webdriver class Website(ABC): """A basic python website interface object to store course information in before saving to database""" def set_domain(self, domain): """ Set domain na...
6dc91b155dbcd6ddc86216f6b665d7aac26b644d
tacostahern/ITM-313
/Homework/2-20-2020/HW_Source_code.py
3,689
4.46875
4
''' This program will calculate the rectangular moment of inertia of one of 3 beams based on the user's choice and input. This program will ask the user to select between 3 beams: I-beam, rectangular beam, and cylindrical beam. Depending on the choice, the user will then be asked to enter info as variables such as B, b...
94572d940f5d7be169c20bb0bf9006bdba856f21
mailinhvu912/C4T15
/session10/engdict.py
315
3.84375
4
dict = { "MANAGER" : "In charge of scheduling and team building", "CAPTAIN" : "In charge of leading the trainings", "COACH" : "In charge of trainings and choosing 12 players" } while True: for i in range(0,4): search = input("enter your position here: ") print(dict[search. upper()])
344fa4a23ab81e1b6e3e7795d2ad1620b674eb1a
baites/examples
/coding/leetcode/az/generate_parenthesis.py
893
3.71875
4
class Solution: def generateParenthesis(self, n: int) -> List[str]: solutions = [] solution = ['']*(2*n) # Recursive generation def generate(left=n, right=n, index=0): # Invalid partial string if left > right: return # I have bala...
1407b1a3eab965470d1b697f8145f87ed0ae51c9
Carolina1018/MinTIC-UNAL
/Ciclo1/Reto2/reto2.py
662
3.671875
4
def adivina(cadena1,cadena2,cadena3): cont1=0 cont2=0 salida="" for i in range (len(cadena3)): p1=0 p2=0 if cadena3[i] in cadena1: p1=1 cont1+=1 else: p1=0 if cadena3[i] in cadena2: p2=1 cont2+=1 else: p...
df02f3d8f0adea9f61344e414972cd745c76a6d0
VitaliiStorozh/Python_marathon_git
/4_sprint/Tasks/s4.5.py
1,893
4
4
# The basic premise of the game Gallows is to follow two rules: # # First character of next word must match last character of previous word. # The word must not have already been said. # Below is an example of a Gallows game: # # ['word', 'dowry', 'yodel', 'leader', 'righteous', 'serpent'] #valid! # # ['motive', 'beac...
c8d38008473bf2adcceaf171eafbd2990dd12889
ruan65/python_algorithms_and_problem_solving
/trees/preorder_postorder_inorder.py
804
3.578125
4
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def pr_eorder(nd: TreeNode): if not nd: return print(nd.val, end='->') pr_eorder(nd.left) pr_eorder(nd.right) def in_order(nd: TreeNode): if no...
7674b414756f6af0d6b1ea3ca2e40fb9c1681d43
NitishTadikonda/Python
/Methods/Strings Methods.py
2,269
4.03125
4
x = "python is awesome." # capitalize() a = x.capitalize() print('Old String: ', x) print('Capitalized String:', a) # center b = x.center(24) print("Centered String", b) new_string = x.center(24, '*') # Center() Method With * fill char print("Centered String: ", new_string) print("Uppercase string:", x.casefold()) ...
d564ef3c7a178cc19f45f9ae545bb1b8f0466577
karakumm/puzzle
/puzzle.py
3,086
3.9375
4
''' Playing board for logic puzzle ''' def check_column(board: list, column: int) -> bool: ''' Checks if the column is valid. Returns True if yes, and False if not. >>> check_column([\ "**** ****",\ "***1 ****",\ "** 3****",\ "* 4 1****",\ " 9 5 ",\ " 6 83 *",\ "3 1 **",\ " 8 2***",\ " 2 ****"...
8310352090dba91861654378a47d04412b962996
arvin1384/Arvin
/Arvin_2/Session 22/3-frequency.py
270
3.6875
4
bascket = [ 'apple', 'apple', 'kiwi', 'kiwi', 'watermelon', 'banana' ] frequensits = [] for fruit in bascket: if fruit in frequensits: frequensits[fruit] += 1 else: frequensits[fruit] = 1 print(frequensits)
634a46e14b7fc9df2a34223a96a750b588046322
meSB29/AI_search_techniques
/assgn1_AIastar.py
8,088
3.828125
4
from queue import PriorityQueue import copy from math import factorial from time import time #Hash function used to save a unique ID for a state . Since the 2nd arguement to a #priority queue can not be a 2d list, hence a unique string is used . def hash(node): string="" for i in range(len(node)): for j in range(...
f5d2fe425e9dbc35515aa457fcf30d0b297e0621
olaruandreea/LeetCodeProblems
/hamming-distance.py
971
4.1875
4
""" The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Example: Input: x = 1, y = 4 Output: 2 Explanation: 1 (0 0 0 1) 4 (0 1 0 0) The above arrows point to positions where the correspo...
b182de01db8e4159a5a2ba1f537d1a80a4e39632
angelleecash/python
/generator.py
237
3.578125
4
__author__ = 'chenliang' def gen_primes(): n = 2 while True: for x in range(2, n): if n % x == 0: break else: yield n n += 1 for p in gen_primes(): print(p)
bf4167f6e62e4df479888faaa7e74812da3b9773
ajaysingh13/Python-Projects-
/moarClasses.py
843
4.28125
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 23 19:16:50 2021 @author: vijay """ # this is the parent class class Person: def __init__ (self, fname, lname): self.firstname = fname self.lastname = lname def printName(self): print(self.firstname, self.lastname) # this is a c...
00f76fd7697464a7667e86e20d524523ca8ad047
buxizhizhoum/leetcode
/construct_binary_tree_from_preorder_and_inorder_traversal.py
1,229
4.15625
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given preorder = [3,9,20,15,7] inorder = [9,3,15,20,7] Return the following binary tree: 3 / \ 9 20 / \ ...
3e276078ccb03fca11ebf6401edb4f73f12c38dd
dmitryokh/python
/ДЗ-3. Цикл while/U. Максимальное количество подряд идущих равных.py
232
3.515625
4
a = int(input()) comp = a count = 1 maxcount = 0 while a != 0: a = int(input()) if count > maxcount: maxcount = count if a == comp: count += 1 else: count = 1 comp = a print(maxcount)
e70a9d30977e03a6666f7a4acad45bedd261944f
shrayasr/Algorithms
/src/main/BinarySearchRotatedArray.py
506
3.609375
4
#rotated sorted array search for minimum class BinarySearchRotatedArray: def get_minimum(self, inp): a = inp low = 0 high = len(a) - 1 # this condition here solves everything!! while a[low] > a[high]: mid = (low+high)/2 print "finding mid " + str(mid...
f68e244f3d2258ddfc44edde126d997e0bc6d5ec
qq2681121906/1803
/17-day/2-不同.py
220
3.65625
4
#5! = 5*4*3*2*1 #4! = 4*3*2*1 #3! = 3*2*1 a = 1 b = 1 while a <= 12: b*=a a+=1 print(b) def xxxx(num): def xxx(num): #4*3! num*xxxx(num-1) 4*xxxx(3) def get_num(num): 5*4! 5*xxx(num-1)
8610b79b503c8d954b943e1804504d1f0761ac0b
kdeckerpyplus/PyPlus_Class4
/ex7_show_int_status.py
1,004
3.671875
4
#!/usr/bin/env python import textfsm from pprint import pprint # Create a file handle to the TextFSM Template .tpl file: template_file = "ex2_show_int_status.tpl" template = open(template_file) # Read in the 'show int status' output from a text file: with open("ex2_show_int_status.txt") as f: raw_text_data = f.read...
00ae79785d3f7c5321f0b43c4e84fb9ee26ef773
omertacs/Python
/vrfy.py
940
3.59375
4
#!/usr/bin/python ### # a simple script that iterates a file containing user names to check if the user exists on a SMTP server (using "VRFY") #### import socket import sys with open('users.txt', 'r') as f: users = f.readlines() # creates an array of users ["user1", "user2", ...etc"] ...
aee64de9a5f7cbfd37ae86be0b250499b87af650
k018c1420/Python
/Challenge6/C-6_1.py
206
3.796875
4
def func(a, b): if a % b == 0: return b else: return func(b, a % b) a = int(input('数値1>')) b = int(input('数値2>')) print("最大公約数:" + str(func(a, b)))
9c25e6375dbea5b508da6fa0be03142e1e8806f7
ChitturiPadma/ComputerVision
/11.Masking.py
966
3.5
4
# coding: utf-8 # In[4]: import cv2 import numpy as np import argparse import imutils # In[13]: #Reading the input image img = cv2.imread('./datasets/flower3.jpg') cv2.imshow('Original_Image',img) cv2.waitKey(0) # In[14]: #Extract ROI using cropping or masking mask = np.zeros(img.shape[:2], dtype='uint8') cv2....
eb9917242d93d58e8c11a0898320bbe9a3b653dd
managorny/python_basic
/homework/les02/task_2.py
730
4.0625
4
""" 2. Для списка реализовать обмен значений соседних элементов, т.е. Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т.д. При нечетном количестве элементов последний сохранить на своем месте. Для заполнения списка элементов необходимо использовать функцию input(). """ a = input("Введите элементы списка че...
90e592dfcf89c3d8ede4705a69de2ebfe1004744
AnilPatel13/Python
/JsonParser/jsonParser.py
3,279
3.515625
4
import re def num_parser(data): data = space_parser(data) match = re.match(r'[\d\.]+',data) or re.match(r'-[\d\.]+',data) # matches for a number and returns a match object if(match): return(data[match.end():]) def string_parser(data): data = space_parser(data) match = re.match(r'".*?"',...
3ecf125aa723acaaf770a856b08c8384bcba9b9e
AthosFB/Exercicios-Python
/ExercícioDoCurso/045b.py
1,265
3.75
4
from random import randint from time import sleep from sys import stdout print("""[ 1 ] Pedra [ 2 ] Papel [ 3 ] Tesoura""") jogador = int(input("Opção: ")) lista = ("Pedra", "Papel", "Tesoura") computador = randint(0, 2) computer = lista[computador] def animation(): stdout.write("\rPedra.") sleep(0.7) stdo...
c1d431fd96461f363e6cf3178ea4a478e0e1cafc
NMH37/Practice_file
/Python/names.py
1,522
3.921875
4
students = [ {'first_name': 'Michael', 'last_name' : 'Jordan'}, {'first_name' : 'John', 'last_name' : 'Rosales'}, {'first_name' : 'Mark', 'last_name' : 'guillen'}, {'first_name' : 'KB', 'last_name' : 'tonel'} ] users = { 'Students': [ {'first_name': 'Michael', 'last_name' : 'Jordan'}, ...
6075581b6731051579537a3e45077fe0d0d7c54e
odinfor/leetcode
/pythonCode/No51-100/no80删除有序数组中的重复项.py
618
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/2/17 5:10 下午 # @Site : # @File : no80删除有序数组中的重复项.py # @desc : class Solution: def removeDuplicates(self, nums: list) -> int: slow = 0 for fast in range(len(nums)): if slow < 2 or nums[fast] != nums[slow - 2]: ...
8fcf501bbad8fe1936bfca0f87ec6d27f092cfb8
Platforuma/Beginner-s_Python_Codes
/12_oops/5_OOPS--Operations.py
327
3.796875
4
''' Method Parameters and self ''' class Operations: '''Double the value''' def double_value(self, value): double = value * 2 return double def add_value(self, a, b): add = a + b return add obj1 = Operations() print(obj1.double_value(2)) print(obj1.add_value(...
c7fa58f6e37a844420eb52a49c936627217d79c7
G-Jarvey/base-python
/验证“哥德巴赫猜想”.py
400
3.8125
4
import math def isprime(n): isprime = True for i in range(2,int(math.sqrt(n)+1)): if n % i == 0: isprime = False break return isprime N = int(input()) if N % 2 != 0: exit(0) for p in range(2,N): if isprime(p) == True: q = N - p if isprime...
97a56120ba9ae129ca3184725376252284a46f12
Aasthaengg/IBMdataset
/Python_codes/p03197/s514368502.py
128
3.546875
4
n = int(input()) for _ in range(n): if int(input()) % 2 == 1: print("first") break else: print("second")
80611d5ed267f303229aacbec3243e7e937455a2
ANSH-SINGH-2006/C-111
/main.py
3,816
3.578125
4
import plotly.figure_factory as ff import plotly.graph_objects as go import statistics import random import pandas as pd student_marks=pd.read_csv("data.csv") data=student_marks["Math_score"].to_list() fig=ff.create_distplot([data], ["Math Scores"], show_hist=False) fig.show() mean=statistics.mean(data) ...
ed223f36c86814d3af214cf3f17f74d56450cf97
Renanrbsc/PadawanPython
/Aula06 13-11 Condicoes/Aula6_for_lista.py
355
3.84375
4
# Juntando listas com for lista = ['Mateus','Matheus','Marcela','Nicole','Tonho','Pablo'] for i in range(0,6): # manipulando uma quant especifica de dados print(lista[i]) lista.append('Natan') for sortudo in lista: # busca imprimir toda a lista print(sortudo) numero = 10 for i in range(0,11): print(f'{i...
4795827f73d767797592a1474c5fd4e9e60eb9d3
evaldojr100/Python_Lista_2
/20_triangulo.py
1,004
4.25
4
'''20) (BACKES, 2012) Dados três valores, A, B, C, verificar se eles podem ser valores dos lados de um triângulo e, se forem, se e um triângulo escaleno, equilátero ou isóscele, considerando os seguintes conceitos: O comprimento de cada lado de um triângulo é menor do que a soma dos outros dois lados. Chama-se equiláte...
06cd8c31ab1fef958b72ca0af022914d9c7dc861
huynhkGW/POTD
/Python/logic-1/squirrel_play.py
1,736
3.671875
4
''' CodingBat Python Activity "squirrel_play" from logic-1. codingbat.com ''' failures = 0 def squirrel_play(temp, is_summer): ''' The squirrels in Palo Alto spend most of the day playing. In particular, they play if the temperature is between 60 and 90 (inclusive). Unless it is summer, then the upper limit is 10...
0d7c0ae4256d40b711533d0e89f8ac21e96a5c82
leilalu/algorithm
/剑指offer/第五遍/13.机器人的运动范围.py
1,772
3.71875
4
""" 地上有一个m行n列的方格,从坐标 [0,0] 到坐标 [m-1,n-1] 。 一个机器人从坐标 [0, 0] 的格子开始移动, 它每次可以向左、右、上、下移动一格(不能移动到方格外),也不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格 [35, 37] ,因为3+5+3+7=18。但它不能进入方格 [35, 38],因为3+5+3+8=19。 请问该机器人能够到达多少个格子? 示例 1: 输入:m = 2, n = 3, k = 1 输出:3 示例 2: 输入:m = 3, n = 1, k = 0 输出:1 提示: 1 <= n,m <= 100 0 <= k <= 20 "...
cc900b65209d3ba03ff4417b9f14cd80870a83b7
KevenGe/LeetCode-Solutions
/problemset/85. 最大矩形/solution.py
1,415
3.53125
4
# 85. 最大矩形 # https://leetcode-cn.com/problems/maximal-rectangle/ from typing import List class Solution: def maximalRectangle(self, matrix: List[List[str]]) -> int: if len(matrix) == 0: return 0 left = [[0 for i in range(len(matrix[0]))] for j in range(len(matrix))] for i in...
d8d5c52e5e8ba1df9b4ab4d1e1e13bb22d15e6a7
assaultpunisher/Leet_Code
/Medium/Python 3/Word_Search(79).py
1,236
3.625
4
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: if not board: # Quick response for empty board return False h, w = len(board), len(board[0]) def dfs_search(idx: int, x: int, y: int) -> bool: ...
4bc795a623cd609cf5f4aff978649bb5d1a36bb2
jpmolden/python3-deep-dive-udemy
/section7_ScopesClosuresDecorators/_98_global_local_scope.py
1,435
3.90625
4
a = 10 printt = print from functools import partial printtab = partial(print, "\t") printtab.__doc__ = "A print with a leading tab, eqiv to print(\"\\t\", *args)" def my_func(n): print("global a: ", a) c = a ** n print(c) my_func(1) print('\n*** When assigning, be careful ***') def my_func(n): ...
1831a863f397175b44ff3baf9653296fa3b2c21f
neilwrawlins/Matplotlib
/Scatter Plot.py
479
3.796875
4
import matplotlib.pyplot as plt import numpy as np def scatterplot(x_data, y_data, x_label = "", y_label = "", title = "", color = "r", y_scale_log = False): _, ax = plt.subplots() ax.scatter(x_data, y_data, s = 10, color = color, alpha = .75) if y_scale_log == True: ax.set_yscale('log') ax...
2500661bdbb9f5ac1b73242ed6c98520df9ea2ba
a-gon/problem_solutions
/medium/graphs.py
1,953
3.765625
4
class Node: def __init__(self, value, children = []): self.value = value self.children = children def printG(self): queue = [self] graph = [] visited = set() while queue: node = queue.pop(0) if node in visited: print(f'{nod...
c35d412b168f37ac779b395a2b110c4af3560b69
emmetyu/web-crawler-data-science-workshop
/introduction_to_python/control_flow/for.py
171
3.90625
4
for i in range(5): print (i) players = ["Curry", "Green", "Durant"] for player in players: print (player) for i, player in enumerate(players): print (i, player)
847b40e8aa5504c609d938447291d2279db4f86a
abhishekparakh/Matasano-Challenges
/AESCBC.py
870
3.546875
4
#Implementing ECB and CBC modes for AES from Cryptodome.Cipher import AES from Cryptodome.Util import Padding class AESECB: def __init__(self, key): self.key = key self.blockLenInBytes = 16 def padder(self, textInBytes): pad = Padding.pad() def encrypt(self, textInBytes): ...
2b1a3141594ad6c66dfa4ce3491b62f7551dccb6
Adem54/Python-Tutorials
/Günün Soruları/3.soru.py
787
4.28125
4
""" Kullanicidan bir kelime alan, ve bu kelimedeki sesli harflerin toplam sayisini ve sesli harflerin kelimenin kacinci harfleri oldugunu ekrana yazdiran python programini yaziniz. Kullanicinin sadece kucuk harfleri kullanidigini varsayabilirsiniz. Ornek Program Outputu: ==================================== lutfen bir ...
2fece686115a0ead1d371d3ce4f7bee549acc5f7
matthieu-eck/wordlist-generator
/worllist-size-estimation
1,561
4
4
#!/usr/bin/env python3 #-*- coding: Utf-8 -*- from math import factorial #Some Functions CS = ['abcefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ','0987654321','*!$?@&'] CS2 = [] #Export this part as a function (thanks to google for that function) def human_read(num, suffix='B'): for unit in ['', 'Ki', 'Mi', ...
3036ac5ea64c99c3f0b4de9d2d83e1fcb785e377
lohithsubramanya/Python
/09_files_and_modules.py
1,651
4.0625
4
#### Files -- Only for txt # f = open('test.txt','r') # result=f.read() ## Reads the entire file # print result # f = open('test.txt','r') # result=f.read(6) ### Reads the first 6 characters of the file # print result # f = open('test.txt','r') ### if we use open it will go to the beginning # resul...
18f7eda1640a71853814c30f96bf07834ae584dc
chrisortman/exercises
/chapter-2/ex-2-2.py
866
4.46875
4
# Programming Exercise 2-2 # # Program to compute expected profit from sales. # This program will prompt a user for a sales projection # and use it to calculate expected profit from a predefined profit margin # then display the result. # Variables to hold the sales total and the profit # initialize them as flo...
27acaf35bb95a69c065eae2ea6bbff42ba3f71da
amos1969/tough-topics
/regexes/regexy-reg_numbers.py
396
4.0625
4
import re def is_reg_number(reg_num): # findall returns a matching string in a list result = re.findall(r"^[A-Z]{2}[0-9]{2}\s[A-Z]{3}$", reg_num) print(result) # The result evaluates to True if it isn't empty false otherwise result = bool(result) return result reg = "MM10 JVP" non_reg = "F387 ...
970bca25d00dc9d394b897552ad6fd234561fb4d
Aarif123456/Fb-Twitter-gui
/AutomatedSpearPhisher/helpers/fieldWarningCreator.py
447
3.671875
4
from tkinter import Frame, Label # field warning create a text field that will show a user-friendly error def createFieldWarning(button_frame: Frame, row: int, col: int) -> Label: field_warning_label = Label (button_frame,text='',font=('orbitron', 13), fg='white', bg=...
361420779aaf3fbd9ff0e1c086ccb877b919474c
YIHANZHOU/A-for-8-puzzle
/solution.py
10,994
3.734375
4
from heapq import heappush, heappop import copy import time import random def issolve(puzzlelist): # to estimate whether this puzzle has the solution to the destination reverse = 0 puzzlecopy = [] for i in puzzlelist: if i == 0: ...