blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
437b86dfd60c3f9e73649c1c6c9af35abfc3ced1
nicohnavarro/curso_python
/01_ejercicios_practicos/00_calculadora.pyw
3,224
3.5625
4
from tkinter import * #Importamos la biblioteca necesaria para crear GUI root=Tk() miFrame=Frame(root) miFrame.pack() operador="" resultado=0 #-----------------Pantalla--------------------------- numeroPantalla=StringVar() pantalla=Entry(miFrame,textvariable=numeroPantalla) pantalla.grid(row=1,column=1,padx=4,pady=4,co...
60470b2002802975c25a44a2f393a29a091e201c
BenjiKCF/Codewars
/day48.py
419
3.765625
4
def count_positives_sum_negatives(arr): if arr != [] or sum(arr) != 0: return [len([i for i in arr if i > 0]), sum(i for i in arr if i < 0)] else: return [] print count_positives_sum_negatives([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15]) #[10,-65] def count_positives_sum_negatives...
2763ea01a72087e8035e4b335058a24a2531043c
JohnZ9865/practicingagain
/hello.py
401
3.859375
4
def pns(a, b): #prime numer searcher primeNumbers = [] for i in range(a, b + 1): isPrimeFlag = True for loop in range(2, i): if i % loop == 0: isPrimeFlag = False break if isPrimeFlag == True: primeNumbers.append(i) print(primeNumbers) i0 = int(input('Please enter the firs...
55ba6836e7c26cd3230a4f40e45d45c4d78b3109
JpryHyrd/python_2.0
/Lesson_7/1.py
1,060
4.375
4
""" 1. Отсортируйте по убыванию методом "пузырька" одномерный целочисленный массив, заданный случайными числами на промежутке [-100; 100). Выведите на экран исходный и отсортированный массивы. Сортировка должна быть реализована в виде функции. По возможности доработайте алгоритм (сделайте его умнее). """ import random ...
9163dae3a5fb21224d2d3c9219714cc879ea6005
lixiang2017/leetcode
/problems/0055.0_Jump_Game.py
3,030
3.734375
4
''' DP from left to right Runtime: 496 ms, faster than 66.35% of Python3 online submissions for Jump Game. Memory Usage: 15.4 MB, less than 35.35% of Python3 online submissions for Jump Game. ''' class Solution: def canJump(self, nums: List[int]) -> bool: N = len(nums) farmost = nums[0] for...
d5a6ebe31b356e7aa1f111c85de2f0ebf5de8228
AngelPedroza/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/8-uppercase.py
229
3.890625
4
#!/usr/bin/python3.4 def uppercase(str): for i in range(len(str)): y = str[i] if ord(str[i]) > 96 and ord(str[i]) < 123: y = chr(ord(str[i]) - 32) print("{}".format(y), end='') print()
a140b001f8bbc078a159c240c45f8ea33b55e151
zhg5482/test
/python/20170814/list_test1.py
529
4.0625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- classmates = ['Michael','Bob','Tracy'] #打印classmates print('classmates = ',classmates) #打印classmates 长度 print('len = ',len(classmates)) #list尾部追加元素 classmates.append('Adam') print('classmates = ',classmates) #list指定位置插入元素 classmates.insert(2,'Jack') print('classmates = ',cla...
8e1efc4326ec6674906a8f00b13523771ab61e02
benzitohhh/cs212-style
/week5/pig14_moreAnalysis.py
6,416
3.890625
4
from functools import update_wrapper def decorator(d): "Make function d a decorator: d wraps a function fn." def _d(fn): return update_wrapper(d(fn), fn) update_wrapper(_d, d) return _d @decorator def memo(f): """Decorator that caches the return value for each call to f(args). Then wh...
932dccce30e2a3bbd66ae4ffb3424479ab13cceb
codork/competitive-coding
/4_NumberComplement.py
852
3.578125
4
''' @author: codork @date: 06-05-2020 @problem: Given a positive integer num, output its complement number. The complement strategy is to flip the bits of its binary representation. ''' class Solution: def complement(self, n): if n == 0: return 1 elif n == 1: retu...
5c0cc7e487986877dbfb63b29f0c0b644a07eff4
FarmanAhmadov/Sudoku_game
/Sudoku game.py
5,224
3.71875
4
from tkinter import * import time import _thread # THEME line_color = 'gray' text_color = 'blue' background_color = 'white' g = 9 # grid variable active = (None, None) board = [[0 for i in range(9)] for _ in range(9)] ####################################################################################################...
5899bfb17f5eee7b395b124b28f3557b482bb355
jackneer/my-leetcode
/no28_str_str.py
448
3.75
4
def str_str(haystack, needle): if needle is None or len(needle) == 0: return 0 found_index = -1 for i in range(0, len(haystack) - len(needle) + 1): if haystack[i: i + len(needle)] == needle: found_index = i return found_index def main(): print(str_str(haystack = ...
d2cae9d38d253e67ffb4bb8cc451c3ac92e53a89
WilliamJCole/IS211_Assignment6
/tests_next.py
9,430
3.796875
4
import conversions_refactored as con #TEMPERATURE CONVERSION TESTS-------------------------------------------------------------------------------------- #TEST FOR convert Celsius To Kelvin print "TEST FOR convert Celsius To Kelvin" tests = [(500.00, 773.15), (490.00, 763.15), (450.00, 723.15), (410.00, 683.15), (...
2025a9901e1173e89b760b5624071a9764e1006c
EruDev/Python-Practice
/菜鸟教程Python3实例/02.py
228
3.65625
4
# 以下实例为通过用户输入两个数字,并计算两个数字之和: def add_num(): n1 = int(input('请输入第一个数字:')) n2 = int(input('请输入第二个数字:')) return n1 + n2 print(add_num())
b1125181aa2054f0ba2c33cd82377b5875fd274e
echoshihab/PyGameSims
/quiz_project/quiz_brain.py
1,001
3.859375
4
# ask the questions # check if answer is correct # check if we're at end of quiz class QuizBrain: def __init__(self, questions_list): self.question_number = 0 self.score = 0 self.questions_list = questions_list def still_has_questions(self): return self.question_number <= len(s...
9b522d5e1728fcd9a867f8e609d7f3f3bec7519c
lucasalvesso/ad1_2021_1
/q4.py
1,387
3.609375
4
def calcCenter(values): med = [0, 0] for lin in range(len(values)): med[0] += values[lin][0] med[1] += values[lin][1] return [med[0]/len(values), med[1]/len(values)] def calcDist(firstValue, secondValue): dist = (((secondValue[0] - firstValue[0]) ** 2) + ((secondValue[1] - firstValue[1...
313f7aac2671c6840b19a745fb851f0ca8582455
GinnyGaga/My-Practice-backup
/py-pra/def_func.py
375
3.78125
4
import math def quadratic(a,b,c): L=[a,b,c] for m in L: if not isinstance(m,(int,float)): raise TypeError('bad operandtype') n=b*b-4*a*c if a==0: return Error elif n>0: x1=(-b+math.sqrt(n))/(2*a) x2=(-b-math.sqrt(n))/(2*a) return x1,x2 elif n==0 : x=-b/(2*a) return x else: return 'No answan' ...
bca28e1c709f82e5d540da25a7f334297780870a
0ushany/learning
/python/python-crash-course/code/6_dictionary/practice/4_vocabulary2.py
149
3.71875
4
# 词汇表2 vacabularys = {'osy':22, 'oshany':14, 'apple':19, 'helen':20} for key, value in vacabularys.items(): print(key + ":" + str(value))
117a7d876cae99062877af17fa4c5de28f7aef62
hubbm-bbm101/lab5-exercise-solution-b2200356076
/exercise2.py
369
4.15625
4
user_input = input("Please enter e-mail:") def valid_or_not(x): email_check = x y = False z = False for i in email_check: if i=="@": y = True elif i==".": z=True return y and z if valid_or_not(user_input): print("This is a valid e-mail.") else...
c8da19c16da19455f510a17e8504946a23447b25
ruoyzhang/AI_public_perception_survey_data_analysis
/WE/clean_functions.py
1,041
3.640625
4
from answer_dict import answer_dicts def recode_answers(dataset, q_num, lang, multi): """ Function to recode single choice questions from the questionaire dataset: the dataset containing the responses, pandas dataframe q_num: the question number to convert lang: which language is the questionaire in, possible va...
9df7c5037360a46d4dfd66cff9ca95f2765812dd
RussellSB/mathematical-algorithms
/task8.py
1,420
3.984375
4
#Name: Russell Sammut-Bonnici #ID: 0426299(M) #Task: 8 import math #for pi #recursive function for finding the factorial of a number x def _factorial(x): #base case, factorial of 0 is 1 if(x == 0): return 1.0 # calls recursively until base case return x * _factorial(x-1) #function for calc...
e3d6f28d5eab72b4c4c8c189f8adc8708fa3c6c2
atsuhisa-i/Python_study1
/if3.py
77
3.515625
4
number = input('Number:') if number == '123456': print('1st Prize:Money')
0847f8ef5d73f6dc44088af0a915658aa04d4230
sairamprogramming/python_book1
/chapter4/programming_exercises/exercise2.py
337
3.75
4
# Calories Burned # Named constant for calories burned per minute. CALORIES_BURNED_PER_MINUTE = 4.2 # Calculating the total caloires burned for minutes in range(10,31,5): total_calories_burned = CALORIES_BURNED_PER_MINUTE * minutes print("Calories burned after", minutes, "of running is", format(total_calorie...
85331bb99489ad7edbd3b8670d320d32ea7d4ab5
saisugeeta/intellify
/ML ALGO/demo1.py
1,652
3.5625
4
import pandas as pd def missing_values(df): mis_val=df.isnull().sum() mis_val_percent=100*mis_val/len(df) mis_val_table = pd.concat([mis_val, mis_val_percent], axis=1) # Rename the columns mis_val_table_ren_columns = mis_val_table.rename( columns = {0 : 'Missing Values', 1 : '% of T...
5acc6ed0e132fb7d280d78d11bab417da9577cb9
reiniertromp/MITCourse
/oddTuple.py
165
3.765625
4
x = ('I', 'am', 'a', 'test', 'tuple'); def oddTuples(atuple): return atuple[0::2] print(type(('I', 'am', 'a', 'test', 'tuple'),)) print(x) print(oddTuples(x))
578135050c3e197d231fe76f4e59c075088c7bf1
NewtonFractal/Project-Euler-1
/#2.py
234
3.5625
4
import time import math start = time.time() a = math.floor(1000/3) b = a * 3 c = math.floor(1000/5) d = c * 5 e = math.floor(1000/15) f = e * 15 print((((b+3)*a)/2)+(((d)*(c-1))/2)-(((f+15)*e)/2)) end = time.time() print(end - start)
d19ebfbeca85cf41dbd0901602bac5045e855052
neternefer/codewars
/python/projectPartners.py
783
4.15625
4
#Mrs. Frizzle is beginning to plan lessons for her science class next semester, #and wants to encourage friendship amongst her students. #To accomplish her goal, Mrs. Frizzle will ensure each student #has a chance to partner with every other student in the class #in a series of science projects. #Mrs. Frizzle does not ...
665709790fb3c8e3f787d45fbb942025c0e92054
zdgeier/programming-problems
/find-peak2/find-peak.py
374
3.625
4
def findpeak(arr): first = 0 last = len(arr) while True: mid = (first + last) // 2 if mid + 1 < len(arr) and arr[mid] < arr[mid + 1]: first = mid + 1 elif arr[mid] < arr[mid - 1]: last = mid - 1 else: return mid while True: arr = lis...
0342017f04a4994d0861be2d145fb00e1c99ebcc
BaoAdrian/interview-prep
/coding-problems/leetcode/arrays/word_search_i.py
1,627
3.828125
4
""" Word Search I https://leetcode.com/problems/word-search/ Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more...
63370dc946ae4b0a0dcfd240c900d6c6442c1d5b
python-naresh/python
/8-2-function.py
227
3.71875
4
def tr(a,b=20,c=30): # in function u can't give like (a=10,b=19,c) it will give u error # u can leave left side values like a and u can give right side value like b,c d=a+b+c print(d) tr(3) tr(3,100) tr(10,20,30)
62be2010cb94106ca0bf9145dec9950a443dafae
dadafros/Harvard-CS50-Course
/pset6/mario/more/mario.py
308
3.90625
4
from cs50 import get_int h = 0 while (h < 1 or h > 8): h = get_int("Height: ") for i in range(h): for j in range(h - i - 1): print(" ", end="") for k in range(i + 1): print("#", end="") print(" ", end="") for k in range(i + 1): print("#", end="") print()
603b917f9acecb3e426b3a979674d070b8fb92c7
tkinoti/python-basics-class
/structures.py
1,242
4.46875
4
#structures - variables that hold multiple variables eg list, tuple and dictionary #list - has square brackets [] person_l =["John", "Doe", 30, 65.54, "Mombasa", True] print(person_l[0]) print(person_l[3]) print(person_l[1:5]) print(person_l[0:5]) print(person_l[2:4]) print(person_l[-4:-2]) person_l.append("em...
76e0cfc6e03c20b9de1fc27e969da044776c92ae
mohasinac/Learn-LeetCode-Interview
/Arrays/Move Zeroes.py
798
3.984375
4
""" Move Zeroes Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] Note: You must do this in-place without making a copy of the array. Minimize the total number of operations. """ c...
bf01f19aee74a48dce8f090f5abde253e3718727
diego-go/taller_python_PROTECO
/1er semana/estacionar.py
296
3.8125
4
entrada=int(input("Cuantas horas estuviste estacionado?: ")) total=entrada*8 print("Debes de pagar un total de:",total,"pesos") monedas=[1,2,5,10] valorMoneda=int(input("\nIngresa las monedas para pagar: ")) if valorMoneda in monedas: print("Continua") pago=valorMoneda+total elif: pago=total
4749cc8b750915657663f61d524874507738a3d3
daftstar/learn_python
/03_Google_Python/foobar_challenges/01_prison_labor_dodgers.py
3,809
3.59375
4
# Python Constraints # ====== # Your code will run inside a Python 2.7.6 sandbox. # Standard libraries are supported except for: # bz2, crypt, fcntl, mmap, pwd, pyexpat, select, signal, # termios, thread, time, unicodedata, zipimport, zlib. # ######################################## # Prison Labor Dodgers # #######...
7119d2ebed8b800d0ca37942dd70b426f9364205
fsnuth98/Computer-Science-Coursework
/Computer Science 1 (Freshman, Python)/CSC101 Lab/Labs/lab06_fixedangle_spiral123/lab06_average.py
410
4.1875
4
''' Franklin Nuth Idrissa Jalloh CSC101 Lab 6 Part 4: Average Value February 24 2017 ''' N= int(input("Enter number of items you want to purchase: ")) total= 0 if N <= 0: print("Cannot calculate average.") else: for i in range(N): item= int(input("Enter the price for...
25e4a5607a77c592a8240f88de9e6a351ec91675
Erika001/CYPErikaGG
/libro/problemas_resueltos/capitulo3/problema3_12.py
398
3.84375
4
MASUE = 0 N = int(input("Determine el numero de empleados: ")) i = 1 for i in range(i,N,1): NUMEMP = int(input("Determine el numero del empleado: ")) SUE = int(input("Determine el sueldo del empleado: ")) if SUE > MASUE: MASUE = SUE MANUM = NUMEMP i = i + 1 print(f"El empleado con mayo...
c319b4f31cadb23409e79287524b73c09fc77604
rapidcode-technologies-private-limited/Python
/jayprakash/assignment2/Q8. program to check whether an alphabet is a vowel or consonant.py
171
3.515625
4
while True: n=input('Enter any alphabate=') if(n=='a')|(n=='e')|(n=='i')|(n=='o')|(n=='u'): print(n,'is vowle') else: print(n,'is consonent')
351104e9d94677b9830f4de306ef299c6a419836
dangulod/PyCourse
/samples/primeros_pasos.py
1,861
4.15625
4
''' Comentando nuestros scripts, Python permite comentar de dos formas diferentes, 1. Para comentarios más largos entre una triple comilla 2. Con # ''' print('Hello World!') # Nuestra primera funcion def hw(): print('Hello World') hw() # Asignar variables x = [1, 'Hi', 3.14, ['a', 'b', 3]] x[0] x[3] x[3]...
bfe57ba2b35b097dbbde25fa8a72b889a41da5f2
perolajanice/Python-random-builds
/circle.py
421
4.15625
4
import turtle def drawPolygon(t, sideLength, numSides): turnAngle = 360 / numSides for i in range(numSides): t.forward(sideLength) t.right(turnAngle) def drawCircle(anyTurtle, radius): circumference = 2 * 3.1415 * radius sideLength = circumference / 360 drawPolygon(anyTurtle, sideL...
74a76cbc642be7af06f31a3438c0a23cc88d3df8
bill-filler/python-examples
/exceptions.py
526
3.8125
4
#generic catch, no full error try: file = open('xxyz.txt', 'r') print(file.read()) except: print("File doesn't exist") #generic catch, put print specific exception try: file = open('xxyz.txt', 'r') print(file.read()) except Exception as err: print("File doesn't exist", err) #specific exception...
e302dc2afeabb4483eec5607615dd25a5a5579be
Yiting916/Python
/0128_p04_dict.py
429
3.84375
4
Keys = 'P', 'M', 'H' values = 'Pikachu', 'Mickey Mouse', 'Hello kitty' dc = dict(zip(Keys, values)) while True: qkey = input() if qkey == '-1': break if qkey == '-2': print(dc.keys()) print(dc.values()) continue elif qkey not in dc: print(qkey,'doe...
d970802864d3471a28fd2a3a63f006dc6a1d6635
chrisyarel117/guessnumber
/guessnumber.py
734
4.21875
4
import random firstname = input("Enter Your First Name: ") lastname = input("Enter Your Last Name: ") attempts = 0 number = random.randint(0,10) ###this has the program choose a randome integer number between a & b. print("Welcome to Guess the Secret Number Game.") print("Start now!") while (attempts < 7): guess =...
26cb10aed8375dec3dcb67fe95b561e64d831071
BeatrizCastex/data-treatment
/aut_fg2.py
2,576
3.8125
4
""" TESTE AUTÔMATO 2 Beatriz de Camargo Castex Ferreira - 10728077 - USP São Carlos - IFSC 05/2020 Nesse programa representamos autômatos probabilisticos como matrizes e os utilizamos para gerar padões que serão salvos em arquivos para análise. O objetivo é ser capaz de gerar padrões com qualquer** autômato ...
66195bb93f5514fbe43bb8345f44519590b97d67
rosspeckomplekt/interpersonal
/interpersonal/classes/interaction.py
1,859
4.40625
4
""" An Interaction describes the interaction between two Persons """ class Interaction: """ An Interaction describes the interaction between two Persons """ def __init__(self, person_a, person_b): """ Initialize an Interaction object for two Persons So we can compute the v...
4756e52f362441b67bbd967979a58e6fdb4f772e
abhisek08/python-dictionary
/dict empty.py
109
3.984375
4
''' Write a Python program to check a dictionary is empty or not. ''' d={} if not bool(d): print('empty')
784786b8e3d235c9f08b324e58b1f8ef1b0cb278
wssir/practice
/py.py
1,053
4.03125
4
#ceasor cipher def encrypt(key, message): message = message.upper() alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" result = '' for letter in message: if letter in alpha: letter_index = (alpha.find(letter)+ key) % len(alpha) result = result + alpha[letter_index] els...
2466f41fc2a493ee6eb3748370f6e213ca23a42b
15zhazhahe/LeetCode
/Python/326. Power of Three.py
199
3.765625
4
class Solution: def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ tmp = 1 while tmp < n: tmp *= 3 return tmp == n
194cfc2e24370a1035bebc6a477ba58e107b222b
skshiwali30/code-chef
/mahasena.py
316
3.578125
4
totalSoldier = int(input()) soldier_list = list(map(int, input().split())) evenCount, oddCount = 0, 0 for soldier in soldier_list: if soldier % 2 == 0: evenCount = evenCount + 1 else: oddCount = oddCount + 1 if evenCount > oddCount: print("READY FOR BATTLE") else: print("NOT READY")
1a6d7319c8e619790a2a4650a2e9f09cac8fddb1
svarogjk/algorithms_completed
/heap_sort.py
2,745
3.703125
4
from math import log2 class Heap(): def __init__(self, array: list): self.array = array self.heap_height = log2(len(self.array)) def parent(self, i: int)->int: return i // 2 def left(self, i: int)->int: return 2 * i + 1 def right(self, i: int)->int: retur...
f24af4dd313bdba85bf4f679411bc56b6fe52ba0
beckysteele/python_projects
/phys650/gamma_exercise/gamma.py
403
3.890625
4
import math as m user_input = input('Input a number >> ') # Check for fraction input if "/" in user_input: temp = user_input.split('/') # print(len(temp)) if len(temp) == 2: real_input = float(temp[0])/float(temp[1]) # For normal decimal inputs else: real_input = float(user_input) result = m.gamm...
372e0e86c7ade80a796de88d9400299442a42229
fluTN/influenza
/models/models_utils.py
13,897
3.5
4
import os import pandas as pd import numpy as np from sklearn.metrics import mean_squared_error from sklearn.model_selection import cross_val_score ##### UTILITIES ####### def generate_keywords(keywords = "../data/keywords/keywords_italy.txt"): """ Generate a list of keywords (Wikipedia's pages) which are us...
cdad8f217abc3b34c2b8806595e348f43eff05f9
zeziba/bmp280_pine64
/src/combiner_csv.py
767
3.53125
4
""" This file is intended to add all the csv entries into the main sqlite file. """ import database import csv import os #_path_ = '/home/ubuntu/pybmp180/pyscript/data' _path_ = 'data' with database.DatabaseManager('data') as db: for file in os.listdir(_path_): if 'csv' in file: _p = os.path...
082a05a1923010746e4bf68c3ecdd8cb70efa183
paik11012/Algorithm
/study/d2/1986_zigzag_num.py
257
3.53125
4
tc = int(input()) for tcc in range(1, tc+1): num = int(input()) result = 0 for i in range(1, num+1): # 1 2 3 4 5 if i % 2 == 1 : result += i else: result += (-1 * i) print('#{} {}'.format(tcc, result))
a0e74f58899f9c6468f7a2b4bd077349e4eb6e48
victoraugusto6/Exercicios-Python
/Programas/Mundo 2/ex056.py
850
3.578125
4
from datetime import date somaIdade = 0 mediaIdade = 0 maiorIdadeHomem = 0 nomeVelho = '' totMulher20 = 0 for p in range(1, 5): print('-=-'*8) print(f'----- {p} Pessoa -----') print('-=-'*8) nome = input('Nome: ').strip() idade = int(input('Idade: ')) somaIdade += idade sexo = (input('...
3646911498cba7627ec5d93654ca853de8b3da0d
scottsuk0306/rcCarEndtoEnd
/catkin_ws/src/control/src/test.py
291
3.734375
4
#! /usr/bin/env python from curtsies import Input def main(): with Input(keynames='curses') as input_generator: for e in input_generator: if e=='w': print("go front") if e=='s': print("go back") print() if __name__ == '__main__': main()
2fc385f1d8f3ec3aa7a3f3da252303dc3637314a
jamortegui/Personal-projects
/OrdenarArchivos.py
8,495
3.6875
4
from FilesManagement import * def readDirectorys(): '''Reads the content of directorys.txt file and returns a dictionary fordelName:forderRoute with the folders contained in the file ''' directorys = {} #Dictionary that will contain the names and routes of the objective folders with open("direc...
50cf4eb13f42bbe2a7bc94ef610deea10fea1192
mohamedlafiteh/strath-uni-problems-and-solution
/python-programming-examples-master/01/python/Dicts.py
854
3.828125
4
#!/usr/bin/env python3 def dicts(dictValues): print(">> Start of dicts") dictValues.clear() dictValues["localhost"] = "127.0.0.1" dictValues["googleDNS1"] = "8.8.8.8" dictValues["googleDNS2"] = "8.8.4.4" dictValues["myMachine"] = "192.168.1.66" print(dictValues) dictValues.pop("myMac...
d30bbd4981e5e8c7da525d3dd432d3722006028a
AKSHAY-KR99/luminarpython
/languageFundamental/flowcontrols/dicisionmaking/scnd_Largst_sort.py
850
4.25
4
num1=int(input("Enter no1 ")) num2=int(input("Enter no2 ")) num3=int(input("Enter no3 ")) if((num1>num2)&(num1>num3)): if num2>num3: print(num2," is second largest") print("Sorted order is ",num1,num2,num3) else: print(num3," is second largest") print("Sorted order is ", num1, nu...
3b1456cf2503a6e55bb6d1e88c859061cb84fc0b
alvarillo89/UGR-MachineLearning
/Práctica 1/codigo.py
15,323
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Trabajo 1 Álvaro Fernández García. Grupo 3. """ import numpy as np import matplotlib.pyplot as plt def simula_unif(N=2, dims=2, size=(0, 1)): m = np.random.uniform(low=size[0], high=size[1], size=(N, dims)) ...
5ec5d76a0ae8bab0e0ff2b85778a2fc3856c5e00
jan1o/Gerador-de-numeros-jogo-do-bicho-teste-
/main.py
732
3.609375
4
from random import * import sqlite3 import os from bd import * def inicio(): op = opcao() if op == 1: sorteador() elif op == 2: adicionador() else: pass def opcao(): x = int(input("Digite sua escolha: \n 1 - Sortear 10 bichos \n 2 - Adicionar resultados \n 3 - Sair \n")...
39a576878500256697496ac4363103af4400e6b7
PiperPimientos/CursoBasicoPython
/Listas.py
2,055
4.3125
4
#Vamos a ver las LISTAS en python # #Como guardar distintos tipos de datos en una sola variable? Es a través de las listas, las listas pertenecen a un conjunto llamado estructuras de datos que son formas que nos brindan los lenguajes de programación para guardar varios valores en una variable, pero con diferente forma...
2ed99e39569b5e0da79a0972251cf1725ac0667e
cdvalenzuelas/daf_selector
/main.py
2,956
3.59375
4
import pandas as pd import numpy as np from auxiliar_funtions import temp_plus from response import response def main(): degree = input("Seleccione °C [1] o °F [2]:" ) #Seleccionar entre grados centígrados o grados farenheit letter = 'F' if degree == 2 else 'C' #Seleccionar la letra adecuada para el mensaje tem...
0c9124b7aed57705785f1f69799299a837e7d0ff
Zircon-X/BaseRPG
/astar.py
3,982
4.1875
4
#This program is going to be testing an astar algorithm of our own device. from graphics import * import random ''' Width and height are variables used to calculate co-ordinates as well as set the size of the window gridsize is used to space gridlines as used in drawGrid, win simply sets the co-ordinates of the w...
21b71ed7b8f53f4dd9b3a48c1c4200ec07d024f2
oliveiralecca/cursoemvideo-python3
/arquivos-py/CursoEmVideo_Python3_AULAS/aula-19c.py
289
4.0625
4
pessoas = {'nome': 'Gustavo', 'sexo': 'M', 'idade': 22} for k in pessoas.keys(): #MOSTRA SÓ O NOME DAS CHAVES print(k) print() for v in pessoas.values(): print(v) print() for k, v in pessoas.items(): # SUBSTITUI O "ENUMERATE" DAS TUPLAS E LISTAS print(f'{k} = {v}')
712d2a7928918fc90a0dfe166bb24100da8d3882
Sundarasettysravanilakshmi/sravani
/pgm5.py
173
3.953125
4
number1=1 number2=2 number3=3 if((number1>number2) and (number1>number3)): print number1 elif((number2>number1) and (number2>number3)): print number2 else: print number3
dd7845b62c385a0b76676c643165fd552bab67fa
TatsumakiSombra/IPB2017
/Tkinter.py
705
3.65625
4
from Tkinter import * root = Tk() frame = Frame(root) frame.pack() bottomframe = Frame(root) bottomframe.pack( side = BOTTOM ) redbutton = Button(frame, text="Red", fg="red") redbutton.pack( side = LEFT) greenbutton = Button(frame, text="Brown", fg="brown") greenbutton.pack( side = LEFT ) bluebutton...
5b9e9ba657042b3732c729f817b524fc070ea18f
leilalu/algorithm
/剑指offer/第五遍/65.不用加减乘除做加法.py
659
3.90625
4
""" 写一个函数,求两个整数之和,要求在函数体内不得使用 “+”、“-”、“*”、“/” 四则运算符号。   示例: 输入: a = 1, b = 1 输出: 2   提示: a, b 均可能是负数或 0 结果不会溢出 32 位整数 """ class Solution: def add(self, a, b): while b != 0: # 进位不为0 temp = a ^ b b = (a & b) << 1 a = temp & 0xFFFFFFFF # 若是负数,则将其变为正数,最终结果要减去429496729...
4fb98af6016d3c196b75ecb143b76ed00f0eade0
Germanc/fisicacomputacional2017
/0321/collatz.py
364
3.640625
4
#!/usr/bin/python3 def funcion(n): if n%2 == 0: n = n/2 else: n = 3*n+1 return n mayor = 13 contador2 = 0 for i in range(13, 1000000): print(i) contador = 0 n = i while n != 1: n = funcion(n) contador = contador + 1 if contador > contador2: mayor...
2d2096f165dbea93e864cd8e40841d4f857f586b
Aplex2723/Introduccion-en-Python
/Basicos/LecturaPorTeclado.py
331
3.984375
4
print("Escribe un texto") valor = input() print("El texto escrito fue: " + valor) valor = input("\nEscribe un valor: ") print("El valor escrito es " + valor) valor = input("\nIntroduce un numero entero: ") valor = int(valor) print(valor + 100) valor = float(input("Introduce un valor entero o decimal: ")) p...
2b641d5c158e45f52ea37f0523bfd534aa93b68a
daniel-reich/ubiquitous-fiesta
/gdzS7pXsPexY8j4A3_2.py
129
3.578125
4
def count_digits(lst, t): k = {'odd': '13579', 'even': '24680'} return [sum([str(x).count(i) for i in k[t]]) for x in lst]
484c5407e4ccbaccb2ec47c12123a7078653eb84
bharat-kadchha/tutorials
/python-pandas/Python_Pandas/seriesfunctions/FunctionDrop.py
484
3.921875
4
import pandas as pd import numpy as np # Return Series with specified index labels removed # Remove elements of a Series based on specifying the index labels. When using a # multi-index, labels on different levels can be removed by specifying the level s = pd.Series(data=np.arange(1, 4), index=list('ABC')) print("<--...
bf7f142aa2870a247de77a89b4a6ca077dc4072e
IrinaEvsei/Python
/lab1/lab1task2.py
1,557
3.8125
4
# -*- coding: utf-8 -*- from pip._vendor.distlib.compat import raw_input def main(): s = raw_input("Введите последовательность: ") array = map(int, s.split()) print(array) sec_smallest = second_smallest(array) sec_larges = second_largest(array) print("Второй минимальный элемент: {}".format(se...
f8114ad8cef888c1ebb6ef33622dc2a1f65de3d6
quoner80/project-euler
/euler0088_wrong_1.py
2,862
4.1875
4
# Product-sum numbers # Problem 88 # # A natural number, N, that can be written as the sum and product of a given set of at least two natural numbers, {a1, a2, ... , ak} is called a product-sum number: N = a_1 + a_2 + ... + a_k = a_1 x a_2 x ... x a_k. # # For example, 6 = 1 + 2 + 3 = 1 x 2 x 3. # # For a given set of ...
fd77f4e2981eed1f0d080bda4e0291264e484039
vincentleeuwen/python-cooking-with-objects
/13/kitchen.py
420
3.609375
4
from storage import Storage class Kitchen: def __init__(self): self.storage = Storage() def order(self, dish): print("KITCHEN: Order received for {0}".format(dish.name)) print("I'm gonna need some:") for ingredient in dish.ingredients: print("{0} - {1}".format(in...
0b4c50f1dacf86c5d10462465a452be3e492c375
saetar/pyEuler
/bib/cybib/cy_amazon_prime.pyx
6,476
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # JESSE RUBIN - Biblioteca from bisect import bisect_right, bisect_left from itertools import count, chain from math import log from bib import xrange from bib.maths import divisors_gen from bib.decorations import cash_it def prime_gen(plim=0, kprimes=None): """ ...
346b461aae98aa2bd607ba70645749b5bea8d512
RunnerMom/Exercise06
/wordcount_excr.py
975
3.9375
4
#Exercise 6 in hackbright GIT curriculum # week two, day one #write a program that opens a file and counts how many times each space -separated wod # occurs in that file. # dictionary with word, counter pairs # if word in dictionary -> increment counter # else add word, 1 to dictionary from sys import argv impor...
df41014cf9eebbaed88097a308f4681216e9ce7e
ClauMaj/pyHomework
/deDub.py
223
3.953125
4
myList = [1,1, 2, 3, 4, 5, 3, 5] deDub = [] for i in range(len(myList)): # i is the index if myList[i] not in deDub: deDub.append(myList[i]) # for item not in myList # deDub.append(item) print(deDub)
a9d6c493d3f7dab4b33dc9253fe094a6f3b21a02
sacsachin/programing
/zigzag_str.py
555
3.6875
4
# !/usr/bin/python3 """ https://leetcode.com/problems/zigzag-conversion/ """ def solve(s, row): if row == 1: return s n = len(s) rows = ["" for _ in range(min(row, n))] is_down = False curr_row = 0 for i in range(n): rows[curr_row] += s[i] if curr_row in (0, row-1): ...
62bc6c11e32ce625ff4bba9b163b0011c235f344
mingjingz/ga-examples
/chromosome.py
3,029
3.609375
4
import random import string class Population(object): def __init__(self, target, size, mutate_prob, mate_percent): self.members = [Chromosome(len(target)) for _ in range(size)] self.target = target self.size = size self.i_generation = 0 self.mutate_prob = mutate_prob ...
2437de8c85f5bdf02101fa0fd682c9d4153f244d
mtan22/CPE202
/labs/lab8/sep_chain_ht.py
2,782
3.75
4
from typing import Any, Tuple, List class MyHashTable: def __init__(self, table_size: int = 11): self.table_size = table_size self.hash_table: List = [[] for _ in range(table_size)] # List of lists implementation self.num_items = 0 self.num_collisions = 0 def insert(self, key...
dff2ca8c5efa8e8f9fe4a13e3738bbb08a8331f1
JoeOlafs/FCCPyInt
/Lists.py
1,550
4.125
4
#Lists: ordered, mutable, allows duplicate elements mylist = ["banana", "cherry", "apple"] print(mylist) mylist2 = [5, 4, 3, 2, 1, 0] print(mylist2) print(mylist[2]) print(mylist[-1]) # Iterate through list for i in mylist: print(i) if 'orange' in mylist: print("yes") else: print('no') # Add to end...
e301564b994712f9af17f26ec094ef0ddff48cfd
rossoskull/python-beginner
/lcm.py
289
3.90625
4
a = int(input("Enter a number : ")) b = int(input("Enter another number : ")) if a < b: c = a a = b b = c lcm = a cond = 1 while cond == 1: if lcm % a == 0 and lcm % b == 0: break lcm += 1 print("The L.C.M of %d and %d is %d." % (a, b, lcm))
4375c4549479a09c3f57ad3c5ec960d2b4262429
NickmBall1/Python
/textsamplea06.py
596
4.40625
4
'''Use nested for loops to print triangles with ***''' #nested for loops n = 1 m = 10 for x in range(n, m+1): for y in range(1, x): print('*', end = ' ') print('\n') '''How to use for loop with list''' sum = 0 numbers = [2, 3, 12, 34, 19] for x in numbers: if x%3 == 0: ...
4825dafe05e00415768d559bb19eaadf006e757d
jonasc/constant-workspace-algos
/geometry/trapezoid.py
8,220
3.984375
4
"""Defines a trapezoid class with various helper classes and methods.""" from typing import Any, List, Optional, Tuple, Union from .polygon_helper import Edge, PolygonPoint class IntersectionPoint(PolygonPoint): """A polygon point with additional information about the edge it lies on.""" def __init__(self, ...
9ede796a964562f7fc81d26bd3f2a4af3a5f4e7d
Dhrumil1808/deep-learning
/Assignment1/code/error.py
161
4.0625
4
a=100 b=100 if( a < b): print "a is less than b" else: print " a is greater than b" #logical error as it prints "a is greater than b" even though a=b
5a4df054cb3a2edf3ef633a19680debfe438b536
KARTHIK-KG/Data-Structures-Lab
/Virtual LMS/Exp 8.py
214
4.28125
4
# Write a Python program to check whether the given character is vowel or consonant. ch=input() if(ch in('a','A','e','E','i','I','o','O','u','U')): print(ch, "is a Vowel") else: print(ch, "is a Consonant")
9a0e2ae9603588e31e4a52c42a68efab8dfe219e
Chekoo/Core-Python-Programming
/8/8-7.py
449
3.890625
4
def getfactors(num): list1 = [1] for i in range(1, num + 1): if num % 2 == 0: list1.append(2) num = num / 2 else: list1.append(num) break return list1 def isperfect(num): if sum(getfactors(num)) == num: return 1 else: r...
6da6f9e94b8af2b6a4f9f92440886ef799c8ad65
sglyon/pytools
/matstat/chi_square.py
7,778
3.6875
4
""" Created July 19, 2012 Author: Spencer Lyon """ from __future__ import division import numpy as np from math import sqrt from scipy.special import gamma, chdtr, chdtri import matplotlib.pyplot as plt class Chi_square: def __init__(self, k=2): """ Initializes an object of chi-squared distributio...
58eea405f6f87429565aaf6bb19662549f151000
mccarvik/cookbook_python
/2_strings_and_text/2_17_handling_html_xml.py
549
3.53125
4
import html from html.parser import HTMLParser from xml.sax.saxutils import unescape s = 'Elements are written as "<tag>text</tag>".' print(s) # replaces special characters such as < and > print(html.escape(s)) # same but without quotes print(html.escape(s, quote=False)) s = 'Spicy Jalapeño' # emit texts as ascii pri...
b1c5f03253572c3d9a55029de48d5723c1aa9692
danielicapui/lua
/src/main.py
621
3.625
4
from Calc import Calc import script def main(c): op=int(input("Digite 1 para somar:\nDigite 2 para subtrair:\nDigite 3 para multiplique:\nDigite 4 para dividir:\n")) if op==1: print(c.some()) elif op==2: print(c.subtraia()) elif op==3: print(c.multiplique()) elif op...
3d8f8e0f7a2d7742c139650c0e567f439dcc44d6
Kanika-Mittal15/RecursionProblems
/fibonacci number.py
165
4.09375
4
def fibonacci(n): #base case if n==0 or n==1: return n else: return fibonacci(n-1)+fibonacci(n-2) n = int(input()) print(fibonacci(n))
31bfb72fe0fe4fa95bf566d0fa8483fe610f487f
iron-bun/project-euler
/problem_022.py
862
4.03125
4
#!/usr/bin/env python3 #Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a nam...
1b47674d1348feb419352925577cf3686e586a04
Muniah-96/PA-WiT-Python-S21
/week_1/age_given_year_example.py
344
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 19 22:06:37 2020 @author: aliciachen """ # code that gives your age, given year you were born! birth_year = int(input("What year were you born?")) current_year = int(input("What year is it right now?")) age = current_year - birth_year print("You...
3d57715dfdf2bc4bd1e7f0a7dbf9f8b2cc9a7eb1
jon-tow/CARP
/eval/check_contrastive_scores.py
456
3.515625
4
from testing_util import compute_logit while True: passages = [] reviews = [] print("Write -1 to specify you're finished") print("PASSAGES:") while True: passage = input() if passage == "-1": break passages.append(passage) print("REVIEWS:") while True: review...
2b5359a3ab53970b4f0b4c4571bbc5edd25cfebe
Rockson-c/smartninja
/homework_6_1.py
1,874
3.765625
4
# Kako v eno od definiranih funkcij vstavit slovarje iz drugih definiranih funkcij in jih zdruziti? # Kaj spremeniti, da playerje dodane preko 'input' doda v file.txt/class (append) in ne zbrise prejsnjega vnosa? # Ali je kakšen line za ustavit program - quit? from HW61funkc import football_p_enter from HW61funkc...
d78e243375dbc4ec3d8e56a144ae3fa07fa09d3a
midas87/myFirstOdd_Even
/Even_Odd.py
324
3.84375
4
import random name = input('What is your name: ') print('Welcome', name,', Please pick a number between 1 to 1000') print('What number are you thinking') num = int(input()) ran = random.randint(1,1000) print(ran) if ran % num == 0: print('This is an even number') else: print('That is an Odd number...
3de0634efdff135eac083be42c6e7a9690da398c
xy008areshsu/Leetcode_complete
/python_version/pascal_triangle_2.py
813
3.984375
4
""" Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? """ class Solution: # @return a list of integers def getRow(self, rowIndex): rowIndex += 1 if rowIndex == 0: ...
dfb4e7059e0e193408cb80c6a3ef40e23ab1e454
gregorykremler/udacity-cs253
/lib/utils.py
2,624
3.796875
4
""" Aplication utility functions. """ import re import hmac import random import string import hashlib # Validation utilities for Birthday and ROT13 forms months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] abbrev_to_month = ...
cfd7692e4a9d358c38dba9d285a7a1a4a0a48c9c
BlendaBonnier/foundations-sample-website
/color_check/controllers/get_color_code.py
1,060
3.859375
4
# This file should contain a function called get_color_code(). # This function should take one argument, a color name, # and it should return one argument, the hex code of the color, # if that color exists in our data. If it does not exist, you should # raise and handle an error that helps both you as a developer, # fo...
cafb6027ddc2a2d0f70874e10a72ee11b78317fa
GeoffNN/interview-prep
/row-col-to-zero.py
868
3.984375
4
import numpy as np def row_col_to_zeros(in_matrix): """ Sets row and col to zero if contains a zero """ row_nb, col_nb = in_matrix.shape flagged_rows = {} flagged_cols = {} # Find rows and cols that contain zeros for row in range(row_nb): for col in range(col_nb):...