blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
bde411b664b36a8a9c38c8615b630f69211d7ce8
mariapaula017/Programacion-
/Clases programación/Talleres/Examenes/Quiz 2.py/quizz.py
1,699
3.9375
4
Temperatuta=[36,37,38,35,36,38,37.5,38.2,41,37.4,38.6,39.1,40.3,33] preguntaNumero = '''Ingrese alguna de estas opciones 1.Hacer conversión a fahrenhint o kelvin 2.Estado del paciente 3.Mostrar temperatura maxima,temperatura minima. 4. Salir ''' preguntaTemperatura = ''' C- Mostrar original...
39801a342ece448e4f3a9b7ece669af29a259bec
EngineerToBe/python-labs
/exercises/play_ground/pg_016.py
283
3.84375
4
# Create a function named same_name() that has two parameters named your_name and my_name. # If our names are identical, return True. Otherwise, return False. def same_name(your_name, my_name): if your_name == my_name: return True else: return False
2fea17039cccb7ed683b6f636c9dc7b817f52181
gonzalopouget/Grupo-J-TT
/Grupo J-TT/Proyecto/categorias.py
2,623
3.71875
4
import tkinter as tk from tkinter import ttk from tkinter import * from tkinter import messagebox from Temas import Temas class Categorias(): def __init__(self, ventanaPrincipal): self.VP=ventanaPrincipal#Aqui se hace una instancia de la ventana principal que se paso vacia como parametro ...
1e02c576cf512f640d1200851f6a2db1699512a2
jayakasadev/MiniFlow
/src/nodes/Add.py
372
3.890625
4
from .Neuron import Neuron class Add(Neuron): def __init__(self, x, y): Neuron.__init__(self, [x, y]) def forward(self): """ Adds the values of all incoming nodes together and sets the sum to current node's value :return: """ self.value = 0 for n in sel...
f1cbc80e162cc12034db88cee859568b43d7f8b1
UgolUgol/SearchEngine
/wiki_script/static_info_analyzer.py
291
3.796875
4
file = open("res1", "r") text = file.read() splitted_texts = text.split("WIKIPEDIA_ARTICLE_END") symbCounts = 0 for part in splitted_texts: symbCounts+=len(part) print(len(part)) print("Average len: ", symbCounts/(len(splitted_texts)) - 1) print("Texts count: ", len(splitted_texts) - 1)
b5c03a027d53cf3e42db8bed3697c6221ad72ddd
Labyrinth108/RecommenderSystemAssignment
/Assignment2/__init__.py
518
3.609375
4
import csv from Problem import Problem reader=csv.reader(file("Assignment 2.csv","rb"))#xls format has problem problem=Problem() index=-1 for row in reader: problem.loadLine(index,row) index+=1 # print(problem.matrix) # print problem.user1 # print problem.user2 # print problem.attributes # #Part1 # problem.com...
42ff4f19e0406b63a7a99c72eae244c2163bfd49
rainmayecho/applemunchers
/131.py
530
3.515625
4
import time def is_prime(n): if not n % 2: return False if not n % 3: return False for m in xrange(6,int(n**.5)+1, 6): if not n % (m+1): return False if not n % (m-1): return False return True time.clock() cubes = [n**3 for n in xrange(1,600)] c...
9a6f287db5457362afe350b75a747ac1c7ff6b35
nbvc1003/python
/ch02/print3.py
355
3.53125
4
a = 22 b = 4 print("%d +%d =%d"%(a,b,a+b)) print("%5d +%5d =%5d"%(a,b,a+b)) # 칸확보 a1 = 7 b1 = 3.56 c1 = "대박" print("%d +%0.2f =%0.2f"%(a1,b1,a1+b1)) # 실수 소수점 2자리까지.. print("%5d +%5.2f =%5.2f"%(a1,b1,a1+b1)) # 실수 소수점 2 print("%5d +%5.2f =%5.2f %s"%(a1,b1,a1+b1,c1)) # 실수 소수점 2 # %d, %f, %s 문자열
c54923616a8b81f8518677e2b6559e480899de58
bogipeneva/-Programming-101-Python-2019
/week06/test_decorators.py
761
3.953125
4
import unittest from decorators import * class TestDecorators(unittest.TestCase): def test_accepts_decorator_when_each_argument_matches_the_type_then_return_function_with_agruments_which_types_are_specified_by_decorator(self): expr1 = str expr2 = int expected_result1 = 'Hello, I am Anna' ...
0964e9887873cd654b99fa36c06aeedd16e37d08
crazy2k/algorithms
/ctci/quicksort/tests.py
657
3.5625
4
import unittest from ctci.quicksort import quicksort class TestQuicksort(unittest.TestCase): def test_partition_simple(self): l = [2, 8, 7, 1, 3, 5, 6, 4] pivot_idx = quicksort.partition(l, 0, len(l) - 1) left_region = l[:pivot_idx] right_region = l[pivot_idx + 1:] self.ass...
7c17bcaf68889e2afe3cda844b18f8c1807befee
zhuolikevin/Algorithm-Practices-Python
/Google/maxLenProductNoShareChar.py
796
3.75
4
# Given a list of words, find two words with no sharing characters that reach the maximum length product class Solution: def maxLenProduct(self, words): if not words: return 0 dic = {} # O(n*k) for word in words: for c in word: if c in dic: ...
7864fde8555445afa4cadac43e0d21e02c150fee
MrTuesday1020/Algorithms
/Python/3Sum.py
772
3.546875
4
""" https://leetcode.com/problems/3sum/ """ def threeSum(nums): """ :type nums: List[int] :rtype: List[List[int]] """ if len(nums) < 3: return[] nums = sorted(nums) res = [] for i in range(len(nums)): # remove redundance if i > 0 and nums[i] == nums[i-1]: continue target = -1 * nums[i] left = i...
77a5df0c5bdb6c05bae6893e9fddff09603e906b
1suraj/Regression-Prediction-Interval
/Regerssion Interval.py
2,492
3.609375
4
# linear regression prediction with prediction interval from numpy.random import randn from numpy.random import seed from numpy import power from numpy import sqrt from numpy import mean from numpy import std from numpy import sum as arraysum from scipy.stats import linregress from matplotlib import pyplot # seed ran...
36068df88dc089cd589efa3729915a605b6b4d6a
abhijitdey/coding-practice
/dynamic_programming/3_CCI_Book/10_paint_fill.py
920
3.625
4
from typing import List class Solution: def colorImage(self, sr, sc, originalColor, newColor): if sr < 0 or sc < 0 or sr >= len(self.image) or sc >= len(self.image[0]): return False #print(sr, sc) if self.image[sr][sc] != originalColor: return False if se...
47ae8da8aa3b26bf68da65c7b2d037ce7f1a0427
listenviolet/leetcode
/104-Maximum-Depth-of-Binary-Tree.py
922
4.15625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: Max = 0 len = 0 def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ Max ...
4d53c6afdf8e64bf0c058a18fde3dbc0787fa6c7
mrizkyfauzi/Dasar_Python
/02. Tutorial Dasar/02. Data_type.py
843
3.578125
4
angka = [10, 3.14, 1000000000000000000000, 10+5j] karakter = "A" kalimat = " Begini amat hidup :D" is_admin = True is_member = False daftar_angka = [1, 2, 3] daftar_huruf = ('a','b','c') data_orang = {'nama':'michael' , 'country':'Paris', 'Telp':2223} print(f"{angka[0]} Class INT") print(f"{angka[1]} Class Float") p...
d455fe71b69c752e40504f96b042ac741524a307
vdonoladev/aprendendo-programacao
/Python/Programação_em_Python_Essencial/5- Coleções/deque.py
571
3.921875
4
""" Módulo Collections - Deque https://docs.python.org/3/library/collections.html#collections.deque Podemos dizer que o deque é uma lista de alta performance. """ # Realizando o import from collections import deque # Criando deques deq = deque('geek') print(deq) # Adicionando elementos no deque deq.append('y') ...
e1880559bfc0a7c94851223c60b03ed959a8496b
Leeman92/Advent-of-code
/2015/python/day06/day06.py
1,549
3.515625
4
__author__ = "Patrick Lehmann" import re from collections import defaultdict r = re.compile("([0-9]+)") lights = set() lights_part2 = defaultdict(int) def main(): with open("../../input/day06.txt") as f: for line in f: x1, y1, x2, y2 = [int(x) for x in r.findall(line)] if line.s...
274ed2b51ecc43d65002f0df8b51ff4a87e0ef1b
pyunixdevops/scripts
/Python/04-08-18/module2.py
654
3.765625
4
#!/usr/bin/python3 def countDistPairs(list1, val1): """Pass a list and the resulting pair of value""" mset=list(sorted(set(list1))) count=0 rcount=0 mlist1=[] for i in mset: for j in mset[count+1:]: if sorted([i,j]) not in mlist1: mlist1.append(sorted([i,j]))...
fa9c7ff4a1a49248ccf4cd14e77b76769e691b42
Siddhartha8960/mission-code
/code/python/day-0/calculator.py
449
4.09375
4
num1 = int(input("Enter the first number ")) num2 = int(input("Enter he second number ")) choice = int(input("Enter your chioce 1 for sum, 2 for subtract, 3 fro multiply and 4 for divide ")) if choice==1: add = (num1) + (num2) print(add,"is the addition") elif choice==2: sub = (num1) - (num2) print(sub) elif choice...
d1c50d3166298bf68665dc2067cf7db55d41664b
keksha1337/BD_phone
/person.py
2,389
3.78125
4
import time from datetime import date class Person: def __init__(self, line='none'): if line == 'none': self.name = 'none' self.surname = 'none' self.birthday_date = 'none' self.phones = dict() else: line = line.split(';') self....
c9606179b26d4dbfbf2c78346e2a11b17098ae2b
julingc/tictactoe-ai
/tictactoe.py
4,260
4.0625
4
""" Tic Tac Toe Player """ import math import copy X = "X" O = "O" EMPTY = None def initial_state(): """ Returns starting state of the board. """ return [[EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY]] def player(board): """ Returns player who h...
91c5cd6c97e322e8a65a62da6ef4255b16f46c8a
ujjwalmaity/PythonArduino
/PythonCode.py
889
3.53125
4
# import the serial and time library import serial import time # initialize a serial object using our serial library # Note: It is very important to mention the correct COM port name. # It can found by using the Device manager on your computer. arduinoData = serial.Serial('com3', 9600) # hold the program for two...
0345f2f0ea759d01f34262de65b14faa9e936a10
dawidsielski/Python-learning
/other/django girls python exercises/solutions/sum digits in number.py
434
3.90625
4
""" Your task is to sum digits in a given number FOr example: sum_digits(1234) should return 10 sum_digits(8000) should return 8 Consicer only postive numbers """ def sum_digits(number): number_str = str(number) result = 0 for digit in number_str: result += int(digit) return result print(sum...
48438b72a6961b9b9df60fbac56db86074a47509
MayWorldPeace/QTP
/Python基础课件/代码/第三天的代码/14-删除元素(del, pop, remove).py
850
4.125
4
# 删除元素 del, pop, remove # 定义一个列表 my_list = ["小明", 20, "小红", 50] # del 删除指定的元素 (通过下标索引) # 格式: del 列表名[下标索引] # del 这个函数 是python内置函数(len del) # del my_list[1] # print(my_list) # pop是属于列表的方法 # pop 默认情况下 会从列表的后面开始删除 # .pop() 会有一个返回值 告知删除元素的值 # print(my_list.pop()) # print(my_list) # pop(下标索引) # ret = my_list.pop(0) # p...
f8914eca7458dd5bce80a63a3c1b3e056f245ba9
RandallCastroValenciano/prueba
/multiplicacion_numero.py
348
3.875
4
""" Dada una lista de números, devolver el resultado de la multiplicacion de todos los números. """ lista_numeros = [1,4,5,6,8] numero_dado = lista_numeros [0] for numero in lista_numeros: if numero * numero_dado: numero_dado = numero print("El resultado de la multiplicacion de todos los números".format(...
c5c88119d05b8fe4c636e7a4509f284b5870dbd8
skybohannon/python
/w3resource/string/42.py
430
4.0625
4
# 42. Write a python program to count repeated characters in a string. # Sample string: 'thequickbrownfoxjumpsoverthelazydog' # Expected output : # o 4 # e 3 # u 2 # h 2 # r 2 # t 2 import collections str1 = "thequickbrownfoxjumpsoverthelazydog" d = collections.defaultdict(int) for char in str1: d[char] += 1 for...
25f13ef0e8e696c488d2889e50c244698d77debb
chikkuthomas/python
/function/variable length argument method/book details.py
311
4.09375
4
# to print the details of the book def book(**details): for k,v in details.items(): print(k,"=",v) print(type(details)) book(name="WHY WE TOOK THE CAR",Author="Wolfgang Herrndorf",pages=345,price="54$") # WE GET THE OUTPUT AS # # name = WHY WE TOOK THE CAR # Author = Wolfgang Herrndorf # pages = 34...
5732fec85c02cd145d092fae097e106bbca4f1c6
abdoul61/data-structure
/data-algo/QueeLinkeList.py
2,293
4.59375
5
# This is the implementation of the quee abstract data structure using the Linked list as node instead of using the list # we can implement a quee data strucuture using a linked list and the to be more efficient we will opt for # inserting a new element from the head of he linkedList since the time complexitys is 0(1...
9f994b41b247c6923920ab9c67d99c0121e4978f
eldonato/Estrdados_Uniesp
/avaliacao 1/exerciciog.py
681
4.4375
4
""" Faça um Programa que peça 2 números inteiros e um número real. Calcule e mostre: 1. o produto do dobro do primeiro com metade do segundo. 2. a soma do triplo do primeiro com o terceiro. 3. o terceiro elevado ao cubo. """ def primeiroCalculo(n1, n2): return (n1*2)*(n2/2) def segundoCalculo(n1,n3): return (...
a6922dc5d44ed8de49aa9ee7134f30791da71ef1
johncoleman83/advent-of-code
/2018/python/src/day1.py
1,094
3.703125
4
#!/usr/bin/env python3 """ Advent of Code 2018: Day # """ import os from shared.readdayinput import readdayinput def first_half(dayinput): """ first half solver: Starting with a frequency of zero, what is the resulting frequency after all of the changes in frequency have been applied? """ lines...
6da1f4043dd83bb18c93a90d6d357d982a18aa5b
Mattw46/CPT223-A2-Stage1
/validator.py
1,693
4.1875
4
""" Validator takes in arguments passed and validates. Data is read in from a file to validate stations against if the data validates a request object and created and passed back """ import request import locations import day import datetime """ validates data and creates request object """ def validate(input): ...
8f4786462cff3a10569bdc86f8a768d69d8821bf
M5FGN/CodeClanWork
/week_01/day_02/conditionals/what_chocolate.py
399
4.15625
4
# SET chocolate = IPUT 'What is your favourite chocolate?' # IF chocolate is 'Bounty' # THEN PRINT 'gross' # ELSE IF choloate is 'snickers' # PRINT 'thats my favourite' # ELSE # PRINT 'yum' # END chocolate = input('What is your favourite chocolate?: ') if chocolate == 'bounty': print('gross') elif ch...
3621cbcced8fc4cc5033516991ab40ae29638932
VazMF/cev-python
/PythonExercicio/ex075.py
1,202
4.3125
4
#desenvolva um programa que leia quatro valores pelo teclado e guarde-os em uma tupla. no final mostre: #quantas vezes apareceu o valor 9; em que posição foi digitado o primeiro valor 3; quais foram os números pares. print('-' * 40) print(f'{"-ANALISADOR DE TUPLAS-":^40}') #titulo print('-' * 40) num = (int(input('Digi...
0cb3ce6d3bbcf150923f0ad847efaa0103a64d18
0mUltramar/Manual-snake
/exercice07/task04.py
2,212
4.03125
4
# Написать функцию, принимающую длину стороны квадрата и рассчитывающую периметр квадрата, его площадь и диагональ. # Сделать два и более варианта функции, которые должна отличаться количеством возвращаемых переменных. Не забыть про # проверки входных данных в самой функции. def inp_side_lenght(): """inp_side_len...
7ee64dec2d2e6418ea04bd634bf2bcdfb9f32fad
alessandraburckhalter/Bootcamp-Exercises
/object-oriented-programming/02-class-vehicle.py
335
3.84375
4
# Task: Create a class Vehicle class Vehicle: def __init__(self, make, model, year): self.make = make self.model = model self.year = year def description(self): return f"My car is a {self.make} {self.model} {self.year}." car = Vehicle("Ford", "Focus", "2020") print(car.d...
ed915280a18ed02328b390089bad36938f44b345
alexljenkins/bootcamp
/W02 Titanic Data with GridSearch Multi-Algorthm/Titanic.py
4,527
3.5625
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 5 13:19:15 2019 @author: alexl """ #TSNE for smushing things into two demensions so we can visualise it import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import numpy as np data = pd.read_csv('Data/train.csv', index_col=0) test = pd.read_csv('Dat...
5cd72f22a828d6c41edf47bce69de2b746653878
a19131100/260201084
/lab5/Example1.py
296
4.0625
4
integer_= int(input("Please enter an integer: ")) while integer_ < 0: integer_= int(input("Please enter a valid integer: ")) while integer_>10: integer_= int(input("Please enter an integer less than 10: ")) for i in range(10): i= int(i) + 1 print( integer_ , "x", i, "=", i*integer_)
6ed2e305505103355c90fdeacbbebc73c986042b
yanayang01/python-playground
/class.py
934
4.65625
5
# simple example class MyClass(object): a = 90 b = 88 p = MyClass() # print(dir(p)) # __init__ method # the constructor method for a class name = "Ilija" class Student(object): """ returns a student object with name, major, year """ def __init__(self, name, major, year): sel...
af87a44d39e0c2e92b8185294617c2fe44d81a20
qsyed/python-programs
/hacker-rank/Capitalize.py
983
4.40625
4
""" You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck. alison heck ----> Alison Heck Given a full name, your task is to capitalize the name appropriately. Input Format A single line...
2866215128c39b244703698fd816316071ce6eee
xinquan-wang/Database_Basic_and_SQL
/src/CSVDataTable.py
7,899
3.640625
4
from BaseDataTable import BaseDataTable import csv import copy class CSVDataTable(BaseDataTable): """ The implementation classes (XXXDataTable) for CSV database, relational, etc. will extend the base class and implement the abstract methods. """ def __init__(self, table_name, connect_info, key_co...
4c51f4238bfbea4e2bbea679de416f13f30a16a8
CleverProgrammer/lpthw
/ex6.py
1,341
4.59375
5
# initialize types_of_people to 10 types_of_people = 10 # initialize x to a formatted string, types_of_people being inserted into it. x = f"There are {types_of_people} types of people." # initialize binary to the string "binary" binary = "binary" # initialize do_not to the string "don't" do_not = "don't" # initialize ...
3ed262e492833ff3ad549b0f527a51d1807dbf29
dkaisers/Project-Euler
/016/16.py
136
3.78125
4
import math n = int(input('Digit sum for 2^n for n = ')) x = int(math.pow(2, n)) sum = 0 for c in str(x): sum += int(c) print(sum)
61d013e6cbd20c5f250dd271db153ca19a8dc96e
prkirankumar/LearningPython
/Basics/decorators.py
659
4.53125
5
# Python Decorator function is a function that adds functionality to another, but does not modify it. # wraps another function. def decor(func): def wrap(): print("$$$$$$$$$$$$$$$$$$$$$$") func() print("$$$$$$$$$$$$$$$$$$$$$$") return wrap def sayhello(): print("Hello") newfunc...
d3eef4c5700ba2717425343dfda202ca5a24c577
mayureshgade19/30-days-of-code-HackeRank
/dictionary.py
836
3.53125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT # d ={} # l=[] # n = int(input()) # for i in range(n): # key,value=input().split() # value=int(value) # d[key]=value # for a in range(len(d)): # a=input() # l.append(a) # for a in l: # if a in d: # print(a+"="...
d7de62aa4a9e2498a8437cdea24cb26831975034
JerAguilon/Python-Sandbox
/dynamic_programming/regex/regex.py
3,516
4.0625
4
# Problem: Create method matches(pattern, string) that returns whether a pattern matches a string. # * after a character means that the previous character can match unlimited times, including no times. # Note: * is called a 'wildcard match' # # Test cases: # a* matches aaaaa, "" (empty string), a, etc. # ca*b matches...
f7a21d928db65e69814e191795ba73d1f3791de1
mkozel92/algos_py
/dynamic_programming/coins.py
469
4.09375
4
def coins(values: list, sum_to: int) -> int: """ count all possible ways how to combine coins of given values into desired sum amount complexity O(N) :param values: coins values :param sum_to: sum :return num of possible ways to combine coins """ dp = [0] * (sum_to + 1) dp[0] ...
a52f12fd6361c53184feb138a69bce1c18be97cf
c-eng/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
369
4.4375
4
#!/usr/bin/python3 """Line counting function """ def number_of_lines(filename=""): """counts and returns number of lines in a file Args: filename (str): filename/filepath """ count = 0 if type(filename) is str: with open(filename, 'r') as fyle: while (fyle.readline() != ...
6de8571bde5b2ebde73e62814c25a7bde3f0243b
zhengminhui/leetcode-python
/src/isAnagram.py
526
3.734375
4
def isAnagram(s, t): """ :type s: str :type t: str :rtype: bool """ #return sorted(s)==sorted(t) di1, di2 = {},{} for char in s: if char in di1: di1[char] += 1 else: di1[char] = 1 for char in t: if char in di2: di2[char] += ...
fe0b0a54d76e695588caa2edd57f68bd53e06a28
Gauravyadav678/pythonlab
/exists.py
63
3.734375
4
a=(1,2,3,4,5,6,'hi','hello') print('exists in tuple',2 in a)
d9c79fc9d8540fd81624acc2294913aab4b21e4f
gjwei/leetcode-python
/medium/Sum of Left Leaves.py
1,034
3.875
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def sumOfLeftLeaves(self, root): """ :type root: TreeNode :rtype: int """ if not root: retu...
7a396472b0aa81d3d35aba78a11eb09d973ce5ff
mubaskid/new
/Evaluation/4.py
411
3.640625
4
a = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] rows = len(a) cols = len(a[0]) for i in range(0, rows): sumRow = 0 for j in range(0, cols): sumRow = sumRow + a[i][j] print("Sum of " + str(i+1) + " row: " + str(sumRow)) for i in range(0, rows): sumCol = 0 for j in range(0, cols): ...
7b2ca9a9bda682fd6d9dbbf7d663373f7b93023b
inaborges/acelera-dev-ds
/10.desafio_final/limpeza_dados.py
5,779
3.515625
4
import pandas as pd from sklearn.preprocessing import StandardScaler class LimpezaDados: def __init__(self): pass def remove_NA(self, dados): """ remove colunas com mais de 70% de NA :param dados: recebe dataframes :return: retorna mesmo dataframe, com as colunas removi...
3d33533136d4e0cf359c7c7a11c3e4b8f4a5065a
malzubairy/programming_tutorials
/Python/tutorial_03/src/tutorial_03.py
9,844
4.375
4
""" Python Tutorial 03: Numerical Python, and Conditions Follow along at: https://christophrenkl.github.io/programming_tutorials/ Author: Christoph Renkl (christoph.renkl@dal.ca) This script provides you with an introduction tp numerical Python using the widely known package 'NumPy'. We will also introduce loops and...
a152e5cb35d3038258e14bbf2013098b079afcff
aguinaldolorandi/Python_exercicios_oficial
/Lista de Exercícios nº 03 Python Oficial/Ex.35-lista03.py
738
3.96875
4
# EXERCÍCIO Nº 35- LISTA 03 - ESTRUTURA DE REPETIÇÃO print('\nNúmeros Primos') print('##############\n') intervalo=0 while intervalo<=0: intervalo =float(input('\nInsira um número inteiro e >0: ')) while (intervalo) != int(intervalo) or intervalo<=0: print('O número deve ser inteiro e maior que...
a98b9977dfc22f0c14ecbc47e6e892498743e0c9
liweicai990/learnpython
/Code/Leetcode/top-interview-questions-easy/Array24.py
786
4.09375
4
''' 功能:存在重复 来源:https://leetcode-cn.com/explore/featured/card/top-interview-questions-easy/1/array/24/ 重点:Python中集合中的元素是没有重复的 作者:薛景 最后修改于:2019/07/06 ''' # 利用集合的去重功能,在将列表转换成集合之后,若两者元素个数相同,即可认为原始列 # 表中无重复元素,是不是超方便呢? # 该方案战胜 99.44 % 的 python3 提交记录 class Solution: def containsDuplicate(self, nums: list) -> bool: ...
3107d9513a273df9bf0e88e322523b880351d268
thuel/xmas_elves
/xmas_elves/user_dialog_prompts.py
684
3.5
4
""" Module providing user input verification methods. Ev. work with https://github.com/nicr9/pydialog (fork it and bump it to pyhton 3) """ def yes_or_no(question, default="no"): """ Returns True if question is answered with yes else False. default: by default False is returned if there is no inp...
679954aab9fb074c1fd52a81819d1e84c3ca675e
AdamZhouSE/pythonHomework
/Code/CodeRecords/2097/60762/240054.py
278
4.1875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import math numerator=int(input())#分子 denominator=int(input())#分母 if(numerator==2 and denominator==3): print("0.(6)") elif(numerator%denominator==0.0): print(numerator//denominator) else: print(numerator/denominator)
87dfa73e4daa5e33b5d69046532398a881e46d01
taivy/Python_learning_projects
/Tkinter/file reader.py
675
3.734375
4
from tkinter import * root = Tk() frame = Frame() frame.pack() def open_f(): f = entry.get() with open(f, 'r') as inf: f_text = inf.readlines() text.insert(1.0, f_text) def save_f(): f = entry.get() with open(f, 'w') as ouf: f_text = text.get(1.0, END) ouf.write(f_text)...
d875d7379e6c2a1fedab4ccf3479c45f65f8ddcc
jtpio/algo-toolbox
/python/mathematics/decimal_to_base.py
575
3.96875
4
import string A = ''.join(str(x) for x in range(10)) + string.ascii_lowercase def dec_to_base(n, b): """ Convert an integer n in base 10 to its corresponding string in base b Parameters ---------- n: int The input integer b: int Base. 2 <= b <= 36 Returns ------- ...
0e5e706cca522a34ca88bb1e60fa45c1d273f828
huangno27/learn
/早期/练习题.py
1,496
3.90625
4
with open(r'C:\Users\13436\PycharmProjects\learnpy\venv\learn_python.txt') as first_name: duqu = first_name.read() print(duqu) #zaidu = '' #for re in duqu: #zaidu = re.rstrip() #print(zaidu) #replace()方法直接替换字符串中特定的单词 firename = (r'C:\Users\13436\PycharmProjects\learnpy\venv\learn_python.txt') with open(f...
3bca7bf6ed5131054f67bf8d0fc7cb39d57ef4e9
hike-training-institute/core-python
/course_content/19_oops/temp.py
1,188
3.59375
4
def sample_function(): print("sample function is called...") class Hand(): finger = 5 def hand_func(self): print("Hi I am from Hand class") class Leg(): toe_color = 'white' class Human(Hand, Leg): # inheritence eyes = 2 finger = 10 # overriding def __init__(self, name, age=27): ...
45f3d0627b88b652863258c39195dae3f0f6ed00
divedeep0123/Justdoit
/Demo1.py
269
3.515625
4
iterable_value = 'Geeks' iterable_obj = iter(iterable_value) while True: try: # Iterate by calling next item = next(iterable_obj) print(item) except StopIteration: # exception will happen when iteration will over break
1a72832d8495e08a419222832084c24f8d7180d8
PuemMTH/history
/Tutol/operator/oop/2SubClassANDSuperClass.py
444
3.828125
4
class ParentClass: name = "Circle" size = 400 r = 20 def SayHello(self): print("Hello") def SayHi(self,fname,lname): print("Hi! %s %s"%(fname,lname)) def Hiv(self): print("Hiv") class ChildClass(ParentClass): #สืบทอด class มาจาก ParentClass def SayObj(self)...
6ce234d9a4e7d09cd391732d1374a5332de84361
HotsauceLee/Leetcode
/DS/Array/Easy/R__189.Rotate_Array.py
2,692
3.796875
4
#========= Pop and insert to the beginning ======== # Time: O(k*n) # Space: O(1) class Solution(object): def rotate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: void Do not return anything, modify nums in-place instead. """ k = k%len(nums) fo...
8fa7b4b95e0fd65016df733a187f1794bab79367
DrydenHenriques/50-coding-interview-questions
/array/06_Zero-Matrix.py
1,154
3.890625
4
#!/usr/bin/python # coding=utf-8 ''' __author__ = 'sunp' __date__ = '2019/1/24' Given a boolean matrix, update it so that if any cell is true, all the cells in that row and column are true. [true, false, false] [true, true, true ] [false, false, false] -> [true, false, false] [false, false, false] [tr...
4140a2a45994c95aa929fa1c1056f52959769734
nowellclosser/dailycodingproblem
/2019-04-29-reverse-polish-notation.py
1,169
4.125
4
# This problem was asked by Jane Street. # Given an arithmetic expression in Reverse Polish Notation, write a program to # evaluate it. # The expression is given as a list of numbers and operands. For example: # [5, 3, '+'] should return 5 + 3 = 8. # For example, [15, 7, 1, 1, '+', '-', '/', 3, '*', 2, 1, 1, '+', '+...
b367816a4623863f8a88509632da4d71142fa961
soaresderik/IFLCC
/01semestre/introducao-algoritmo/python/atv03.py
106
3.984375
4
num = int(input("Digite um númro: ")) print("O sucessor do número " + str(num) + " é " + str(num + 1))
b64e268688387563f7004d4707003c6cd84d142c
addisonpohl/Python-Games
/debug.py
374
4
4
import random number1 = random.randint(1, 10) number2 = random.randint(1, 10) print('What is ' + str(number1) + ' + ' + str(number2) + "?") answer = input() if answer == str(number1 + number2): #Answer is a string, so the number 1 + 2 need to be converted using str() to compare value. print('Correct!') else: p...
2ebfab9b1777ed721a0913cce7534fbd6f4594ad
techehub/pythonbatch20
/functest.py
574
4
4
def add (a,b): return a+b def diff (a,b): return a-b def mul (a,b): return a*b def div (a,b): return a/b def calc(func, a,b): res=func(a,b) return res def main (): x = int (input("Num1#")) y = int (input("Num2#")) op = input("Ops#") if (op == '+'): logic = a...
ce151d9a51bb7fa68184ffa90f1163f73f09654d
As4klat/Tutorial_Python
/Tanda 1/02.py
470
3.78125
4
def interes_compuesto(ci, x, n): return ci * (1 + x / 100) ** n compr = True while compr: try: capital = float(input("Introduce el capital inicial: ")) anios = float(input("Introduce los años : ")) interes = float(input("Introduce el interés (%): ")) compr = False except V...
c1c02ca60c20bb48232f6c2bc3fdc337ed12d463
PyLamGR/Text-Based-RPG
/Codes/Combat.py
1,965
3.78125
4
import random as r from CharacterClass import Character from enemy import Enemy """@Iznogohul""" def end_of_battle(): Enemy.die if Character.current_hp <= 0: print("You Dead") Character.alive = False return False elif not(Enemy.alive): print("You Won") return False ...
069832bda6c1740668a6fca2d520460bf6245fae
Musawir-Ahmed/OOP
/WEEK-1/PDF 3/SMART_LILLY_PROBLEM.py
962
4.09375
4
# SMART LILY PROBLEM # TAKING AGE AS A INPUT age = int(input(" ENTER AGE =")) # TAKING PRICE OF THE WSHING MACHINE AS THE INPUT pricewm = float(input("ENTER PRICE OF THE WASHING MACHINE =")) # TAKING TOYPRICES AS THE INPUT toyprice = float(input("ENTER PRICE OF THE TOY =")) toys = 0 toys = float(toys) money = ...
0665afb4f26b1e179afce3b4b3a31759c5a0cbcc
Michaelnstrauss/Byte
/foundations_assessment/assessment_part_2/q3_part2.py
163
3.625
4
d = { 'Carter': 'value', 'Greg': ['list', 'of', 'values'], 'Kenso': 'VALUE' } d['Nikhil'] = 'another value' print(d['Carter']) print(d['Greg'][1])
ba6ae5402d7396a8f20f5f0ab08b58f9dbaa3e74
dake3601/advent-of-code-2020
/Day6/solver.py
858
3.703125
4
import fileinput from typing import List import string values = [] temp = '' for line in fileinput.input(): line = line.strip() if not line: values.append(temp.strip()) temp = '' else: temp += line + ' ' if temp: values.append(temp.strip()) def count_anyone(values: List[str]) -...
6476d70eb4d6dd5b61c2d8f6ef6d238ac8ecb746
batmit/Introducao-a-Python
/#11/#1.py
874
3.828125
4
# as listas vistas até agora não possuem uma lista organizada # para fazer isso vamos usar o método Bubble Sort, que consiste em trocar de posição dois valores se # eles forem repetidos l = [7, 4, 3, 12, 8] fim = len(l) while fim > 1: # devemos repetir várias vezes, para que não tenha de fato nenhuma repetição t...
6922ed701a8e73110f76ad5f92c56dca6de539cb
heyestom/TDD-practice
/Shapes/shapes.py
472
3.984375
4
import math class Rectangle: def __init__(self, x,y): self.x = x self.y = y self.circumference = (self.x+self.y) *2 self.area = x*y def __str__(self): return "Circumference : " + str(self.circumference) + "\nArea :" + str(self.area) class Circle: def __init__(self, r): self.r =r self.circumference ...
659275791b733c9151d54080d7186711467a9b6f
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/mjlkhw001/question2.py
227
4.125
4
# Program to create an isoceles triangle # Khwezi Majola # MJLKHW001 # 20 March 2014 def tri(): h = eval(input('Enter the height of the triangle:\n')) for i in range(h): print(' '*(h-i-1) + '*' * (2*i+1)) tri()
44f92bf1de84155640c491b4f6a4fb1899e2cf4c
rafaelperazzo/programacao-web
/moodledata/vpl_data/169/usersdata/268/72528/submittedfiles/divisores.py
362
3.984375
4
# -*- coding: utf-8 -*- import math n=int(input('Digite a quantidade de multiplos: ')) a=int(input('Digite o numero a : ')) b=int(input('DIgite o numero a : ')) i=1 while (i<=n): multiploa= a*i multiplob= b*i if ( multiploa == multiplob ): print(multiploa) else: print(multiplo...
1f3a68c2473242f195a320e77a27c097ddc0f946
bobbobbio/monopy
/board.py
13,059
3.78125
4
import json import random import game import cards # Abstract class that represents a tile on the Monopoly board class MonopolyBoardTile(object): def __init__(self, board, name): self.name = name self.board = board def __str__(self): return self.name def activate(self, _inout, _p...
6813c6bd9af5639726575d9f70a56d0825ef6b88
CyberSmart02/competitive-programming
/Dynamic Programming/(LEETCODE)Regular _Expression_ Matching.py
757
3.546875
4
// Solution to https://leetcode.com/problems/regular-expression-matching class Solution: def isMatch(self, s: str, p: str) -> bool: cache={} def dfs(i,j): if (i,j) in cache: return cache[(i,j)] if i>=len(s) and j>=len(p): return True ...
117d68690749a7da52f8aef7a8c882d573b61964
text-utf8/text-utf8
/benchmarks/python/strip_tags.py
445
3.5
4
#!/usr/bin/env python import utils, sys def strip_tags(filename): string = open(filename, encoding='utf-8').read() d = 0 out = [] for c in string: if c == '<': d += 1 if d > 0: out += ' ' else: out += c if c == '>': d -= 1 print(''.join(...
1ccd3e6cb8676a8d71e24f7b5095db11d9a42c11
jkashish33/Assignments
/Task4/ques12.py
130
3.625
4
def divide_num(n): try: n = n/0 except ZeroDivisionError: print("Divisor can't be zero") divide_num(5)
8c132f66178f5988d98bb863ad7a535d67ed197a
c4n2012/python_hw
/basics/matrix_reverse.py
1,095
3.921875
4
def matrix2array(matrix): matrix_size = len(matrix.split()) matrix_temp = matrix.split() splitted_matrix = [] for i in range(0,matrix_size): splitted_row =[] for j in range (0,matrix_size): splitted_row += matrix_temp[i][j] splitted_matrix += [splitted_row] #print...
31c13d7b227a8fe42e76bcf012fce233b539581a
cn5036518/xq_py
/python16/day1-21/day002 while 格式化输出 运算符 编码/01 while循环/04 运算符.py
3,185
3.625
4
#!/usr/bin/env python #-*- coding:utf-8 -*- print(2 > 3 and 4 < 6) #False print(False and False) #False print(10 < 6 or 9 > 7 or 5 > 8) #True print(False or True or False) #True print(not 5 > 6) #True print(not False) #True # 面试题 # 运算顺序 () => not => and => or print(1 > 2 and 3 < 6 or 5 > 7 and 7 > 8 or 5 < 1 ...
f76662ed94850b2eb2dccdfbdd73f78615120a98
muyisanshuiliang/python
/function/function_demo_001.py
289
3.609375
4
def foo(): print('in the foo') bar() def bar(): print('in the bar') def double(x, y, z): return x * 2, y * 2, z * 2 # 多个return,只执行第一个 return 'hello' foo() double_value = double("yl", 234, "234") print(type(double_value)) print(double_value)
d038b9bca15b00db31812f2eee5bba63d9aba08b
laksh10-stan/Python-Core-Tutorial-Codes
/Edureka_tut_2/Edureka_tut_2.7.py
771
4.09375
4
#FUNCTIONS AND OOPS ''' Functions ---> block of organized, reusable code that is used to perform a single and related action use--> section of code to be used multiple times ''' num = int(input('Number: ')) factorial=1 if num<0: print('Must be positive') elif num==0: print('Factorial = 1') else: for i in r...
046675bfd3ffa80632e8dd6469d522c61b762ead
banana-galaxy/challenges
/challenge4(zipcode)/BlackDragon36.py
210
3.703125
4
def validate(code): if code.isdigit() and len(code) == 5: for i in range(0, 3): if code[i] == code[i + 2]: return False return True else: return False
2e44f519c4d9c20133ac8ef6dbffb4f46c90bfca
axim1/LABS
/Python/air_gauge.py
915
3.609375
4
from matplotlib.pyplot import * from numpy import * R = 287.058 #Specific Gas Constant for Dry Air. [J/Kg.K] d0 = 1.2922 #Density of Air at 273.17 K. M = 0.02897 #Molar Mass of Dry Air. [Kg/mol] b = 3.4E-3 ...
56aac2eab89e8bf1e45e3a01f0a05bfaa18f3d18
ashrafm97/python_projects
/factory_functions_actual.py
1,094
4.15625
4
#creating function for making dough #water, flour = return dough #else:return not dough def make_dough(ingredient1, ingredient2): if ingredient1 == 'water' and ingredient2 == 'flour': return 'dough' else: return 'not dough' #baking bread robot... #when dough = baked #return bread was baked #el...
0a5ea20c69b00d46c8224fd4dbbf8a8bde461e8b
EduChancafe/T07.Chancafe_Carrion
/bucles_para/ejercicio4.py
517
3.765625
4
import os #imprimir la suma de los cubos de los numeros del intervalo [2,4] #input numero=int(os.sys.argv[1]) i=0 #validador de datos intervalo_no_permitido=(numero<2 or numero>4) while(intervalo_no_permitido): numero=int(input("ingresar un numero del intervalo permitido:")) intervalo_no_permitido=(numero<2 ...
ed638710658e88f012908175827bb760cc98bfbd
justmarkham/DAT4
/code/05_pandas.py
16,825
3.609375
4
''' CLASS: Pandas for Data Exploration, Analysis, and Visualization MovieLens 100k data: main page: http://grouplens.org/datasets/movielens/ data dictionary: http://files.grouplens.org/datasets/movielens/ml-100k-README.txt files: u.user, u.data, u.item WHO alcohol consumption data: article: http://fiv...
6676ae64d40db1e0b3a433cfdc1ee026eb73e3b8
jeongwook/python_work
/ch_08/8_10_great_magicians.py
773
4.1875
4
magicians = ['jason', 'dave', 'jin', 'josh', 'rodney'] def show_magicians(magicians): """Show a list of magicians.""" for magician in magicians: print(magician) def make_great(magicians): """Modify and add "the Great" to each magician.""" # Build a new list to hold the great musicians. great_magicians = [] ...
0ed50edb64c049d80e493061e78cf798c7526679
fineguy/Markov-Chain-Text-Generator
/text_generator.py
1,989
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 2 20:31:12 2015 @author: timasemenov """ import json import random import time PATH_TO_STATISTICS = "./statistics.json" class TextGenerator: def __init__(self): self.__data = {} self.__seed = 1337 self.__pairs = [] self.__words_cou...
3d4fd473b51e5112592a755c94e42a32beb492ff
emilia98/Python-Algorithms
/02. Lists & Functions/02.MaxNumber.py
150
3.53125
4
a = [10, 45, 67, 89, 34, 91, 15, 18, 34] n = len(a) print(a) max = a[0] for i in range(1, n): if (max < a[i]): max = a[i] print('Max = ', max)
1816fc8f8444cbcc40633d1d7a9b91e114a4de53
test3207/learnPythonInOneDay
/05面向对象.py
1,907
4.21875
4
# 任何事物都可以作为变量,而一个变量往往无法用简单的数据结构表示,比如人有姓名年龄身高体重。 # 这些属性视情况而定,有的需要有的不需要,但是一般来讲编程很容易遇到需要很多属性才能实现的功能。 # 因此面向对象一个重要点在于构造合适的对象,对应的结构在python中也就是dict。 # 手动为不同的人一个个写dict有些太复杂了,有很多属性是可以复用、或者大多数dict的某一属性是相同的。 # 为了减少冗余,更好地复用,引入了class的概念,也就是同一类对象,可以通过class来批量生成。 class Dancer(object): def __init__(self, name, age): sel...
db631263d81bd7070a49937d6a98c21d526f3384
gabriellaec/desoft-analise-exercicios
/backup/user_154/ch79_2019_04_04_20_53_39_557725.py
288
3.5
4
def monta_dicionario(lista1, lista2): result = {} i = 0 while i < len(lista): lista = [] if lista1[i] in result: lista = result[lista1[i]] lista.append(key) result[lista1[i]] = lista return result
f9444b6a742973153413eeeafc3e599fcebae9af
justinux75/BlindTeX
/BlindTeX/iotools/iotools.py
6,361
3.546875
4
#-*-:coding:utf-8-*- import os import copy import string import subprocess import mainBlindtex import os import re from sys import argv #HU1 #Method to open a file and return its content as a string. def openFile(fileName): '''This function takes a file a return its content as a string. Args: fileName(str): The...
ed3d7d37e4478ce80d81e3036ba308028aad6fba
deepkumarchaudhary/python-poc
/DevOps/xmltojson.py
869
3.765625
4
# Program to convert an xml # file to json file # import json module and xmltodict # module provided by python import json import xmltodict # open the input xml file and read # data in form of python dictionary # using xmltodict module with open("D:\Data\git-deep\python-poc\DevOps\emp.xml") as xml_file: ...
284802fde1bb708a7a577b72d15dd06cc2d7c6d1
robgoyal/CodeChallenges
/CodingBat/Python/Logic-2/round_sum.py
339
3.8125
4
#!/usr/bin/env/python # round_sum.py # Code written by Robin Goyal # Created on 27-08-2016 # Last updated on 27-08-2016 def round_sum(a, b, c): a = round10(a) b = round10(b) c = round10(c) return a + b + c def round10(num): if (num % 10 < 5): return num / 10 * 10 else: retu...