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
8f4f69e8893fb4b6b8f5a1796e6557ef9e181a83
hiSh1n/learning_Python3
/py_project08.py
141
4.125
4
#To accept a positive value from a user and prints the square of the number. positive_no = int(input("enter a no. ")) print(positive_no**2)
b6d75f871bb2a85f93d87234fd97c73cd7350ecf
hiSh1n/learning_Python3
/Day_02.py
1,249
4.3125
4
#This is day 2 #some variable converters int(),str(), bool(), input(), type(), print(), float(), by default everything is string. #Exercise 03- #age finder birth_year = input("what's your Birth Year:") age = (2021 - int(birth_year)) print("your are " + str( age) + " years old !") print(" ") ...
d6c402df355a719358c4e8e113e2b39de8744d47
hiSh1n/learning_Python3
/py_challenge01.py
706
4.09375
4
#5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Ente...
f18af1407eea2d8808465da0491bf766f57858df
suryakarki/6th-Semester-College-Project
/SignUp.py
4,633
3.640625
4
import cx_Oracle import re class Signup: def __init__(self): self.fname = '' self.lname = '' self.gen = '' self.mob = 0 self.eml = '' self.al1 = '' self.al2 = '' self.addr = '' self.city = '' self.state = '' self...
b6ec7850d06b74c6009467c3dc860bde78298164
DanielHabib/HowManyBalloons
/HowManyBalloonsAlg.py
514
4.125
4
"""How Many Balloons Alghorithm""" import math class BalloonCount(object): grams = 453.593 liters_in_balloon = 14 def __init__(self, weight): self.weight = weight def how_many_balloons(self): balloons = self.weight * self.grams / self.liters_in_balloon return ("It would take %...
fe8eda8d33813fc75672649d78bb805919aed155
CTEC-121-Spring-2020/mod-5-programming-assignment-Ilya-panasev
/Prob-2/Prob-2.py
2,156
3.71875
4
# Module 4 # Programming Assignment 5 # Prob-2.py # Ilya Panasevich """IPO Inputs: total cost of transaction, amount tendered Process: takes the amount tendered and the total transaction cost to return the amount of change in appropriate denominations. Outputs: summary line containing the total cost, amount...
b1c4194a1e5c7b458670c65aa3da8a1f6defb201
jacecao/python-game
/reversi/main.py
9,565
3.828125
4
# 64格棋盘游戏 # 相比Tic Tac Toe更厉害的AI # # 游戏玩法: # X O 代表双方落子,在不同方向中只要一方中间的对方落子就会变为己方落子 # 例如 X O O X => X X X X # 最终谁的棋子多谁获胜 import random import sys SPACE = ' ' * 5 SPACE_3 = ' ' * 3 # 记录上一个落子的坐标 # 第一个元素记录x坐标,第二个元素记录y坐标,第三个元素记录是什么落子‘x’'o' MOVED_X_Y = [] # 绘制棋盘数据 def drawBoard(board): HLINE = '+' + '---+' * 8 print(S...
5e0cd0722bd3d2e59a77e3a36c40963138013305
jacecao/python-game
/hangman/test.py
1,863
3.890625
4
''' word = 'hello' for s in word: print(s) lis = [1, 3] for i in lis: word = word[:i] + '_' + word[i+1:] print(word) ''' missLetters = '' correctLetters = '' secretWord = getRandomWord(words) puzzleList = getPuzzleIndexList(secretWord) puzzleWord = getPuzzleWord(secretWord, puzzleList) hideWord = getHideWord...
45e07dd6b8722c4f6223fe86f545eefba2c15028
thaalank/connect_four_nn
/randomVSminimax.py
1,277
3.671875
4
from randomAI import manage_ai_input import minimax from connect4 import Connect4 import time # play the random ai against another random ai and print the board after each move # do this 10 times and record the number of times blue won and the number of times red won NUM_TRIALS = 100 # define the AIs and the number ...
f0ff74f068802834c8cdc29472e34397c82c1c15
rfaguiar/python3-OO
/datas.py
237
3.609375
4
class Data: def __init__(self, dia = 1, mes = 1, ano = 2018): self.__dia = dia self.__mes = mes self.__ano = ano def formatada(self): print("{}/{}/{}".format(self.__dia, self.__mes, self.__ano))
a61941a1d02f0fe26da9dfb3586341bcaa5cb419
joshuaabhi1802/JPython
/class2.py
793
4.125
4
class mensuration: def __init__(self,radius): self.radius=radius self.pi= 22/7 def area_circle(self): area = self.pi*self.radius**2 return area def perimeter_circle(self): perimeter = 2*self.pi*self.radius return perimeter def volume_sphere(self): ...
d25b0789d0995741201d0ec2117bb34b0eae8326
cybersaksham/flavor-predictor
/main.py
744
3.671875
4
import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.tree import DecisionTreeClassifier # Importing Data data = pd.read_csv("flavour.csv") # Encoding Gender Enc = LabelEncoder() Enc.fit(["Male", "Female"]) # Male - 1 & Female - 0 data["Gender"] = Enc.transform(data["Gender"]) # Making inp...
e64c1fa44aea2264c2d00dd662f045739fc4013a
engineersamuel/algorithms-and-datastructures
/sort/merge/merge.py
3,127
4.21875
4
def merge_sort(arr, low, high): if low < high: middle = (low + high) // 2 merge_sort(arr, low, middle) merge_sort(arr, middle + 1, high) merge(arr, low, middle, high) def merge(arr, low, mid, high): # Since python doesn't natively have arrays, create a list of all 0s. The 0s a...
41e62a85d934a22fefb3356fd9595c4623632335
zhangwei1989/algorithm
/Python/15-three_sum_first_2_modify.py
897
3.546875
4
# Difficulty - Medium # Url - https://leetcode.com/problems/3sum/ # Time complexity: O(N2); # Space complexity: O(1); class Solution: def threeSum(self, nums): nums.sort() result = [] for i in range(0, (len(nums)-2)): if i > 0 and nums[i] == nums[i-1]: continue ...
47e731a2b1c0dfba085d8447bf3dd70811a009e7
zhangwei1989/algorithm
/Python/15-three_sum_first_3_refer.py
581
3.625
4
# Difficulty - Medium # Url - https://leetcode.com/problems/3sum/ # Time complexity: O(N2); # Space complexity: O(1); class Solution: def threeSum(self, nums): nums.sort() result = set() for i in range(0, (len(nums) - 2)): if i >= 1 and nums[i] == nums[i - 1]: c...
eddbba30f1181e6021f75f81e8edb9c1fea919bf
zhangwei1989/algorithm
/Python/20_valid_parentheses_first.py
778
3.859375
4
# Difficulty - Easy # Url - https://leetcode.com/problems/valid-parentheses/ # Time complexity: O(N); # Space complexity: O(N); # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def isValid(self, s): ...
888b44f0a78e40d9e004a9579895bac339dd3f1c
rezinak/PyLadies-domaci-projekty
/5/05_06_holkanebokluk.py
254
3.96875
4
lastNameIn = input("Napis svoje prijimeni bez diakritiky: ") def guess(lastName): if lastNameIn[-3:] == "ova": print(lastNameIn + "? Tak to jsi nejspis holka.") else: print(lastNameIn + "? Tak to jsi asi kluk.") guess(lastNameIn)
a1058d4e2dfb6f1b9c7c50d7da295ba3244f891f
matarhaller/Seminar
/Solutions/homework_8/homework8solutions.py
6,555
3.5625
4
''' Solutions to PySci Parallelism Homework Fall 2012 Author: Isaac Shivvers ''' ############################################### # imports from time import time, sleep from random import uniform from math import sqrt import numpy as np import multiprocessing as mp from subprocess import Popen from IPython import para...
4d43a1657da8d82cc5d60b3aef4a78630db11d09
matarhaller/Seminar
/Solutions/homework_4/xmlrpc_server.py
3,432
3.953125
4
#!/usr/bin/env python """ AY 250 - Scientific Research Computing with Python Homework Assignment 3 Solutions Author: Christopher Klein Modified: Isaac Shivvers IMPORTANT NOTE ABOUT IMAGE ARRAYS, NUMPY ARRAYS, AND LISTS: Images on computers are generally stored as unsigned 8-bit integers, but that data type is not cons...
e228f338f02b9e52978784244dd16a4615c3e995
matarhaller/Seminar
/Solutions/homework_1/CalCalc.py
4,034
3.546875
4
#!/usr/bin/env python ''' This file provides the calculate function, which is both a local Python evaluator and W|A interrogator. Isaac Shivvers, 2012, PySci ''' from __future__ import division import math, urllib, re def calculate(eval_string, return_float=False): ''' Calculates the expression contained in...
07465a853e6f94cfe85b645cec5e141f20c41ad0
startgis/Point-in-Polygon
/main_from_file.py
7,800
3.8125
4
from plotter import Plotter from geometry_classes import * import sys import os def user(): # input your file path of the polygon, the points into the main function # Different types of errors that the user may face file_list = os.listdir() while True: """ This error handling ensures ...
886f42ba4d95d29f0a142b49241de48e3d308e08
eva990417744/my_leetcode
/数组与链表/leectode-141.py
21,721
3.640625
4
import copy import math import random from collections import defaultdict from typing import List, Any import collections import heapq from functools import reduce import functools import re class ListNode: def __init__(self, x): self.val = x self.next = None class TreeNode: def __init__(se...
97ea7427a1c33172935ac56d747380e14be7a33c
eva990417744/my_leetcode
/单例.py
1,973
3.6875
4
# 使用__new__方法 class Singleton(object): _instances = None def __new__(cls, *args, **kwargs): if not hasattr(cls, '_instances'): orig = super(Singleton, cls) cls._instances = orig.__new__(cls, *args, **kwargs) return cls._instances class MyClass(Singleton): a = 1 p...
7e23b1d5d6ae569fae47944e1b668e12d20804ab
alan-nguyen/algorithms-python
/04_quicksort/02_recursive_sum.py
197
4.125
4
def sum_recursive(list): """ Sum function using recursive """ if list == []: return 0 return list[0] + sum_recursive(list[1:]) # test case print(sum_recursive([1, 2, -1, 2]))
c654cecfb2c5a136520da41c226cf3b4f063bcf2
mthompson36/newstuff
/Exerciseforsandip2.py
1,754
4
4
#This class will take a word you enter and return it capitalized """class getyourinput(): #def __init__(self): #self.test = "" #function to get the string from user def get_string(self): self.test = raw_input("Please enter a word: ") #function to print string that was previously entered by user. def print_str...
abd5cb0421cd452bdb1405cca6a680f7f7f2ead3
mthompson36/newstuff
/codeacademypractice.py
856
4.1875
4
my_dict = {"bike":1300, "car":23000, "boat":75000} """for number in range(5): print(number, end=',')""" d = {"name":"Eric", "age":26} for key in d: print(d.items()) #list for each key and value in dictionary for key in d: print(key, d[key]) #list each key and value in dictionary just once(not like above exampl...
d931cd0af05e12e47743549abf8caacd0fca1c5f
Dchoudhary4444/2020-all-work
/python/del/eg1.py
144
3.859375
4
a={'one':1,'two':2,'three':3} print(a) result=1 for i in a: result=result*a[i] print(result) b={'four':4,'five':5} print(a.update(b)) print(a)
afe5276c8223c1de5eda173e64c1f0d161ae7513
rafaelsaidbc/Exercicios_python
/ex044.py
1,407
3.90625
4
'''Elabore um programa que calcule o valor a ser pago por um produto, considerando o seu preço normal e a condição de pagamento: - à vista no dinheiro/cheque: 10% de desconto - à vista no cartão: 5% de desconto - até 2x no cartão: preço normal - 3x ou mais no cartão: 20% de juros''' preco = float(input('Digite o preço...
5c3f99706ec2d60bddf0731b9faf4f29cf3af15d
rafaelsaidbc/Exercicios_python
/ex048.py
373
3.90625
4
'''Faça um programa que calcule a soma entre todos os números ímpares que são múltiplos de três e que se se encontram no intervalo de 1 até 500''' soma = 0 for variavel in range(1, 500 + 1, 2): if variavel % 3 == 0: soma += variavel print('A soma dos números ímpares e múltiplos de 3 que existem entre 1 e 50...
d416f36e048c95fd1d331c0e9b5d4dd64c16c7ca
rafaelsaidbc/Exercicios_python
/ex093.py
1,246
4.125
4
'''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 campeonato.''' from ti...
d67f311810fdb51e783885fe989adad456ad4966
rafaelsaidbc/Exercicios_python
/ex025.py
375
4
4
nome = input('Qual o seu nome completo? ') nome_lower = nome.lower() nome_split = nome_lower.split() if 'silva' in nome_split: print('Você é da família Silva.') else: print('Você não é da família Silva.') print('Outra forma de fazer') pessoa = str(input('Qual seu nome completo? ')).strip() print('Tem Silva no s...
59a3f75b4cfc0851b9478a998b94262fdccdbece
rafaelsaidbc/Exercicios_python
/ex080.py
783
4.25
4
'''Crie um programa que o usuário possa digitar cinco valores numéricos e cadastre-os em uma lista, já na posição correta de inserção (sem usar o sort()). No final , mostre a lista ordenada na tela.''' lista = [] for elemento in range(0, 5): numero = int(input('Adicione um número na lista: ')) if elemento == 0 ...
c7e5b3fc53c87bdf48206b6a3e32d0d3c44a7935
rafaelsaidbc/Exercicios_python
/ex013.py
211
3.6875
4
salario = float(input('Qual o seu salário? ')) aumento = salario + (salario * 0.15) print('Parabéns, hoje você recebe R${:.2f} reais, com o aumento de 15% receberá R${:.2f} reais.'.format(salario, aumento))
ea15a8ad82692f6c410b3b3e2b76b83e3d7863d0
rafaelsaidbc/Exercicios_python
/ex076.py
700
4.0625
4
'''Crie um programa que tenha uma tupla única com nomes de produtos e seus respectivos preços, na sequência. No final, mostre um listagem de preços, organizando os dados em forma tabular.''' tupla = ('Lápis', 1.75, 'Borracha', 2.00, 'Caderno', 15.90, 'Estojo', 25.00, 'Transferidor', ...
37277bbd39ba1a73e04a4d28d8e41a0eb04da7ad
rafaelsaidbc/Exercicios_python
/ex042.py
947
4.34375
4
'''Verificar se 3 retas podem formar um triângulo e qual tipo de triângulo elas formarão - equilátero: todos os lados são iguais - isósceles: dois lados iguais - escaleno: nenhum lado igual''' lado1 = float(input('Dê a medida de uma reta: ')) lado2 = float(input('Dê a medida de outra reta: ')) lado3 = float(input('Dê a...
1d3a372c4230bb5ae90b11bba094b0492b63ec19
fisico-alienado/BPP
/Codigo Leccion 4/actividad_4.py
1,064
4.0625
4
import pdb pdb.set_trace() # 1. Haciendo uso de comprensión de listas realice un programa que, dado una lista de listas de números enteros, devuelva el máximo de cada lista. lista = [[2, 4, 1], [1,2,3,4,5,6,7,8], [100,250,43]] maximos = [max(i) for i in lista] print(maximos) # 2. Haga uso de la función filter para c...
320159133067a17db857be36c1df7fa6b1451030
agianchandani2018/ISP
/Get.py
1,255
3.578125
4
import requests import json f = open("pw.txt", "r+") pw = f.read() response = requests.get('https://api.github.com/', auth=('agianchandani2018', "")) token = "b8a58e94ac70cb4f640d1b4d14901c55d4198b7e" #print(response.text) obj = json.JSONDecoder() dict = obj.decode(response.text) # print(dict) # print("_________...
b3b88fe8ea17fd2a5d32e6ca796633d9855c7aa4
Izaya-Shizuo/lpthw_solutions
/ex9.py
911
4.5
4
# Here's some new strange stuff, remember type it exactly # Assigning the days variable with a string containing the name of all the 7 days in their short form days = "Mon Tue Wed Thu Fri Sat Sun" # Assigning the month variable with the name of the months from Jan to Aug in their short forms. After ech month's name the...
96b6fcee94b847a5566d1541e87f885688a84cd7
21fchang/parseltongue-1
/01_player.py
91
3.546875
4
name = input('Hello hacker, what is your name? ') print(''.join(['Welcome, ', name, '!']))
41925bae39b1ab9472d933a9f9a87e11f076fa0a
entropy-dj/word2vec
/key_lambda_test.py
612
4.28125
4
""" 在排序的时候,接使用sorted方法,返回一个列表就是排序好的 测试一下 啧啧啧 """ a = [4, 2, 6, 1, 8, 3, 6, 3] b = ["d", "a", "x", "w", "v", "c"] print(sorted(a)) print(sorted(b)) print(sorted(a, reverse=True)) print(sorted(b, reverse=True)) """ x[0]表示元组里的第一个元素,x[1]当然就是第二个元素; """ a = [("d", 4), ("a", 1), ("c", 9), ("b", 5), ("e", 2),...
e9defa95f9f37bb9389be52b3fccc9a7ec099de0
Vishnu-Kaladharan/PythonLearnings
/classes_inheritance.py
284
3.78125
4
class Mammal: no_of_legs = 4 def walk(self): print('Walk') class Dog(Mammal): def __init__(self, dog_name): self.type = dog_name def bark(self): print(f"Bark {self.type}") dog1 = Dog('Jacky') dog1.bark() dog1.walk() print(dog1.no_of_legs)
d8d738641084dce7e9ca2caaab7e01030b90bc6a
Vishnu-Kaladharan/PythonLearnings
/unpacking.py
146
3.78125
4
numbers = [1,2,3] tup = (12,1,9) x,y,z = numbers print(f"x is {x}, y is {y} and z is {z}") a,b,c = tup print(f"x is {a}, y is {b} and z is {c}")
20c4a76df6738e9b36265396acd9087072387d20
Vishnu-Kaladharan/PythonLearnings
/dictionary_mails.py
724
3.53125
4
import files # file_name = input('Enter File name') fhandle = open('sample_file.txt') #print(fhandle) mail_day_wise = {} mail_email_wise = {} for line in fhandle: list_words = [] line = line.rstrip() if line.startswith('From '): list_words = line.split() mail_day_wise[list_words[2]] = mail_...
a287b1c23a46ca2c35824764b46f8e60f22eca71
joymajumder1998/Coding-By-Joy-Majumder
/dummy python code templates/a_.py
487
3.828125
4
def AStarSearch(): n=int(input("Enter the number of nodes : ")) aug=[[[]for i in range(n)]for j in range(n)] print("Enter the augmented matrix : ") for i in range(n): for j in range(n): print("Enter A[",i,"][",j,"] : ",end="") aug[i][j]=int(input()) initial=int(input(...
c4ef00109f7f2caa0fc118412abfee738b8490c6
joymajumder1998/Coding-By-Joy-Majumder
/dummy python code templates/digits.py
196
3.5
4
n=input() n=list(n) count0=0 count1=0 for i in n: if(i=='0'): count0=count0+1 if(i=='1'): count1=count1+1 if(count0<=1 or count1<=1): print("YES") else: print("NO")
90267740b601205ac24f86e36428f0d93752e94f
joymajumder1998/Coding-By-Joy-Majumder
/dummy python code templates/prime.py
138
3.609375
4
for i in range(101): f=0 for j in range(2,i): if(i%j==0): f=1 break if(f==0): print(i)
67767770ebf33924c6bc7415eb2f260636e66b1b
joymajumder1998/Coding-By-Joy-Majumder
/dummy python code templates/jumbleGame.py
1,182
4
4
import random def choose(): words=["water","tiger","soccer","biriyani","icecream","rainbow","puzzel","mafia","programming"] select=random.choice(words) return select def jumble(word): qn="".join(random.sample(word,len(word))) return qn def thanks(p1,p2,s1,s2): print(p1,"'s score : ",s1) print(p2,"'s score :...
1b3ac8d19f355e8efe01c510f7b5eaecba0d4bb6
priscilalobo/Python_Studies
/Exercicios/exercicio3.py
133
3.75
4
n1 = int(input('Digite um valor:')) n2 = int(input('Digite outro valor:')) s = (n1+n2) print(f'A soma de {n1} + {n2} é igual a {s}')
539082886e62467899af61402fe1130351d9740f
priscilalobo/Python_Studies
/Exercicios/exercicio11.py
495
3.96875
4
""" Faça um programa que leia a largura e a altura de uma parede em metros, calcule sua área e a quantidade de tinta necessária para pinta-la, sabendo que cada litro de tinta, pinta uma área de 2m². """ alt = float(input('Qual a altura da sua parede? ')) larg = float(input('Qual é a largura da sua parede? ')) area = a...
c0284726bd258045a72e74e2a2e0baa902067435
priscilalobo/Python_Studies
/Exercicios/exercicio29.py
554
3.90625
4
# Escreva um programa que leia a velocidade de um carro. Se ele ultrapassar 80Km/h, mostre # uma mensagem dizendo que ele foi multado. A multa vai custar R$7,00 por cada Km acima do limite. from time import sleep velocidade = int(input('Informe a velocidade do carro: ')) print('Verificando a velocidade máxima utilizad...
198144fb410628ec9afe4457204c78cb7df7d12e
priscilalobo/Python_Studies
/aulas/aula9.py
1,052
4.125
4
# Manipulando textos '''frase = curso em video python frase.split() = dividir uma string em uma lista '-'.joint(frase) = junta as frases e separa pelo - frase.count('o') - contar quantas strings especificas len(frase) - contar quantas caracteres tem frase.found('deo') - procurar na frase a lista sempre começa a contar...
635d019d5c51c7f64b773658ca226762b5698db6
priscilalobo/Python_Studies
/Exercicios/exercicio24.py
187
3.828125
4
#crie um programa que leia o nome de uma cidade e diga se ela começa ou nao com o nome santo cidade = input("Em que cidade você nasceu? ").strip() print(cidade[:5].lower() == 'santo')
d910de90778f636cc6253c53f749e328aa5956ab
priscilalobo/Python_Studies
/Exercicios/exercicio20.py
603
3.921875
4
# Sorteando uma ordem na lista: nome de 4 alunos e o programa vai definir a ordem de apresentação from random import shuffle pa = str(input('Nome do primeiro aluno: ')) sa = str(input('Nome do segundo aluno: ')) ta = str(input('Nome do terceiro aluno: ')) qa = str(input('Nome do quarto aluno: ')) lista = [pa,sa,ta,qa...
9224069954e9e321b596b41d93630454b4b016ba
priscilalobo/Python_Studies
/Exercicios/exercicio59.py
2,250
4.15625
4
#Crie um programa que leia dois valores e mostre um menu na tela: #[ 1 ] somar #[ 2 ] multiplicar #[ 3 ] maior #[ 4 ] novos números #[ 5 ] sair do programa #Seu programa deverá realizar a operação solicitada em cada caso. """n1 = int(input('Digite o primeiro número: ')) n2 = int(input('Digite o segundo numero: ')) esc...
12bdbdb6881f9bbad36918b70d3cb0a76de9c586
priscilalobo/Python_Studies
/Exercicios/exercicio17.py
339
3.84375
4
# Faça um programa que leia o comprimento do cateto oposto e do cateto adjacente # de um triangulo retangulo, Calcule o mostre o comprimento da hipotenusa from math import hypot co = float(input('Qual o valor do cateto oposto? ')) ca = float(input('Qual o valor do cateto adjacente?')) print(f'O valor da hipotenusa é ...
132ea231e98635179260ef483986c4bc201f1091
cocoa-dev-1/coding-class
/부녀회장이-될테야.py
315
3.5
4
from typing import no_type_check_decorator t = int(input()) def get_person(k, n): b = 0 if k == 0: return n for j in range(n): b += get_person(k-1, j+1) return b for _ in range(t): k = int(input()) n = int(input()) a = get_person(k, n) print(a)
abd4fcf9cc9f8e6ed7e1510fa546f74d6f289134
cocoa-dev-1/coding-class
/ex2.py
284
3.5
4
while True: t = input() if t != 'exit': print(t) else: break math_score = [80, 79, 65, 100, 32] a = 0 for i in math_score: a += i print(a) print(a/len(math_score)) b = 0 for i in math_score: if i > a/len(math_score) : b += 1 print(b)
6bc444632a5e4b55e344d0476a8fa7c3d3fca9a8
cocoa-dev-1/coding-class
/Nested-Function/closure_2.py
257
3.5625
4
def start_compplex_at(x): one = 1 def increment_by(y): added = x + y + one def multiply_by(z): return added * z return multiply_by return increment_by c1 = start_compplex_at(2) c2 = c1(3) c3 = c2(4) print(c3)
d4dcce7c45a4086ddc6cc2c76f59aca5e04daf98
cocoa-dev-1/coding-class
/지영-공주님의-마법-거울.py
441
3.96875
4
n = int(input()) main_list = [] def print_pickture(k): if k == 2: for i in main_list: i = i[::-1] for j in i: print(j,end="") print() elif k == 3: main_list.reverse() for i in main_list: print(i) else: for i in ...
0cf9cf17591a161eafe806ecb0f3f3038657602e
cocoa-dev-1/coding-class
/단어공부.py
333
3.5625
4
Lang = input() dic = {} for i in Lang: if i.upper() in dic: dic[i.upper()] += 1 else: dic[i.upper()] = 1 result_dic = {value:key for key, value in dic.items()} result_count = list(dic.values()).count(max(list(dic.values()))) print(result_dic[max(list(dic.values()))]) if result_count == 1 else...
50f907b545a6cbf428d710d64ebb2e008f6f26b0
cocoa-dev-1/coding-class
/OOP/ex_1.py
449
3.671875
4
class Dog: def __init__(self,name,id, age): self.name = name self.__id = id # __를 변수 앞에 붙이면 privite 변수가 된다. self.age = age def change_id(self, id): self.__id = id def __str__(self): return f"{self.name} is {self.age} years old" def speak(self, sound...
0f8601c66a2986ad3a5f456bb0108c06f604ea39
tardatio/granary_ai
/base/backprop_web.py
2,117
3.734375
4
# based on above website # https://mattmazur.com/2015/03/17/a-step-by-step-backpropagation-example/ import numpy as np def softmax(x,w1,b1,w2,b2): # step one z = 1/(1+np.exp(-x.dot(+w1)-b1)) # step two output = 1/(1+np.exp(-z.dot(+w2)-b2)) return output, z def derivative(output,z,w2,x): # der...
461429563f5fdc85714222f189c0aadf27c7371d
jerichochua/H2Comp
/datastructures/queue/simplequeue.py
824
4.0625
4
#Queue ADT - Simple Implementation class Queue: def __init__(self): self.data = [] def isEmpty(self): """Returns True if queue is empty, False otherwise""" return len(self.data) is 0 def enqueue(self, item): """Inserts new item into rear of queue (front of list)""" ...
154a5bbd9dde0fb2db46b8e3a7712949f1923e56
jerichochua/H2Comp
/programmingchallenges/pc14/pc14.py
863
3.828125
4
# Programming Challenge 14 - Cipher infile = open('cipher.txt', 'r') keyphrase = infile.readline().rstrip() cipher = '' # Get alphabets alphabets = '' for i in range(26): if chr(97+i) not in alphabets: alphabets += chr(97+i) # Get key phrase without repeated letters for letter in keyphrase: letter =...
31d706c66b87cb28de376b79655735858afd34b5
jerichochua/H2Comp
/datastructures/queue/circularqueue.py
1,252
4.0625
4
#Queue ADT - Circular Queue class Queue: def __init__(self, limit): self.data = ["" for i in range(limit)] self.front = 0 self.rear = limit-1 self.size = 0 self.limit = limit def __str__(self): return str(self.data) def insert(self, data): """In...
a99310fa82a25ea70ba7cc74347e386bb232ac03
SharedControlAutonomousDriving/scad_tot
/scripts/chunk_csv.py
1,601
3.71875
4
#!venv/bin/python3 """ chunk_csv.py Splits a CSV into chunks and handles the headers Examples: help ./scripts/chunk_csv.py -h split input.csv (with header row) into chunks of 100 rows ./scripts/chunk_csv.py -f input.csv -s 100 -o ./outdir split input.csv (without header row) into chunks of 10 rows ./scripts/chunk_...
8c1eb055d1f5dde3b4f95b7afed8b90a9044ee90
sebas-mora28/2048_game
/Codigo base_linux.py
39,856
3.5
4
from tkinter import * #Tkinter import os #Nenecesario para usar el os.path.join import random #Generadador de numeros random from tkinter import messagebox #Caja de mensajes import pickle #Necesario para hacer el leaderboard...
a31653a68f2d025058d27d5d76609306459804b6
DikranHachikyan/python-verint-20190128
/day01/ex07.py
228
3.65625
4
#!/home/wizard/anaconda3/bin/python3.7 def suma(a,b): c = a + b return c def main(): x,y = 5,6 res = suma(x,y) print('{} + {} = {}'.format(x,y,res)) if __name__ == '__main__': main()
00d49222df91505583e440d8cb5f1ece9d6f9180
Jacqueline-A-Shay/python-exercises
/working/little_panda.py
1,309
3.796875
4
import json import datetime import pandas as pd # Input and read in customer info based on customer_id def retrieve_customer_profile(customer_id): customer_id = customer_id + '.json' with open(customer_id, "r") as jsonFile: data = json.load(jsonFile) return data print("Good Day! Please provide your customer id ...
13f2a7be28c473970d6f75ae27e9bbd650c192ec
Jacqueline-A-Shay/python-exercises
/4.3_control_structures_exercises.py
17,247
4.21875
4
## Conditional Basics # prompt the user for a day of the week, print out whether the day is Monday or not Prompt_day = input("Which day is it (Monday - Sunday)? ") if Prompt_day == 'Monday': print("Yes it is Monday.") else: print("not Monday") # prompt the user for a day of the week, print out whether the day is a w...
42ced87cf398c28ccfba09b55f1de135599f32d0
swetankmodi/eqsolver
/alternate/prog.py
3,047
4.28125
4
import json def convertToInfix(lis): """This function converts a prefix expression to an infix expression Args: prefix(list): The Prefix expression as a list. Returns: list: The resultant infix expression. """ lis.reverse() stack = [] ans = "" for i in lis: if(type...
85cb07f35a394c449b84bd28414341655f4e6057
XiaoYuhao/somecodes
/effective.py
7,010
4.09375
4
''' 第7条: 用列表推导来取代map和filter ''' def clause7(): a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] alt = map(lambda x: x**2, filter(lambda x: x % 2 == 0, a)) print(list(alt)) ''' [4, 16, 36, 64, 100] ''' ''' 列表推导比内置的map和filter函数清晰,因为它无需额外编写lambda表达式 ''' even_squares = [x**2 for x in a if x %...
545b772ff90ff61d0701c3d69c42eabadedaf6ae
herbetelem/Quizz
/game_file/sql_function.py
3,443
3.515625
4
# coding : utf-8 # import de la librairie import sqlite3 # * Fonction pour recuperer depuis la bdd class SQL_request: def __init__(self): # # * connection a la bdd # self.connection = sqlite3.connect("quizz.db") # # * instance du curseur # self.cursor = self.connection.cursor...
f7632939bc9b7e16c16dcd36706212ae0b2d68bb
vickylance/python-predictive-analytics
/preprocessing.py
889
3.765625
4
import pandas as pd from sklearn.impute import SimpleImputer #import data data = pd.read_csv("./insurance.csv") # see the first 15 lines of data # print(data.head(15)) # check how many values are missing (NaN) before we apply the methods below count_nan = data.isnull().sum() # the number of missing values for every...
631c7270b94f71996281cbb2640637d152a87737
SwatiPrasad18/Python
/prog5.py
405
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 12 17:52:00 2020 @author: SWPRASA """ import random a =[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] print([set(a) & set(b)]) #gives a list of set #------------------ a = range(1, random.randint(1,30)) b = range(1, random...
732add993707e0cfcfb66ca2cff505b6c4fa553e
sonali4596/python-assignment-1
/question 7.py
319
3.953125
4
deposit=0 withdrawl=0 d = input("Enter a deposit amount separated by space ") list1 = d.split() w = input("Enter a withdrawl amount separated by space ") list2 = w.split() for num in list1: deposit += int (num) for num in list2: withdrawl += int (num) balance=deposit-withdrawl print(balance)
8df83445e494e7137b3ba2721433d7d63ba88244
tudormihaieugen/DataScientistCourse
/Courses/Course1.py
1,530
4.21875
4
# # Type of variables # a = 5 # print(type(a)) # # # Power: ** (double * operator) # print(2 ** 3) # =8 # # # Area of circle # pi = 3.14159 # radius = 2.2 # area = pi * (radius ** 2) # # # string concat # hi = "Hello there" # name = "Ana" # greet = hi + " " + name # print(greet) # # three_times = name * 3 # print(thre...
f42239650552814aa84b8a81e5a500e59bb0dbb1
LandonSwartz/Hydrobot-Python-Scripts
/python-sensor-listener.py
4,978
3.640625
4
#python sensor controller listener #Need to add sending commands to while loop #Need to add try-catch excepts for messing up with data #Need to connect and disconnect from serial port if errors occurs import serial #for serial communication import time #for sleep and other time related functions import datetime #for d...
db128c83fc6f8ac6901427286d71309047275207
DaleEMoore/pTLACS
/chapter4.py
9,473
4
4
#/bin/python3 # There are more exercises in section 4.3 page 31. Not really, they are covered here. # A 2 monitor system gets the previous centered on the 2 monitor break; move it. Dale fixed this by using tkinter # canvas with turtle. I'm not really happy with that solution because I think there's overhead. But it w...
439ea3b68db1a2404303bf993de647284cf480f9
steellsas/First_project
/test/testas.py
624
3.828125
4
def add_numbers(a: int, b: int): return a + b def palindrom(word :str): return str(word).lower() == str(word)[::-1].lower() def test_is_polindrom(): word ="aabbaa" expected = True assert palindrom(word) == expected def test_is_polindrom_uper(): word = "AABBAA" expected = True assert ...
f3ce7e4eb14cae94c3a282015fc8dd36aa9702b2
steellsas/First_project
/algoritms_and_datastruct/time-memory cals/calc_func_time.py
186
3.515625
4
import time def calc_time(func, arg): t1 = time.time() func(arg) runinig_time = time.time() - t1 return runinig_time lst = [1,5,6,8,4,25] for i in lst: print(i)
ee5a015add0a37475ff54b591f80e56d145b61d6
MaxiHartmann/myNacaAirfoilGenerator
/src/tkinter_snippets/3.py
496
3.609375
4
import tkinter as tk def say_hi(): print("Hello - !") root = tk.Tk() frame1 = tk.Frame(root) frame2 = tk.Frame(root) root.title("tkinter frame") label = tk.Label(frame1, text="Label", justify=tk.LEFT) label.pack(side=tk.LEFT) hi_there = tk.Button(frame2, text="say hi ~", command=say_hi) hi_there.pack() frame...
b0d59dccc05d4f44ad1e8938325cfd178d39908e
zdYng/python
/sparktest/Numpytest/numpytest001.py
1,868
3.578125
4
import numpy as np from numpy.linalg import * def main(): list=[[1,3,5],[2,4,6]] print(type(list)) np_list=np.array(list) #only one print(type(np_list)) np_list=np.array(list,dtype=np.float) # print("shape"+np_list.shape) # print("ndim"+np_list.ndim) # print("dtype"+np_list.dtype) #...
e8221c55d4a1f4f1989009d0623cbcb48313a632
todaatsushi/python-data-structures-and-algorithms
/algorithms/search/exponential_search.py
1,062
4.09375
4
""" Exponential search. Searches list/array arr for element x where binary search is performed given a range of elements to search over. """ # reuse binary search from binary_search import binary_search def exponential_search(arr, x): """ Input: - arr - sorted array of ints - x - int - value to be fou...
d1608587d280fd2ed388aaa71241f856421f7648
todaatsushi/python-data-structures-and-algorithms
/algorithms/sort/insertion_sort.py
1,025
4.40625
4
""" Insertion sort. Sort list/array arr of ints and sort it by iterating through and placing each element where it should be. """ def insertion_sort(arr, asc=True): """ Inputs: - Arr - list of ints to be sorted. Assumes arr is longer than 1 element long. - asc - True for ascending, False for desce...
c13d2cf0fa077577b6801d89192a07ee58437e7c
rishi1212/algorithms_python
/removeDuplicatesFromString.py
178
3.953125
4
def removeDuplicates(string): unique='' for i in string: if i not in unique: unique+=i return unique a='geeksforgeeks' print removeDuplicates(a)
640d0422e829634f8f6ac41c7ed823dfef592ad2
hypp/math
/one/main.py
1,697
3.6875
4
import polynomial def test(): p1 = polynomial.Polynomial([13/5,1/5]) s2 = p1.evaluate(2) s7 = p1.evaluate(7) print("f(2) = %s f(7) = %s" % (s2,s7)) def calc_term(points, i): print("-> calc_term: %s, %i" % (points, i)) term = polynomial.Polynomial([1.]) xi, yi = points[i] for j,p in ...
453fc0baf0163d84d4b0b26ffa2164826bec58cf
fslichen/Python
/Python/src/main/java/Set.py
207
4.34375
4
# A set is enclosed by a pair of curly braces. # Set automatically removes duplicate elements. set = {'apple', 'pear', 'banana', 'apple'} print(set) if 'apple' in set: print('Apple is in the set.')
946b8778d4ac9879cd987fc045e9c8205620d564
shovha/leetcode-problem-solutions
/MoveZeroes.py
694
3.5625
4
from typing import List class Solution: def moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ #my solution # # for index in range(len(nums)): # if(nums[index]==0): # nums.remove(0) ...
ec0a052b5f64985c365711c80e8d17edbc07b96e
shovha/leetcode-problem-solutions
/BackspaceStringCompare.py
1,188
3.5625
4
class Solution: def backspaceCompare(self, S: str, T: str) -> bool: sList=[] for item in S: if(item=='#'): if(len(sList)>0): sList.pop() else: sList.append(item) S="".join(sList) tList=[] for item in...
e60a527d22ecd1adec728290b83ce35b1a8de2c2
gettymoor/GPIO_globalcode
/week2/lmf.py
199
3.859375
4
def is_even(x): if x % 2 is 0: return True else: return False num = [1,56,234,87,4,76,24,69,90,135] N = list(filter(is_even,num)) #N = list(map(is_even,num)) print (N)
28428a1cab35f4625b2a84a034de2f2c5c51cba3
gettymoor/GPIO_globalcode
/week2/even.py
176
3.71875
4
def even (a): if a % 2 is 0: return True else: return False numbers = [12, 54, 33, 67, 24, 89, 11, 24, 47] print (list(filter(even, numbers)))
6908ae99fec9e84d2097e1726074a95003db32e3
ArtemKhymenko/LPTHW
/ex36.py
2,758
3.890625
4
from sys import exit import random def forest(): print "You entered into the forest." print "Here you see the cave and the hut." print "Which one would you prefer?" choice = raw_input("> ") if choice == "cave": print "You see a witcher in the cave." print "You can do: 1. Tell me f...
7be80dfa534762a2f6900c3fba47d500f156d0e4
ch33kuu/Python-Programming
/7619958.py
148
3.75
4
k={'number':[1,2,3],'other':[4,5,6]} d={k:k*2 for k in range(10)} print(d) a=[3,8,6,14] for i,v in enumerate(a): print(i,v)
7f1ad9f6c00a96480a425e1596d66657b49b3575
lavosprime/euler
/python/problems/005.py
130
3.5625
4
from python.common.number_theory import lcm result = 1 for number in range(1, 20): result = lcm(result, number) print(result)
b89555e9e55c4cf3dedbcfa31f9e1eeee2c7b225
Tsarcastic/mailroombooooooo
/mail_room_madness.py
1,534
3.84375
4
DONORS_AMT = {'example': 100, 'other': 20, 'more': 200} DONORS_CT = {'example': 1, 'other': 2, 'more':} def mail_room(): """Menu Interface""" reply = None while reply is not quit: print("Message") print("1: Process a Donation & Send a Thank You") print("2: Create a Report") ...
a75d18b675db291d97ff97e0a3a55f4d4e80965f
trongpl94/TestGit
/Bmi _calculate.py
380
4.03125
4
val = input("Enter your Height(cm) and Weight(kg) :").split() cm = int(val[0]) mass = int(val[1]) meter = cm/100 bmi = mass/(meter**2) if bmi < 16: print("Ur Severely") elif 16 < bmi < 18.5: print("Ur Underweight") elif 18.5 < bmi < 25: print("Ur Normal") elif 25 < bmi < 30: ...
f971de6ef077936890555dda79ffafc73914c712
rprojas/Tarea-1
/puntotres.py
359
3.734375
4
def numero_perfecto(): num = int(input("Escribir un numero::> ")) suma = 0 for i in range(1, num): if num % i == 0: suma += i if suma == num: print("el numero es prefecto") else: print("el numero no es prefecto") return 0 def main(): numero_perfecto()...
a01bf098fb9a323b7e55331500e25d1025ad0953
georamirez23/Tarea3
/Lista1.py
366
3.953125
4
# Ejemplos sobre listas # Ejercicio #1 number1 = int(input("Ingrese un numero: ")) i=1 list1=[] if int(number1) > 0: for i in range(number1): word1= input("Ingrese la palabra: ") list1.insert(i,word1) print(len(list1)) for n in range(len(list1)-1): print(list1[n]) ...
3b4df8b1a1a392f5bab1e9d24316ae4e139b645a
shubhamjain31/demorepo
/OOPS_Concept/Constructor.py
545
3.84375
4
class Employee: #constructor initializing def __init__(self, name, age, salary, gender): self.name = name self.age = age self.salary = salary self.gender = gender def show_employee_details(self): print('Name of the employee is',self.name) prin...