blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
7b5b3ff7995758cb199808977015ea635a879309
Farazi-Ahmed/python
/lab-version2-6.py
288
4.125
4
# Question 8 Draw the flowchart of a program that takes a number from user and prints the divisors of that number and then how many divisors there were. a=int(input("Number? ")) c=1 d=0 while c<=a: if a%c==0: d+=1 print(c) c+=1 print("Divisors in total: "+str(d))
03074b61771fa4e751fd84c97aac21e3a918fa35
Farazi-Ahmed/python
/problem-solved-9.py
326
4.4375
4
# Question 9 : Draw flowchart of a program to find the largest among three different numbers entered by user. x=int(input("Value of x: ")) y=int(input("Value of y: ")) z=int(input("Value of z: ")) if x>y and x>z: print(x) elif y>z and y>x: print(y) else: print(z) MaxValue = max(x,y,z) print(Max...
28f739f2ac311a56f42af138f8c3432a4e0620e9
Farazi-Ahmed/python
/problem-solved-7.py
303
4.375
4
# Question 7: Write a flowchart that reads the values for the three sides x, y, and z of a triangle, and then calculates its area. x=int(input("Value of x: ")) y=int(input("Value of y: ")) z=int(input("Value of z: ")) s = (x + y + z) / 2 area = ((s * (s-x)*(s-y)*(s-z)) ** 0.5) print(area)
f35496403292596c761ce41726f723a35d783be2
wearnold/cmpe255-spring19-lab2
/friends.py
761
3.78125
4
# import statistics def mean_num_friends(x): # TODO # total = 0 # [total += val for val in x] # return total return sum(x)/len(x) def median_num_friends(x): # An easier way if importing libraries # result = statistics.median(x) list_len = len(x) x_sorted = sorted(x) if l...
3290835515bd9c2e4c885696e3356a62d44298d1
jacobmeneses/PythonCodigos
/probabilidad-y-estadistica/poisson-2.py
244
3.6875
4
from math import pow,exp,factorial,sqrt x=0.88 y=1.55 avg_ca=160+40*(x + pow(x,2)) print( 'expected ca = {:.3f}'.format(avg_ca)) avg_cb=128+40*(y + pow(y,2)) print( 'expected cb = {:.3f}'.format(avg_cb)) # expected output # 226.176 # 286.100
fb318c21ff72a7ce9aa6d361547f0f4ee32b2c80
ranjit-manutd/Python3_CodeAcademy
/Unit 10 Advanced Topics in Python/01 Advanced Topics in Python/List Slicing/9-Reversing a List.py
96
3.609375
4
my_list = list(range(1, 11)) # Add your code below! backwards = my_list[::-1] print(backwards)
52eae320e0934fbfc264d7ee651fcb88a67817d1
achen4290/bag-of-words-test
/main.py
1,748
3.6875
4
import re import string import json def clean_transcript(transcript): """ Cleans a given transcript for easy searching in the 20k most common words in the Google Trillion Words Corpus ... Parameters ---------- transcript : str The transcript to be cleaned Output : str The...
f69085468400c80e8b263df05ffff2e0a7e723cb
cr7flab77/Data_Structure_n_Algorithms
/Competitive_Programming/Pokemon_1.py
1,772
3.90625
4
""" Obama has always wanted to be the best Pokemon trainer in this world. And he thinks he has achieved his goal, so he wants to quickly go and meet Professor Oak and verify this fact. But like all Pokemon trainers, he has a weird habit, too. He catches Pokemons which can go through evolution to become a better one. ...
39cef4570d58ba1bf47521cb778b315a8e29a9bb
BurakEselik/currency-converter-app
/_exchange.py
1,909
3.53125
4
import requests import json base_url = "https://api.exchangerate-api.com/v4/latest" valid_currencies = ['TRY', 'USD', 'EUR'] @property def version(): return 1.0 def get_currency_data(currency: str) -> str: if currency in valid_currencies: url = '/'.join([base_url, currency]) responce = reques...
31232a874d98df2ac242c3f0ff33a7b3b5c658fe
igorleshchuk/algorithms-leetcode-python-scha-poreshaem
/episode35-2021-04-29/q1108_defanging_ip.py
344
3.640625
4
class Solution: def defangIPaddr(self, address: str) -> str: new_ip = '' for s in address: if s == '.': new_ip = new_ip + '[.]' else: new_ip = new_ip + s return new_ip if __name__ == '__main__': ip = "255.100.50.0" print(Solu...
0c09aabf2e3bb879a46c6b0da07a9ac4b023e70f
igorleshchuk/algorithms-leetcode-python-scha-poreshaem
/episode39-2021-05-13/q1672_richest_customer_wealth.py
887
3.65625
4
from typing import List class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: wealth = [] for account in accounts: s = 0 for bank in account: s = s + bank wealth.append(s) cur_max = wealth[0] for w in wealth[...
60c62162f3ea8fdca7d5cbfe9d790fef63058511
VictorOnink/Algorithmic-Toolbox
/Divide-and-Conquer/Improving QuickSort/quicksort.py
1,113
4.03125
4
# python3 from random import randint def partition3(array: list, left: int, right: int): # We take the first element as our pivot pivot_value = array[left] start = index = left end = right while index <= end: if array[index] < pivot_value: array[index], array[start] = array[st...
c3718e31a1a978b7011a28763845e6ac71512dc2
VictorOnink/Algorithmic-Toolbox
/Algorithmic Warm Up/Last Digit of the Sum of Fibonacci Numbers Again/last_digit_of_the_sum_of_fibonacci_numbers_again.py
1,642
3.859375
4
# python3 def last_digit_of_the_sum_of_fibonacci_numbers_again_naive(from_index, to_index): assert 0 <= from_index <= to_index <= 10 ** 18 if to_index == 0: return 0 fibonacci_numbers = [0] * (to_index + 1) fibonacci_numbers[0] = 0 fibonacci_numbers[1] = 1 for i in range(2, to_index ...
22670066db0906d203ace382ad31bb41e47250aa
VictorOnink/Algorithmic-Toolbox
/Greedy Algorithms/Maximum Salary/maximum_salary.py
951
3.9375
4
# python3 from itertools import permutations def largest_number_naive(numbers): numbers = list(map(str, numbers)) largest = 0 for permutation in permutations(numbers): largest = max(largest, int("".join(permutation))) return largest def which_is_best(candidate, max_value): if int(str...
eb0e4d27278682bbc273e53df2a611336a5eac43
jabadia/advent-of-code-2018
/d12/d12p1.py
2,105
3.5625
4
from collections import namedtuple, defaultdict TestCase = namedtuple('TestCase', 'case expected') INPUT = """ initial state: #....##.#.#.####..#.######..##.#.########..#...##...##...##.#.#...######.###....#...##..#.#....##.## .#.## => # .#.#. => # #.#.# => . .#### => . .#... => . #..## => . ..#.# => # #.#.. => . ##...
0dec5b194f366368df6899498fdc86769e8ac6bb
poojithayadavalli/sorting
/subsetswithconsecutivenumbers.py
837
4.03125
4
""" Given an array of size n.Array consists of distinct positive numbers, the task is to calculate the number of subsets (or subsequences) from the array such that each subset contains consecutive numbers. Input: Firstline consists of integer n secondline consists of the elements of array Output: print the minimum ...
d2a1e39ade77e72b19d5d69109747db67c9b968e
sahilomatic/Flask-Application-with-unitTes
/payments/validations.py
5,288
3.53125
4
from datetime import datetime, timedelta class Validation: def validate_request(self,CreditCardNumber,CardHolder,ExpirationDate,SecurityCode,Amount): """ Validate received parameters Args: CreditCardNumber (str): CreditCardNumber (mandatory, string, it shou...
0f0a49807add62a6e4b75f9746e4eeec9cec2297
king-11/Information-Technology-Workshop
/python assignments/Assignment1/assignment1/12.py
144
3.75
4
# takes input for b and insert it a position 1 i.e. 2 as # zero based indexing a = [1, 2, 3, 4, 7, 8] b = int(input()) a.insert(1, b) print(a)
3491b309bc26e884f04f0e0029ed2e9b66ef3b6c
king-11/Information-Technology-Workshop
/python assignments/Assignment1/assignment1/23.py
195
3.8125
4
# function arguments two lists # iterates over both simulatenously # print both list until least lenght one exhusted def fun23(a: list, b: list): for x, y in zip(a, b): print(x, y)
a1fc52ae8d69d3fc506131f8872990f1b930cbd3
king-11/Information-Technology-Workshop
/python assignments/Assignment1/assignment1/6.py
198
4.03125
4
# input string # convert into list # stores set of list having all distinct characters # prints count if each element in set s = input() a = list(s) b = set(a) for x in b: print(x, s.count(x))
77b657cfad7701d753be15c3934ab22747b2ecec
king-11/Information-Technology-Workshop
/python assignments/Assignment1/assignment1/11.py
212
3.8125
4
# split input numbers using split function # convert binary to decimal anf then check # print answers nums = input().split(',') a = list() for x in nums: if int(x, 2) % 5 == 0: a.append(x) print(a)
82a40933d7cf9b1bf284dc5145cfb2f5c5d5205c
luke-james/python-exercises
/src/ex3_list_less_than_ten.py
1,174
3.890625
4
import numbers """ Write a program that prints out a set of the elements of the list that are less than 5. """ class ListChecker: @staticmethod def get_sublist(ceil, list_to_check): return [x for x in ListChecker.validate_list_input(list_to_check) if x < ceil] @...
3e5006cf9e83f5127beb05765bf276de6efcc3d3
peoolivro/codigos
/Cap5_Exercicios/PEOO_Cap5_ExercicioProposto03.py
509
4.21875
4
# Livro...: Introdução a Python com Aplicações de Sistemas Operacionais # Capítulo: 05 # Questão.: Exercício Proposto 3 # Autor...: Fábio Procópio # Data....: 15/06/2019 import random RIFA = [] while True: nome = input("Informe um nome: ") RIFA.append(nome) resp = input("Deseja continuar [S|N]? ") if ...
39b6f848cd2579bbc0c33cdafa3a73dbf356244d
peoolivro/codigos
/Cap2_Exercicios/PEOO_Cap2_ExercicioProposto05.py
475
4.375
4
# Livro...: Introdução a Python com Aplicações de Sistemas Operacionais # Capítulo: 02 # Questão.: Exercício Proposto 5 # Autor...: Fábio Procópio # Data....: 18/02/2019 from math import sqrt print("Dados do ponto P1:") x1 = float(input("Digite x1: ")) y1 = float(input("Digite y1: ")) print("Dados do ponto P2:") x2 =...
9badcbc5bc0a142e7fea1b8f5057ada50378e713
peoolivro/codigos
/Cap3_Exercicios/PEOO_Cap3_ExercicioProposto07.py
749
4.3125
4
# Livro...: Introdução a Python com Aplicações de Sistemas Operacionais # Capítulo: 03 # Questão.: Exercício Proposto 7 # Autor...: Fábio Procópio # Data....: 31/05/2019 altura1 = float(input("Digite a estatura da 1ª pessoa (em metros): ")) altura2 = float(input("Digite a estatura da 2ª pessoa (em metros): ")) altura3...
ca22c26a971c31449b679a1e243d835105b0b2a7
peoolivro/codigos
/Cap5_Exercicios/PEOO_Cap5_ExercicioProposto02.py
735
4.125
4
# Livro...: Introdução a Python com Aplicações de Sistemas Operacionais # Capítulo: 05 # Questão.: Exercício Proposto 2 # Autor...: Fábio Procópio # Data....: 15/06/2019 ATLETA = [] TEMPO = [] for x in range(7): nome = input("Informe o nome do nadador: ") tempo = float(input("Informe o tempo do nadador: ")) ...
de9d698079b2f694b6233ebc72eb35e899dd530e
peoolivro/codigos
/Cap3_Exercicios/PEOO_Cap3_ExercicioProposto01.py
390
4.28125
4
# Livro...: Introdução a Python com Aplicações de Sistemas Operacionais # Capítulo: 03 # Questão.: Exercício Proposto 1 # Autor...: Fábio Procópio # Data....: 31/05/2019 num = int(input("Digite um número: ")) if num % 2 == 0: quadrado = num ** 2 print(f"{num} é par e o seu quadrado é {quadrado}.") else: cu...
cd6cf9147c719c39f25a7d206bbb09be2fd397ec
peoolivro/codigos
/Cap7_Exercicios/PEOO_Cap7_ExercicioProposto03.py
813
4
4
# Livro...: Introdução a Python com Aplicações de Sistemas Operacionais # Capítulo: 07 # Questão.: Exercício Proposto 3 # Autor...: Emanuel Lázaro # Data....: 29/10/2019 from MinhasFuncoes import * linhas = int(input('Informe a quantidade de linhas da matriz: ')) colunas = int(input('Informe a quantidade de colunas d...
6713ce569d9bd93b9bccdb4e85e9caddb1fc0848
peoolivro/codigos
/Cap3_Exercicios/PEOO_Cap3_ExercicioProposto02.py
958
4.625
5
# Livro...: Introdução a Python com Aplicações de Sistemas Operacionais # Capítulo: 03 # Questão.: Exercício Proposto 2 # Autor...: Fábio Procópio # Data....: 31/05/2019 num1 = float(input("Digite um número: ")) num2 = float(input("Digite outro número: ")) print("\n1. Média ponderada, com pesos 2 e 3, respectivamente...
58df08bc90edaf08f828285d1ed3701c50f671ae
peoolivro/codigos
/Cap4_Exercicios/PEOO_Cap4_ExercicioProposto07.py
759
4.125
4
# Livro...: Introdução a Python com Aplicações de Sistemas Operacionais # Capítulo: 04 # Questão.: Exercício Proposto 7 # Autor...: Fábio Procópio # Data....: 04/06/2019 idade = int(input("Idade: ")) '''Como não há nenhuma idade a ser comparada, neste momento, a primeira idade é, ao mesmo tempo, o mais novo e o mais ...
0fb778e823b622c9095e96c7ca5393e585176825
AryaMath/AryaMath.github.io
/python/If statements.py
180
3.921875
4
print ("Give a number.") num1 = input () print ("Give another number.") num2 = input () if (num1 < num2): print ("B") elif (num1 > num2): print ("A") else print ("C")
d6e5e17a596d792960911a28b5b7b55739f2d27b
swuhcg/python
/rpsls.py
3,835
3.6875
4
#coding:gbk """ һСĿRock-paper-scissors-lizard-Spock ߣƳ̹ ڣ2020/11/24 """ import random # 0 - ʯͷ # 1 - ʷ # 2 - ֽ # 3 - # 4 - # ΪϷҪõԶ庯 def name_to_number(name): """ ϷӦͬ """ if name=="ʯͷ":# ʹif/elif/else佫ϷӦͬ name=0 elif name=="ʷ": name=1 elif na...
01664fafa27bbbdb7b19cf18436ad076d87d0f93
fishsey/code
/python/fishsey/draw/plt_plotScatter.py
620
3.9375
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 30 16:42:09 2016 @author: fishsey this is a example-module for matplotlib use """ from matplotlib import pyplot as plt import numpy as np def drawPlot(): ''' 绘制不同颜色、大小的散点图 ''' x = np.random.random_sample(40).reshape(10, 4) plt.plot(x) def d...
519d04e843b4966f58d0d2ffc1e4a4596ef1ea09
manand2/python_examples
/comprehension.py
2,044
4.40625
4
# list comprehension nums = [1,2,3,4,5,6,7,8,9,10] # I want 'n' for each 'n' in nums my_list = [] for n in nums: my_list.append(n) print my_list #list comprehension instead of for loop my_list = [n for n in nums] print my_list # more complicated example # I want 'n*n' for each 'n' in nums my_list = [n*n for n i...
59e6e78835b05d319640d93331c6f1c90e85d0c0
FredTinio/python-challenge
/PyPoll/main.py
2,103
3.5
4
#This is the starting of the PyPoll assignment import os import csv #Create path, read file #get the current working directory current = os.getcwd() #Join Current to csv file csv_path = os.path.join('Resources', 'election_data.csv') #Initialize empty lists: voter_ids, Counties and Candidates voter_ids = [] Counties ...
0b1de941e438a9f941763903004297fb7f57d5de
bradbrandon/class-assignments
/untitled3.py
241
3.640625
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 17 12:30:38 2018 @author: Brandon """ import os def(s): try: x=int(s) except (ValueError,TypeError) as e:#this is assignment print("conversion eror:{}".format(str(e)),,
a9c44f593b5e256e6d7a0e2a4992ebb08cb8e8d0
bradbrandon/class-assignments
/Tanaka Muchandibaya oop assignment.py
963
3.84375
4
#code for input mlist=[] flist=[] namelist=[] count=0 #def minput(): # while (len(mlist) <5 ): # print("enter your age") # age=int(input()) # # if (age>=23) : # print("enter your name:") # mlist.append(input()) ...
7093a3d6d7a3a5787c7c6714b1b799c80782c3ae
Andrea-Tellez/Poo
/Semana_4/estudiante.py
1,584
3.78125
4
class Estudiante: #Atributos nombre= "Andrea" matricula= "17191101" carrera= "tic´s" edad= "18" cuatrimestre= "segundo" #Metodos def elegir(self): print("elegir") def asignar(self): print("asignar") def __init__(self): print:("metodos estudiante") class EstudianteAndrea (Estudiante):...
d2ecc870fca17089eb4f84b9862fb82abf6de1cb
Abhineeth09/Code-Solutions
/Leetcode - Remove Nth Node from End of List/solution.py
1,069
3.859375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: size=0 if head: size=1 pointer=head point...
dda3475e6f1291f4545f3783e56c253311040e11
Abhineeth09/Code-Solutions
/Leetcode #55 - Jump Game/solution.py
416
3.5625
4
class Solution: def canJump(self, nums: List[int]) -> bool: maxdist=nums[0] #Keep track of the maximum distance you can reach, if you come to an index you cant reach, return false for i,v in enumerate(nums): if maxdist<i: return False if maxdist>=len(n...
6e9b08a3388999e74b72ca3412d9b595052a0a48
Crossroadsman/hackerrank
/algorithms/warmup/mini_max_sum.py
901
3.8125
4
#!/bin/python3 import sys import functools def miniMaxSum(arr): def gt(a, b): '''behaves like > except any value compared to None returns true''' if b == None: return True else: return a > b def lt(a, b): '''behaves like < except any value compared ...
c958ac7555fefcf31ba9c0677e949ae2463e631f
mohemed-aml/sudoku-website
/setup.py
2,301
4.03125
4
#row array definition row = [[ False, 9, [c for c in range(9)] ] for r in range(9)] #column array definition col = [[ False, 9, [c for c in range(9)] ] for r in range(9)] #box array definition box = [[ False, 9, [c for c in range(9)] ] for r in range(9)] #set value function def enter_val(ro, co, val): ...
b9526d2465351f4cf46bb0e62c2b732f7054a180
SriKaratalapu/Bikeshare-udacity-project
/bikeshare.py
9,568
4.28125
4
import pandas as pd import time CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } MONTHS = ('all', 'january', 'february', 'march', 'april', 'may', 'june') DAYS = ('all', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', '...
2370e6e5c4fccec6ac18d608d8773252c9a0c9e8
ahammadshawki8/Command-Line-Fundamentals
/06. virtualenv.py
4,062
3.921875
4
# virtual environment # virtual env is a way that we can separate different python environment for different projects. # why would we do something like this? # lets say, we have multiple projects and they all rely on a single package lets say django. # each one of these projects may using different version of django. ...
3cf9b30f2ec8e7f68f3626e2a559482ebfa32ba7
EnderEmber/ElevatorSim
/elevator.py
8,451
3.703125
4
import random import numpy.random as random from queue import PriorityQueue class Simulation: def __init__(self): self.time = 0 self.numFloors = 6 self.elevatorCapacity = 8 self.floor1ArrivalRate = 1 #Per minute self.floorXArrivalRate = self.floor1ArrivalRate/(self.numFloors) + 0.01 #Per minute ...
a97fa146142b2b0d74ffa1e2d0e18ca3411637d9
bradellison/pokemon-simulator
/test.py
301
3.921875
4
def printList(printedList): for line in printedList: print(line) print("") print("❨◗") print("◖❩") print("◖❩") x = [ " ⪽⪾ ", "(┣┫)", " ⌋⌊ ", " ⪾⪾ ", "(||\\", " ⌊⌊ ", " ⪽⪽ ", "/||)", " ⌋⌋ ", " ⫏⫐ ", "(⍞⍞)", " ⌋⌊ "] printList(x)
37498e70f1550bd468c29f5b649075ce4254978d
chrishaining/python_stats_with_numpy
/arrays.py
384
4.15625
4
import numpy as np #create an array array = np.array([1, 2, 3, 4, 5, 6]) print(array) #find the items that meet a boolean criterion (expect 4, 5, 6) over_fives = array[array > 3] print(over_fives) #for each item in the array, checks whether that item meets a boolean criterion (expect an array of True/False, in this ...
8eeec768d3a9a91abadbb067abcc543a3a622c50
yasmineholb/holbertonschool-interview
/0x09-utf8_validation/0-validate_utf8.py
625
3.859375
4
#!/usr/bin/python3 """validUTF8""" def validUTF8(data): """ Function that determines if a given data set represents a valid UTF-8 encoding""" bin1 = 1 << 6 nb = 0 for dt in data: bin2 = 1 << 7 if nb == 0: while dt & bin2: nb += 1 bin2...
c0585d2d162e48dd8553ccfc823c3e363a2b28c0
samson027/HacktoberFest_2021
/Python/Bubble Sort.py
416
4.125
4
def bubblesort(array): for i in range(len(array)): for j in range(len(array) - 1): nextIndex = j + 1 if array[j] > array[nextIndex]: smallernum = array[nextIndex] largernum = array[j] array[nextIndex] = largernum array[j...
989fc24b827dd742146b148cbc4e88d6bd277481
samson027/HacktoberFest_2021
/Python/tower_of_hanoi.py
355
3.84375
4
# program for tower of hanoi def toh(n , src, dest, aux): if n==1: print ("Move disk 1 from source",src,"to destination",dest) return toh(n-1, src, aux, dest) print ("Move disk",n,"from source",src,"to destination",dest) toh(n-1, aux, dest, src) print("Enter N: \n") n = int(input()) ...
10ad41295d71d24ef231ad24f7a45ff70bf1a5cc
rustyworks/python-scripts
/sieve.py
1,818
3.984375
4
#!/usr/bin/python3 import argparse class Prime(): ''' Program to generate prime number using sieve of Eratosthenes ''' def __init__(self): self.primes = [2] self.generate(10000) def get(self, prime_limit): ''' This is to get the last prime number before the limit...
2beb3478ce6d885bbbfcf5f6914e5ab98c547d52
snehlatamsr12/python_tutorial
/Exercise5.py
125
3.859375
4
degree_c=float(input('Enter celius degree')) degree_f=((degree_c*9)/5)+35 print('Degree Fahrenheit') print(round(degree_f,2))
96482f2ded321007429d6c3e9cd2b5db0fec37da
snehlatamsr12/python_tutorial
/Exercise12.py
415
4
4
import sys max = -sys.maxsize-1 min = sys.maxsize while True: ip=input('Enter a number: ') try: if ip=='done': break ip=int(ip) if max<ip: max=ip if min>ip: min=ip except: ...
64139289b8d3e788d20e5baa098df1475261081b
youngdukk/python_stack
/python_week3/lectures/python_lecture.py
1,668
3.6875
4
def first_function(param_one): return 5 print(param_one) return_value = first_function("Hello") print("Return value is {}".format(return_value)) ################### database = [] def registration(first_name, last_name, email, password): register_dictionary = {} register_dictionary['first_name'] = ...
5c6d604625248e7f70887260ed49bad269336265
youngdukk/python_stack
/python_activities/oop_activities/animal.py
1,714
4.03125
4
class Animal(): def __init__(self, name, health): self.name = name self.health = health def walk(self): self.health -= 1 return self def run(self): self.health -= 5 return self def displayHealth(self): print("Name: {}".format(self.name))...
148418a17af55f181ecea8ffd5140ba367d7dc2d
youngdukk/python_stack
/python_activities/oop_activities/bike.py
974
4.25
4
class Bike(object): def __init__(self, price, max_speed): self.price = price self.max_speed = max_speed self.miles = 0 def displayInfo(self): print("Bike's Price: ${}".format(self.price)) print("Bike's Maximum Speed: {} mph".format(self.max_speed)) print("Total ...
59e45445112996f48f574cebdfe03441aa5b9da7
ExtremelySunnyYK/MIT-6.006-Introduction-to-Algorithms
/Module 2 Project/Algorithim Assigment/Visualisation of double for loops.py
149
3.859375
4
# -*- coding: utf-8 -*- """ Visualisation of double for loops """ for i in range(2): print(i) for j in range(2): print(str(j) + "j")
266f3471ec27d1e2037f080d816562ec493daef3
hassanshamim/adventofcode
/2015/2_drunk_santa.py
2,615
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Oct 9 00:50:41 2016 @author: Hassan Shamim --- Day 3: Perfectly Spherical Houses in a Vacuum --- Santa is delivering presents to an infinite two-dimensional grid of houses. He begins by delivering a present to the house at his starting location, and...
b7229eb93af0d7bc90c71256a3c49477cad6d9d1
hassanshamim/adventofcode
/2015/12_json.py
1,951
4.03125
4
"""" --- Day 12: JSAbacusFramework.io --- Santa's Accounting-Elves need help balancing the books after a recent order. Unfortunately, their accounting software uses a peculiar storage format. That's where you come in. They have a JSON document which contains a variety of things: arrays ([1,2,3]), objects ({"a":1, "b"...
0d9ec693cf11544098aaf190b917c1795ec79692
hassanshamim/adventofcode
/twentysixteen/day18.py
1,283
3.90625
4
PUZZLE_INPUT = '^.....^.^^^^^.^..^^.^.......^^..^^^..^^^^..^.^^.^.^....^^...^^.^^.^...^^.^^^^..^^.....^.^...^.^.^^.^' SAFE = '.' TRAP = '^' def generate_new_row(previous_row): # PAD previous row with safe tiles last = SAFE + previous_row + SAFE return ''.join( determine_tile_type(last, position)...
dd8e5ef1d54aba11cc7820ad025e164a199c5b71
hassanshamim/adventofcode
/twentysixteen/day15.py
1,482
3.71875
4
PUZZLE_INPUT = """Disc #1 has 17 positions; at time=0, it is at position 1. Disc #2 has 7 positions; at time=0, it is at position 0. Disc #3 has 19 positions; at time=0, it is at position 2. Disc #4 has 5 positions; at time=0, it is at position 0. Disc #5 has 3 positions; at time=0, it is at position 0. Disc #6 has 13 ...
34bab49746599de59d7cfc2ef5fa4f73305969c0
hassanshamim/adventofcode
/twentysixteen/day5.py
1,080
3.640625
4
from hashlib import md5 from itertools import count puzzle_input = b'reyedfim' def generate_password(code): password = '' for i in count(1): result = md5(code + str(i).encode('utf8')) if result.hexdigest().startswith('0' * 5): password += result.hexdigest()[5] if len(pa...
26cde2f129db23aafa1f986c7e5918f10d54b0a2
hassanshamim/adventofcode
/2015/7_bitwise.py
4,662
4
4
""" This year, Santa brought little Bobby Tables a set of wires and bitwise logic gates! Unfortunately, little Bobby is a little under the recommended age range, and he needs help assembling the circuit. Each wire has an identifier (some lowercase letters) and can carry a 16-bit signal (a number from 0 to 65535). A si...
872fc9ac93950f85a866e803f664cf8d002c512b
minhvvu/writing_ass
/text_parser.py
1,424
3.5
4
# text_parser module for parsing text file into pair # of close words with weight denote it's distance from nltk.corpus import PlaintextCorpusReader def load_data(data_root, file_ext): """ Load all text file in directory `data_root` with extension as `file_ext`. Return list of all sentences. """ r...
9e08a48a041463866c1d543067b1fbefb11f14d1
KhomZ/tkinterGUI
/frame.py
457
3.609375
4
# Adding Frames to Your Program # Developer: Khom # @ikhomkodes # Date: Friday, 2 April 2021 from tkinter import * from PIL import ImageTk, Image root = Tk() root.title('Coding with iKhom') frame = LabelFrame(root, text="This is my Frame...", padx=50, pady=50) frame.pack(padx=100, pady=100) b = Button(frame, text="...
f0a2f129c3182421296e28e16eee7e29061e891a
Duclearc/ping-pong-game
/game_table.py
1,204
3.90625
4
from turtle import Turtle class GameTable(Turtle): def __init__(self, screen_height, screen_width, ball_and_paddle_width): super().__init__() self.BOTTOM_SCREEN = -(screen_height + ball_and_paddle_width - 5) self.TOP_SCREEN = screen_height + ball_and_paddle_width - 5 self.LEFT_EDGE...
b9cab4a582bc2528cad77637da30bb4458b7ac67
frankiegu/python_for_arithmetic
/力扣算法练习/day95-柱状图中最大的矩形.py
1,185
3.875
4
# -*- coding: utf-8 -*- # @Time : 2019/6/7 8:42 # @Author : Xin # @File : day95-柱状图中最大的矩形.py # @Software: PyCharm # 给定 n 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。 # # 求在该柱状图中,能够勾勒出来的矩形的最大面积。 # day95-题目图1.png # # 以上是柱状图的示例,其中每个柱子的宽度为 1,给定的高度为 [2,1,5,6,2,3]。 # # day95-题目图2.png # 图中阴影部分为所能勾勒出的最大矩形面积,其面积为 10 个单位。 # #...
55c8c6571d9dab68666b08976fef349cbc0dda63
frankiegu/python_for_arithmetic
/力扣算法练习/day24-组合总和.py
2,404
3.75
4
# -*- coding: utf-8 -*- # @Time : 2019/3/24 21:50 # @Author : Xin # @File : day24-组合总和.py # @Software: PyCharm # 给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 # # candidates 中的数字可以无限制重复被选取。 # # 说明: # # 所有数字(包括 target)都是正整数。 # 解集不能包含重复的组合。 # 示例 1: # # 输入: candidates = [2,3,6,7], tar...
9e166f73f6c7df50c79ebc56dfa523e237ae0c07
frankiegu/python_for_arithmetic
/力扣算法练习/day43-最小路径和.py
1,554
3.5625
4
# -*- coding: utf-8 -*- # @Time : 2019/4/12 11:32 # @Author : Xin # @File : day43-最小路径和.py # @Software: PyCharm # 给定一个包含非负整数的 m x n 网格,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 # # 说明:每次只能向下或者向右移动一步。 # # 示例: # # 输入: # [ # [1,3,1], # [1,5,1], # [4,2,1] # ] # 输出: 7 # 解释: 因为路径 1→3→1→1→1 的总和最小。 # 首先对于第一行和第一列进行处理.因为第一...
f3ec69f37ea7b4363653d36c471f8c7c4f979794
frankiegu/python_for_arithmetic
/力扣算法练习/day66-路径总和2.py
1,541
3.796875
4
# -*- coding: utf-8 -*- # @Time : 2019/5/5 20:34 # @Author : Xin # @File : day66-路径总和2.py # @Software: PyCharm # 给定一个二叉树和一个目标和,找到所有从根节点到叶子节点路径总和等于给定目标和的路径。 # # 说明: 叶子节点是指没有子节点的节点。 # # 示例: # 给定如下二叉树,以及目标和 sum = 22, # # 5 # / \ # 4 8 # / / \ # 11 13...
a576343401f51ebb66a83bec27a6baaa5288dca9
frankiegu/python_for_arithmetic
/力扣算法练习/day28补-实现strStr().py
1,976
3.96875
4
# -*- coding: utf-8 -*- # @Time : 2019/3/28 21:28 # @Author : Xin # @File : day28补-实现strStr().py # @Software: PyCharm # 实现 strStr() 函数。 # # 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回 -1。 # # 示例 1: # # 输入: haystack = "hello", needle = "ll" # 输出: 2 # 示例 2: # # 输入: hayst...
6ff43a461924ffec1d42dfd5278586188ec85ec8
frankiegu/python_for_arithmetic
/力扣算法练习/day47-字符串相乘.py
2,194
4.09375
4
# -*- coding: utf-8 -*- # @Time : 2019/4/16 10:24 # @Author : Xin # @File : day47-字符串相乘.py # @Software: PyCharm # 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。 # # 示例 1: # # 输入: num1 = "2", num2 = "3" # 输出: "6" # 示例 2: # # 输入: num1 = "123", num2 = "456" # 输出: "56088" # 说明: # # num1 和 num2 的长度...
1a3113a91f5b6ffe95899f952be3248e8197498b
frankiegu/python_for_arithmetic
/力扣算法练习/day86-实现 Trie (前缀树).py
1,698
4.1875
4
# -*- coding: utf-8 -*- # @Time : 2019/5/28 22:15 # @Author : Xin # @File : day86-实现 Trie (前缀树).py # @Software: PyCharm # 实现一个 Trie (前缀树),包含 insert, search, 和 startsWith 这三个操作。 # # 示例: # # Trie trie = new Trie(); # # trie.insert("apple"); # trie.search("apple"); // 返回 true # trie.search("app"); // 返回 fals...
f3d599a4891a036ee0dd315b0424a7184efb31f3
frankiegu/python_for_arithmetic
/力扣算法练习/day5-寻找两个有序数组的中位数.py
1,162
3.703125
4
# -*- coding: utf-8 -*- # @Time : 2019/3/3 18:34 # @Author : Xin # @File : day5-寻找两个有序数组的中位数.py # @Software: PyCharm # 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。 # # 请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 # # 你可以假设 nums1 和 nums2 不会同时为空。 # # 示例 1: # # nums1 = [1, 3] # nums2 = [2] # # 则中位数是 2.0 # 示例 2: # # nums1 =...
797d224072c34473343a93e16fbadd7015d5f484
frankiegu/python_for_arithmetic
/力扣算法练习/day39-接雨水.py
1,944
4.15625
4
# -*- coding: utf-8 -*- # @Time : 2019/4/8 21:23 # @Author : Xin # @File : day39-接雨水.py # @Software: PyCharm # 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 # # day39图 # 上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 感谢 Marcos 贡献此图。 # # 示例: # # 输入: [0,1,0,2,1,0,1,3,2,1,2,1] # 输出: 6 ...
3f8c51290404170d3380e4ecdf1b0855de89938d
frankiegu/python_for_arithmetic
/力扣算法练习/day29-全排列.py
945
3.875
4
# -*- coding: utf-8 -*- # @Time : 2019/3/29 20:51 # @Author : Xin # @File : day29-全排列.py # @Software: PyCharm # 给定一个没有重复数字的序列,返回其所有可能的全排列。 # # 示例: # # 输入: [1,2,3] # 输出: # [ # [1,2,3], # [1,3,2], # [2,1,3], # [2,3,1], # [3,1,2], # [3,2,1] # ] class Solution(object): def permute(self, nums): ...
dee3f9bd5877d8e13987685b84de2d3c096ec255
prefrontal/leetcode
/answers-python/0029-DivideTwoIntegers.py
1,413
3.578125
4
# LeetCode 29 - Divide Two Integers # # Given two integers dividend and divisor, divide two integers without using # multiplication, division and mod operator. Return the quotient after dividing dividend by divisor. # # The integer division should truncate toward zero, which means losing its fractional part. # For exam...
054bb6f21605bcd9e306546d7d7564f17716c9fd
prefrontal/leetcode
/answers-python/0011-MostWaterContainer.py
1,320
3.8125
4
# LeetCode 11 - Container With Most Water # # Given n non-negative integers a1, a2, ..., an , where each represents a point at # coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i # is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, # such that the ...
52d35b2a21c30e5f35b1193b123f0b59a795fa17
prefrontal/leetcode
/answers-python/0021-MergeSortedLists.py
1,695
4.21875
4
# LeetCode 21 - Merge Sorted Lists # # Merge two sorted linked lists and return it as a new sorted list. The new list should be # made by splicing together the nodes of the first two lists. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def mergeTwoLists(l1: ...
b1ff4822be75f8fffb11b8c2af5c64029a27a874
prefrontal/leetcode
/answers-python/0023-MergeKSortedLists.py
2,349
4.125
4
# LeetCode 23 - Merge k sorted lists # # Given an array of linked-lists lists, each linked list is sorted in ascending order. # Merge all the linked-lists into one sort linked-list and return it. # # Constraints: # k == lists.length # 0 <= k <= 10^4 # 0 <= lists[i].length <= 500 # -10^4 <= lists[i][j] <= 10^4 # lists[i...
807dbe979901e1a547baf4b72c97a339f7a9b828
TomCoupe/Year1-CompSci
/Python-Programming/Thomas_Coupe-CA07.py
7,355
4.0625
4
#201241037, Thomas_Coupe-CA07.py #Coded december of 2017 #The program will take the users input from the menu and then run the game Go. players will take turns selecting squares with their numbers attempting to get a 2x2 slot of their number. row = 5 col = 5 Board = [[0]*col for i in range(row)] #the variable Boa...
45756f4dcd832e22c33ed876cf7a4628753a7756
gmoraisbrivia/image-picker
/imagepicker.py
1,278
3.515625
4
import requests import urllib.parse import os ''' This class uses the Google Images Search. Repo: https://github.com/ggmorais/image-picker ''' class ImagePicker: def __init__(self, name): self.name = name # Images from Google servers, low resolution due to encryption made self.fromGoogle = [] # Images f...
e26099b29d2bbf0bb641bbc49ccbdc7296477f59
seilcho7/week_2-python
/Collections_Recap/game-of-thrones/game-of-thrones-histogram.py
1,490
3.515625
4
from characters import characters import requests import json import time # count the number of people who are part of a house def make_house_histogram(character_list): histogram = {} # do the thing! # loop through all the characters for person in character_list: # what do I check for...
fa8154835e817dba99dc4a7b0bb3613d87667976
mjbernalv/ST0245-001
/talleres/taller04/Fibonacci.py
539
4
4
from time import time import matplotlib.pyplot as plt def Fibonacci(n): if n==0: return 0 if n==1: return 1 else: return Fibonacci(n-1)+Fibonacci(n-2) #tomar tiempos times=[] for i in range(36): start = time() print(Fibonacci(i)) end = time() total = end-start ...
9348abc87c6ec5318606464dac6e792960a0bc0f
NNHSComputerScience/cp1ForLoopsStringsTuples
/notes/ch4_for_loops_&_sequences_starter.py
1,795
4.78125
5
# For Loops and Sequences Notes # for_loops_&_sequences_starter.py # SEQUENCE = # For example: range(5) is an ordered list of numbers: 0,1,2,3,4 # ELEMENT = # So far we have used range() to make sequences. # Another type of sequence is a _________, # which is a specific order of letters in a sequen...
f6ccf4fa74bc616ae4ef5e5baefa86a979dd2052
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex73.py
921
4.25
4
'''Exercício Python 73: Crie uma tupla preenchida com os 20 primeiros colocados da Tabela do Campeonato Brasileiro de Futebol, na ordem de colocação. Depois mostre: a) Os 5 primeiros times. b) Os últimos 4 colocados. c) Times em ordem alfabética. d) Em que posição está o time da Chapecoense.''' times = ('PALMEI...
a25b6b3661d34d69f23dc8882410d9f7cf136a3d
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex33.py
414
3.953125
4
#Exercício Python 033: Escreva um programa que pergunte o salário de um funcionário e calcule o valor do seu aumento. Para salários superiores a R$1250,00, calcule um aumento de 10%. Para os inferiores ou iguais, o aumento é de 15%. sal = float(input('Digite o Salário para calculo do aumento ')) if sal > 1250: sal ...
342a4c85d50b5551c56265b8d0d37f6862bddd21
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex92.py
927
3.859375
4
'''Exercício Python 092: Crie um programa que leia nome, ano de nascimento e carteira de trabalho e cadastre-o (com idade) em um dicionário. Se por acaso a CTPS for diferente de ZERO, o dicionário receberá também o ano de contratação e o salário. Calcule e acrescente, além da idade, com quantos anos a pessoa vai ...
60a90abddad95055618302d95db8b21cb33d907f
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex93.py
1,037
4.25
4
'''Exercício Python 093: Crie um programa que gerencie o aproveitamento de um jogador de futebol. O programa vai ler o nome do jogador e quantas partidas ele jogou. Depois vai ler a quantidade de gols feitos em cada partida. No final, tudo isso será guardado em um dicionário, incluindo o total de gols feitos durante o...
d420b23f1cc6f0211573d671e9899fde2b5d43c9
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex13.py
152
3.546875
4
#Digite o sálario de um funcionário e depois aumente em 15% sal = float(input('Digite o slalário ')) print('O novo salário é {}'.format(sal*1.15))
a73e0adf7527348b492741b5bd782081775d9113
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex72.py
653
4.25
4
'''Exercício Python 72: Crie um programa que tenha uma tupla totalmente preenchida com uma contagem por extenso, de zero até vinte. Seu programa deverá ler um número pelo teclado (entre 0 e 20) e mostrá-lo por extenso.''' numeros = ('Zero', 'Um', 'Dois', 'Três', 'Quatro', 'Cinco', 'Seis', 'Sete', 'Oito', 'Nove', 'D...
f3fdc60439a3a4219e11a6b285eaa0db756244eb
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex105.py
944
4.15625
4
'''Exercício Python 105: Faça um programa que tenha uma função notas() que pode receber várias notas de alunos e vai retornar um dicionário com as seguintes informações: – Quantidade de notas – A maior nota – A menor nota – A média da turma – A situação (opcional) ''' def notas(*num, sit = False): """ :p...
01f05a223c484ec121098828e64d7a5310177f33
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex107/ex107.py
533
3.921875
4
#Exercício Python 107: #Crie um módulo chamado moeda.py que tenha as funções incorporadas aumentar(), diminuir(), #dobro() e metade(). Faça também um programa que importe esse módulo e use algumas dessas funções. import moeda f = int(input('Digite o valor em R$ ')) print(f'O valor aumentado de R${f} em 30% é R${moeda...
7cb2c3e5720f6f5fb26c1572b02c2b233ff631e7
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex68.py
1,289
4.15625
4
'''Exercício Python 68: Faça um programa que jogue par ou ímpar com o computador. O jogo só será interrompido quando o jogador perder, mostrando o total de vitórias consecutivas que ele conquistou no final do jogo. ''' import random jogador = '' computador = '' c = 0 n = 0 s = 0 cont = 0 while True: jogador = in...
04914dce7a30e572a1eebc3753e01b47d7278258
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex111/ex111.py
583
4
4
#Exercício Python 111: Crie um pacote chamado utilidadesCeV que tenha # dois módulos internos chamados moeda e dado. Transfira todas as funções utilizadas # nos desafios 107, 108 e 109 para o primeiro pacote e mantenha tudo funcionando.Exercício Python # 111: Crie um pacote chamado utilidadesCeV que tenha dois módulos ...
ad3cef712641be757edcdf61982c63ae5733fe90
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex87.py
1,124
4.09375
4
'''Exercício Python 087: Aprimore o desafio anterior, mostrando no final: A) A soma de todos os valores pares digitados. B) A soma dos valores da terceira coluna. C) O maior valor da segunda linha. ''' matriz = [[], [], []] x = 0 c = 1 l = 1 soma = 0 soma1 = 0 maior = 0 for y in range(0, 9): x = int(input(...
d4b5e14e734ceb87bb39611c05759918fd2fad80
EduardoLucas-Creisos/Python-exercises
/Exercícios sobre fundamentos/ex47.py
182
3.859375
4
#Exercício Python 47: Crie um programa que mostre na tela todos os # números pares que estão no intervalo entre 1 e 50. for c in range(0, 51): if (c%2 == 0): print(c)
89e4f9118061ec16735c52d3c7b38d5013acf267
IraMargolina/My_LR
/km_quadratic.py
225
3.59375
4
a = 1 b = -5 c = 6 d = b**2 - 4*a*c if d >= 0: x1 = (-b + d**(1/2))/(2*a) x2 = (-b - d**(1/2))/(2*a) print('x1 = ' + str(x1)) print('x2 = ' + str(x2)) else: print('Нет корней')
d3a53755beb01713817d3ef2dbeb0a6ee73cc9d4
superdebugman/project
/01_名片管理系统/cards_main.py
801
3.78125
4
#! usr\bin\python3 import cards_tools while 1: # 显示功能菜单 cards_tools.show_menu() action_str=input("请选择希望执行的操作:") print("您选择的操作是【%s】"%action_str) # 1、2、3 针对名片的操作 if action_str in ["1","2","3"]: # 新增名片 if action_str=="1": cards_tools.new_card() # 显示全部 e...
851f51a27d76b5669da2d18e249eff43a14db0f0
X-Guo-TUD/cable_capacity_calculation
/scripts/capacity_boxes.py
3,308
3.734375
4
# -*- coding: utf-8 -*- # # This file is part of MIEZE simulation. # Copyright (C) 2019, 2020 TUM FRM2 E21 Research Group. # # This is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Conversion between index value and capacities class....