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
a80e15edf0e97f024f05012f9a8541f95676d7e6
joselejinpj/Algorithm
/Python/NonOverlappingIntervals.py
1,043
4.09375
4
""" Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. ----------------- Sample Test Cases ----------------- Test Case 1: Input: [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: [1,3] can be removed and the rest of intervals ar...
84b0e95af6b1e6c64f006e139cf9754a62cac1db
qvantumman/python
/round.py
448
3.5625
4
import random import antigravity round(3.67, 1) print(round(3.6789778,5)) print(2!=3) print() ljlk """def answer(num): if num == 1: return 'one' elif num == 2: return "two" elif num == 3: return 'three' print(answer(random.randint(1,3)))""" def spam(div): try: return 10/div e...
0f1340c8a6ca573e8729fa3ba5d0f2195dfa421d
dsklein/Trailblazr
/data/coord_tools.py
3,785
3.8125
4
# A toolbox of reusable functions involving latitude, longitude, and elevation coordinates import math import requests mean_earth_radius = 6371008.8 # meters # A simple function to request elevation data from The National Map (TNM) elevation API # NOTE: x=longitude, y=latitude def get_elevation(lat_y,lon_x): URL_E...
5cdfcabbfdd01552eb1c7e26c09f00df4140e766
suhasbhattu/python_projects
/db_operations.py
1,652
3.703125
4
import sqlite3 class db_operations: def connect_to_db(self): con = sqlite3.connect('contact_book.db') print('Connected to database') return con def add_contact(self, contact): con = db_operations.connect_to_db(self) cur = con.cursor() cur.execute(...
41a3c87f4494962b830a3fae87ce7864d7b2a502
CHINNACHARYDev/PythonBasics
/venv/ConditionalStatements.py
1,071
4.5
4
# Conditional statements (Selection Statements/Decesion Making Statements) # It will decide the execution of a block of code based on the condition of the expression # 'if' Statement # 'if else' Statement # 'if elif else' Statement # Nested 'if' Statement A = 'CHINNA' B = 'CHARY' C = 'CHINNACHARY' D = 'CHINNA CHARY'...
7014390c7d7031113d04ac773ee1dec33950aeea
KKobuszewski/pwzn
/tasks/zaj2/zadanie1.py
1,623
4.15625
4
# -*- coding: utf-8 -*- def xrange(start=0, stop=None, step=None): """ Funkcja która działa jak funkcja range (wbudowana i z poprzednich zajęć) która działa dla liczb całkowitych. """ #print(args,stop,step) x = start if step is None: step = 1 if stop is None: stop = st...
e0930e5492c95845156463060900eabb738cad42
clark-ethan9595/CS108
/lab03/dict_practice.py
466
4.0625
4
''' A program to print an updated dictionary. Fall 2014 Lab 03 @authors Ethan Clark and Jacob Schott (elc3 and jps29) ''' #Create a dictionary for people and their scores. scoreDict = {'Joe':10, 'Tom':23, 'Barb':13, 'Sue':19, 'Sally':12} #Print Barb's score. print("Barb's score is :", scoreDict['Barb']) #Update Sall...
795ba72cd3cb4e3000dc67ebb46f9d08dc3e7d8e
clark-ethan9595/CS108
/lab10/exercise1.py
1,009
3.5
4
'''A program to see what kinds of errors are out there. Created on Nov 6, 2014 Lab10 @author: elc3 ''' try: import happiness except ImportError as ie: print('Dealt with Import Error:', ie) try: 'hi' + 4 except TypeError as te: print('Dealt with Type Error:', te) try: 10 / 0 except ZeroDivisio...
9aab8e7e48f9e49f5769bd101b6697adb7809ea5
clark-ethan9595/CS108
/lab02/stick_figure.py
936
4.1875
4
''' Drawing Stick Figure September 11, 2014 Lab 02 @author Serita Nelesen (smn4) @authors Ethan and Mollie (elc3 and mfh6) ''' #Gain access to the collection of code named "turtle" import turtle #Give the name "window" to the screen where the turtle will appear window = turtle.Screen() #Create a turtle and name it ...
91023ff23cf97b09c25c2fe53f787aa764c8ca69
clark-ethan9595/CS108
/lab05/song.py
1,076
4.375
4
''' A program to specify verses, container, and desired food/beverage. Fall 2014 Lab 05 @author Ethan Clark (elc3) ''' #Prompt user for their own version of the song lyrics verses = int(input('Please give number of verses for song:')) container = input('Please give a container for your food/beverage:') substance = inp...
8bcb5e719f1148779689d7d80422c468257a9f0f
clark-ethan9595/CS108
/lab02/einstein.py
729
4.21875
4
''' Variables and Expessions September 11, 2014 Lab 02 @author Ethan and Mollie (elc3 and mfh6) ''' #Ask user for a three digit number. number = int(input('Give a three digit number where the first and last digits are more than 2 apart : ')) #Get the reverse of the user entered number. rev_number = (number//1)%10 * 1...
1843fc726c70b019d9299fd4cc8dccd9963e35bd
ankurbansal/projectfunproblems
/euler/dictionary.py
391
3.515625
4
def add(dict,fact): if dict.has_key(fact): dict[fact]=dict[fact]+1 else : dict[fact]=1 def delete(dict,k): if dict.has_key(k): if dict[k]==1: del dict[k] else: dict[k]=dict[k]-1 def compute(dict): value=1; ...
8b9a8adc9586f1ab7b401b9c803e8bd637ab8797
ankurbansal/projectfunproblems
/euler/question19.py
522
3.859375
4
from datetime import datetime,date,timedelta; #1 Jan 1900 v_date=date(1900,1,1); print v_date,v_date.day,v_date.month #date.month=date.__add__() v_date2=date(v_date.year,v_date.month+1,1); print v_date2 d=v_date2-v_date print d print v_date2.weekday() print date(2012,10,29).weekday() count=0; print "~~~~~~~~~~~~~~~~~~...
6bebf290fd631a17db2ac9eb9352ea73edef720b
kimmonti/Bootcamp
/Clases/Fizzbuzz_game.py
663
3.90625
4
# EJ1. Crear un codigo que permita imprimir fizz si un numero es divisible por 3, # buzz si es divisible por 5 y fizzbuzz si es divisible por ambos. def fizzbuzz_game(number): #Creo una función para el juego if (number % 3 == 0) and (number % 5 == 0): #Primero corroboro que sea divisible por ambos return ...
da5f32b3d985ef52be1c5414dd0c277a589703ca
vador/adventofcode2019
/18/mazeKeys.py
11,180
3.5
4
import sys import heapq from queue import Queue def is_door(val): return 'A' <= val <= 'Z' def is_key(val): return 'a' <= val <= 'z' def is_entrance(val): return '0' <= val <= '9' class key_list: _keys = None def __init__(self, keylist=[]): self._keys = keylist def add_key(sel...
aa372c6473c26ab6e552478e744a8685fd35968c
TheBroMoe/Algorithm_Implementations
/bubble_sort.py
252
3.90625
4
def bubble_sort(givenList): numIterations = len(givenList) - 1 for i in range(numIterations): for j in range(numIterations): if givenList[j] > givenList[j+1]: temp = givenList[j] givenList[j] = givenList[j+1] givenList[j+1] = temp
09717d0f20064917bb793cef7e53d826f217d8d6
TheBroMoe/Algorithm_Implementations
/insertion_sort.py
313
4.03125
4
def insertion_sort(givenList): for index in range(1, len(givenList)): searchIndex = index insertValue = givenList[index] while searchIndex > 0 and givenList[searchIndex - 1] > insertValue: givenList[searchIndex] = givenList[searchIndex - 1] searchIndex -= 1 givenList[searchIndex] = insertValue
c141c9e00feebb88f90740e0faf94ef6ea6d6c0a
huajianmao/pyleet
/solutions/a0130surroundedregions.py
1,398
3.8125
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/surrounded-regions/ # # DESC: # ===== # Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. # # A region is captured by flipping all 'O's into 'X's in tha...
a97d7d4f88e8994b5c250b1220b65abc2e336fd1
huajianmao/pyleet
/solutions/a0096uniquebinarysearchtrees.py
855
3.796875
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/unique-binary-search-trees/ # # DESC: # ===== # Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? # # Example: # Input: 3 # Output: 5 # Explanation: # Giv...
70bddc24109ab6f858681ce375a0060a157d027b
huajianmao/pyleet
/solutions/a0060permutationsequence.py
1,122
3.796875
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/permutation-sequence/ # # DESC: # ===== # The set [1,2,3,...,n] contains a total of n! unique permutations. # # By listing and labeling all of the permutations in order, we get the following sequen...
2ab3022ae0ea51d58964fffd5887dbd5f1812974
huajianmao/pyleet
/solutions/a0056mergeintervals.py
1,085
4.21875
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/merge-intervals/ # # DESC: # ===== # Given a collection of intervals, merge all overlapping intervals. # # Example 1: # Input: [[1,3],[2,6],[8,10],[15,18]] # Output: [[1,6],[8,10],[15,18]] # Explan...
eadb2b784b377c2de348e0d77a08683beded327a
huajianmao/pyleet
/solutions/a0207courseschedule.py
1,979
3.875
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/course-schedule/ # # DESC: # ===== # There are a total of n courses you have to take, labeled from 0 to n-1. # # Some courses may have prerequisites, # for example to take course 0 you have to firs...
8d4114729ad09293a0bac2501d974b3369a76fa1
huajianmao/pyleet
/solutions/a0143reorderlist.py
1,188
3.921875
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/reorder-list/ # # DESC: # ===== # Given a singly linked list L: L0→L1→…→Ln-1→Ln, # reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… # # You may not modify the values in the list's nodes, only nodes itself ma...
bbde5f040b3434c52d9b251b9f4a2672e0d7327f
huajianmao/pyleet
/solutions/a0089graycode.py
1,210
3.9375
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/gray-code/ # # DESC: # ===== # The gray code is a binary numeral system where two successive values differ in only one bit. # # Given a non-negative integer n representing the total number of bits ...
3bdea4bd21aef8d38f465cfddd2a9c0a480299bb
huajianmao/pyleet
/solutions/a0133clonegraph.py
1,938
3.859375
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/clone-graph/ # # DESC: # ===== # Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. # Each node in the graph contains a val (int) and a list (List...
eb5dfd3124b557db082044e916455a3f9926773d
huajianmao/pyleet
/solutions/a0064minimumpathsum.py
982
4.03125
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/minimum-path-sum/ # # DESC: # ===== # Given a m x n grid filled with non-negative numbers, # find a path from top left to bottom right which minimizes the sum of all numbers along its path. # # Not...
837ea9966d95ea7509d3f4d0d403ed27a80fbfec
huajianmao/pyleet
/solutions/a0138copylistwithrandompointer.py
1,399
3.953125
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/copy-list-with-random-pointer/ # # DESC: # ===== # A linked list is given such that each node contains an additional random pointer # which could point to any node in the list or null. # # Return a...
cd72d43f6a973cf8d0bb3b522e9226dc7f8eef76
ACES-DYPCOE/Data-Structure
/Searching and Sorting/Python/merge_sort.py
1,939
4.125
4
''' Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the two sorted halves.The merge() function is used for merging two halves. The merge(arr, l, m, r) is key process that assumes that arr[l..m] and arr[m+1..r] are sorted and merges ...
aad803d232b8bb4e205cd3b0cac8233f228b44d3
ACES-DYPCOE/Data-Structure
/Searching and Sorting/Python/shell_sort.py
1,254
4.15625
4
#Shell sort algorithm using python #Shell sort algorithm is an improved form of insertion sort algorithm as it compares elements separated by a gap of several position. #In Shell sort algorithm, the elements in an array are sorted in multiple passes and in each pass, data are taken with smaller and smaller gap sizes....
251ae76c065a5179f5a63badd46940dbe937ee6c
DakTheProgrammer/4883-Programming-Techniques-Wilson
/Assignments/P01/11172/main.py
900
3.84375
4
############################################################################### ## ## Author: Dakota Wilson ## Email: dtw3200@live.com ## Label: 11172 ## Title: UVa 11172 ## Course: 4883 ## Semester: Fall 2020 ## ## Description: ## This program is writte...
4edc8677f42054a52105253d7e524782b8e2d700
chrxr/python_slayer
/app/heroes/hero_builder.py
1,524
3.53125
4
class BaseHero: def __init__(self, name, race): self.name = name self.race = race self.weapon_skill = 4 self.ballistic_skill = 4 self.hit_points = 4 self.strength = 4 self.toughness = 4 self.armour = 0 self.initiative = 2 self.attacks =...
aa2d2168218798f6faeb170c323366eb0be2b567
SH-Bae94/SC
/min/fn/minpy/2.float,max,eval.py
925
3.796875
4
#!/usr/bin/env python # coding: utf-8 # In[16]: a=input("실수를 입력하시오:") b=input("실수를 입력하시오:") c=input("실수를 입력하시오:") # In[17]: values=[a,b,c] #values에 a,b,c 즉 1,2,3 입력 x=max(values) #x에 values의 max값을 입력 y=min(values) #y에 values의 min값을 입력 print(x,y) #x,y값 즉 values의 max와 min값을 출력 # In[18]: concatenate = eval('x+y...
e63cba42e5bf1e6f01ffd2969fb935a76da031e1
khangma/Digital-Image-Processing
/assignment2/Compression/Run_Length_Encoding.py
728
3.546875
4
import numpy as np class rle: def encode_image(self,binary_image): """ Compress the image takes as input: image: binary_image returns run length code """ return np.zeros(100) #replace zeros with rle_code def decode_image(self, rle_...
cc72561c82d1b927ba5c12bdba19c341c3249a64
Vaan525/Bit_seoul
/Keras/2020-11-10/keras09_split2.py
1,249
3.59375
4
# 1. 데이터 import numpy as np x = np.array(range(1, 101)) # 테스트 하고싶은 데이터 y = np.array(range(101, 201)) x_train = x[:60] # 60개 x_val = x[:20] # 20개 x_test = x[:20] # 20개 y_train = y[:60] y_val = y[:20] y_test = y[:20] # [60:80] 61 ~ 80 from tensorflow.keras.models import Sequential from tensorflow.keras.layers...
db09970ae741f144d2d1cc85baed7a1b15a637b7
rosekamau/data_types
/data_type.py
444
3.8125
4
def data_type(z): if type(z) == str: return len(z) elif z is None: return "no value" elif type(z) == bool: return z elif type(z) == int: if z < 100: return "less than 100" elif z == 100: return "Equal to 100" else: return "more than 1...
4fc35071689bad45b1cc4c9c02aee401b1364ccc
shiuchunming/python3_learning
/datatype.py
1,496
4.1875
4
def list(): print("---List---") a_list = ['a'] a_list = a_list + [2.0, 3] a_list.append([1, 2]) a_list.extend(['four', '#']) a_list.insert(0, '1') print("List A: " + str(a_list)) print("Length of list: " + str(len(a_list))) print("Slice List:" + str(a_list[1:3])) print("Slice ...
f68744a8a6c12acb2e1d34fe246d977333cad045
finnmcclone/Databae
/question.py
894
3.71875
4
#CS374 Database Management Final Project # -Finn McClone, Andi Brandsness, James Holtz, and Spencer Gariano # question is a class to hold: # the points awarded if two people match # a dictionary of responses and their corrosponding responseText class Question: # this is a constructor to just make empty dat...
ae392d2820b30a30d09fa291ec1299f283b46180
jackattack1415/pyrosolchem
/src/d02_extraction/extract_least_sq_fit.py
3,480
3.609375
4
import numpy as np import pandas as pd from lmfit import minimize, Parameters, Parameter, report_fit, conf_interval, Minimizer import lmfit from sklearn.linear_model import LinearRegression from src.d00_utils.data_utils import save_data_frame, import_treated_csv_data from src.d03_modeling.model_functions import * de...
56fe12ffb610f7731184276be004b7bd39f58c65
Thiagomrfs/Desafios-Python
/aula 13/desafio053.py
198
3.71875
4
pal = str(input("Digite a sua palavra: ")) var = pal.replace(" ", "").lower() inv = var[::-1] if var == inv: print("\033[34mÉ UM PALÍNDROMO") else: print("\033[31mNÃO É UM PALÍNDROMO")
8fb8ff134ea6d226b205e7982ed6130f733e4337
Thiagomrfs/Desafios-Python
/aula19/desafio093.py
774
4.0625
4
# gerencie o aproveitamento de um jogador de fut: leia o nome de um jogador e a quantidade de partidas, # deois a quantidade de gols em cada partida. No final guarde tudo isso em um # dicionário, incluindo a quantidade de gols feitos no campeonato. jogador = {} jogador["nome"] = input("Insira o nome do jogador: ") j...
cfe6ec5447c21a416f33dff7300b62435d8925fa
Thiagomrfs/Desafios-Python
/aula12/desafio044.py
763
4
4
# 44 - calcule o preço de um produto e a condição. à vista dinheiro/cheque = -10% / à vista cartão = -5% # 2x no cartão = preço normal / 3x no cartão ou + = 20% de juros price = int(input("Insira o preço do produto: ")) print("""Escolha a condição: 1 ) à vista (dinheiro/cheque) 2 ) à vista (cartão) 3 ) 2x no cartão 4 ...
359004666cef99d8256812bc5f84d324d7a1432b
Thiagomrfs/Desafios-Python
/aula 8/desafio017.py
255
3.765625
4
#leia o cateto oposto e o adjacente e dê a hipotenusa import math CO = float(input("Digite o valor do cateto oposto: ")) CA = float(input("Digite o valor do cateto adjacente: ")) print(f"A hipotenusa desse triangulo retângulo é {math.hypot(CA, CO)}")
0a55d30d211c9f74fb34431b5f7d0e1dcf8ef818
Thiagomrfs/Desafios-Python
/aula 14/desafio64.py
522
3.875
4
# leia vários numeros inteiros e pare quando o usuário digitar 999 #depois mostre a quantidade de números e a soma entre eles(desconsiderando o flag) sum = 0 count = 0 resp = "" while resp != "N": print("ATENÇÃO! Digite o número 999 para parar o programa") n = int(input("Digite um número inteiro: ")) count ...
f9c771fff2985618f527b3997a229674ec0e0863
Thiagomrfs/Desafios-Python
/aula 13/desafio056.py
1,000
3.921875
4
# leia nome idade e sexo de cada pessoa e mostre: média de idade do grupo, o nome do homem mais velho e quantas # mulheres tem menos de 20 anos count = 0 somaid = 0 hvelho = "" mulheres = 0 maioridade = 0 for c in range(1, 6): nome = str(input(f"Digite o nome da {c}° pessoa: ")) idade = int(input(f"Digite a ...
90b8d66e95e2e72adacd78f24a3bf8082273ef6b
Thiagomrfs/Desafios-Python
/aula 8/desafio018.py
314
3.984375
4
#mostre o seno, cosseno e tangente de um ângulo import math ang = float(input("Digite o valor do ângulo desejado: ")) print(f"Para o ângulo {ang}°, temos {math.cos(math.radians(ang)):.2f} como cosseno, {math.sin(math.radians(ang)):.2f}" f" como seno e {math.tan(math.radians(ang)):.2f} como tangente.")
10c907612e4dc729045fa33ec56d1044f65448ce
Thiagomrfs/Desafios-Python
/aula22/utilidadesCev/dados.py
560
4.03125
4
def verifica_num(num): while num.isnumeric() != True: num = input("\033[31mInsira um valor numérico: \033[m") return num def leia_dinheiro(): num = input("Insira um valor: ") if num.isnumeric() == False: if "," in num: num = num.replace(",", ".") return float(num...
8d2a7fde1146845c98bf72beb7e2b4d68cb994da
Thiagomrfs/Desafios-Python
/aula22/desafio0108.py
574
3.703125
4
# adapte o 107 para mostrar os valores monetários formatados from utilidadesCev import moeda from utilidadesCev import dados num = float(dados.verifica_num(input("Insira um valor: "))) print(f"O valor {moeda.formatado(num)} dobrado é: "+moeda.formatado(moeda.dobro(num))) print(f"O valor {moeda.formatado(num)} adiciona...
a66605fe7c586639962a4a76a794a8337d902f7f
Thiagomrfs/Desafios-Python
/aula 13/desafio048.py
195
3.90625
4
import math sum = 0 cont = 0 for c in range(1, 501, 2): if c % 3 == 0: cont = cont + 1 # cont += 1 sum = sum + c # sum += c print(f"The sum of these {cont} numbers is {sum}.")
724251e44fc98f99a179f920d0be34bccf090e21
Thiagomrfs/Desafios-Python
/aula12/desafio043.py
566
4.0625
4
# 43 - calcule o IMC de uma pessoa e categorize. -18.5 = abaixo do peso / 18.5~25 = ideal / 25~30 = sobrepeso # 30~40 = obesidade / +40 = obesidade mórbida. peso = int(input("Insira seu peso: ")) heigth = int(input("Insira a sua altura: ")) IMC = peso/heigth**2 if IMC <= 18.5: print("Você está abaixo do peso") e...
1bcb75a3018db4787bf38568854b6030e833ae55
Thiagomrfs/Desafios-Python
/aula 18/desafio087.py
1,113
3.796875
4
# aprimore a matriz mostrando a soma dos valores pares, a soma da 3º coluna e o maior na linha 2 valores = [] col1 = [] col2 = [] col3 = [] pares = [] for c in range(1, 4): num = int(input(f"Insira o valor da posição 1x{c}: ")) col1.append(num) if num % 2 == 0: pares.append(num) for c in range(1,...
6889b82627be17f6d366f625fb5253845e81f328
LeidyJr/Python
/coincidence.py
207
3.71875
4
def arrayCoincidence(arr1): for i in range(len(arr1)): if (arr1[i]==i): print(i); elif(arr1[i]!=i): print(-1); # Arreglos arr1=[4,1,2] arrayCoincidence(arr1);
cf021fb2c318d5ed8b831e1f398e76c1258cee08
justAcoderguy/Alien-Invasion-Game
/ship.py
1,626
3.71875
4
import pygame class Ship(): def __init__(self, screen, ai_settings): """Initialising ship and its starting position""" self.screen = screen self.ai_settings = ai_settings # Loading ship image and its rect self.image = pygame.image.load('images/ship.bmp') self.rect...
73c666d221803d3d6a7394fa18e9a5afa1d01af8
lcsgauna/exercicios-python-cursoemvideo
/exercicios-mundo-2/ex044.py
1,366
3.828125
4
# Elabore um programa que calcule o valor a ser pago por um produto, # considerando o seu preço normal e condição de pagamento: # - À vista dinheiro/cheque: 10% de desconto # - À vista no cartão: 5% de desconto # - Em até 2x no cartão: preço normal # - 3x ou mais no cartão: 20% de juros valor_do_produto = float(input...
e893dee3424a043a9de2196243bb28a1450a3166
lcsgauna/exercicios-python-cursoemvideo
/exercicios-mundo-2/ex062.py
715
4.03125
4
# Melhore o desafio 061, perguntando para o usuário se ele # quer mostrar mais alguns termos. O programa encerra quando ele # disser que quer mostrar 0 termos. print('Gerador de PA') print('-='*10) primeiro_termo = int(input('Primeiro termo: ')) razao = int(input('Razão: ')) termo = primeiro_termo contador=1 total = 0...
7ab206c4b440353cf23d46b674b5908e557867f8
lcsgauna/exercicios-python-cursoemvideo
/exercicios-mundo-2/ex036.py
800
4.09375
4
# Escreva um programa para aprovar o empréstimo bancário para # a compra de uma casa. O programa vai perguntar o valor da casa, # o salário do comprador e em quantos anos ele vai pagar. # Calcule o valor da prestação mensal, sabendo que ela não pode exceder # 30% do salário ou então o empréstimo será negado valorImove...
aa9f117c48610b59b44c3af5e8c5dfb0b3687fc7
lcsgauna/exercicios-python-cursoemvideo
/exercicios-mundo-2/ex064.py
473
4
4
# Crie um programa que leia vários números inteiros pelo # teclado. O programa só vai parar quando o usuário digitar # o valor 999, que é a condição de parada. No final, mostre # quantos números foram digitados e qual foi a soma entre eles # (desconsiderando o flag) num=0 cont = 0 soma=0 while num != 999: num = i...
507404a5065aef9590a71e2653f6a764c5635a35
lcsgauna/exercicios-python-cursoemvideo
/exercicios-mundo-1/ex030.py
294
4.09375
4
# Crie um programa que leia um número inteiro # e mostre na tela se ele é PAR ou IMPAR. numeroEscolhido = int(input("Me diga um número: ")) if numeroEscolhido % 2 == 0: print("O número {} é PAR".format(numeroEscolhido)) else: print("O número {} é IMPAR".format(numeroEscolhido))
fc297944d72133e54ad45b13d3d3ae3b3d8b5c65
lcsgauna/exercicios-python-cursoemvideo
/exercicios-mundo-2/ex043.py
827
3.984375
4
# Desenvolva uma lógica que leia o peso e a altura de uma pessoa, # calcule seu IMC e mostre seus status, de acordo com a tabela abaixo: # - Abaixo de 18.5: Abaixo de peso # - Entre 18.5 e 25: Peso ideal # - 25 até 30: Sobrepeso # - 30 até 40: Obesidade # - Acima de 40: Obesidade mórbida peso = int(input("Qual é seu ...
bf41de9acbc41869bd103d2b22be3377a4b3a5b3
bhartendudubey/Multiplication-Table-App
/tables.py
2,153
3.796875
4
from tkinter import * def ShowTable(): table = entry.get() two = int(table) * 2 three = int(table) * 3 four = int(table) * 4 five = int(table) * 5 six = int(table) * 6 seven = int(table) * 7 eight = int(table) * 8 nine = int(table) * 9 ten = int(table) * 10 ...
57c1adf2144899ced5d4a7b1ac32b2024719179e
tpap50/Programming-Training
/MIT6_0001F16/Assignments/Problem Set 3/testing_play.py
831
3.515625
4
import unittest import sys sys.path.append("/Users/tompapas/Documents/Programming/Programming-Training/MIT6_0001F16/Assignments/Problem Set 3") import ps3test words = {("", 7):0, ("it", 7):2, ("was", 7):54, ("weed", 6):176, ("scored", 7):351, ("WaYbILl", 7):735, ("Outgnaw", 7):539, ("fork", ...
cb347c385eb6c423520f31ba1366b8bc68c6147d
ankitaJagtap/shell
/hashmap.py
387
4.03125
4
def hashmap(str1,str2): dict1={} str1=str1.split() str2=str2.split() for i in str2: dict1[i]=str2.count(i) print(dict1) for i in dict1: if dict1[i]==str1.count(i): continue else: return False return True string="two times three ...
8ced615596c0691a910b95b8ea18db97e36a2e78
jobiaj/Problems-from-Problem-Solving-with-Algorithms-and-Data-Structures-
/Chapter_01/sum_foo.py
198
3.59375
4
import time def foo(tom): start = time.time() fred = 0 for bill in range(1, tom+1): barney = bill fred = fred + barney end = time.time() return fred, end-start print(foo(10))
a09c2652fa5d723f481d85a5ab8e61c3f3fe2292
jobiaj/Problems-from-Problem-Solving-with-Algorithms-and-Data-Structures-
/Chapter_01/anagram_Solution2.py
310
3.78125
4
def anagram_solution2(s1,s2): a_list1 = list(s1) a_list2 = list(s2) a_list1.sort() a_list2.sort() pos = 0 matches = True while (pos<len(s1) and matches): if a_list1[pos] == a_list2[pos]: pos = pos + 1 else: matches = False return matches print (anagram_solution2("abcd", "dcba"))
7cae8389c94b7ddf8c357aafc1462e61584a331d
jobiaj/Problems-from-Problem-Solving-with-Algorithms-and-Data-Structures-
/Chapter_04/turtle_code.py
272
4.09375
4
import turtle my_turtle = turtle.Turtle() my_win = turtle.Screen() def draw_spiral(my_turtle, line_len): if line_len > 0: my_turtle.forward(line_len) my_turtle.right(120) draw_spiral(my_turtle, line_len - 5) draw_spiral(my_turtle, 200) my_win.exitonclick() main()
b6b899c2f95c682bf53e170bbc2c90e9fef846c7
denilbhatt0814/Checkers_in_python
/checkers/piece.py
1,444
3.828125
4
from .constants import RED, SQUARE_SIZE, GREY, CROWN import pygame class Piece: PADDING = 15 OUTLINE = 3 def __init__(self, row, col, color): self.row = row self.col = col self.color = color self.king = False #setting direction for peice to move if self.co...
fe77acbc97be7ea713e32aee028de7cd54f7c5e0
farahnorma/Homework6
/patterns.py
821
3.78125
4
#Norma #patterns2.py def triangle(N): print("This is your triangle: ", '\n') for count in range(N): for i in range(count+1): print(end=' ') for x in range(N - count): print('*', end='') print() def hollow_box(N): print("This is your box: ", ...
119ebe5effccde23e28afc67ecf6b9bc0e58fec8
jeramiefletcher/bstl-scala
/spark/src/test/resources/scripts/WorkingDays.py
8,582
3.859375
4
from datetime import timedelta, date import re def workday(datevalue, offset): # ------------------------------------------------------------------------- # Workday Function # ------------------------------------------------------------------------- datevalue = str(datevalue) # use regex to to sep...
1fe3b264d7f90067f40e310061cd45a1532b1117
faizanzafar40/Intro-to-Programming-in-Python
/2. Practice Programs/2. greet_user.py
144
4.1875
4
''' Write a program that asks user their name and greets the user: ''' name = str(input("Enter your name: ")) print("Hello, how are you", name)
f5cf5e85ffd22f6a59d4d1c1f183b2b668f82e29
faizanzafar40/Intro-to-Programming-in-Python
/2. Practice Programs/6. if_statement.py
298
4.1875
4
""" here I am using 'if' statement to make decisions based on user age """ age = int(input("Enter your age:")) if(age >= 18): print("You can watch R-Rated movies!") elif(age > 13 and age <= 17): print("You can watch PG-13 movies!") else: print("You should only watch Cartoon Network")
849333f5889c432c219263908a0d789ce93f428e
faizanzafar40/Intro-to-Programming-in-Python
/2. Practice Programs/22. get_largest_item.py
666
3.96875
4
''' Given a list of strings(names), write a function(get_largest_item) that takes that list and returns the item with more number of characters ''' def f1(names): lenlist = [] for i in names: a = len(i) lenlist.append(a) return lenlist def get_largest_item(lenlist,names): maximum = 0 ...
a43da9c440c8e4ed7d15f1791cf06dad0ab6b1b8
faizanzafar40/Intro-to-Programming-in-Python
/2. Practice Programs/7. list_example1.py
156
3.6875
4
""" here I am printing a list of animals using 'print' statement """ animals = ['dog', 'cat', 'tiger', 'lion', 'trump', 'bufallo', 'zebra'] print(animals)
ec7b21ecd84c569359c1f6cf724f987c969bbdcd
faizanzafar40/Intro-to-Programming-in-Python
/2. Practice Programs/24. string_functions.py
212
3.890625
4
name = " faizan zafar " print(name.strip()) print(name.capitalize()) print(name.center(40)) print(name.count("e")) age = input("enter your age") print(age.isdigit()) name = name.replace('l', 'la') print(name)
c16323fdf1d78bac52e463c084c7781077e50f74
faizanzafar40/Intro-to-Programming-in-Python
/5. Full Exercises/e6_crack_pincode.py
836
3.9375
4
""" Problem ------- Take a numeric pin code as input and let your program crack it by checking different combinations. print it as you match the combinations Start with a pin length of 4 and experiment with larger pin codes when done. Example: Enter your pincode: 1025 checking combination: 1000 checking combination...
ce5ae7e6d228bb64dae26346a66061fb43ea422b
spawulski/python
/assignments/pythong.py
843
3.6875
4
"""Context Manager.""" """Easy file manipulation.""" class OpenFile: """Class that will function as a Context Manager.""" def __init__(self, filename, mode): """Initialize OpenFile class.""" self.filename = filename self.mode = mode def __enter__(self, content): """Manip...
4883263a6c26b07160bb999581ccc08777fb343e
spawulski/python
/assignments/webapp/app.py
568
3.671875
4
""" My first Python web app. Use flask to build a basic web application. """ from flask import Flask, render_template app = Flask(__name__) @app.route('/') def index(): """Render index.html.""" return render_template('index.html') @app.route('/cakes') def cakes(): """Render cakes.html.""" return r...
c56354bd9e49655c5f7f4a4c8f009ee7c13b7272
razi-rais/toy-crypto
/rsa.py
1,457
4.1875
4
# Toy RSA algo from rsaKeyGen import gen_keypair # Pick two primes, i.e. 13, 7. Try substituting different small primes prime1 = 13 prime2 = 7 # Their product is your modulus number modulus = prime1 * prime2 print "Take prime numbers %d, %d make composite number to use as modulus: %d" % (prime1, prime2, modulus) prin...
a9fdc54482403b170cda925a7c1e93016a4750b7
jagallegos4/actividadMN1
/A1.ejercicio6.py
311
3.9375
4
import math x = math.pi/3 exp = 1 seno = 0 compara = 1 i = 1 while math.fabs(compara - seno) > 0.001: compara = seno if i % 2 == 0: seno -= (x ** exp) / math.factorial(exp) else: seno += (x ** exp) / math.factorial(exp) exp += 2 i += 1 print("El seno de pi/3 es: ", seno)
2454892e27a8fbd7c521ea7fabc3348112d3e8dd
zjbao123/learn_python_demo
/python27/algorithm/selection_sort.py
625
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'zjbao123' def selection_sort(sort_list): iter_len = len(sort_list) if iter_len<2: return sort_list for i in range(iter_len-1): smallest = sort_list[i] location = i for j in range(i+1,iter_len): ...
b7122c2fe6dbefae5c4a15841d5f22129b3d8abf
zjbao123/learn_python_demo
/python27/algorithm/quick_sort.py
991
3.78125
4
#!/usr/bin/env lowython # -*- coding: utf-8 -*- __author__ = 'zjbao123' class quick_sort(object): def _partition(self, alist, low, high): i, j = low, high x = alist[low] while i < j: while i < j and alist[j] >= x: j -= 1 if i < j: ...
221148ad5bd229e13678c535e810cf88001dd3ac
tisalowts/test
/oop/111.py
429
3.640625
4
class Person(): name = "init" age = 0 __age = 0 _name = "halfname" def sleep(self): print("sleep.....") def Work(self): print("Get some money") class Teacher(Person): name = "zhaolinger" # def Work(self): # Person.Work(self) # print("teacher students") # d...
9185ed921103efce7bc35eecbdbe44b9b3017e8b
BeatrizAmieiro/Jogo-da-Forca
/forca_12-11-2019-master/forca.py
2,921
3.859375
4
#importando pacotes e módulos necessários from random import randint from utilidades import menu from utilidades import desenho from utilidades import palavra import os #Chamando o menu principal e o menu de dificuldade dif=2 opcaoMenu = menu.menu() if opcaoMenu == 2: opcaoDif = menu.dificuldade() if opcaoDif ...
8564acda157deee5822a451959a53b30982b26f3
markoseb/Matura_Inf_Python
/inf/csv_data.py
1,691
3.9375
4
import pandas as pd import os import requests import pprint def Read_course_from_csv(symbol="USD"): """ The function to get current currency rate from Exchange_rates.csv file Parameters: symbol (str): The symbol to return. Returns: current prise: A current curre...
6cabde04cac34749f2fb5e87dc6c99c57742f3ea
NeuPasha/PythonBasics
/Lesson5/divisor_master.py
714
3.578125
4
def if_simple(x): if x % 2 == 0: return x == 2 a = 3 while a * a <= x and x % a != 0: a += 2 return a * a > x def divisors(x): div = [] for i in range(1,x+1): if x % i == 0: div.append((i)) return div def biggest(x): for i in reversed(range(1,x+1)): ...
4e50815ed9421f7c693e8e2168f416491932a5e2
june2413/python3
/ex08.py
1,036
3.71875
4
# 차량 2부제 프로그램 # date = int(input('오늘 날짜를 입력하세요')) from datetime import datetime as dt date = dt.now().day date = dt.today().day num = int(input('차량번호 4자리를 입력하세요')) print(f'오늘 날짜 : {date}일') if date % 2 == 0: print('오늘입차 : 번호가 짝수인 차량') if num % 2 == 0: print('입차 가능합니다') else: print('입차 불가 ...
1a7d4dee8206867c65d498ac9892b1690092ec75
june2413/python3
/ex16.py
2,032
3.78125
4
# 수학시험 프로그램 quiz = ('3+2', '5//2', '10-2', '(10**2)*2', '1-(10 % 4)', '2**4', '4/2') answers = [] solution = ['5', '2', '8', '200', '-1', '16', '2'] right = [] wrong = [] for i in quiz: answer = input(f'문제 : {i}') answers.append(answer) for i in range(7): if answers[i] == solution[i]: right.append...
d5b86cab616cf322e731f9387e6d957ed44e658c
saibabu2811/MySampleProject
/remove_empty.py
1,089
3.5625
4
import json import os filepath = input("Enter the input json file path::") try: f = open(filepath) try: data = json.load(f) f.close() print("Input:" + str(data)) def dictCheck(dkey,dvalue): if not dvalue: del data[kst] return ...
75709069d3d3a0921f8fd439371d6d89540f7634
KobatosPony/tensorflow-test
/chapter1(MNIST)/demo02.py
1,966
3.53125
4
from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np if __name__ == '__main__': #加载 mnist 数据 mnist = input_data.read_data_sets('MNIST_data', one_hot=True) # 使用更方便的 InteractiveSession 代替session可以让你在运行图的时候插入一些计算图 sess = tf.InteractiveSession() ...
26960cd52e3c63adcedc75d86f102741dea7aace
nitishjatwar21/Competitive-Coding-Repository
/Bit Manupulation/Is Power Of 2/is_pow_of_2.py
238
4.4375
4
def is_pow_of_2(num): return (num and (not(num & (num-1)))) number = 5 if(is_pow_of_2(number)): print("number is power of 2 ") else: print("number is not a power of 2") ''' Input : 5 Output :number is not a power of 2 '''
1e46d77cee0ab60606c1fe24fd90ef39361d865d
AMKreme/summit
/summit/multiview_platform/utils/transformations.py
875
3.984375
4
import numpy as np def sign_labels(labels): """ Returns a label array with (-1,1) as labels. If labels was already made of (-1,1), returns labels. If labels is made of (0,1), returns labels with all zeros transformed in -1. Parameters ---------- labels The original label numpy ar...
0bfcf20dfd43f16726202ac672c7d247a99f4e84
eastonsuo/Python_exercise
/1.linked_list/functional-linked-list.py
4,626
4.28125
4
# implementing a linked list data structure in Python using a Lisp-like functional style. # https://dbader.org/blog/functional-linked-lists-in-python # Nil represents the empty list # 练习使用递归 Nil = None # cons operation extends a list at the front by inserting a new value def cons(x, xs=Nil): return (x, xs) asse...
2d727e0acb9fcca8ecee72742970dbc8831af33d
RodolfoBaez/financial-calculators
/main.py
1,662
4.21875
4
print("Welcome to Financial-Calculators ") print("What would you like to calulate ") print("") print("1. Bank Savings Account Interest ") print("2. Stock Market Growth Per Year") print("") user_choice = input("Input your response ") if user_choice == "1": print("Using the Annual Inflation Rate Of 2.5%, We Will Te...
c98d1cc1022a5f236f35a4a257c0d485d5d463d1
sirdesmond09/mypython-
/test.py
598
3.96875
4
a=4 b=3 w=4 y=((a+b)/w) add=(a+b+w) print ("adding a and b, then dividing by w, gives:",y) print("the sum of a,b,w:",add ) print("the product of b and w:",b*w) print("dividing a and w, gives",a/w) #this is just a practical name=input("enter your username") e=int(input("enter a value for e")) f=int(input("enter a valu...
7715a9ad5a59aa0962b4257520b0143b0b9e98ea
sirdesmond09/mypython-
/pro.py
2,901
4.125
4
print("WELCOME TO MATHCALS") operations=['Add', 'Sub', 'Mult', 'Divi'] print(operations) g=1 q=int(input("Choose the number of times you want to solve ")) while g<=q: gee=input("choose your arthimetric operation") if (gee==operations[0]): w=int(input("are you adding 2 or 3 numbers")) if (w==2): ...
29c96a0b21786f71005b2c79e10368f755d0f98f
YaserMarey/AI_for_Medicine_deeplearning.ai
/AI_for_Medical_Diagnosis/W_3/utf-8''AI4M_C1_W3_lecture_ex_03.py
14,435
3.953125
4
# coding: utf-8 # # AI4M Course 1 week 3 lecture notebook # ## U-Net model # In this week's assignment, you'll be using a network architecture called "U-Net". The name of this network architecture comes from it's U-like shape when shown in a diagram like this (image from [U-net entry on wikipedia](https://en.wikiped...
792132695ddc76aa3e898c87eac3cc1b313cfc46
alourie/parade
/parade2.py
1,887
3.65625
4
#!/usr/bin/python import sys class City(object): def __init__(self, name): self.righties = [] self.hasLefties = False self.name = name def addRight(self, city): if not ( self.name == city.name or city.name in (righty.name for righty in self.righties) ...
f07f36d32e9514a3ae913e41aea60ec9acea386b
FranHuzon/ASIR
/Marcas/Python/Ejercicios/Final Evaluacion 1/Ejercicio 4.py
1,997
3.65625
4
#-------------------- CREACION LISTA --------------------# almacen = [] precio_con_iva = [] #-------------------- FIN CREACION LISTA --------------------# #-------------------- AÑADIR ARTICULOS --------------------# codigo_articulo = int(input('Código del artículo: ')) while codigo_articulo != 0: nombre_articulo = inp...
4b5d6455c9f53c4a97645c4d2443706e83bde4bc
FranHuzon/ASIR
/Marcas/Python/Ejercicios/Final Evaluacion 1/Ejercicio 5.py
5,102
3.84375
4
#-------------------- INTRODUCIR DATOS --------------------# cantidad_total = float(input('Cantidad total: ')) cantidad_entregada = float(input('Cantidad entregada: ')) cantidad_devolver = print ('Cantidad a devolver: {}'.format(round(cantidad_entregada - cantidad_total,2))) cantidad_devolver_2 = round(cantidad_entrega...
c67a86b7932e9a52d5861a573cf5472a0c269ee2
FranHuzon/ASIR
/Marcas/Python/Ejercicios/Funciones/Ejercicio 1.py
991
3.640625
4
from Funciones import convertir_a_segundos, calcular_coste, convertir_a_euros tarifa = int(input('Coste por segundo (Centimos): ')) llamadas = int(input('Indica el número de llamadas realizadas: ')) llamadas_duracion = [] total_segundos = 0 indice = 1 for elem in range(llamadas): lista = [] print ('Indica la du...
5a25d397ed98da278f080f2d97fd9149c33e403e
FranHuzon/ASIR
/Marcas/Python/Ejercicios/Listas/Ejercicio 2.py
2,246
4.3125
4
#-------------------- CREACIÓN LISTA --------------------# palabras = input('Escribe la palabra que quieras añadir a la lista (Para terminar pulsa ENTER sin escribir nada): ') lista_palabras = [] while palabras != '': lista_palabras.append(palabras) palabras = input('Escribe la palabra que quieras añadir a la lista ...
a32c70a414afe5a7b939ea4e54ceafd3d3cfd7dd
kennethjmyers/ds
/pairwork/mcnulty1/thursday_factorial.py
447
3.671875
4
from functools import reduce import unittest def f_fact(n): if n>1: return reduce(lambda x,y: x*y, range(1,n+1)) elif n == 0: return 1 else: return print('Bad Input') class TestFactorial(unittest.TestCase): def test_factorial(self): self.assertEqual(f_fact(5), 120) ...