blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
50f85888d7f5d0524c4f1bc186fee8cfee806dc0
soomankk123/DSA-Scapgoat
/scapegoat.py
5,048
3.703125
4
import math class Node: def __init__(self, key): self.key = key self.left = None self.right = None self.parent = None class Scapegoat: def __init__(self,a): self.a = a self.root = None self.size = 0 self.maxSize = 0 def insert(...
ddb03347841abd88481030480f136eaf5f6fa98a
lindsaymarkward/cp1404_inclass_demos_2021_2
/product_client.py
963
3.59375
4
"""Product class demo - week 6 and 7""" from product import Product p1 = Product("Phone", 340.0, False) p1.sku = "2134567890" print(p1) if p1.is_on_sale: print("Bargain") else: print("Whatevs") p1.put_on_sale(.9) p2 = Product("Horse", 500, True) print(p1) print(p2) result = p1.give(p2, 10000) print(result) pr...
094a482b64af5fd1fd28ded5ebb1a9731efe0f92
francososuan/2-PracticePythonOrg
/15-ReverseWordOrder.py
417
4.125
4
def reverser(sentence): sentence_list = sentence.split(" ") reverse_list = [] for i in range(len(sentence_list)-1,-1,-1): reverse_list.append(sentence_list[i]) return " ".join(reverse_list) input_sentence = str(input("Please enter a sentence: ")) print(reverser(input_sentence)) def reverse...
e532c50b095a049240c82fc410472425a4c75127
sehrishkhangh/deeplearning
/s.marksheet.py
1,425
3.984375
4
print('\n') name=input('Name of Student :') #print('name :'+'name of student') name_of_institute=input('Name of Institute:') #print('name') standard=input('Level:') print('\n') physics=int(input('Marks of PHYSICS=')) math=int(input('Marks of MATHS=')) chem=int(input('Marks of CHEMISTRY=')) english=int(input('Marks of E...
a5433801f434070ee97870a42d0286d11b602fa5
xErik444x/apuntesPython
/codes/Parte2/led.py
1,064
3.5625
4
numeros2 = [ ["###", "# #", "# #", "# #", "###"], [" #", " #", " #", " #", " #"], ["###", " #", "###", "# ", "###"], ["###", " #", "###", " #", "###"], ["# #", "# #", "###", " #", " #"], ["###", "# ", "###", " #", "###",], ["###", "# ", "###", "# #", "###",], ["###", " #", " #", " #", ...
518c4dcb18a373592a6db933087a38a885a30dfb
gabrielwai/Exercicios-em-Python-B
/ex093.py
1,154
3.75
4
jogador = dict() gols = [] jogador['nome'] = str(input('Nome do jogador: ')) jogador['partidas'] = int(input(f'Quantas partidas {jogador["nome"]} jogou?: ')) for c in range(jogador['partidas']): gols.append(int(input(f"Quantos gols na partida {c+1}?: "))) jogador['gols'] = gols.copy() del gols print("-="*30...
07634f12bee2e43543219e50e65d1a9560868db5
zukowski2012/InfoShare-Python
/homeworks/day4/zadanie_1.py
778
3.828125
4
# 1P. program wydający resztę z dostępnych monet: 5, 2, 1, 0.5, 0.2, 0.1 reszta = float(input("Ile mam wydać reszty: ")) dostepne_monety = [5, 2, 1, 0.5, 0.2, 0.1] reszta_w_monetach = [] # dopoki kwota jest wieksza niz 10 gr, to mozemy dalej wydawac reszte while (reszta >= 0.1): for moneta in dostepne_monety: ...
8334bf7b6ee3e78656f4b0d4ed2505e370ace359
rajeshvermadav/XI_2020
/controlstatements/for_seq.py
408
4.3125
4
# Display a list using for cl = ["c", "python", "php"] for x in cl: print(x) #Display a string in sequence #cl = "python" #for x in cl: #print(x) #Display the list item is found break cl = ["c", "python", "php"] for x in cl: print(x) if x == "python": break #Display the Continued list ...
f3a6a9b2d9f09b6eb0eddf31a879ce5c2a310f07
omnimike/exp
/fb-practice/mergesort.py
1,317
3.921875
4
def merge_sort(arr): tmp = arr[:] chunk_size = 1 while chunk_size < len(arr): offset = 0 while offset < len(arr): part_a_start = offset part_a_end = min(offset + chunk_size, len(arr)) part_b_start = part_a_end part_b_end = min(part_b_start + c...
983c9586a3471a4b70590b2ea7b34093473088a8
comesanha/pyclass
/scriptpy/CeV_exercicios/ex004_saida_formatada.py
512
3.609375
4
''' Código: IMC. Autor: Raphael Comesanha Período de Elaboração: Em 16/01/2020 O Código Executa: Solicita o peso e a altura do usuário e mostra na tela o valor do IMC daquele usuário. Parte do Projeto:CeV_exercicios Restições de acesso: Nenhuma ''' peso = float(input('Qual o seu peso?')) altura = float(input('Qual sua ...
2bacaaff2147cde5118be7ca30b776ddec7589e9
rsanjeevsingh/python-assignment
/PythonAssignment/ComparisionOperator.py
1,109
3.859375
4
''' Title - Comparision OPerator Description - This program will find average of given input numbers Program - 12 ''' try: num = int(input('How many numbers: ')) total_sum = 0 lst=[] for n in range(num): numbers = float(input('Enter number : ')) lst.append(numbers) ...
953bd41a35828eebc0bb1fba533b222dc0a6ca8b
kabessert1994/My-scripts
/Kieran Python CISS301 Iteration & Recursion.py
985
3.859375
4
# Lab2.py # CISS 301 Winter Quarter 2021 # Coded by Kieran Bessert on 13 Jan 2021 # Last edited by Kieran Bessert on 17 Jan 2021 # Question 1 def One(Num): if Num < 0: print("ERROR: Please Utilize Positive Integers") i = 0 Ans = 0 while i <= Num: Ans += (i*i) i += 1 return A...
f37de1013698130ca4bb6292543ec76bfa31a4de
corneliussigei/hello-world
/Day_3/Andela labs solutions/missing_number.py
174
3.6875
4
def find_missing(a, b): #find the symm. diff (items that are in one or the other but not both) the_list = list(set(a) ^ set(b)) return the_list[0] if the_list != [] else 0
92e682273bf83819d155635c778b5a443ff5e3f7
godspysonyou/everything
/pythonall/ooot12.py
398
3.6875
4
class Person: def __init__(self,name,age,sex): self.name = name self.age = age self.sex = sex def __hash__(self): return hash(self.name+self.sex) def __eq__(self, other): if self.name == other.name and self.sex == other.sex:return True p_lst = [] for i in range(84...
724d678297d3fb0f931a741541cf078cc921257c
ManishRana11/Basic_Python_Codes
/maximum_number.py
379
4.21875
4
def maximum_number(x1, x2): if x1 > x2: print(f"{x1} is greater") else: print(f"{x2} is greater") x1 = int(input("Enter the first number:")) x2 = int(input("Enter the second number:")) maximum_number(x1, x2) # Alternate way a = int(input("Enter first number:")) b = int(input("Ent...
070a7d7f7b9d2a867759f247197ebe2dce6a6b81
saranya-1621/sara.py
/p1.py
133
4.03125
4
num=float(input("enter a numbrer:")) if num>0: print("Positive number") elif num==0: print("Zero") else: print("Negative number")
c3a727c16b7ee68dc2c6b989ce5875e7ad9f236f
suprasannap/ProgrammingProblems
/rotateMatrixWithZip.py
204
3.875
4
def rotate_matrix(a): rotated = [] for col in zip(*a): rotated.append(list(reversed(col))) return rotated print(rotate_matrix([[1,2,3],[4,5,6],[7,8,9]]))
a092b6f53efeabd77fecd9353cb51800d3ed25ed
Tyrhen/Thinkcspy_Solutions
/Chapter26.py
4,398
3.796875
4
import time from random import shuffle class Node: def __init__(self, value=None, next=None): self.next = next self.value = value def __str__(self): return str(self.value) class ListQueue: def __init__(self): self.items = [] self.size = 0 def __str__(self): ...
dd0022b18b153ead8e17ab8dc446535a878b3a86
sureshallaboyina1001/python
/Functions/MultipleStringArds.py
134
3.890625
4
def display(lst): for i in lst: print(i) print("Enter the strings:") lst=[x for x in input().split(',')] display(lst)
f9f8d7a913e4e2cf0c33ce87f77c98405522b00e
kberkey/ccal
/ccal/reverse_complement_dna_sequence.py
205
3.671875
4
def reverse_complement_dna_sequence(dna_sequence): dna_to_complement = {"A": "T", "T": "A", "C": "G", "G": "C", "N": "N"} return "".join(dna_to_complement[dna] for dna in reversed(dna_sequence))
194e2fc5c76c0c594d29429f25efad58de71cefc
greed-dev/pySnake
/pySnake.py
3,997
3.5625
4
import random import pygame from pygame.locals import ( KEYDOWN, K_UP, K_DOWN, K_LEFT, K_RIGHT, K_ESCAPE, K_c, QUIT ) SCREEN_HEIGHT = 500 SCREEN_WIDTH = 500 GRID_HEIGHT = SCREEN_HEIGHT/20 GRID_WIDTH = SCREEN_WIDTH/20 X_STEP = GRID_HEIGHT Y_STEP = GRID_WIDTH x_pos = SCREEN_WIDTH/2 - ...
c5d8aed7b98a16d6521b947e3a570717f644b43e
AhmedElkhodary/Python-3-Programming-specialization
/1- Python Basics/Week3/pro3.py
595
4.5
4
#rainfall_mi is a string that contains the average number of inches of #rainfall in Michigan for every month (in inches) with every month separated #by a comma. Write code to compute the number of months that have more than 3 #inches of rainfall. Store the result in the variable num_rainy_months. #In other words, count...
a0c643d1e257d1d07e209749b466e2a48b67bf60
BenoitStef/LearnPython3
/chapter9/ex40.py
848
4.34375
4
#------------------------------------------------------------------------------- # First class - Learn Python 3 the hard way - page 184 # Author : Benoit Stef # Date : 25.02.2019 #------------------------------------------------------------------------------- class Song(object): #method to init itself whil...
6a30642d8146b29276a82b597ac07ec19a8ff5f5
M0673N/Programming-Fundamentals-with-Python
/exam_preparation/final_exam/02_mock_exam/02_problem_solution.py
335
3.671875
4
import re string = input() pattern = r"(=|/)([A-Z][A-Za-z][A-Za-z]+)\1" destinations = re.findall(pattern, string) destinations_ready = [i[1] for i in destinations] score = 0 for destination in destinations_ready: score += len(destination) print(f"Destinations: {', '.join(destinations_ready)}") print(f"Travel Poi...
7c70905035a69c03922d17f0145ac231600ab92d
AbdielDiazPalomino/Teoria-1
/return.py
661
3.953125
4
#es verdad que no necesariamente tenemos que #escribir return para imprimir esa operación #pero el return no solo sirve para imprimir esos valores #sino tambien para tenerlos ahí pero no imprimirlos #como el daño de ataque de un personaje en un videogame. #o para hacer operaciones como esta #acá le estamos dic...
f238e3cdbe387823a91a7791f89eca6363c76175
tpracser/PracserTamas-GF-cuccok
/week-03/day-3/07.py
342
4.125
4
# create a function that takes a list and returns a new list with all the elements doubled def doubleList(): myList = [10, 20, 30, 40] doubledList = [] a = 0 while a < len(myList): position = a doubledList.append(myList[position]*2) a += 1 print("The doubled list: ", doubl...
4593bb03d24c0bda9fe60283495ee2fcad059ffb
anandlearningstudio/python-codes
/Bubble_sort.py
575
4.28125
4
my_list_soln = [1,2,3,4,8,10] def bubble_sort(my_list): print ("Hello There!!") for i in range(len(my_list)): print ("Outer Loop started.. Whooa!! i is: ",i)#This will always shows you the value of outer loop. for j in range(len(my_list)-1,i,-1): print ("Inner loop also started.. ...
627ee64749cfd4022b0c3e1f5dd70ed6fa98d3c8
Sisyphus235/tech_lab
/algorithm/string/longest_substring_equally_0_1.py
1,200
3.84375
4
# -*- coding: utf8 -*- """ 输入一个字符串,全部由 0 和 1 构成,寻找一个子字符, 使得这个子字符串中 0 和 1 的数量相等, 求子字符串最大长度。 Example 11010111110 最大长度为 4,可以是 1010 (第 2 到 第 5 位), 或者是 0101 (第 3 到 第 6 位) """ def longest_substring_equally_0_1(s: str): # record of difference of 1 and 0 one_minus_zero = 0 # record of the first position of the ...
bc083bd9ff6c417f23920c8b8f751e96db2b463a
roman-sktm/algorithms
/lucky_seven.py
763
3.609375
4
def lucky_seven(A:list): """ Return True if sum three any elements (natural numbers) of list A equal 7 (seven) and print this elements; else - return False. One element of list A can't be a summand twice. """ assert len(A) >= 3, "List must content minimum three values!" B = [] # Filling tempopary li...
0515c12a42b3d54d2150a9108022d45ab0cca0d4
Iris23707/All-project-code
/a3.py
21,275
3.734375
4
import tkinter as tk import random import time from random import choice from tkinter import messagebox TASK_ONE = "task1" TASK_TWO = "task2" ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" UP = "up" DOWN = "down" LEFT = "left" RIGHT = "right" DIRECTIONS = (UP, DOWN, LEFT, RIGHT, f"{UP}-{LEFT}", f"{UP}-{RIGHT}", ...
f7ceb51230de83f1e697f6d44ee3dd7d85b9ddc9
kandrews92/xls_keithley_analysis
/tests/ppt/pptx_method/makeppt.py
6,045
4.03125
4
def get_FilePaths(directory, extension=['']): """ /*-----------------------------------------------------*/ description: This function will generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directo...
299899f6cb6b811ee2601163f2166ab01ab02693
LeiLu199/assignment6
/jl6583/operational_functions.py
1,688
3.640625
4
''' Created on Oct 27, 2014 @author: luchristopher ''' import sys import re from custom_exception import * from __builtin__ import str from interval import * def isLegal(arg_interval_str): '''Returns True if a string representation of an interval(arg_interval_str) is legal, following validations are included: ...
0d084d287d91880df6e38e8c8887150ec4db85da
rrricardo00/python-class
/nomeinicioefim.py
164
4
4
frase = str(input("Digite seu nome: ")).strip() print("Seu primeiro nome é {}".format(frase.split()[0])) print("Seu último nome é {}".format(frase.split()[-1]))
325e31fc2f6622f0e609526cf4bcc01b31ecd49a
ElkinAMG/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/100-print_tebahpla.py
153
4.15625
4
#!/usr/bin/python3 for char in reversed(range(ord('a'), ord('z') + 1)): print("{:c}".format(char if char % 2 == 0 else char - 32), end="")
d919d53aef5c3e6ef0b95d438c44bae4857be208
julienemo/exo_headfirst
/9-reading3med.py
843
4.0625
4
# reading a file as a whole my_file = open('lib.txt', 'r') template = my_file.read() print(template) my_file.close() # reading line by line my_file = open('lib.txt', 'r') while True: line = my_file.readline() if line != '': print(line) else: break my_file.close() # reading line by line aut...
7975b55d9ae90a7a9696f89ee15c9a784007d1d3
sergeevev/tceh_Python
/HW_1/homework_1.py
1,162
3.90625
4
input('Ответь на несколько вопросов. Если готов, нажми Enter.') correct = 0 q1 = input('Какой язык мы изучаем?') if q1 == 'python' or q1 == 'Python': correct += 1 print('Верно') else: print('Ты точно был на занятии?') q2 = input('25 это int или float?') if q2 == 'int': correct += 1 print('Верно'...
ddfe9d075b3d341ed5dec172300c7a824f790cf7
JagadeeshVarri/learnPython
/Basics/prob_6.py
316
4.28125
4
# Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers values = input("Enter values separated by commas',' : ") store_list = values.split(",") store_tuple = tuple(store_list) print('List : ',store_list) print('Tuple : ',store_tuple)
e90ea4c50c0fc032d62d19136c65ded54d275a19
bjsh1/Assignment2-IW
/Question7.py
706
4.21875
4
#7. Create a list of tuples of first name, last name, and age for your friends and colleagues. # If you don't know the age, put in None. # Calculate the average age, skipping over any None values. # Print out each name, followed by old or young if they are above or below the average age. lists=[('Ram','Dashrat',38)...
2357c09714ab21e50474c557c955555d78c8a34d
HyeonJun97/Python_study
/2018_Mid/Problem_2.py
611
3.828125
4
while(True): x=eval(input("행의 개수를 입력하세요: ")) if x>=1 and x<=10: for row in range(x,0,-1): for i in range(0,x-row): print(" ", end='') for j in range(row,0,-1): print(format(j,"2d"),end=' ') ...
68c8ee96d014db5435a08f4c2f61305943e7e06d
UWPCE-PythonCert-ClassRepos/Python210_Fall2019
/students/philip_korte/lesson02/grid_printer.py
2,544
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ grid_printer.py @author: philipkorte """ PLUS = '+' MIN = '-' BAR = '|' # Part 1 def grid_function_1(): """Print a 2x2 square grid.""" grid = range(11) for i in grid: if i % 5 == 0: # print the + and - part of grid ...
0ad709adeb6127859490c57608f781d0a0fa115a
stat88/textbook
/_build/jupyter_execute/content/Chapter_04/01_Cumulative_Distribution_Function.py
6,402
3.796875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: # NO CODE from prob140 import * from datascience import * import numpy as np from scipy import stats import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') import matplotlib matplotlib.style.use('fivethirtyeight') import warnings warning...
8f5278cf636e2d481a119c658e9f6c35a1a63ecc
CoderLeechou/LeetCode-Python
/019RemoveNthNodeFromEndofList/Rnnfeol.py
427
3.578125
4
#-*-coding:utf-8-*- class ListNode(object): def __init__(self,x): self.val=x self.next=None class Solution(object): def removeNthFromEnd(self,head,n): res=ListNode(0) res.next=head tmp=res for i in range(0,n): head= head.next while head!=None: ...
2d7644d21ad38354ba1b9e7dadf43fc4081138d8
josemalcher/Python_Tutoriais
/03-numeros-e-operadores/aula3-2-3-WhileOperadoresLogicos.py
239
4.09375
4
# 3.2.3 While e Operadores Lógicos - Python 3.5 Tutorial # https://www.youtube.com/watch?v=an5NQVJNwOM # # while False: print("FALSE") while True: print("OK, VERDADE") break i = 10 while i < 20: print(i) i = i + 1
2098091239450ebd79a632b91f9a64f2158f5dad
alejandrogonzalvo/Python3_learning
/Crashcourse_python_course/6_Classes/restaurant.py
517
3.703125
4
# !/usr/bin/python3.5 class Restaurant(): """A simple attempt to represent a restaurant irl""" def __init__(self, name, cuissine, ophour, clhour): self.name = name self.cuissine = cuissine self.ophour = ophour self.clhour = clhour def describe(self): print(self.cu...
05e3bbdc13ec6c889bb0c182dbfc86072c5740d6
JaBoBo/quiz-generator
/make_test.py
8,099
3.734375
4
#!/usr/bin/python # format: python take_test.py <input q/a database filename> <output test file name> num_answers_per_question num_qs_to_generate # provide final answer key + scantron type from os import system,name # used to clear screen in windows or linux from random import randint # to randomize questions & answe...
ee19b3f6f9ce25031410348025ad025781fd4b7a
unamfi/sistop-2020-1
/tareas/1/FloresEmanuel-GarcíaAndrea/gato_raton.py
3,120
3.6875
4
import threading import sys #Protege la variable ratones mutex = threading.Semaphore(1) #Protege la variable gatos mutexg = threading.Semaphore(1) #Se usa el patrón multiplex para verificar, que únicamente un animal coma a la vez de un plato, por lo que los animales comiendo a la vez en todos los platos no deben sobre...
ff7df35fc4e590863a45603b5c320c198f67a662
Rheasilvia/PythonLearning
/TensorflowDemo/Scikit_TF/relu.py
769
3.59375
4
import tensorflow as tf #复用relu def relu(X): # 封装在一个scope with tf.variable_scope("relu", reuse=True): threshold = tf.get_variable("threshold") # resue existing variable w_shape = (int(X.get_shape()[1]), 1) w = tf.Variable(tf.random_normal(w_shape), name="weight") b = tf.Variabl...
8ea1d9b51e3c56a6e21a1909ee1883d0fdda501d
venmad/PyBasics
/break_continue.py
1,230
3.921875
4
# program to print the first 50 fibonacci numbers def a(): a = 0 b = 1 print(a, b, end=" ") for i in range(50): c = a + b a = b b = c print(c, end=" ") print() def b(): list = [0, 1] for i in range(50): list.append(list[-1] + list[-2]) for i in l...
1b283d5770c033ad7d1608d62c080fa0ef854d8f
AnandManwani/Python-Codes
/String_formatting&number_conversion.py
453
4.125
4
#print number into decimal , octal, binary, hexadecimal in python def print_formatted(number): # your code goes here for i in range(1, number+1): b = str("{0:b}".format(number)) print(str(i).rjust(len(b)) + str("{0:o}".format(i)).rjust(len(b)+1) + str("{0:X}".format(i))....
cbafb19500ff6ee3b5df91dc9e16b657e13a49c6
ninos77/Bash_Skript_file-merge
/thor.py
9,042
4.125
4
def get_user_int_input(question): # Get input from user called int_input as int based on str question. If input is not int reppet until it is an int. while True: try: int_input = int(input(question)) break except ValueError: print('You have to chose a integer'...
76be9d519792d30af11e0b4968aa1e3b79cd64d0
rvigneshwaran/one-snippet-pro
/python/more-insights/Backup-Utils.py
1,030
3.515625
4
import os as osInstance import time as timeInstance #get the current working directory in python currentDirInstance = osInstance.getcwd() #user can change this to comman line args to pass it from command line sourceDir = [currentDirInstance] targetDir = currentDirInstance #set the target directory to save the dat...
756d934d904236f56ce074ec99b609dafc7a991f
amshrestha2020/IWAssignment-Python-
/DataTypes/SwapString2Char.py
471
4
4
'Program to get a single string from two given strings' 'separated by a space and swap the first two characters of each string' 'Sample String: abc xyz' 'Expected Result: xyc abz' def main(): a = input("Enter First String:") b = input("Enter Second String:") new_a = b[:2] + a[2:] new_b = a[:2] + b[2:]...
60c8e8522aa0ac147b09099f4b78ac24f986aad7
satish-pyboyina/python
/doc.py
261
4
4
def expo(num=2,pow=2): """ this function returns exponential value. num defaults to 2 and pow defaults to 2 """ return num ** pow print(expo(2,3)) print(expo(3)) print(expo(4)) print(expo()) print(expo(pow=5,num=10)) print(expo.__doc__)
525f018628643af9b1fafb20a032302216387e13
JanDimarucut/cp1404practicals
/prac_01/shop_calculator.py
478
4.03125
4
total = 0 number_of_item = int(input("Enter number of items: ")) while number_of_item <= 0: print("Invalid number of items!") number_of_item = int(input("Enter number of items: ")) for i in range(number_of_item): price = float(input("Item price: ")) total += price if total > 100: total_price = t...
42bbd1d37bcd13b522239fc4021efb231c9b5f5c
emilroy/summer21-pythonprojects
/TicTacToe.py
4,411
4.125
4
#Author: Emil #Description: Two player tictactoe game import time #create a dictionary to hold our board's slot number and space to enter X or O board = {'1': ' ' , '2': ' ' , '3': ' ' , '4': ' ' , '5': ' ' , '6': ' ' , '7': ' ' , '8': ' ' , '9': ' ' } p1name = '' p2name = '' def printBoard(board):...
880d0f8a1eb5f1a1ca6d0cbd5b28ac302b59ca97
jucajata/portalIDO-XM
/IDO.py
4,557
3.828125
4
from datetime import datetime print('') print('---------------------------------------') print('Secciones IDO:') print('(1) IDO completo') print('(2) Generación') print('(3) Intercambios internacionales') print('(4) Disponibilidad') print('(5) Sucesos') print('(6) Costos') print('(7) AGC programado') print('(8) Hidrol...
e74c3390e3b22f95302d05efebdd1723aad28c7f
akira2nd/CODES
/Algoritmos e Lógica de Programação/testes/brincando285.py
277
3.6875
4
mes = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'] m = input('Digite uma data DD/MM/AAA : ') m = m.split('/') x = int(m[1]) x -= 1 print('você digitou dia %s de %s de %s' %(m[0],mes[x],m[2]))
137bf8d5c8cbb2157883d08c33f7677a66a8ea78
duyipai/Intelligent-Glove
/sensor_fusion/Generate_data.py
709
3.640625
4
#! /usr/bin/env python3 import sys # To use this script, specify one file, like # 'python Generate_data.py sample_data.txt' # The output file is saved as 'data.txt' in current directory if len(sys.argv) != 2: print('Please specify input file') exit() in_file = open(sys.argv[1]) file_name = (((sys...
ddfddec74472ea281c3e2d844bfbb0e05d5b4a36
ltzp/LeetCode
/剑指offer/斐波拉契数列.py
609
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/9/29 0029 20:44 # @Author : Letao # @Site : # @File : 斐波拉契数列.py # @Software: PyCharm # @desc : """ 可以DP 可以递归 """ class Solution(object): def fib(self, n): """ :type n: int :rtype: int """ F = [0] * (n+...
5c8d66b51e09ad76db78d559880fe47c88f4e538
bluginbuhl/CSV-appender
/csv-sqm.py
3,876
3.671875
4
#!/usr/bin/env python import csv import os import sys from tkinter import filedialog, messagebox from openpyxl import load_workbook import tkinter as tk # load the tk interface application_window = tk.Tk() # define the window as a Tk class application_window.withdraw() # withdraw the root window # def...
c81c8d73a83d4024ea5b601fc2dbea844a477d1a
Leahxuliu/Data-Structure-And-Algorithm
/Python/巨硬/C12.加油站.py
1,685
3.578125
4
''' 一辆汽车,从0要开到n,路线上分布着kk个加油站(0号点必有) 每个加油站可以加a_i油,(1油可以跑1km),假设油箱初始为0,无装油上限,若可以跑nkm 求最少加油次数,不能就输出-1 ''' ''' 贪心 + heap? ''' ''' 类似 45 跳跃 ''' class Solution: def jump(self, nums: List[int]) -> int: if nums == []: return 0 if len(nums) == 1: # 易错 return 0 co...
37fff9cac16ec3922bb60162d1e6ab1bacde2744
josiane-sarda/CursoPythonHbsisProway
/Aulas Marcello/exercicio lista (array) - 6.py
397
3.96875
4
#Faça um algoritmo para ler 20 números e armazenar em um vetor. Após a leitura total dos 20 números, # o algoritmo deve escrever esses 20 números lidos na ordem inversa. print('Números na ordem inversa') numeros = [] for i in range(0, 5, 1): print('Digite o {}º número'.format(i + 1)) num = int(input()) ...
c9be14e5b9a621183a37e6178cfad9de3250f693
claytonchagas/ML-arules-noW
/teste2.py
136
3.921875
4
print("hello world!") x = ["d", "a", "c", "b", ] print(x) x.sort() print(x) string = "ola_mundo" pos = string.find("_") print(pos)
68de463971dffb50fd433b67b09323fdc7483346
cnguyenm/InterviewPreparation
/Tree/IsTreeSymmetric.py
1,858
4.375
4
""" Given a binary tree t, determine whether it is symmetric around its center, i.e. each side mirrors the other. Here's what the tree in this example looks like: 1 / \ 2 2 / \ / \ 3 4 4 3 As you can see, it is symmetric. """ from tree import Tree # # Definition for binary tree: # class Tree(object...
5edcdaf52112dbd6aa74052f5ab9bb793dd0bc16
Valen0320/TutorialesPython
/ejercicio25.py
496
4.125
4
x=int(input("Ingrese coordenada x")) y=int(input("Ingrese coordenada y")) if x>0 and y>0: print("Se encuentra en el primer cuadrante") else: if x<0 and y>0: print("Se encuentra en el segundo cuadrante") else: if x<0 and y<0: print("Se encuentra en el terce cuadrante") ...
6acf389572ac8a8cfabf22594222f99654c01581
roselidev/Studylog
/Algorithm/sort/counting_sort.py
912
3.640625
4
import time import random # O(n*lg(n)) def counting_sort(A, m): tmp = [0]*(m+1) ret = [0]*len(A) for i in A: tmp[i] += 1 for i in range(2, m+1): tmp[i] = tmp[i] + tmp[i-1] j = 0 for i in reversed(range(len(A))): ret[tmp[A[i]]-1] = A[i] tmp[A[i]] -= 1 return ...
f0fedfb59a8c805fb5e40d2552bc7801b2121bb6
madeibao/PythonAlgorithm
/PartA/py二叉树的左面叶子节点之和.py
671
3.640625
4
class TreeNode(object): def __init__(self, x): self.left = None self.right = None self.val = x class Solution(object): def getSumLeft(self, head): if not head: return 0 cur, left, right = 0, 0, 0 if head.left!=None and head.left.left==None and head...
18e88cb8ccb0859909c01217021a60b4f9675149
LorranSutter/HackerRank
/Python/Built-Ins/Any_or_All.py
171
3.765625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT N = input() S = input().split() print(all(int(s) > 0 for s in S) and any(s == s[::-1] for s in S))
890cb664f3d37fbe96408ee6fb89cbc2ac712ccb
baranc/itp-w1-list-of-prime-numbers
/list_of_prime_numbers/main.py
497
4.15625
4
"""This is the entry point of the program.""" def _is_prime(number): #if number < 2: return False for i in range(2, number): if number % i == 0: return False return True def list_of_prime_numbers(max_number): primes_list =[] for number in range(1, max_number+1): if _i...
834c6f862de5d546047fa3a96f047229575e560d
labinkadel/3rdassignment
/qn18.py
269
3.53125
4
# import jsn package to deal with json in python import json print(dir(json)) my_info = {"name": "labin kadel", "age": 27} with open("my_info.json", "w") as write: json.dump(my_info, write) with open("my_info.json", "r") as read: res = json.load(read) print(res)
8e8aac64dd5331b81cda4ff75bd2476b6b711189
adiojha629/CS2103-Machine-Learning-and-Neural-Networks
/PerceptronClass.py
1,585
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 22 10:59:54 2019 @author: Adi """ import numpy as np import math class Perceptron: def __init__(self, numberofInputs): self.weights = [] for i in range(numberofInputs+1):#Plus 1 so that the last weight is the bias self.weights.a...
69bd8a37373f36ea0b914f8f3500a245c12ce5ce
jnthmota/ParadigmasProg
/Exercicio4/Ex2.py
452
4.09375
4
#2 - Mesma letra: Escreva uma função que receba uma string com duas palavras e retorne True # se ambas palavras começarem com a mesma letra. Exemplo: def comecam_com_a_mesma_letra (palavra): partes = palavra.split(" ") if partes [0][0].upper() == partes[1][0].upper(): return True return False resu...
b9cf7c83ffabf5c34d02412069a0fbf2e040d52f
Bluedillydilly/Advent-of-code-2020
/day10/day10.py
879
3.78125
4
from math import prod, factorial INPUT_FILE_NAME = "day10.txt" volts = [int(line.strip()) for line in open(INPUT_FILE_NAME, 'r')] volts += [max(volts) + 3] + [0] order = volts[:] order.sort() diff = [order[i+1] - order[i] for i in range(0,len(order)-1)] print("PART ONE:", diff.count(1)*diff.count(3)) def subDivide(bigL...
f897796985cf77ed9ae7a189586b5da9ab07dd23
WouterDelouw/5WWIPython
/06-Condities/Risk.py
2,621
3.875
4
# invoer dobbelsteen_1_a = int(input('aantal ogen dobbelsteen 1 aanvaller : ')) dobbelsteen_2_a = int(input('aantal ogen dobbelsteen 2 aanvaller : ')) dobbelsteen_3_a = int(input('aantal ogen dobbelsteen 3 aanvaller : ')) dobbelsteen_1_v = int(input('aantal ogen dobbelsteen 1 verdediger : ')) dobbelsteen_2_v = int(inp...
6012cd960117e6ccb24f914ffa1db482f9c3a488
Vana-Vanch/py_algo
/dfs.py
551
3.921875
4
#directed graph graph = { 'a':['b','c'], 'b':['d'], 'c':['e'], 'd':['f'], 'e':[], 'f':[] } # ITERATIVE # def depthFirstSearch(graph, start): # stack = [start] # while len(stack) > 0: # curr = stack.pop() # print(curr, end=" ") # for neighbour in graph...
67f365f75bdaa1a702526f6b4a0840941dba64a4
elenaborisova/Python-Advanced
/18. Exam Prep/list_pureness.py
976
3.65625
4
from collections import deque def rotate_list(numbers): numbers.appendleft(numbers.pop()) return list(numbers) def find_pureness(numbers): curr_pureness = 0 for index, digit in enumerate(numbers): curr_pureness += index * digit return curr_pureness def best_list_pureness(numbers, k): ...
6da33fb87da30dce17204e59c7b0449cd50d58f8
Muhammad-huzaifa18/detailed-assignment-q1-17
/detailed assignment q1-17.py
3,557
3.71875
4
PRACTICE PROBLEM 3.1 a) age = eval(input('Enter your age:')) if age > 62: print('You can get your pension benefits') b) name = (input('Enter the name of any baseball player name:')) if name in ['Musial', 'Aaraon', 'Williams', 'Gehrig', 'Ruth']: print('One of the top 5 baseball players,ever!') c...
63af25aed804c505e134fc12a9b9c65b7af70e3f
cylmemory/CodeTraining
/Leetcode/002--942. DI String Match/Solution.py
1,703
3.5625
4
# -*- coding:utf-8 -*- # 题目: 942. DI String Match # 题目链接:https://leetcode.com/problems/di-string-match/ # 题目大意: # 给出只包含'D'和'I'的字符串S,D代表降序,I代表升序,按照S每个字符代表的升降顺序来返回[0,1...N]符合该顺序的数据,如下: # 条件: # 1.1 <= S.length <= 10000 # 2.S只包含D和I的任意字符串 # # Example 1: # Input: "IDID" # Output: [0,4,1,3,2] # Example 2: # Input: "III" # ...
dcbf0bc6b334d2eca44f9fa6612e027b1f32c4a9
Pooja281196/pooja_repo1
/Blackjack.py
12,747
3.625
4
'''The code presents a blackjack game between 2 players(Player and Dealer).The aim of the game is to get as close to 21points or 21 points without exceeding it. The Player has choices to ask for another card(hit) or stand depending on his cards. The dealer has an automated play of hitting till he/she reaches 17 point...
d2f4c54766ad6670fdaecb0d233c1dacb18e0aef
nachocodexx/IDA-1
/IDA/tools.py
4,833
4.0625
4
import math import numpy def isPrime(p): """ Inputs: p : an integer Output: True if p is prime, False otherwise """ if p<2: return False if p==2: return True if p%2==0: return False for d in range(3,math.ceil(math.sqrt(p))+1): if p%d==0:...
a1285730e75834ad52ee6aa982f2a07fd4273ce0
wesleyzilva/006algoritmoComPython
/aula20201020exercicioAluno.py
1,610
4.03125
4
# Receber 2 notas de um aluno, e a quantidade de faltas. # Verificar a situação do aluno: # reprovado por faltas: faltas > 20 # aprovado: média ≥ 6.0 # prova final: média entre 4.0 e 6.0 # reprovado por média: média menor que 4.0 # algoritmo + código em Python # Declare # nota1, nota2, media real # f...
94ab675e03ca216052da404b27603d7671c6a314
chalkedgoose/l33tcode
/removeduplicatesfromsortedarray/removeduplicatesfromsortedarray.py
797
3.65625
4
class Solution: def removeDuplicates(self, nums: List[int]) -> int: next_new = 0 for i in range(len(nums)): if i == 0 or nums[i] != nums[i-1]: nums[next_new] = nums[i] next_new += 1 return next_new ''' Runtime: 64 ms, faster than...
f7a2cbe5863045a59f7e89eb39a0cc88133c8768
Elohim-Santiago/Projetos-simples
/maior_e_menor_valor_de_um_conjunto.py
462
4.125
4
numero = 1 calculo = 0 quant = 0 Maior = 0 Menor = 0 while numero != 0: numero = float (input("Digite o numero:")) calculo = (calculo + numero) if quant == 1: Maior = Menor = numero else: if numero > Maior: Maior = numero if numero < Menor: Menor = numero if Menor == 0: ...
6cf8f9e83bc90273db4621eaa386d4b8f4b6752d
SHLIM1103/python-basic
/day02/code07-02.py
2,959
3.8125
4
a = [10, 20, 30, 40] """ 리스트의 범위 """ print(a[0]) print(a[3]) # print(a[4]) # 에러 print(a[-1]) # 뒤에서부터 출력 print(a[-4]) # print(a[-5]) # 에러 print(a[0:3]) # 결과: [10, 20, 30] -> index 0 부터 index 3-1 까지 출력 print(a[2:]) # 결과: [30, 40] -> index 2 부터 끝까지 출력 print(a[:2]) # 결과: [10, 20] -> 처음부터 index 2-1 까지 출력 print(a) # ...
38ef8002b0cffedef020c73cb187b9a22717ff25
rohanraj14/python-my-sample
/Firstday/StepOne.py
286
3.84375
4
ip = raw_input() print(ip) ip = ip.split(' ') print(ip) operation = ip[0] int1 = int(ip[1]) int2 = int(ip[2]) if operation == '+': print(int1 + int2) if operation == '-': print(int1 - int2) if operation == '*': print(int1 * int2) if operation == '/': print(int1 / int2)
dfa3beca03945fd8d54afbe0d3b8656f8091b3f7
malinovskiss/Python_2021
/lists.py
495
3.796875
4
#Mainīgais saraksts jeb list # [] #Mainīgais var saturēt dažādus datu tipus my_list = ['Teksts', 1, 2] print(my_list) #Elementu skaits mainīgajā print("Saraksa my_list elementu skaits: ", len(my_list)) #index metode print(my_list[1]) print(my_list[0:]) #elementa maiņa my_list[0] = 'Sveiki' print(my_list) #el...
00007bfe12cf54ef79d08960d05f09f2f058533f
vbelousPy/py_base
/Lesson_03/2.py
126
3.8125
4
text = input("Input text: ") step = int(input("Enter step: ")) i = 0 while i < len(text): print(text[i::step]) i += 1
662e164f4bc6c49940d04a54e51b94f22c2f873d
Philngtn/pythonDataStructureAlgorithms
/Algorithm/Sorting/Practice.py
679
3.6875
4
def qs(array, left, right): pivot = partition(array, left, right) if left < pivot - 1: qs(array,left, pivot-1) if right > pivot: qs(array,pivot, right) def partition(array, left, right): pivot = array[(left + right)//2] i = left j = right while (i <= j): whi...
66e70b1c348f2aac7e413af7d9b754140c64d9bc
somzs/Elso_Telusko3
/Function.py
839
3.734375
4
def update(x): x = 8 print("x: ", x) update(10) x = 7 update(x) a = 10 update(a) # 8, de más az id(x)! # pass by value; pass by reference list = [10,20] a = 10 def change_variable(): global a # emiatt változik meg a globáis változó a = 15 print("function a: ", a) change_vari...
367309f7dc0f24962c0594f60abc934f5eb21225
cool-python-course/course-public
/basics/mote-carlo/manhattan.py
936
3.59375
4
import random from typing import Tuple, Dict from tqdm import tqdm DIRECTIONS = [(1, 0), (0, 1), (-1, 0), (0, -1)] def random_walk(number_of_turns: int) -> Tuple[int, int]: location = (0, 0) for _ in tqdm(range(number_of_turns)): direction = random.sample(DIRECTIONS, 1)[0] location = (locati...
2f0aa5a94b9a28d07aa02b92f5141d1d00233f8e
janinewhite/bitesofpy
/103/winners.py
224
3.5625
4
games_won = dict(sara=0, bob=1, tim=5, julian=3, jim=1) def print_game_stats(games_won=games_won): for key, value in games_won.items(): print(f'{key} has won {str(value)} game{"" if value==1 else "s"}') pass
d5d8eee082bec009b5d3c81015c2c1adddf367f2
Mike-Bryukhov/Cheezy_Pirates_Game
/Ship Repair.py
919
4.25
4
# "Funny repairs" program # Usage of randomly generated numbers as a cycle breaker. import random print('\n Welcome to funny repairs!') ship_hull = int(input('\n Set your ship hull remaining hp:')) while ship_hull <= 0 or ship_hull >= 2401: print('\n The number is wrong. Try number from 1 to 2400.') ship_hu...
f1ca1bdbcd7b7368f2e280bdaa7aa16428ec6f5c
XenikaIllust/Wallbreakers-Leetcode-Solutions
/Week_2/multisets/451-sort_characters_by_frequency.py
642
4.0625
4
""" Having a counter and sorting it in reverse order makes the question really convenient and has less lines of code. After that, its simply just about iterating through the sorted list and appending a new string according to frequency. """ from collections import Counter class Solution: def frequencySort(self, s...
3b6dddaa8a4307f0eefb194ddcd12b4badacfdfe
mdterrenal/caesar-cipher
/test_decoder.py
729
3.84375
4
"""A module to test the methods in the Decoder class.""" import unittest from decoder import Decoder class TestDecoder(unittest.TestCase): """A class to test the functionality of the Decoder class.""" def test_empty_string(self): decoder = Decoder('') self.assertEqual(decoder.decode_message(...
0e7db592508212feff93bb3980da34930fb993da
Abarna13/Py_script
/Programs/Minimum of list.py
391
4.0625
4
#Program for Minimum of a list of Numbers n = int(input("Enter the total number of numbers in the list : ")) a = [] for i in range(0,n): b = int(input("Enter the Numbers : ")) a.append(b) print("The given list is",a) small = a[0] for i in range(0,len(a)): if(small<a[i]): pass else: ...
c4202d76bc11d62e3f1d5def1ca6b7f24ea12f8e
maddrum/Python_Fundamentials_Course
/Old_exams/04 March 2018/01. Padawan Equipment.py
570
3.671875
4
from math import ceil money = float(input()) students = int(input()) lightsaber_price = float(input()) robe_price = float(input()) belt_price = float(input()) student_sabres = ceil(1.10 * students) free_belts = students // 6 needed_belts = students - free_belts needed_money = student_sabres * lightsaber_price + needed...
0b537dce803fc0ce2d760e611bbd7c2bd672cf45
Jay23Cee/100_Day_Challenge
/Python/Merge_two_array.py
749
3.84375
4
def mergeArrays(arr1, arr2, n1,n2): i=0; j=0; k=0; arr3 = [None] * (n1+n2) while i < n1 and j < n2: if arr1[i] > arr2[j]: arr3[k] = arr2[j] j= j+1 k =k+1 elif arr1[i] < arr2[j]: arr3[k] = arr1[i] i =i+1 ...
c469aa301f04991075bab827f1165bd82558aa46
lfdyf20/Leetcode
/TrieClass.py
784
4.1875
4
from collections import defaultdict class TrieNode(object): """ A node for Trie """ def __init__(self): self.nodes = defaultdict( TrieNode ) self.isWord = False class Trie(object): """ A Class for Trie Methods: - insert(word) - search(word) - startsWith(prefix) """ def __init__(self): self.root = Tr...
facc58ef54751062c68eca165c8427f2331da0a6
kesia-barros/exercicios-python
/ex001 a ex114/ex076.py
920
3.734375
4
lista = ('Lapis', 1.75,'Borracha', 2.00, "Caderno", 15.00, "Estojo", 25.00, "Transferidor", 4.20, "Compasso", 9.99, "Mochila", 120.32, "Canetas", 22.30, "livro", 34.90) print("-="*20) print(" LISTAGEM DE PREÇOS") print("-="*20) for pos in range(0, len(lista)): # vai de 0 ate o tamanho da li...
31127ad407b6386ad6c54167028e57cff4a4851c
binamify/python
/factorial.py
337
4.28125
4
# Python Program to calculate factorial num = int(input("Enter a Number: ")) factorial = 1 if num < 0: print("Factorial doesn't exists for negative numbers.") elif num == 0: print("Factorial of 0 is 1") else: for i in range(1, num+1): factorial *= i print("The factorial of ", num ,...