blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
6a948bb37bb11f71db132c06fdf9990d7b50a4f0
zeroam/TIL
/algorithm/change_counter.py
849
3.53125
4
# 1센트, 5센트, 10센트, 25센트, 50센트 동전이 있고 # 동전을 무한정 확보할 수 있다고 하면 # 이들의 조합으로 특정 금액 m을 만들 수 있는 경우의 수는? class ChangeCounter: def __init__(self, coins): self._coins = coins @property def coins(self): return self._coins def _count_recursive(self, amount, index): if amount == 0: ...
0f7338535d03dbfbde4ca9b1729b6710d387ada3
natureko/magic-ball
/magic-ball.py
1,228
3.984375
4
import random answers = ["Бесспорно", "Мне кажется - да", "Пока неясно, попробуй снова", "Даже не думай", "Предрешено", "Вероятнее всего", "Спроси позже", "Мой ответ - нет", "Никаких сомнений", "Хорошие перспективы", "Лучше не рассказывать", "По моим данным - нет", "Можешь быть увер...
f27e16db948f50a56da32a75c2136c797b7e98e6
Phantom1911/leetcode
/209.py
946
3.703125
4
# this whole algo is O(n) and not O(n^2) # because each element is visited at max twice # l and r are constantly moving right , l is never reset in the inner loop (which is what happens in n^2 cases) from typing import List class Solution: def minSubArrayLen(self, target: int, nums: List[int]) -> int: l,r...
d63149c40bbaf69c7fbe4878b5fdfc50fddcb3dd
JuanesFranco/Fundamentos-De-Programacion
/sesion-11/24-Parametros/4.py
377
3.625
4
def cantidad_vocales(cadena): cant=0 for x in range(len(cadena)): if cadena[x]=="a" or cadena[x]=="e" or cadena[x]=="i" or cadena[x]=="o" or cadena[x]=="u": cant=cant+1 print("cantidad de vocales total de la palabra",cadena,"es",cant) #bloque principal cantidad_vocales("administracion")...
1f9ab5b89d6312036024078b13c9d960c768d1ad
Meemaw/Eulers-Project
/Problem_36.py
495
3.796875
4
__author__ = 'Meemaw' def isPalindrome(x, i): zacetek = 0 konec = len(x)-1 while zacetek <= konec: if x[zacetek] != x[konec]: return 0 zacetek+=1 konec-=1 return 1 vsota = 0 print("Please insert upper bound:") x = int(input()) for i in range(1,x+1): if isPalind...
4e49d7885f23f3323bb5bebb2694878ffe3f6e3a
ivanyu/rosalind
/algorithmic_heights/ms/ms.py
616
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(argv): from ms_logic import merge_sort if len(argv) < 2: print("Input file isn't specified. Using test values:") print('n = 10') n = 10 print('A = [20, 19, 35, -18, 17, -20, 20, 1, 4, 4]') arr = [20, 19, 35, -18, ...
f10148a24fe5b21ab7f7a54322c089c9215ac135
aakriti04/30DaysOfCode
/Day 6 Let's Review/Review.py
389
3.765625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT test_cases =int(input()) str=[] for i in range(test_cases): str.append(input()) for i in range(test_cases): even="" odd="" for index in range(len(str[i])): if (index %2==0): even += str[i][index] else : ...
1d196b5b51d9241e780cd9eba1f0fc3e46b986d3
andriidem308/python_practice
/myalgorithms/LinkedList.py
637
3.875
4
class Node: def __init__(self, item): self.item = item self.next = None class LinkedList: def __init__(self): self.first = None def empty(self): return self.first is None def insert(self, item): new_node = Node(item) new_node.next = sel...
484d5ef6803c468d9fb32861376e183263ae34f4
dphillips97/pract
/general_py_pract_ex/game_board.py
645
4.4375
4
''' Time for some fake graphics! Let’s say we want to draw game boards that look like this: --- --- --- | | | | --- --- --- | | | | --- --- --- | | | | --- --- --- This one is 3x3 (like in tic tac toe). Obviously, they come in many other sizes (8x8 for chess, 19x19 for Go, and many more)...
eb2a42fde41d2ddfd6bc6ebd106893099bc5d5b1
IoAdhitama/CP1404
/prac_05/colour_lookup.py
593
4.25
4
COLOUR_CODES = {"aliceblue": "#f0f8ff", "antiquewhite": "#faebd7", "beige": "#f5f5dc", "black": "#000000", "brown": "#a52a2a", "burlywood": "#deb887", "chocolate": "#d2691e", "coral": "#ff7f50", "cyan": "#00ffff", "firebrick": "#b22222"} colour_input = input("Enter colour name: ").lower...
20ec3624f6dc2bafcc53a6136aa9ee2727762199
diskpart123/xianmingyu
/2.python第四章学习/26闰年计算.py
1,382
3.859375
4
year = eval(input("year:")) month = eval(input("month:")) day = "" if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): if month == 2: day = 29 print(year, "年", month, "月份有", day, "天") else: if month == 1: day = 31 print(year, "年", month, "月份有", day, "天") elif month =...
9b186bc8a3785afac90b5428bdfafb11c3f4ef05
sw561/AdventOfCode2015-17
/2017/11/hex_ed.py
768
3.625
4
#!/usr/bin/env python3 directions = { 'n': (1, 0), 'ne': (1, 1), 'se': (0, 1), 's': (-1, 0), 'sw': (-1, -1), 'nw': (0, -1) } def distance(pos): # Find shortest distance in hex-grid steps distance = 0 if pos[0] * pos[1] > 0: m = min(pos, key=abs) else: m = ...
03d6976a960238aef9904f42b800cf57915e8261
vishweshs4/digitalcrafts
/week2/wednesday/assignment/test_calculator.py
441
3.640625
4
import unittest import calculator class TestCase(unittest.TestCase): def test_add(self): self.assertTrue(calculator.add(1,2) == 3) def test_subtract(self): self.assertTrue(calculator.subtract(1,2) == -1) def test_multiply(self): self.assertTrue(calculator.multiply(1,2) == 2) def...
034c8dac4a0c8b8de802bf7ffe49886fd509a332
akniyev/leetcode
/solutions/00081_search_in_rotated_sorted_array_ii.py
1,095
3.828125
4
from typing import * class Solution: def binary_search(self, arr, i, j, value): while i < j: m = (i + j) // 2 if arr[m] == value: return m if arr[m] < value: i = m + 1 else: j = m if arr[i] == value: ...
01f3d03979b4eaf7d01b3c84699f73ffe7c13319
studentjnguyen/myprojects
/Section 4 Exercise Project.py
477
4.34375
4
""" This is a rest style. If input is divisible by 3, it prints fizz If input is divisible by 5, it prints buzz If input is divisible by both 3 and 5, it prints FizzBuzz Anything else is returned """ def fizz_buzz(input): fizz = input % 3 buzz = input % 5 if fizz == 0 and buzz == 0: p...
e4f5faabb01d9991cfaed624e436636f51548b3f
itsmygalaxy/python
/General/if_elif_else.py
274
4.125
4
__author__ = "Venkat" num = input('Enter a number between 1-10:\n') print type(num) if num < 10: print"num value is less than 10" elif num == 10: print"num value is neither less nor greater than 10(so its 10)" else: print"num value is greater than 10"
e9ecbf8e6f62974d11a9ceb8c0bbbbf085ced01a
ryan9dai/SwimmyFish
/main.py
5,303
4.3125
4
""" fishspeed: 0 to 100 as a raw value sharkspeed: arbitrary, but say 30, increasing to 100 over time. behaviour of increase can be quadratic or exponential. wavespeed = fishspeed, calibrated fishtailspeed = fishspeed, calibrated fishdistance, sharkdistance = speed * Delta time, incrementing with each loop fishpo...
2f197612d6d80ac8c73f2282f2183a7f58086e78
nawaf-aljehani/Encryption
/Encryption.py
805
3.625
4
import hashlib import bcrypt password = input("Enter your password : \n") byte_password = bytes(password,'utf-8') print("******************************************** (sha1) ************************************************") for i in range(3): hash_password = hashlib.sha1(byte_password) pw = hash_passwo...
d872121f61450d898ebc212c1fcb9fc488e3911b
curtissalisbury/python_projects
/py4e/ex05_01.py
681
4.15625
4
""" Write a program which repeatedly reads numbers until the user enters 'done'. Once 'done' is entered, print out the total, count, and average of the numbers. If the user enters anything out than a number, detect their mistake using try and except and print an error message and skip to the next number """ number = 0 ...
46f807f7cdda102656d6b30aa244bd685d08b4a7
shuowenwei/LeetCodePython
/Medium/LC208.py
1,556
4.15625
4
# -*- coding: utf-8 -*- """ @author: Wei, Shuowen https://leetcode.com/problems/implement-trie-prefix-tree/ https://labuladong.gitee.io/algo/2/20/47/ https://leetcode.com/problems/implement-trie-prefix-tree/discuss/58834/AC-Python-Solution LC79, LC212, LC208, LC1268 LC208, LC1804, LC648, LC211, LC677 Trie """ class...
215ff9b65bbba5bc2d7c00526cb8bc8b378b87b3
GuJun1990/learn-python
/src/09-io.py
587
3.6875
4
# -*- coding: UTF-8 -*- def read_all(): with open('/Users/gujun/PycharmProjects/learn-python/data/input.txt', 'r') as f: print(f.read()) def read_line_by_line(): with open('/Users/gujun/PycharmProjects/learn-python/data/input.txt', 'r') as f: for line in f.readlines(): print(line...
fa2e687fecb3ac61cc059671987c55bbcb09af73
mfislam007/python
/Python work/notebook_using_pickle.py
2,321
3.671875
4
import pickle import time def readfile(filename): while True: try: readfile = open(filename,'rb') content = pickle.load(readfile) readfile.close() return content except IOError: newfile(filename) print("No default n...
ece2abc01da6dbb9dd807785eb2900da166d2c9f
Swift-2016/Python
/PythonIntroduction/lesson2/task5/arithmetic_operators.py
211
3.859375
4
number = 9.0 # float number result = number / 2 remainder = number % 2 ''' result = int(number) / 2 remainder = int(number) % 2 ''' print("result = " + str(result)) print("remainder = " + str(remainder))
dfd69e11ed99ca859612b402858b3741777c8568
mel-oezkan/MLinPractice
/test/preprocessing/tokenizer_test.py
1,168
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 7 14:30:41 2021 @author: ml """ import unittest import pandas as pd from code.preprocessing.tokenizer import Tokenizer class TokenizerTest(unittest.TestCase): def setUp(self): self.INPUT_COLUMN = "input" self.OUTPUT_COLUM...
d6450d744b35d1b53e10593aaa3cb0f20dba4dcb
SteeleAlloy/learn_python_the_hardway
/ex3.py
1,328
4.53125
5
# Prints out a statement print('I will now count my chickens: ') # NOTE: python uses PEMDAS (parenthesis, exponent, multiply, divide, add, subtract) # Prints a statement and adds 25 plus 5 print('Hens', 25.0 + 30.0/6.0) # Prints a statement and first divides 3 by 4, ,then takes the remainder and multiplies that by 25 ...
bab45cf173eebc3e88df4253ef527ffab8fd62b6
Jonatasfeliper/novo
/testes.py
269
3.53125
4
#testes python assert 4 == 4 #não deu erro é igua 4 #assert 4<4 #4 não é menor que 4 def soma (x,y): #def cria uma função nova return x + y assert soma(2, 2) == 2 + 2 #verdadeiro #assert afirma assert soma(2,2) == 5 , '2 mais 2 é diferente de 5'
746b12bced31031f7d3fb25b724702ffe60e10d6
kevinkong91/tensorflow-mnist-dense
/src/training.py
1,864
3.609375
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data def train_network(training_data, labels, output, keep_prob=tf.placeholder(tf.float32)): # Define the net architecture learning_rate = 1e-4 steps_number = 1000 batch_size = 100 # Read the data mnist = input_data...
0ed6ec857b8c9858f2d4b4d8681d0bef0ad77642
GilliamD/Digital-Crafts-Day-2
/hello2.py
153
4.09375
4
name = input("What is your name?") reply = "Hello, " + name + "!" + " Your name has " + str(len(name)) + " letters in it! awesome!" print (reply.upper())
09274852fa51154f00def17f348fa07746e6f198
Stengaffel/kattis
/hissing_microphone.py
213
3.640625
4
import sys word = str( sys.stdin.readline() ) hiss = False for i in range( 0, len(word)-1): if word[i] == 's' and word[i+1] == 's': hiss = True if hiss: print('hiss') else: print('no hiss')
5c52e5f4a66ed5765f24cf8fdaed5096941905ea
solomonli/udacity.cs212
/unit2/yielding_res.py
206
3.78125
4
#generator functions def ints(s,e=None): i = s while i <e or not e: yield i i = i+1 #test 1 L = ints(0,10) print next(L) print next(L) #test 2 infinite loop L = ints(0) print next(L)
beeb39b80fe67d6fe9166774779493d7c36f9691
poojaKarande13/ProgramingPractice
/GoogleCodeJam/snapper.py
679
3.75
4
# input() reads a string with a line of input, stripping the '\n' (newline) at the end. # This is all you need for most Kickstart problems. # if i == 0 then toggle # if s[i] == 0 and s[i-1] == 0 then s[i] = 0 # if s[i] == 0 and s[i-1] == 1 then s[i] = 0 t = int(input()) # read a line with a single integer for i in ran...
d0b8b2c95b7b8de3426a6072003ba077ec30cb10
uchile-robotics/uchile_system
/hooks/samples/python/hook-test.py
751
3.625
4
import sys def println(text): sys.stdout.write(text + "\n") if __name__ == "__main__": println("List of common python errors to be avoided") # some errors! # ---------------------- # E703 statement ends with a semicolon println(); # some warnings, we dont want to consider # ------...
d836cba74a6831c3276a78e11bf94a3957a1f9c3
marielitonmb/Curso-Python3
/Desafios/desafio-52.py
572
3.96875
4
# Aula 13 - Desafio 52: Numeros primos # Ler um numero inteiro e dizer se ele eh ou nao primo num = int(input('Digite um numero: ')) primo = 0 for n in range(1, num+1): if num % n == 0: primo += 1 print('\033[1;32m', end=' ') else: print('\033[m', end=' ') print(f'{n}\033[m ', end=...
c524ed26a34a9c79d212691fbfe344c00cb7eef7
juliakastrup/estudos
/Ex006.py
297
3.984375
4
# ler um número e mostrar seu dobro, triplo e raiz quadrada n = int(input('Por favor digite um valor:')) print('O valor digitado foi {},\no seu dobro é {},\nseu triplo {}' '\ne sua raiz quadrada {:.3f}'.format(n, n*2, n*3, n**0.5)) #poderia colocar as contas direto dentro do {} ex: {n*2}
0eed54a44e46a5b540b6eadf882142856e641ad2
wonjong-github/Python_algorithm
/leetcode/2.py
1,185
3.8125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): def addTwoNumbers(self, l1: ListNode, l2: ListNode)->ListNode: """ :type l1: ListNode :type l2: ListNode :rty...
8aaa2678ff03043725c5990ea6f87fa8664a8005
andrijr/pythonPWN
/d2_2_conditions/p45.py
556
3.921875
4
# P45 # Używając serii instrukcji if, sprawdź, czy wartości od 0 do 4 są równe True lub False. # Wykonaj 5 osobnych testów i wypisz tylko te wartości dla których konwersja daje wynik True. for x in range(0, 5): if (x == True): print(x, "Podana liczba jest równa True") else: print(x, "Podan...
5fef075576477799d188beb3ef0ef46a22d27ed8
koking0/Algorithm
/LeetCode/Problems/1640. Check Array Formation Through Concatenation/code.py
567
3.65625
4
from typing import List class Solution: def canFormArray(self, arr: List[int], pieces: List[List[int]]) -> bool: arrIndex = 0 while arrIndex < len(arr): for piece in pieces: if arr[arrIndex] == piece[0] and arr[arrIndex: arrIndex + len(piece)] == piece: ...
7adaa7303850b49f9b461f04de83d0c5cdff80c7
AriyandaP/GitPushPull
/rabu1006.py
3,556
3.828125
4
# Rabu 10 06 2020 # HH:MM:SS # if HH>99 "invalid input" ''' seconds = 14251 hour = seconds // 3600 hourleft = seconds % 3600 minute = hourleft // 60 minuteleft = hourleft % 60 # hour = 9 # minute = 9 # minuteleft = 9 # print(hour) # print(hourleft) # print(minute) # print(minuteleft) hh = [] mm = [] ss = [] zero...
82d688e7a2ce2b553c955c8f33c64d6a65063302
molamphd/MongoDBCodingAssessment
/flatten.py
759
3.71875
4
import ast endProgram = 0; # Function returns flattened JSON object def flatten_json(jsonObject): flatJObject = {} # Flattens if key-value pair is nested def flatten(x, key = ''): if type(x) is dict: for c in x: flatten(x[c], key + c + '.') else: ...
c925fdfc50c9f4204c675e9ae9bc58cb788473ea
HackBulgaria/Programming101-3
/week4-Music-Library/1-Music-Library/music.py
5,417
3.515625
4
import datetime import random import time from tabulate import tabulate import json class SongLength: def __init__(self, length): self.length = length self.hours = 0 self.minutes = 0 self.seconds = 0 parts = [int(part.strip()) for part in length.split(":")] if len...
a402a751662da20800b2be9aa1b8d761f4320478
camirmas/ctci-python
/tests/test_queue.py
636
3.546875
4
import unittest from src.ch3.queue import Queue class QueueTestCase(unittest.TestCase): def test_is_empty(self): self.assertTrue(Queue().is_empty()) def test_add(self): q = Queue() q.add(2) self.assertFalse(q.is_empty()) self.assertEqual(q.first.data, 2) ...
af0e138ee644620215c22bfbddbebb51e028e208
shubham2704/ZIp-UnZip
/zip&unzip.py
3,630
3.609375
4
import os import tkinter as tk from tkinter import * from zipfile import ZipFile from tkinter import messagebox, filedialog def CreateWidgets(): selectlabel = Label(root, text="Files to Zip : " , bg="steelblue") selectlabel.grid(row=0,column=0,padx=5,pady=5) root.zipFilesEntry = Text(root,height=4,width=...
f9758a3ce595cb799bb760e57a048942a60c87cb
ashu123git/Library-Management-System
/mini project 1.py
2,056
4.09375
4
# LIBRARY MANAGEMENT SYSTEM # import sys class Library: def __init__(self, books): self.books = books def dis_books(self): for book in self.books: print(book) def lend_book(self, a): print("Enter the name of the book you want to borrow : ") choice1 = input() ...
c77f0e602478863dc4a55d34a609a3f209445a06
danielsunzhongyuan/my_leetcode_in_python
/daily_temperatures_739.py
1,278
4.25
4
""" Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. For example, given the list temperatures = [73, 74, 75, 71, 69, 72, 76, 73], your ou...
48073f8a982cc5832d9b052bb2e6abf68fc8c0ce
klaxminarayan/Hackerrank-python
/Math/Triangle Quest 2.py
186
3.78125
4
for i in range(1,int(input())+1): print(((10**i-1)//9)**2) """ It makes a series of geometric progression 1^2 11^2 111^2 sum = ((10^n) - 1)//9 We need to print square so sum^2 """
7a9a9935f48e5269e54fb7df2c981baf809d70e5
3lLobo/basic-probability-programming
/weekly_tasks/week2/homework/code/start_code.py
2,915
4.65625
5
""" The code that implements the programming assignment 2. This is the start. You have to fill in the rest. """ import random #we import the random module, to be able to randomly select elements from collections import Counter #this can be useful if you are going to use Counter as a container for word frequencies #Th...
c3886224ef132f059eb058f7398e32663cd7af81
mohammedlutf/cg
/1.py
784
3.515625
4
import csv print("the most specific hypothesis is :[000000]") a=[] print("the given training dataset \n") with open('ws.csv','r') as csvfile: reader=csv.reader(csvfile) for row in reader: a.append(row) print(row) num_attributes=len(a[0])-1 print("the initial value of hypothesis:\n") hypothesis = ['0']*num_attr...
82e02a2058bc80eb80aef7078bddd0813c7c9bb9
JamesDutton94/JamesDuttonPython
/BigJim/homework/hw2/hw2c.py
1,298
3.9375
4
#James Dutton #hw2c Diopphantine equation in python #define globals A = 6 B = 9 C = 20 #prototype function call #function recursively calls as it decrements x def solveDis(x): #Check to see if it is divisible by 9 if (x % B) == 0: x = x - B #Once it is 0 let the user know if(x == 0): ...
7d79125a72b2b094c779a0e86e8134a43d6e45ec
coldhair/Conda
/Try044.py
263
3.828125
4
# 输出 print('{0}和{1}'.format('Google','Baidu')) print('{1}和{0}'.format('Google','Baidu')) for x in range(1,11): print('{0:2d}{1:4d}{2:5d}'.format(x,x*x,x*x*x)) import math print(math.pi) print('{!r}'.format(math.pi)) print('{0:.3f}'.format(math.pi))
debdb5143c3daeb6724dbd888c4d9921e43c2c2b
wufanwillan/leet_code
/Reverse Vowels of a String.py
970
4
4
# Write a function that takes a string as input and reverse only the vowels of a string. # Example 1: # Given s = "hello", return "holle". # Example 2: # Given s = "leetcode", return "leotcede". # Note: # The vowels does not include the letter "y". class Solution(object): def reverseVowels(self, s): """ ...
2a60106847435d465b3b5142109adf34eb8835b1
viralsir/OOP_proje
/demo1.py
1,083
3.5625
4
''' no=1 variable no=[] list dynamic array dict={} dict key value pair class --> object class : member variable (data) member defination (proccess) eMPLOYEE PRODUCT tICKET ''' class student: rollno=0 name="" marks="" # student_list=[] # title=["Roll No...
8a800c6fb8a79b6ea428cac5168629816f383100
jrsalunga/coursera-python-class-mini-projects
/stopwatch-the-game.py
2,151
3.96875
4
# Name: Jefferson Salunga # @jrsalunga # Mini-project # 3: “Stopwatch: The Game” # Coursera # An Introduction to Interactive Programming in Python # URL: http://www.codeskulptor.org/#user22_EdujtQFJuNgKMF4.py import simplegui # define global variables interval = 100 ctr = 0 a = 0 b = 0 c = 0 d = 0 score1 = 0 score2...
0c49a2ab8e226bfb97ffb611677b30656eb5e9a2
ianhom/Python-Noob
/Note_1/while.py
497
3.859375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- count = 0; while(count < 20): print "The count is: ", count; count = count + 1; print "end"; # result """ The count is: 0 The count is: 1 The count is: 2 The count is: 3 The count is: 4 The count is: 5 The count is: 6 The count is: 7 The count is: 8 The count is: 9 T...
48ed61a53480b6384e6a4a6a6e43225a67ec7717
zadrozny/python_notes
/loading_data_from_files.py
1,368
3.8125
4
# Calculate the average household income in NYS from # a dataset containing a bunch of extraneous crap # The problem is trivial. The question is, for a large dataset, # is there any way to load it row by row without # without overhwelming memory? # The generator in the second approach presumably does nothing # bec...
eeabfb1ee533782f03e15e0adfcc5943920ce213
IslamFadl/CS106A_Stanford_Spring_2020
/Assignments/Assignment2/Assignment2/khansole_academy.py
846
4.1875
4
""" File: khansole_academy.py ------------------------- Add your comments here. """ import random def main(): correct_answers = 0 while correct_answers != 3: num1 = random.randint(10, 99) num2 = random.randint(10, 99) print("What is " + str(num1) + " + " + str(num2) + " ?") su...
d59ec0c0e3de9f481eebe7063f9af154c00c6d12
nataliaqsoares/Curso-em-Video
/Mundo 01/desafio019 - Sorteando um item na lista.py
932
4.125
4
""" Desafio 019 Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que ajude ele, lendo o nome deles e escrevendo o nome escolhido. """ # Solução 1 import random aluno1 = str(input('Informe o nome do primero aluno: ')) aluno2 = str(input('Informe o nome do segundo aluno: ')) al...
93ece054a786dfcf8f2da00ba667243359262453
vaibhavg12/Problem-Solving-in-Data-Structures-Algorithms-using-Python3
/Algorithms/2 Searching/OddCount.py
2,473
4.0625
4
""" Given an array find the elements which appear odd number of times. """ def OddCount(arr): size = len(arr) hs = {} for i in range(size): if arr[i] in hs : hs[arr[i]] += 1 else: hs[arr[i]] = 1 for key in hs: if hs[key] % 2 == 1: print key , ...
0ce996309e9eb572d69df877e57f1e25eb141b0f
Maisa-ah/Python
/assignment_33.py
440
4.5
4
#Maisa Ahmad #June 20, 2018 #This program prompts user for a list of nouns and approximates the fraction that are plural. nouns = input("Enter nouns:") #words = int(input("Number of words:")) list=nouns.split(" ") length = len(list) print("Number of words", length) count = 0 for nouns in list: if nouns[-1]=="s": ...
97ef4e5aa4ebc325bf26ad70cba98fc179671456
randyarbolaez/pig-latin
/src/main.py
1,262
4.40625
4
VOWELS = ['a','e','i','o','u'] def remove_punctuation(string): correct_string = '' for letter in string: if letter.isalpha(): correct_string += letter return correct_string def input_string_to_translate_to_pig_latin(prompt): return input(prompt).strip().lower() def split_str(input...
4ea2e784ac9ebbafc25dca63e8f335ec86faf306
trilamsr/LeetCode
/0019_RemoveNthNodeFromEndofList/RemoveNthNodeFromEndofList.py
871
3.734375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: ret, ret.next = ListNode(0), head back = front = ret while front.next: fr...
cbaf6849f6dba3c809acb14913f2934c70f12a68
nirusant/python_projects
/regex/diff.py
6,893
3.640625
4
import argparse import highlighter import re import sys import os.path def save_text(text): """ Writes a texfile to disc. Input: text, a list where each element is a textline Output: a texfile to current director """ file = open('diff_output.txt', "w") for l...
8dfeb2b12c3611078b78fe8eef35d7a03cc69aad
rcrick/python-designpattern
/Singleton/Singleton.py
579
3.53125
4
# -*- coding: utf-8 -*- import threading def singleton(cls): instance = cls() instance.__call__ = lambda: instance return instance @singleton class Highlander: x = 100 # Of course you can have any attributes or methods you like. def worker(): hl = Highlander() hl.x += 1 print hl ...
b2a10c8918e2cacfcd8ae9248f2c0d0721d5a0ef
CrazyCoder4Carrot/lintcode
/python/Interval Minimum Number.py
1,911
3.671875
4
""" Definition of Interval. class Interval(object): def __init__(self, start, end): self.start = start self.end = end """ class treeNode: def __init__(self, low, high, left= None, right = None): self.low = low self.high = high self.left= left self.right = right ...
62000990d81f15522f9dcdfc7952b22ee5a61e8c
sosan/herencias
/herencias.py
2,049
4.0625
4
""" HERENCIAS """ # supèrclase class Vehiculos(): def __init__(self, marca, modelo): self.marca = marca self.modelo = modelo self.enmarcha = False self.acelera = False self.frena = False def arrancar(self): self.enmarcha = True def acelerar(self): ...
96035c943b1762b3c586fdb9e0a2ef08d3c7248e
MohitBaid/CodeChef
/Others/ISCC2017/SEQUA.py
141
3.515625
4
for _ in range(int(input())): m=int(input()) term=0 sum=0 for i in range (0,200): term=i**i sum+=term if i%m==0: print(i,sum%m)
d1b1bdca16e30c55c505e61fa7d7ab0f0ccfa9b6
Dev-rick/Contact_class
/contact.py
6,659
4.1875
4
# -*- coding: utf-8 -*- class Contact(object): def __init__(self, first_name, last_name, phone_number, birth_year, email): #Hier definiert man den self! Das heisst wenn man das jetzt Ham nennen wuerde dann wuerde man im naechsten Schritt siehe 1 immer hm.first_name verwenden self.first_name = first_name #1...
3d2f35ebc13769a46173268a7e863fdb32bd4f21
swang2000/CdataS
/Backtracking/permutation.py
404
3.71875
4
''' 46. Permutations Given a collection of distinct numbers, return all possible permutations. ''' def perm(a): result = [] def dfs(temp, t): if len(t)==0: result.append(temp[:]) for e in t: temp.append(e) s = t[:] s.remove(e) dfs(temp,...
5e8a02b878c2895a0aed283ee53f3958a7266359
q36762000/280201102
/lab3/example6.py
514
4.0625
4
print("Write the parameters for represented quadratic equation : (ax**2 + b*x + c)") a = float(input("Type a: ")) b = float(input("Type b: ")) c = float(input("Type c: ")) discriminant = b**2-(4*a*c) x1 = (-b+discriminant**(1/2))/(2*a) x2 = (-b-discriminant**(1/2))/(2*a) if discriminant > 0: print("Roots of quadra...
81b08468f7c27491d6e40d91ce65b9bf9ab0555d
rtanyas/git-geekbrains
/algorithms_lesson3/3.9.py
606
4.25
4
# Найти максимальный элемент среди минимальных элементов столбцов матрицы. from random import random M = 6 N = 5 MAX = 10 arr = [] for i in range(N): b = [] for j in range(M): n = int(random() * MAX) b.append(n) print(' |%3d| ' % n, end='') arr.append(b) print() mx = -1 for j ...
e408087ff3b11da84f198243981d9ad73a5634d0
alexthemonkey/interviewBit
/Heap_and_Map/Ways_To_Form_Max_Heap.py
1,520
3.78125
4
""" Ways To Form Max Heap https://www.interviewbit.com/problems/ways-to-form-max-heap/ Max Heap is a special kind of complete binary tree in which for every node the value present in that node is greater than the value present in its children nodes. If you want to know more about Heaps, please visit this link So n...
cd1e15561c9034410725d8f3ff691b09fd9315a5
theorclord/pythoncourse
/PythonExercises/5namereverse.py
98
3.9375
4
first = input("Enter first name: ") last = input("Enter last name: ") print("Hello", last, first)
121d4e2d38295556ffcd00a7f0f02ef610a04dfc
anhtylee/abx-algorithm-exercices
/src/remove-duplicates-from-sorted-array.py
467
3.5
4
# url https://leetcode.com/problems/remove-duplicates-from-sorted-array/ # writtenby:anhty9le class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ i = 0 n = len(nums) while i < n - 1: ...
5e12400919307f222ee742f24e971d384a9da2cd
UddhavNavneeth/DSA-practice
/interviewBit/string/reverseTheString.py
266
3.84375
4
# Link to the question: # https://www.interviewbit.com/problems/reverse-the-string/ class Solution: # @param A : string # @return a strings def solve(self, A): lis=A.split(" ") lis=lis[::-1] ans=" ".join(lis) return ans
efaab53f50c47acdcc13249a7871add4830fe4ca
xingyezhi/leetcode
/src/SumRoottoLeafNumbers.py
871
3.796875
4
__author__ = 'xingyezhi' # encoding: utf-8 # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def sumTotal(self,node,nlist): nlist.append(node.val) if node.left==Non...
e510122b382dfa7c90a59aa7452c3e60c38bcea9
rogervaas/learn-python-the-hard-way
/ex3.py
891
4.53125
5
print "I will now count my chickens:" print "Hens", 25 + 30 / 6 print "Roosters", 100 - 25 * 3 % 4 print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 print "Is it true that 3 + 2 < 5 - 7?" print 3 + 2 < 5 - 7 print "What is 3 + 2?", 3 + 2 print "What is 5 - 7?", 5 - 7 print "Oh, that's w...
d49be7f959025b16d105ed50ed263f0965a69a08
Mengau93/python-project-lvl1
/brain_games/cli.py
276
3.6875
4
"""Welcome the user.""" import prompt def welcome_user(): """Welcome user with his name.""" print('Welcome to the Brain Games!') name = prompt.string('May I have your name? ') print('Hello, {0}!'.format(name)) if __name__ == '__main__': welcome_user()
e34343961eb51657971fed2cf4087132d5e157db
Bgaoxing/p1901
/P1901lesson/lesson/lesson3.4.3.py
1,277
3.984375
4
# str (字符串) # 字符串不能被修改 # s1 = 'hello' # s2 = 'world' # s3 = """hello""" # s4 = '''world''' # # s1 = s1 + s2 #拼接 # # s1[0] = 1 # 错误 被修改了 # # # # capitalize 首字母大写,其他字母小写 # s = 'www.Baidui.com' # s1 = s.capitalize() # print(s1) # print(s.upper()) # 所有字符转换为大写 # print(s.lower()) # 所有字符转换为小写 # print(s.swapcase()) # 交...
a60ac4a1171e110ef92594ceea34599dd6f2a786
Menda0/pratical-python-2021
/12_objects_oriented.py
2,027
4.09375
4
class Car: # attributes # variable inside a class are called attributes fuel = None brand = None model = None # custroctor method def __init__(self, brand, model, fuel): self.brand = brand self.model = model self.fuel = fuel # Methods # Function inside a c...
3a0f283f80e24bcce9f6fae393c71c2c47e984c6
SoftDesFall2012/entangle
/test.py
2,738
3.625
4
__author__ = 'jpark3' '''tix_Editor_simple1.py a very simple Tkinter/Tix editor shows you how to create a menu and use the file dialog to read and write files of text data for faintful hints see: http://tix.sourceforge.net/man/html/contents.htm tested with Python27 and Python32 by vegaseat ''' try: ...
99552b7f904d520aee6819be578c017e39e28918
dagtag/lambdata-a.murray
/test_sample.py
1,224
3.890625
4
### TEST FILE USING ASSERT STATEMENTS AND PYTEST FOR UNIT TESTING ### ### import statements import pytest from sample import inc def test_inc_pint(): """ method to test inc function with positive ints """ assert inc(10) == 11 assert inc(2) == 3 def test_inc_zero(): """ method to test inc function wi...
55365bfa31ac47df980cd32602ea4cba7ffc5821
laxmanlax/Programming-Practice
/game_of_life.py
3,636
3.609375
4
#!/usr/bin/env python import random class Cell: def __init__(self, state='Rand'): # alive:dead = True:False if state == 'Rand': self.state = random.choice([True, False]) else: self.state = state def get_state(self): return self.state def set_state(self, state...
f0f22c7b782e95dd4cdba5fab35e35b6f204c32c
lithiumspiral/python
/listGen.py
565
3.90625
4
import random def createList(count) : list = [] for i in range(0, count) : list.append(random.randint(1,100)) return list def printList(lst) : for val in lst: print(val) def smallLarge(lst) : smallest = lst[0] largest = lst[0] for val in lst: if smallest > val : ...
a91b6f71bd0177645e4df968c9e4fffbc2ece92a
lamba09/pynigma
/Classes/Permute.py
15,925
3.71875
4
import types as t import ConfigParser def ExtendStringTo(string, number): length = len(string) if length > number: pass else: spaces = [" " for i in xrange(number-len(string))] space = "".join(spaces) string += space return string def PrintOnMachine(before, string, afte...
9849dfc51c77cb91cbdcd54e9079920f24e07213
amitrajhello/PythonEmcTraining1
/RegularExpressions2.py
654
3.671875
4
""" DEmo to search a pattern in a files""" import re from fileinput import input, filelineno, filename class GrepMe: def __init__(self, pattern, *args): self.pattern = pattern self.file_names = args self.do_match() def do_match(self): for line in input(self.file_na...
82b2a08209cb7dfcb00c8c515ff8b42f6158adf5
Pereirics/Exercicios_Curso_Python
/ex036.py
371
4.03125
4
print('Bem-vindo ao banco!') valor = float(input('Qual é o valor da casa? ')) sal = float(input('Qual é o seu salário? ')) anos = int(input('Em quantos anos pretende pagar a casa? ')) meses = anos * 12 prestacao = valor / meses if prestacao > sal * 0.3: print('Lamento! O seu empréstico foi negado!') else: pr...
52a2e88366a9f0b582f206f060b7550989510f0c
venkatrag1/ADSND
/P0/Task0.py
1,051
4.15625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 0: What is the first record of tex...
115d3e4b4062aa9143cd655752d10597846355ab
edwardsonjennifer/Scratchpad
/.vscode/Module_9/pokemon_oop.py
1,603
4.125
4
caterpie = ['caterpie', 13, 40, ('String Shot', 10)] print (caterpie[0]) caterpie = { 'name': 'caterpie', 'level': 13, 'hp': 40, 'move': ('String Shot', 10) } ### Module 9.1 Notes ## What is OOP? # sometimes code can repetitive or weird, wanting a neat and clean code # it gives you the ability to dist...
c64a8a01434a3bc26f5b782237c13f3ab773cacc
VySan93/ICB_EX7
/#1.py
289
3.734375
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 25 13:48:30 2018 @author: vysan """ import pandas as pd def oddrows(filename): data=pd.read_csv(filename,header=0,sep=",") return data.iloc[1::2] print oddrows("filename") #filename is the name of the file with your dataframe
30836140218357b25e62d505dd7310f5f4acdc89
entrekid/codeplus
/basic/10866/deque.py
871
3.5625
4
import sys from collections import deque input = sys.stdin.readline def main(): test_case = int(input()) dequeue = deque() size = 0 for _ in range(test_case): order = input().rstrip().split() if order[0] == "push_front": dequeue.appendleft(int(order[1])) elif order[0...
c0534b53741e0362c30ad4657bc3e0d7e25e9283
GithubWangXiaoXi/Study_Repositories
/学习笔记/机器学习/统计学习/第二章 感知机/code/code003_感知机(例题).py
7,601
3.78125
4
import pandas as pd import numpy as np from sklearn.datasets import load_iris import sklearn import matplotlib.pyplot as plt #注意要将一般的数组转化成numpy的ndarray数组,否则会报TypeError: 'numpy.float64' object cannot be interpreted as an integer x1,x2,x3 = np.array([3.0,3.0]),np.array([4.0,3.0]),np.array([1.0,1.0]) y1,y2,y3 = 1,1,-1 ...
fcdfde530a6e1ec3299f50fc7decf47465e36046
syllamacedo/exercicios_python
/python_org/ex1.14_contabiliza_peso_valor.py
433
3.546875
4
peso = float(input("Qual peso total dos peixes que está trazendo? Kg ")) excesso = peso - 50 multa = excesso * 4 if excesso <= 0: multa = 0 print(f'Com o peso total de {peso}kg de peixes, você não está ultrapassando o limite de 50kg e não será multado.') else: print(f'Com o peso total de {peso}kg de peixes,...
437da36888fef803555444f580ca2d1730fbbfab
1Tian-zhang/easyspider
/old/twister-example/twister-3.py
974
3.515625
4
#coding=utf-8 #非阻塞获取socket端口/服务器发送的值 #这个一定要等前面一个 for循环执行完后,再来执行下面一个... #就算把for里面换成 yield 反而却没有作用...什么事都没发生 import argparse,socket def parse_cmdline(): parser = argparse.ArgumentParser("接收端口输出") parser.add_argument("-p","--port",default=10000,type=int,nargs="+",choices=[i for i in xrange(1,65536)]) args = parser....
f40f488e5b699df6994979ac89fda5ab285bbb1a
kedixa/LeetCode
/Python-jk/258.py
251
3.515625
4
class Solution(object): def addDigits(self, num): """ :type num: int :rtype: int """ res=num%9 if res: return res elif num: return 9 else: return 0
bd27b0fe754dbb46d0f8abb2d9f5fd6358b483ee
phuong16122000/Movie-To-WatchA2
/movie.py
752
4.09375
4
"""...""" # TODO: Create your Movie class in this file class Movie: """Movie class""" def __init__(self, title='', year=0, category='', is_watched=False): """Constructor of movie class""" self.title = title self.category = category self.year = year self.is_watched = i...
e8e1532e264f0c126d59711a8117d35e96097ccc
ninjrok/leetcode
/LC43_multiply_strings.py
1,265
3.609375
4
class Solution: def str_to_int(self, num): num_int = None if num == '0': num_int = 0 elif num == '1': num_int = 1 elif num == '2': num_int = 2 elif num == '3': num_int = 3 elif num == '4': num_int = 4 ...
5c60d11822db28902cf6db7a4f5918f9cbae7cfc
c16c1073/self_study
/practice_deep_learning/step_func.py
1,367
3.875
4
# p.45~ import numpy as np import matplotlib.pylab as plt def step_func(x): # 引数xは実数(浮動小数点)しか入力することができない if x>0: return 1 else : return 0 print( step_func(1) ) print( step_func(0) ) # 実際にはNUMPY配列を使って計算するので、以下のやり方がある print("--------------numpyの配列を引数に取るには、、、↓ -------------------") ...
3cb9572a369c04e45b7c2c4ed427b587446bea92
kahuroA/Python_Practice
/holiday__.py
600
4.25
4
# Create a dictionary of kenyan holiday names & corressponding dates Kenyan_holidays = {'Labour_Day' : '01/05', 'Madaraka_Day' : '01/06', 'Moi_Day' : '10/10', 'Kenyatta_Day' : '20/10', 'Jamuhuri_Day' : '12/12'} # Ask for an input...
ba2bcf676d29a05fe730835fdba7c9ae7f653184
yeshengwei/PythonLearning
/03数据序列/27-字典的操作-删除.py
124
3.609375
4
dict1 = {"name": "yeshengwei", "age": 19, "address": "suzhou"} del (dict1["name"]) print(dict1) dict1.clear() print(dict1)
3e5bc49948c58363af6e8866866ef6344135e81d
azure0309/TBANK
/bank.py
1,089
3.703125
4
import sqlite3 class Connection(): def connect(self): conn = sqlite3.connect('tbank.db') return conn def cursor(self, connect = connect()): cur = connect.cursor() return cur class User(): def __init__(self, id, first_name, last_name, age, register_id, account_number, card_number): self.id = id self.fir...
4ee9918a0e020983d4c1ed6bc1519b81da611203
Vya-cheslav/geek
/outOfQuarter/Алгоритмы и структуры данных на Python/lesson_2/task_1.py
502
3.84375
4
while True: a = int(input('Введите число 1 :')) b = int(input('Введите число 2 :')) c = input('''Какую операцию выполним? + - сложение - - вычитание * - умножение / - деление 0 - выход их программы ''') if c == '0': break if c == '/' and b == 0: print('О...