blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8a3e79e896efda14d7035308134493f94bc87eed
alexandraback/datacollection
/solutions_5634697451274240_1/Python/mediocrates/2016-GCJ-B-Revenge_of_the_Pancakes.py
2,230
3.53125
4
def flip_stack(stack, top_n): # Left represents the top of the stack """ :rtype : str """ new_top = ''.join('-' if pancake == '+' else '+' for pancake in stack[top_n-1::-1]) old_bottom = stack[top_n:] assert len(stack) == len(new_top + old_bottom) return new_top + old_bottom ...
adc892eea104d9d8f74c0ea54f202ac4f9b07319
xvzezi/Otsu-s-Method
/otsu.py
2,916
3.65625
4
from PIL import Image class MyOtsuMethod: """ This Class implements a way to read in a gray level image, and apply otsu's method onto that. it will provide a binary image, with 0 and 255 to present. """ def __init__(self, file_path): ''' init the needed data :param file_...
4b2c7c5b880d9c435880d1cf12dacb12546e453a
attenka/programmeringskurs
/prick_i_planet.py
293
3.796875
4
import turtle def prick_i_planet(): sissi = turtle.Turtle() print("Vart på planet ritar man en prick?") x = int(input("Ange X")) y = int(input("Ange Y")) sissi.penup() sissi.setpos(x,y) sissi.pos() sissi.dot() sissi.write(x,y) prick_i_planet()
01da33f7af77f2fd5f5dadb484a7f0274486cb2a
JakubMlocek/Introduction_to_Computer_Science
/Cwiczenia2/zad11.py
470
3.640625
4
def isgrowingstr(sequence): for i in range(1, len(sequence)): if sequence[i-1] >= sequence[i]: return False return True def isgrowingint(sequence): prev = 10 #wieksze od cyfr while sequence > 0: if sequence % 10 >= prev: return False prev = seq...
e53d5037f2531b3cf63f4a2052db64276cc5bdc4
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaSequencial/exercicio12.py
304
3.8125
4
# Tendo como dados de entrada a altura de uma pessoa, construa um algorítmo que calcule seu peso ideal, usando a seguinte fórmula: (72.7*altura) - 58 altura = float(input("Digite sua altura em metros: ")) peso = (72.7 * altura) - 58 print("O seu peso ideal baseado na sua altura é: {}kg".format(peso))
10b4e9a6fbec7378ec7370dcf583ce7a6df87d4e
asfanmeliawan/Tugas-Struktur-data
/R.1.6.py
184
3.703125
4
def squared_odd_sum(n): sum = 0 for angka in range(n): if angka%2 == 0: continue sum += angka**2 return sum print(squared_odd_sum(4))
50db5eea1161ef7b13d768c0a7643a4f9fe17909
benjberg/CS-Build-Week-2
/day2.py
1,713
3.828125
4
class MyQueue: def __init__(self): """ Initialize your data structure here. """ #initiate size and storage array self.size = 0 self.storage = [] def push(self, x: int) -> None: """ Push element x to the back of queue. """ #increme...
a8b8d05f36641f4038bd76bcb5e386fd0c5f3387
dillon4287/CodeProjects
/Python/MIT/average_of_lists.py
1,073
3.75
4
__author__ = 'dillonflannery-valadez' def addLists(list_of_lists): """ Assumes all lists are same length :param list_of_lists: :return: sum across multiple lists of element i for all i. """ sumOfLists = [] x = -1 y = -1 for i in range(0, len(list_of_lists[0])): x += 1 ...
7ea92369c18c224dadcf1d80ff86765725cb2705
stratosm/NLP_modules
/src/clean_rows.py
1,090
4.25
4
# Author: Stratos mansalis import numpy as np import pandas as pd def clean_NaN(df): """ Clean the sentences from NaN (Not a Number) and empty rows. Note! Drop the unnecessary columns first and then use this function. Arguments --------- df: the given dataframe ...
2f87489b8849bda664057e9394501ab649bf226c
rayony/LeetCode
/529. Minesweeper/s1.py
2,458
3.5625
4
#Leetcode 529 - Mine Sweeper #https://leetcode.com/problems/minesweeper/ class Solution: #ensure global variable is initialized for each test case in LeetCode. def __init__(self): self.isVisited = {} #************************************************************ #check if selected cell boar...
25904a3d66d6465a83d47545d85c30a2cbf812d2
runpingzhong/MyRepositories
/数据结构和算法/树与树算法/二叉树的广度优先遍历.py
2,531
4.125
4
class Node: def __init__(self,item): self.elem=item #元素 self.lchild=None #左孩子 self.rchild=None #右孩子 class Tree: def __init__(self): self.root=None #根节点 def add(self,item): node=Node(item) #判断根节点是否为空 if self.root is None: self.root=node ...
81bb151c00c1bebdeb3a47bc97f0014a9187cefe
brickgao/leetcode
/src/algorithms/python/Simplify_Path.py
613
3.796875
4
# -*- coding: utf-8 -*- class Solution: # @param {string} path # @return {string} def simplifyPath(self, path): l, ret = path.split('/'), [] for elem in l: if elem == '..': if ret != []: ret.pop() elif elem == '.' or elem == '': ...
663cb9c40b83cfe716473dc8f6c927ef5c4f189e
jing1988a/python_fb
/lintcode_lyft/LRUCache134.py
3,349
3.890625
4
# Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. # # get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. # set(key, value) - Set or insert the value if the key is not alrea...
91d3b3fe553e0e7156350f60e40c7ec21f0f1f24
foxtrot0811/Tkinter-Syntax-
/Binding-Function.py
733
3.609375
4
from tkinter import * class Tkinter : def __init__(self, master) : frame = Frame(master) frame.pack() self.printButton = Button(frame , text = "Print message" , command = self.printMessage) self.printButton.pac...
6b9f7b4c96a8ef84ac49810d1596fd7f1db51095
I-will-miss-you/CodePython
/Curso em Video/Aula 09 - Manipulando Texto/desafio03.py
175
3.859375
4
#Crie um programa que leia o nome de uma cidade e diga se ela começa ou não com o nome "Santo" nomes = input("Nome da cidade: ").strip().split() print("Santo" in nomes[0])
11e2e2f19f8e72856792a6b5a9b7533972abc47e
flaugher/examples-py
/primes.py
354
4.03125
4
#!/usr/bin/env python def is_prime(num): '''Determine if a number is prime.''' for x in range(2, num): if num % x == 0: # return False print "%s is not a prime number" % num # return True print "%s is a prime number" % num def main(): '''Main''' is_prime(5) if ...
64666b78ed5a03271d46d018e0ccc85de116d2aa
SylarBurns/CodingTestPrep
/DFS_BFS/여행경로.py
940
3.609375
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 27 16:54:06 2021 @author: sokon """ def solution(tickets): graph = {} for f, t in tickets: if f not in graph: graph[f] = [t] else: temp = list(graph[f].copy()) temp.append(t) graph[f] ...
d6c3bbf03ff120232334e191079cce560e0bf55c
Sree-creator-123/RPS
/rps.py
1,652
4.28125
4
#Imports the random library import random # Creates a list called rps with the words rock, paper, and scissors rps = ["rock", "paper", "scissors"] # Asks the user for their name name = input("What is your name? ") # Prints the user's name with hello and a description of the game print("Hello " + name, "This ...
059a8a66987385ec767a8c36be824d596c3b1d44
daniel-reich/turbo-robot
/dcFp6EuCm8J2HNKFG_12.py
700
4.1875
4
""" Write a function that returns the sum of all the `elements` included in the `root list`. ### Examples func([ [], [] ,[] ]) ➞ 3 # 1 + 1 + 1 = 3 # The three empty lists inside the root list. func([ [3], [2] ,[1,2] ]) ➞ 7 # 1 + 1 + 1 = 3 # The three lists inside the root list. # 1...
25eeab4d37aae63f2906c8a40842b4c2bc88e1d4
castingdyw/python_foundation
/PycharmProjects/day05/day05 函数.py
1,206
3.578125
4
# 定义两个函数,分别实现任意个数之间的累加、累减操作。如实参为 1,2,3,4,5,累加即是1+2+3+4+5 # def add1(*args): # s = 0 # for i in args: # s += i # print(args) # print(s) # # ls = [1,2,3,4,5,6] # add1(*ls) # def sub(*args): # s = args[0] # for i in args[1:]: # s -= i # print(args) # print(s) # ls = [1,2,3,...
869fb134d815268843c50d02307b42f10b3366a7
ShushantLakhyani/200-Python-Exercises
/exercise_18.py
329
4.125
4
# Write a Python program to find common items from two lists. # input # color1 = "Red", "Green", "Orange", "White" # color2 = "Black", "Green", "White", "Pink" # output # {'Green', 'White'} color_1 = ['Red','Green','Orange','White'] color_2 = ['Black','Green','White','Pink'] print ((set(color_1)) & (set(color_2))) ...
f2f1d8f8eada59e46910425ee509989d9054a824
GongFuXiong/leetcode
/old/t20191017_maxProduct/maxProduct.py
1,601
3.71875
4
#!/usr/bin/env python # encoding: utf-8 ''' @author: KM @license: (C) Copyright 2013-2017, Node Supply Chain Manager Corporation Limited. @contact: yangkm601@gmail.com @software: garner @time: 2019/10/17 @url:https://leetcode-cn.com/problems/maximum-product-subarray/ @desc: 152. 乘积最大子序列 给定一个整数数组 nums ,找出一...
13c4c1ae2d52802a61bd2e979caccc737940b45e
Insper/design-de-software-exercicios
/pages/dicionario/raw/dicionario/if_in.py
265
3.78125
4
port2eng = {'couve': 'kale', 'repolho': 'cabbage', 'brocolis': 'broccoli'} port = 'alface' if port in port2eng: eng = port2eng[port] print('{0} em inglês é {1}'.format(port, eng)) else: print('A palavra {0} não existe no dicionário'.format(port))
fcc38ad8d6ccf4b208c1e2eb58ba7dafb77ed788
kapilsid/TagService
/db/SQLiteDB.py
3,017
4.125
4
import sqlite3 class SQLiteDB: """SQLiteDB is sqlite specific class for inetarcting with SQLite. Attributes: conn: DB Connection cursor: cursor for the database access. """ def __init__(self,dbfile): """Constructor Args: dbfile: name of sqlite db file ...
1aa25b88654acd45802bc166723da0995a3d480f
daniel-reich/ubiquitous-fiesta
/jwiJNMiCW6P5d2XXA_4.py
224
3.640625
4
def does_rhyme(txt1, txt2): txt1_vowels = [char for char in txt1.lower().split()[-1] if char in 'aeiou'] txt2_vowels = [char for char in txt2.lower().split()[-1] if char in 'aeiou'] return txt1_vowels == txt2_vowels
cb3fcffcce020e331d597981ef9f7e673dfb1794
JonCS/z340
/files/TestData2/english2.py
1,071
3.59375
4
#python import random print("\n** Begin Script **\n") MAX_CHARS = 136 MIN_WORDS = 48 NUM_SAMPLES = 1000 # dictionary of words f = open("alice_oz.txt", "rt") print("\reading 'alice_oz.txt'...\n") for x in f: #print(x) x.strip() f.close() wordList = x.split(' ') out = open("english_text.txt", "a") out2 = open(...
4009ac056f6f4bfaa78299f5677975abc571c944
ANJI1196/assignment2
/4power bill.py
673
4.25
4
#POWER CONSUMPTION CALC APP: units=int(input("Please Enter Number of Units:")) if units>=1 and units<=50: print("Rate Per Unit($) is 3") print("Bill Amount:",bill_amt) rate=3.00 elif units>=51 and units<100: print("Rate Per Unit($) is 6") print("Bill Amount:",bill_amt) rate=6.00 elif u...
8190b6c9bde38327b0f24eba6f3e7d192af9b090
lexpol/python_homework
/lesson05/lesson05-2.py
770
4.3125
4
# 2. Создать текстовый файл (не программно), сохранить в нем несколько строк, выполнить подсчет # количества строк, количества слов в каждой строке. with open('lesson05-2-sample.txt') as my_file: print(f"\nСодержимое Файла: \n\n{my_file.read()}\n") with open('lesson05-2-sample.txt') as my_file: lines = 0 f...
9e3cd58109529fd49e164ec1630597b77e50ff7c
qerty123/Arrays-sorts
/methods.py
3,662
3.796875
4
from random import randint from functools import reduce def sort_countion(array): another_array = array.copy() for i in range(len(array)): less = 0 for o in range(len(array)): if array[i] > array[o]: less += 1 elif array[i] == array[o] and i >...
0fc55124582dd41013b65b13ea832f963a93b19d
liuleee/python_base
/day06/06-使用类名调用父类的方法.py
1,081
3.875
4
# -*- coding:utf-8 -*- class Animal(object): #对象方法 def run(self): print('动物跑起来了') class Dog(Animal): # def run(self): # print('小狗跑起来了') def shut(self): #再次调用父类方法 #1.self,前提当前类没有父类的方法,否则调用的是当前类的方法 # self.run() #2.使用父类的类名,需要传入实例对象 # Animal.run(sel...
79f62a7ee6eb1f0d6df192c475af8fec47ca39a9
celiyan/PyPassManager
/crypto.py
1,530
3.65625
4
from Crypto.Cipher import AES from os import urandom def pad(txt): "AES CBC requires the number of plaintext bytes to be a multiple of 16, so we pad it to the nearest multiple. Takes&Returns bytes object." padding_length = AES.block_size - len(txt)%AES.block_size # we pad with a character = to the padding length...
202ca74204129de20c5a3618b8170265868a4583
PiyushChaturvedii/My-Leetcode-Solutions-Python-
/Leetcode 6/Word Ladder.py
1,214
3.515625
4
class Solution: def ladderLength(self, beginWord, endWord, wordList): """ :type beginWord: str :type endWord: str :type wordList: List[str] :rtype: int """ wordset=set(wordList) if endWord not in wordset: return 0 pastset...
91f2e9d58b8bfe36f0f9b7a662ab8170f509c85a
Yuliya-N/MyScripts
/Scripts/Class_Monkey.py
244
3.90625
4
class Monkey: age = 0 name = "" # now it's like fancy dict # you can access attributes by .name, just like [name] in dict monkey1 = Monkey() monkey1.name = "Jimmy" monkey1.age = 5 monkey2 = Monkey() monkey2.name = "Johny" monkey2.age = 3
5d246085dd5b5ccb929154072fd704026d26855f
gabriellaec/desoft-analise-exercicios
/backup/user_367/ch19_2020_03_04_18_33_55_752672.py
200
3.546875
4
def classifica_triangulo(a,b,c) if a==b and a==c: return 'Triangulo equilátero' if a==b or a==c or b==c return 'Triangulo isósceles' if a!=b and a!=c and b!=c return 'Triangulo escaleno'
2ee1c7e4d5dcd618604df1e250175ad71891842f
lindo-zy/leetcode
/二分查找/1198.py
401
3.765625
4
#!/usr/bin/python3 # -*- coding:utf-8 -*- from typing import List class Solution: def smallestCommonElement(self, mat: List[List[int]]) -> int: n = len(mat) m = len(mat[0]) ans = 0 return ans if __name__ == '__main__': s = Solution() mat = [[1, 2, 3, 4, 5], [2, 4, 5, 8,...
bad30a0935200115a0213895f04caefa5b1b87a3
evanpelfrey00/python-assignments
/HW00_EvanPelfrey.py
2,870
4.125
4
""" Evan Pelfrey CS 100 2018F Section 101 HW 00, Sep 12, 2018 """ #Exersise 5b face = 1 limbs = 4 fingers = 10 #Exercise 5c oneAndQuarter = 1.25 oneAndHalf = 1.5 oneAndThreeQuarters = 1.75 #Exercise 5d NJIT = "Awesome" newJerseyDevils = "Good" newYorkRangers = "Bad" #Exercise 6, Chapter 1.9, Exercise 1...
67e8dc7c47a615200ef5fa261b8cbad16c21332b
AnacondaRecipes/pycryptodome-feedstock
/recipe/run_test.py
654
3.515625
4
from Crypto.Random import random def test_pycryptodome_pkg(): """ Tests to validate the pycrptodome pkg. """ print("Validating pycryptodome package") # Returns an integer <=a and <=b x = random.randint(0, 5000) y = random.randint(0,5000) assert 0 <= x <= 5000, "Failed to assert the r...
8cae0297d71e65efda74f8c7374e405f4592b72a
margierain/bootcamp-6-exerices
/Day 4/oop/example.py
850
4.375
4
class Animal(object): ''' animal_count is a class property that increases the number of animals''' animal_count = 0 def __init__(self, name): self.name = name Animal.animal_count += 1 self.id = Animal.animal_count def eat(self): return "yes, I eat :)" class Cat(A...
cc8cd4a17de0574a213387683241bbb77d1b499e
nitesh619/DataScience
/linerREgression.py
705
3.671875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt df = pd.DataFrame({'X': [1, 2, 4, 3, 5], 'Y': [1, 3, 3, 2, 5]}) df['x-mean'] = df['X'] - np.mean(df['X']) df['y-mean'] = df['Y'] - np.mean(df['Y']) df['mul'] = df['x-mean']*df['y-mean'] df['xsquare'] = df['x-mean']**2 sumCov = np.sum(df['mul']) ...
688c70b8ad0c2362015fe0f0b2357ac89f099bca
Jesselinux/Data-Structures-and-Algorithms
/001,Data Structures and Algorithms Basics/013,图(Graph).py
36,355
3.703125
4
# 第一部分、创建图: # 1,矩阵表示法: class Vertex: def __init__(self, node): self.id = node # Mark all nodes unvisited self.visited = False def addNeighbor(self, neighbor, G): G.addEdge(self.id, neighbor) def getConnections(self, G): return G.adjMatrix[self....
bda367b6fa0c001b4af4dce5dbd767d3a0d83135
qazmko19/Python
/Python Стартовый/Четвёртое занятие/Домашнее задание/dz1.py
228
4.09375
4
a = int(input("Write number a: ")) b = int(input("Write number b (b is greater than a): ")) summa = 0 if a < b: for i in range(a, b+1): summa += i print(summa) else: print("Number b isn`t greater than a.")
fbc7065a7bed2a85cd4574f5654447e9556389c5
venky5522/venky
/oops_concept/encapsulation/encapsul.py
217
3.9375
4
class Encapsulation: a = "hello" _a = "python" __a = "welcome" print(Encapsulation.a)#hello print(Encapsulation._a)#python #print(Encapsulation.__a) we cant print private variable out side of a class
bc311dc105a6dfd39a02ad591618332503394409
chat-code/leetcode-everyday
/past/20191214_1276/duangduang.py
432
3.609375
4
from typing import List class Solution: def numOfBurgers(self, tomatoSlices: int, cheeseSlices: int) -> List[int]: if cheeseSlices * 2 > tomatoSlices or cheeseSlices * 4 < tomatoSlices: return [] if tomatoSlices % 2 == 1: return [] total_jumbo = (tomatoSlices - che...
902e76108c7caf8c0c23ec93b0d092bed7e59ef3
MichaelTA0111/ELE2024-lab-2
/Utilities.py
1,420
3.78125
4
from control import TransferFunction as Tf class Utilities: """ Class to define static methods which are used in multiple questions """ @staticmethod def evaluate_at_equilibrium(f, F, F0, x3, x30, x4, x40): """ Function to evaluate a symbolic expression with variables F, x3, and x...
f4e466540e8bf6b3e6cde1d2dee38c81acf4bafd
Tanmai2002/Pycharm-Projects
/FirstPro/Basics/Loops.py
810
3.828125
4
list1 = [["tanu", 12], ["Anu", 10], ["Manu", 51], ["Paanu", 16], ["Kanu", 1]] for item in list1: print(item) """" ['tanu', 12] ['Anu', 10] ['Manu', 51] ['Paanu', 16] ['Kanu', 1] """ for item, marks in list1: print(item, "Has got", marks) """ tanu Has got 12 Anu Has got 10 Manu Has go...
8edbaf7bc2a2534e74bf7e4a4e521c7251bb0bd8
KevinWangTHU/LeetCode
/43.py
1,330
3.59375
4
class Solution(object): def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ def strNum(s, num): # return List[int] c = [] add = 0 for i in range(len(s)): c.append((ord(s[i]...
63b1d9b856e1702197698f48118000d47d020776
vooydzig/L-System-python-simulation
/vector.py
4,724
4.125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- import math class Vector2(object): """Vector2 class. Implements typical vector2 math.""" def __init__(self, x = 0, y = 0): """Constructor. @param x: Vector's X value @param y: Vector's Y value """ self.x = float(x)...
9da657c1859f98a2b62813b3c58f23ae5e8bf590
ananyajana/practice_problems
/binary_tree.py
703
4.0625
4
class Node: # fn to initialize the node object def __init__(self, data): self.data = data self.left = None self.right = None #linked list contains a node object class binary_tree: def __init__(self): self.root = None def print_tree_inorder(self, root): if(ro...
8ed72b014d7ea11eae3318a113044867a1075c33
lwb426/20190303ESRI
/sorting_examples.py
1,284
3.796875
4
#!/usr/bin/env python fruits = ["pomegranate", "cherry", "apricot", "Apple", "lemon", "Kiwi", "ORANGE", "lime", "Watermelon", "guava", "Papaya", "FIG", "pear", "banana", "Tamarind", "Persimmon", "elderberry", "peach", "BLUEberry", "lychee", "GRAPE", "date" ] f0 = sorted(fruits) print("f0: {}".format(f0), '\n') def ...
b29858cd26c82021b492380aed7faaf48b0dd56f
guimeisang/algorithm013
/Week_01/01数组类型/移动零.py
911
3.953125
4
# 题目: # 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 # 示例: # 输入: [0,1,0,3,12] # 输出: [1,3,12,0,0] # 思路:1. 双指针的方式,当为0的时候,i 会往一直前走,但是i 不为零的时候,就会进行替换,并且j也往前面走; # 但是i 为零的时候,i会往前面走,但是不置换,j也不会往前面走,在那边等i找到非零的数 class Solution(object): def moveZeroes(self, nums): """ :type nums: List[int] :rtype: None Do n...
4f3611738f2a413d09f0d70cc1601db589253600
rafaelperazzo/programacao-web
/moodledata/vpl_data/35/usersdata/106/13691/submittedfiles/dec2bin.py
342
3.71875
4
# -*- coding: utf-8 -*- from __future__ import division p = input ('Digite um número:') q = input ('Digite um número:') menor = p maior = q contador1 = 0 contador2 = 0 while menor>=1: contador1 = contador1 + 1 menor = menor//10 while maior>=1: contador2 = contador2 + 1 maior = maior//10 print (contador...
293cbb2f5f377769a2d12094d1f04f5f32414a13
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/leetCode/String/ImplementStrStr().py
1,872
4.09375
4
""" Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = "hello", needle = "ll" Output: 2 Example 2: Input: haystack = "aaaaa", needle = "bba" Output: -1 Clarification: What should we return when needle is an empty...
c070ca724f216961ae6d6e1a459a60269cfbeaa3
aa-fahim/practice-python
/Ex30.PickWord.py
336
3.609375
4
## Pick Word # Picks a random word from the sowpods.txt file which contains a list of # the official words used in Scrabble game. import random lines = [] with open('sowpods.txt', 'r') as f: lines = f.read() lines = lines.split('\n') print('Random word from sowpods list: {}'.format(random.c...
10fd5c23a8982dcc68214b38dcde68dd8cdf38c5
emt2017/CS5590PythonSpring2018
/Lab3Python/Question2.py
1,906
3.90625
4
#2)Implement Support Vector Machineclassification, # 1)Choose one of the dataset using the datasets features in the scikit-learn##### # 2)Load the dataset############################################################## # 3)According to your dataset, split the data to 20% testing data, 80% training data(you can also us...
da841f1e697cb5cc8ece5b2a2f8c0f415f287566
shakiz/PythonWorks
/pprintpart2.py
219
3.625
4
import pprint print('Enter your message : ') message=input() count={} for char in message: count.setdefault(char,0) count[char]=count[char]+1 pprint.pprint(count) print(pprint.pformat(count))
789d69f4fddcbc60fd7d02f5357052532b5635e6
SanusiWasiu/Python-Projects
/Number_guessing.py
1,948
4.03125
4
""" Number Guessing Game """ import random attempts_list = [] def score(): if len(attempts_list) <= 0: print("There's no high score yet, its your for the taking") else: print(f"The current high score is {min(attempts_list)} attempts") def start_game(): wanna_play = input("do y...
e70f705f1d9c6ea575cf5440711b7f56271b4c80
gabriel-lynn/Moto-Logger
/prioritizer.py
972
3.625
4
import operator global priority_reference priority_reference = { "tire": 2, "brake light": 5, "clutch": 7, "transmission": 11, "crankshaft": 12, "brake": 10, "brakes": 10, "oil": 4, "oil change": 4, "shock": 6, "shocks": 6, } def pri...
2bdeec11c825e69c0686bcb4d940706ed1801944
Maheen-khalid/Riddle-Game
/Riddle Game/Youwin.py
618
3.734375
4
import tkinter import tkinter.messagebox import tkinter.font as font window=tkinter.Tk() window.configure(bg='blue') #Setting font size myFont = font.Font(family = "Comic Sans MS",size=20,weight='bold') var=tkinter.Label(window,text="Congratulations !!",bg='blue',fg='yellow') var2=tkinter.Label(window,text="You have...
cc6744fe91a65380c89cd36eb9a58df8d3b0b74b
narendraparigi1987/python
/exercises/EXAMPLE_iterating_over_tuples.py
1,164
4.21875
4
def get_data(aTuple): """ aTuple, tuple of tuples (int, string) Extracts all integers from aTuple and sets them as elements in a new tuple. Extracts all unique strings from from aTuple and sets them as elements in a new tuple. Returns a tuple of the minimum integer, the maximum intege...
e97fafb6a33f3d8a9820f191340381df398916b4
shen-huang/selfteaching-python-camp
/exercises/1901040031/d10/mymodule/stats_word.py
2,660
3.625
4
#coding = utf-8 from collections import Counter #collections 是python内建的集合模块,Counter 是其中的一个函数,需要用到from...import... 否则counter函数出现Undefined的情况 text = ''' The Zen of python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complic...
ff40a05332bcacce5250c217f0ac7f47a4b18796
Suswan114/CodeStrife
/python/Amusing Jokes.py
98
3.609375
4
a = input() b = input() c = input() if sorted(a+b) == sorted(c): print("YES") else: print("NO")
914f6c1b875e63c53bbb8dd035590de3fa0671ad
stfnylim/P2Ppersonal
/server_client/server.py
3,822
3.609375
4
""" This file takes part of the server side of the peer to peer network This file deals with uploading of the song for other peers """ from server_client.constants import * class Server: def __init__(self,msg): try: # the message to upload in bytes self.msg = msg ...
e17f99008a81714f07dfc24172466e7b15224758
jsebdev/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
192
3.734375
4
#!/usr/bin/python3 """check if obj is of the same class as a_class""" def is_same_class(obj, a_class): """check if obj is of the same class as a_class""" return type(obj) == a_class
c4d76bf921cba72fec4175a2f569a8967079eed6
max180643/PSIT-IT
/Week-13/3nPlus1.py
495
3.78125
4
""" 3nPlus1 Author : Chanwit Settavongsin """ def main(answer): """ input value and value != 0 """ while True: number = int(input()) if number == 0: break else: answer.append(check(number, 1)) print(*answer, sep="\n") def check(number, total): """ Check n...
bf8e2b192b659ccf25043b8353a5e771c32b5ee1
ErisonSandro/Exercicios-Python
/exercicios/ex074 - Maior e menor valores em tupla.py
274
3.78125
4
from random import randint numeros = (randint(0, 10), randint(0, 10), randint(0, 10), randint(0, 10), randint(0, 10), ) print(f'Os numeros sorteados foram: {numeros}') print(f'O maior valor sorteado foi {max(numeros)}') print(f'O menor valor sorteado foi {min(numeros)}')
7eaf3dec47840750e58b69afc08bb59136886717
nhanif-cognito/python-learning
/code7
371
4.15625
4
#!/usr/bin/env python # programe to display users given name , age and job titleself. data = {} name = input("enter your full name: ") #print(name) age=int(input("enter your age: ")) #print(age) department = input("enter your department") #print(department) for i in range(name , department): id = input("enter yo...
81cf5eee49b1b242d0b487a56062f249178a9a23
douglassli/CSPSudokuSolver
/sudoku_CSP.py
3,108
4.0625
4
class SudokuCSP: def __init__(self, initial_sudoku, next_var_heuristic): """ Initializes an instance of a SudokuCSP. Keyword arguments: initial_sudoku -- an instance of a Sudoku object representing the initial state of the sudoku to be solved. next_var_heuristic -- an option...
a1124ba0789708d5fd629075c35f36614ee28538
jeffvswanson/CodingPractice
/Python/Zelle/Chapter10_DefiningClasses/ProgrammingExercises/12_DisplayPlayingCards/randomFiveCardHandGenerator.pyw
2,470
4.3125
4
# randomFiveCardHandGenerator.pyw # A program to display a hand of five random cards. """Extend your card class from Chapter 10 Programming Exercise 11 with a draw(self, win, center) method that displays a hand of five random cards. Hint: The easiest way to dio this is to search the Internet for a free set of card ima...
2d27a9641984d7e8607e4166491518f8a57c3f77
ikonushok/My_studying_Python_developer
/lesson_4/HW_4_UltraLight.py
285
3.5625
4
# Функция без параметров def empty(): print('Это функция без параметров') print(empty()) # Функция с параметрами def sqr(a): return a**2 print(sqr(4)) # Лямбда функция s = lambda x: x**3 print(s(3))
1f7c89c5148b2a7700b946ef187b13392c1709e1
LyleMi/Leetcode
/longestCommonPrefix.py
291
3.515625
4
class Solution(object): def longestCommonPrefix(self, strs): if not strs: return "" pre = strs[0] for i in range(len(pre)): for s in strs: if i >= len(s) or pre[i] != s[i]: return pre[0:i] return pre
1c6464405929b6b3e54e21aea65eeeb763e561f6
shangli-cuc/Python-
/colors_spiral_line.py
286
3.578125
4
#绘制彩色螺旋线colors_spiral_line.py import turtle turtle.tracer(False)#不需要等待直接出图 turtle.bgcolor("black") color=["red","yellow","violet","blue"] for i in range (400): turtle.forward(i*2) turtle.color(color[i%4]) turtle.left(91) turtle.tracer(True)
462601c0b33faf60c3b7974694dc15753800680f
kkravchenkodev/main_academy
/lesson_10/homework/2.py
702
4.125
4
""" 2. Написать свой декоратор, который выбирает рандомное приветствие для введенного имени 'Hello, <Name>', 'Welcome, <Name>','Greetings, <Name>!','Salutations, <Name>!','Good day, <Name>!', 'Yo, <Name>!' """ from random import choice phrases = ['Hello', 'Welcome', 'Greetings', 'Salutations', 'Good day', 'Yo'] def ...
70b7a80a33548efaa90494a03c129146333d03a4
jlym/practice-python
/practice_with_references/stack_frame_demo.py
609
3.984375
4
# Stack frame demo --------------------- # Let's explore how stack frames work def get_average(numbers): sum = 0 count = len(numbers) for number in numbers: sum += number return sum / count def get_min(numbers): if len(numbers) == 0: return 0 min = numbers[0] for numbe...
84c6813f8788f277a6b538e02dde6297193ffc69
YangLiyli131/Leetcode2020
/in_Python/0690 Employee Importance.py
1,182
3.625
4
""" # Definition for Employee. class Employee(object): def __init__(self, id, importance, subordinates): ################# :type id: int :type importance: int :type subordinates: List[int] ################# self.id = id self.importance = importance ...
82a1b76c8330f830f8b9e985e2dcb6881e367693
NazarPonochevnyi/Programming-Labs
/Programming/Sem1/Lab5/lab5.py
1,137
3.765625
4
""" 2. Створіть програму, що підраховує частоти входження слів в текстовому файлі. """ import string from collections import Counter input_file = 'text.txt' def count_words(words, sort=False): words_count = {} for word in words: if word in words_count.keys(): words_count[word] += 1 ...
1bc434e75b9584020bd2eccf5e7659b590e41a76
kiiikii/ptyhon-learn
/exercise-variables-2.py
510
4.28125
4
# Exercise 1 # What is the output of the following snippet? x = int(input("Enter a number: ")) # the user enters 2 print(x * "5", end="\n\n") # Exercise 2 # What is the expected output of the following snippet? x = input("Enter a number: ") # the user enters 2 print(type(x), end="\n\n") x = input() y = input() print(...
b7f871ad4196c115981a102faf33abac0373b9b7
hattwick/pywork
/app.py
554
3.65625
4
# Nested budget/expense functions def get_budget(): budget_string = input("What is your allocation for this month: ") budget = int(budget_string) return budget def day_of_month(): day_string = input("What day of the month is today: ") day = int(day_string) return day def burndown(budget, day): committed = bud...
55d3a7e0a166ba5d7b36233ce13090873e2baf15
AdamZhouSE/pythonHomework
/Code/CodeRecords/2531/60799/237690.py
150
3.5
4
S = list(input()) dict1 = {} for i in S: dict1[i] = S.count(i) print(dict1) S.sort(key=lambda x: (-dict1[x], x)) print(''.join(str(i) for i in S))
f720812f213027ef64d26bba58dcc5f21a9b1971
sharda2001/Function
/MINIMUM_no_.py
165
3.59375
4
def min(list): i=0 min=list[0] while i<len(list): if list[i]<min: min=list[i] i=i+1 print(min) min(list=[1,4,87,5,80])
d76a3be51dae60e1a64c595746403ee0e89cdfcb
sepabe/pythonProject1
/exercici7.py
454
3.84375
4
from array import * def main(): num1 = int(input("Ingrese el primer numero entero: ")) num2 = int(input("Ingrese el segundo numero entero: ")) num3 = int(input("Ingrese el tercer numero entero: ")) # Valida si los tres numeros son iguales if num1==num2 and num1==num3: for x in range(3): ...
61a006e2f78ccf5abb60d924f6d9fac42f8e38aa
anttinevalainen/automating-GIS
/Final assignment/TableJoiner.py
3,253
3.625
4
def TableJoiner(matrix_txt, output_folder): import pandas as pd import geopandas as gpd import os '''creates a layer from the given text table or a list of tables by joining the file with given YKR grid GeoDataFrame where from_id in Matrix file corresponds to YKR_ID in the Shapefile Args: ...
9d53c1576c7297c40f94fd01ecc9a717d44c4907
ujey02/leetcode
/BinaryTreeZigzagLevelOrderTraversal.py
1,214
3.875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right from queue import Queue class Solution: def zigzagLevelOrder(self, root: TreeNode) -> List[List[int]]: ans = [] ...
05b4f842d0ec855d70b8414bdde0329cc4443e93
chenpc1214/test
/7-11(方法4 tag).py
278
3.53125
4
list1=[i for i in range(1,10)] f="" for o in list1: f=str(o)+f print("{0:>9}".format(f)) """原先方法 n = 1 for x in range(1,10): for y in range(1,n+1): if x>y: n+=1 print(y,end="") print() """
d9b2b7a311e4a2b952ecf010bab36a87e9a06cd0
Ghulamfatima/Python.
/New 6th Assignment.py
2,563
4.09375
4
#-------------------------------- pythan LOOPs -------------------------- #while loop a = 2 while a < 4: print(a) a += 1 #-------- using break statemen --------- a = 2 while a < 5: print(a) if a == 3: break a += 1 #------- continue statement ------------ a = 2 w...
4f30d4b82d5e89baf3289f2bf5393f6b13723f3f
tiberiomorais/respostas5
/atividade8.py
173
4.15625
4
# 8. Faça uma função que informe a quantidade de dígitos de um # determinado número inteiro informado. numero = input('número: ') tamanho = len(numero) print(tamanho)
290c7aef95c037749d35ae9f36f8dae3c0935a31
ataabi/pythonteste
/Desafios/ex059.py
1,078
4.1875
4
#Crie um programa que leia dois valores e mostre um menu na tela. #[1]Somar , [2]Multiplicar, [3]maior, [4]novos números, [5]sair do programa. # Seu programa deverá realizar a operação solicitada em cada caso. from time import sleep n1 = float(input('Digite o 1° valor : ')) n2 = float(input('Digite o 2° valor : ')) whi...
9100f37fe8536130ec614b449c4f5ef5d76a30dd
pcewebpython/wsgi-calculator
/calculator.py
2,460
4.1875
4
""" For your homework this week, you'll be creating a wsgi application of your own. You'll create an online calculator that can perform several operations. You'll need to support: * Addition * Subtractions * Multiplication * Division Your users should be able to send appropriate requests and get back proper...
c03a646f6223588d3bce42db0ef7f8d537added8
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3/randomguywithoutaname/C.py
600
3.625
4
## Problem C raw_input() N, J = tuple(int(n) for n in raw_input().split(' ')) assert N % 2 == 0 divisibilities = [3, 2, 5, 2, 7, 2, 3, 2, 11] divstr = ' '.join(str(s) for s in divisibilities) def check(s): for i in range(2, 11): assert int(s, i) % divisibilities[i-2] == 0 print 'Case #1:' ...
944038280e1e76a91a6d773f156cf8c094c5a0d7
loveritsu929/ENG1600
/smartSnake.py
15,264
3.59375
4
# -*- coding: utf-8 -*- """ ENG 1600 the path-finding snake """ import random import time import pygame import sys import numpy as np from pygame.locals import * class PFSnake(object): # class attributes # a 50x50 gameboard window_height = 100 #400 window_width = 100 #400 cell_size = 20 boar...
4824788473d3f0872efbec024340f28c6e5beaa9
hrishikeshtak/Coding_Practises_Solutions
/hackerrank/stack/si-rectangular-area-under-histogram.py
1,801
3.78125
4
#!/usr/bin/python3 # p1 = Find 1st smaller elements on left side # p2 = Find 1st smaller elements on right side # area = arr(i) * (p2 - p1 - 1) # Time Complexity: Since every bar is pushed and popped only once, # the time complexity of this method is O(n). INT_MIN = -(1 << 31) def first_smaller_on_left(arr, N): ...
c29ad84f3431f31a54d8e61a7f9822adf3ea34de
ayanchyaziz123/all-competitive-programming-documents-and-problem-solving
/codecheaf/VOWELTB.py
153
3.59375
4
import sys #sys.stdin = open("input.txt", "r") sr = input() L = ['A', 'E', 'I', 'O', 'U'] if sr in L: print("Vowel") else: print("Consonant")
78e994dbe8dc9af67584cb6e5e2c2e35ad3e958e
eoin18/AdventOfCode2017
/day5/part2/offsets2.py
552
3.640625
4
#!/usr/bin/env python def main(): steps = 0 position = 0 instructions = [] with open('data.txt') as f: lines = f.readlines() for line in lines: instructions.append(int(line.strip('\n'))) while position >= 0 and position < len(instructions): temp = position ...
bfed79dcb802cf656c76b024458e2e46a175c1a4
sidv/Assignments
/Thanushree/Assignment/Aug_13/total_count.py
257
3.796875
4
str = input("Enter the string") d_count=0 l_count=0 for i in str: if i.isdigit(): d_countt +=1 elif (i == " " or i == "."): pass else: l_count+=1 print(f"Total digits in the string => {d_count}") print(f"Total letters in the string => {l_count}")
f3abfeaab34a9112737329dbf09df315b8754b1c
jake-g/Driver-Awareness
/pylibs/zmq_publisher.py
2,362
3.71875
4
# Sends messages through assigned topics, using port and address provided by constructor. # Refer to https://learning-0mq-with-pyzmq.readthedocs.org/en/latest/pyzmq/patterns/pubsub.html import zmq class Publisher: def __init__(self, ipaddr, port, list_of_topics): """Generates a publisher object which can ...
45c3fdfa0cb8b3e40fa3c90cad59956a5cfd64d9
mrliuminlong/note
/practise/student_project/student.py
744
3.90625
4
# student.py # 此模块用于描述Student类的定义 class Student: def __init__(self, n, a, s=0): self.__name = n self.__age = a self.__score = s def get_infos(self): return (self.__name, str(self.__age), str(self.__score)) def get_name(self): return self.__name def set_score(s...
95f662521584bbda74073eeadf6fb16a6622f2d6
gerrrd/visualstoryteller
/visualstoryteller/getmorewords.py
2,922
3.734375
4
# visualstoryteller/getmorewords.py # the function "get_more_words" is implemented to analyze (NLP) and input text # with spaCy. import random import spacy def noun_adj(adj=[], verb=[]): ''' given a list of adjectives (adj) and verbs (verb), it returns a random element from the list of adjectives, or if i...
dd8c31e2df92753f7dd444048e4b7383f954612b
tjschaeffer/CMPSC-132
/hw1DifferentMathematical Functions/HW1.py
2,672
3.953125
4
#HW #1 #Due Date: 09/20/2019, 11:59PM ######################################## # # Name: TJ Schaeffer # Collaboration Statement: Got help from LAs # ######################################## def isPower(x, y): """ >>> isPower(4, 64) ...
505918148311a9e0a2e13f3aae0bec18f9f8823d
vik407/holbertonschool-higher_level_programming
/0x06-python-classes/4-square.py
944
4.46875
4
#!/usr/bin/python3 class Square: """Square - a class Square that defines a square by: (based on 2-square.py) """ def __init__(self, size=0): """Instantiation with optional size""" if type(size) is not int: raise TypeError("size must be an integer") elif size < 0: ...
97a02173909bf33bdcc155895cf0dc26dca8fa3b
arunraman/Code-Katas
/Interview/Trees/is_subtree_of_another_tree.py
990
3.828125
4
from binarytree import Node as Treenode class Solution(object): def identical_trees(self, tree_1, tree_2): if tree_1 is None and tree_2 is None: return True if tree_1 is not None and tree_2 is not None: return ((tree_1.value == tree_2.value) and self.ide...
4fe75d53c46f04d477ba3335a7523b9d679f8dfd
PizzaShift/TwitterPMI
/DataCollection/driver.py
968
3.515625
4
__author__ = 'asb' import main, collections, itertools PMITerm = 'apple' listOfBGWords = main.GetSortedRelevantTweets(PMITerm) lister = [] #this code block calcs tuplesIT variable for words in listOfBGWords: lister.append(words) counted = collections.Counter(lister) sortedCounter = counted.most_common() tuplesI...