blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
bbe45526e78a6c149ba67881a2b55243721b9d24
Danilo-mr/Python-Exercicios
/Exercícios/ex041.py
275
3.828125
4
ano = int(input('Ano de Nascimento: ')) idade = 2020 - ano print(f'{"CATEGORIA":=^20}') if idade < 10: print('MIRIM') elif idade < 14: print('INFANTIL') elif idade < 19: print('JUNIOR') elif idade < 20: print('SÊNIOR') else: print('MASTER')
ceb0b9e762fadd6d2931fe9e0f572f4df4f3e355
rafael-larrazolo/ml-keras
/sesion_1/ej7-lineales.py
254
3.578125
4
#-*- coding: utf-8 -*- import numpy as np # A x = b A = np.array([ [2, 3, 12], [1, 1, 2], [2, 0, 3] ]) b = np.array([ 31, 9, 7 ]) # x = A^-1 b Ainv = np.linalg.inv(A) x = np.matmul(Ainv, b) print(x) print(np.matmul(A, x))
83eeb25bd083c8470d2c68cca6879629122c2666
keegangunkel/SoftwareTestingLab2
/problem6.py
893
4.3125
4
#################################################### # # Keegan Gunkel # # Purpose to find the area of a trapezoid # #################################################### import math def main(): print("-------------------------------------------------------------") print("PYTHON PROGRAM TO FIND THE ARE...
e91fd58bb7b69c5db7ee1a3669cdb0c456decbf0
meghakashyap/dictionary
/odd_and_even.py
194
4.1875
4
Input = {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5} for value in Input.values(): print(value) if value%2==0: print("even", value) else: print("odd") #find even and odd
b2370a0114613876290ac4776210884920462eb9
pcuste1/ProjectEuler
/prob5.py
466
3.65625
4
import math def smallest(number): for i in range(2, number): if number % i == 0: return smallest(number // i) return number def patvisor(list, total): for i in list: if(total % i != 0): return patvisor(list, total * smallest(i)) return total def...
950ee33e52e62a940861334f1a405c8156e9ca00
justsolo-smith/-trie
/113.路径总和-ii.py
981
3.625
4
# @before-stub-for-debug-begin from python3problem113 import * from typing import * # @before-stub-for-debug-end # # @lc app=leetcode.cn id=113 lang=python3 # # [113] 路径总和 II # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x #...
fafe4f8a60a3ac26cffce2fbbca8df430470078e
juanoyarceg/Python-Ejercicios
/Python_EjerciciosCiclos/cuenta_regresiva.py
470
3.578125
4
# -*- coding: utf-8 -*- """ Created on Mon May 13 19:43:56 2019 @author: JUAN """ """cuenta_regresiva = int(input("Ingrese un numero para comenzar la cuenta\n")) for i in range(cuenta_regresiva): tmp = cuenta_regresiva print("Iteracion {}".format(tmp - i))""" cuenta_regresiva = int(input("Ingrese u...
f70b4a24ed5e02a7cf3c7ffca5559bb134a54287
amanchourasiya/leetcode
/algoexpert/singleCycleCheck.py
626
3.5625
4
# Space O(1) | time O(n) def hasCycle(arr): n = len(arr) startIndex = 0 currIndex = 0 for i in range(n-1): index = getIndex(currIndex, arr[currIndex], n) print(currIndex, index) if index == startIndex: return False currIndex = index if getIn...
29b71cdacb117580a9b0f27f014db5233f8b4c9b
jtrain/supapowa
/textentry.py
7,100
3.5
4
import pygame from pygame.locals import * from string import maketrans from constants import * from font import * from button import * from textgrab import TextGrab __all__ = ['Textentry', 'PermaText'] class Textentry(pygame.sprite.Sprite): def __init__(self, pos, containers, callback, heading='Enter Text..', ...
a9de2b04d609e101941429a2606185ea637c6f59
Maxim-Krivobokov/python-practice
/Book_automation/ch6/pw.py
568
3.6875
4
#! python3 #pw.py - program for unsecure password keeping PASSWORDS = {'email': 'po4ta_po4ta_pe4kin', 'blog': 'blogblogblog123321', 'luggage': '12345' } import sys, pyperclip if len(sys.argv) < 2: print('You should enter an argument - name of your credential/login') sys.exit() acc...
584f43aeec954d11a60c4903f60b69a3cc7e1a4a
Rohan2015/fsdse-python-assignment-103
/build.py
644
3.578125
4
def compress(user_string): op_string = "" count = 1 if user_string == None: return None elif user_string == '': return '' op_string += user_string[0] for i in range(len(user_string)-1): if(user_string[i] == user_string[i+1]): count+=1 else: ...
5ab2826b77989f189afc263f460b65c8f8d1e263
mychristopher/test
/pyfirstweek/第一课时/通用装饰器.py
396
4
4
#!/usr/bin/python # -*- coding: utf-8 -*- #通用装饰器 def outer(func): def inner(*args, **kwargs): #添加修改的功能 print("&&&&&&&&&&&&&&&&&&&&&") func(*args, **kwargs) return inner @outer #函数的参数理论上无限制,但最好不要超过6-7个 def say(name,age): print("my name is %s, I am %d years old" %(name ,age)) say("s...
a5605ddad0ed34de3b1d878ff4b02fa94793bd6d
Ashish9426/Python-Pattern-Printing
/Pattern_15.py
173
3.515625
4
def fun15(): for i in range(5, 0, -1): for j in range(i, 0, -1): print(j, end=' ') print() ''' 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 ''' fun15()
ebba6bafd11d8ad4bf73d6b76b7e92b142f03443
lwoiceshyn/leetcode
/unique-paths.py
2,822
4.15625
4
''' https://leetcode.com/problems/unique-paths/ ''' class Solution: ''' Top-down dynamic programming (recursion + memoization). Every time we move down or right, we are solving a subproblem of the same type, just on a slighty smaller grid (optimal substructure property). Thus, we have a recursion tree with two chil...
11e9603e6a0f67b36cba31bc6852302a79e79eaa
zackhsw/myTest_flask
/advance_apply/chapter08/getattr.py
711
3.890625
4
# __getattr__ 、__getattribute__ # __getattr__ 在查找不到属性的时候调用 from datetime import date, datetime class User: def __init__(self, name, birthday, info={}): self.name = name self.birthday = birthday self.info = info def __getattr__(self, item): return self.info[item] def __ge...
8100be0d070adbf1a747ae44a96a197a89133c0a
RaffaeleMarchisio/SISTEMI_E_RETI
/esercizi_vacanze/es1/main.py
959
3.515625
4
import random alfabeto = {0: "a", 1: "b", 2: "c", 3: "d", 4: "e", 5: "f", 6: "g", 7: "h", 8: "i", 9: "j", 10: "k", 11: "l", 12: "m", 13: "n", 14: "o", 15: "p", 16: "q", 17: "r", 18: "s", 19: "t", 20: "u", 21: "v", 22: "w", 23: "x", 24: "y", 25: "z", 26: 1, 27: 2, 28: 3, 29: 4, 30: 5, 31: 6,...
b803f4b936c9b20dc33d90faa7abc26a654662a0
sympy/sympy
/sympy/printing/conventions.py
2,580
3.71875
4
""" A few practical conventions common to all printers. """ import re from collections.abc import Iterable from sympy.core.function import Derivative _name_with_digits_p = re.compile(r'^([^\W\d_]+)(\d+)$', re.U) def split_super_sub(text): """Split a symbol name into a name, superscripts and subscripts The...
b36283dcf18ce454c8630d25248c38712c582de0
zhy19950705/python
/1.py
113
3.59375
4
def normalize(name): return name.capitalize() L1=['adam','lisa','bart'] L2=list(map(normalize,L1)) print(L2)
43f34c7509bf297cf3c0d00bcaae9d0548017c2e
BrettMZig/PythonFun
/primes.py
454
3.765625
4
def composite_gen(prime, first, last): c = prime + prime while c < last: if c > first: yield c c = c + prime def find_primes(first, last): if first < 2: first = 2 mSet = set(xrange(first, last)) primes = [] for x in xrange(2, last): if x in mSet: primes.append(x) mSet = mSet - set(compo...
0e4d12155d53a4ced32fa56f7ef0c8e169b6dc0e
benjaminner/python-scripts
/food.py
201
3.984375
4
food = {"hamburger" : "delicious", "cheeseburger" : "even more delicious", "anchovies" : "no thanks", "pizza" : "yum"} what_did_you_eat = raw_input ("what did you eat? ") print food[what_did_you_eat]
5a3af94ebd384cf529efe8000ddd9c97aab35af2
serpherino/python
/Projects/Notepad/notepad-gui.py
1,061
3.546875
4
from tkinter import * import pyperclip from tkinter import filedialog root=Tk() root.title("Notepad") def copy_to_clipboard(): pyperclip.copy(text.get("1.0","end-1c")) def clear(): text.delete(1.0,'end') def save(): opf=filedialog.asksaveasfile(mode='w',defaultextension='.txt') if opf is None: return entry...
79b436e880cd21b6d5ccf5fd2a1c0dd00aa16018
zhengw060024/pythoncookbookpractice
/exCookbook3.3.1.py
471
3.984375
4
#对数值做格式化输出使用format x = 1234.56789 print(format(x,'0.2f')) #当需要限制数值位数时,数值会根据round()函数规则来进行取整 print(format(x,'>10.1f')) print(format(x,'<10.1f')) print(format(x,'^10.1f')) #千位分割 print(format(x,',')) print(format(x,'0,.1f')) #如果要采用科学计数法只要将f改成e或者E即可 print(format(x,'e')) print(format(x,'0.2e')) #指定宽度和精度格式一般为[<>^]?width[,]?(...
7b4ab424c64f5cb31c2bca5244eaf3e2a4594d74
gholhak/Information_extraction
/misc/second_largest_element.py
2,017
3.734375
4
''' Your desired array is here Example = [2, 4, 9, 10] ''' import random import time ARRAY = [random.randint(1, 100000) for _ in range(100000)] class SecondLargestElement: def __init__(self): pass @staticmethod def check_for_identical_elements(args): temp = [] for e in args: ...
835f467304f690e8cfdcb898d8bb0060e953b912
Arxtage/leetcode
/detect-capital/detect-capital.py
587
3.65625
4
class Solution: def detectCapitalUse(self, word: str) -> bool: # O(n) if len(word) <= 1: return True first_letter = word[0].isupper() second_letter = word[1].isupper() if not first_letter and second_letter: return False ...
78acd9f5b7d19697af10010c1e19b249bfa23730
fraboniface/fbml
/optimization/base_optimizer.py
1,576
3.5
4
import numpy as np class Optimizer: """Optimizer base class. Much slower than scikit-learn implementation.""" def __init__(self, gamma, epsilon): self.gamma = gamma self.epsilon = epsilon def gradient_check(self, func, grad, points): """Checks wether or not the given gradient is correct.""" def base_vecto...
7360c010b554800c22b8577f90a6b3b0cbc53bcd
kmineg144/AccountModule
/python_scripts/scripts/sfdc_account.py
2,605
3.53125
4
import pandas as pd import numpy as np from utility_scripts.account_winner import EstablishWinner def merge_accounts(opportunity, accounts, subset_opp_columns=None): """ Nested function where the inner function loads the df and the outer function merges the two df Parameters ---------- ...
723e76fb7faefb0d4d4f5705b61ca559c7298bd7
ChantalMP/FoobarChallenge
/challenge3_2.py
7,832
3.8125
4
import fractions from fractions import Fraction ''' Making fuel for the LAMBCHOP's reactor core is a tricky process because of the exotic matter involved. It starts as raw ore, then during processing, begins randomly changing between forms, eventually reaching a stable form. There may be multiple stable forms that a s...
1f5ed4f1416a31eaffc12a4f61e2cc03f1c5de2b
Jen456/Examen_Fund_Programacion-
/PythonApplication1.py
482
3.75
4
numero= int(input('Ingrese numero:\n')) contador =0 lista_mul= [] lista_sum=[] mul=1 suma=0 while (): numero= numero /10 if contador==1 or contador ==3: lista_mul.append(numero) contador= contador+1 else: lista_sum.append(numero) contador= contador+1 for i...
b86774ac2d76ac1a1074609a3c0559633dfcced0
scotttct/tamuk
/Python/Python_Abs_Begin/Mod4_Nested/4_1_2-Birds.py
706
4.0625
4
# Found answer on: https://www.codeproject.com/Questions/1247399/Calling-function-in-nested-IF-in-Python bird_names=('crow', 'parrot', 'eagle') def bird_guess(): bird_guess1=input('Enter the bird guess :') return bird_guess1 guess = bird_guess() if(guess not in bird_names): print('1st try fail, do 2nd tr...
b95933bb910c31c20795b77af93db09cdda490af
codeswhite/get_cover_art
/get_cover_art/deromanizer.py
851
3.796875
4
import re # based on https://www.tutorialspoint.com/roman-to-integer-in-python class DeRomanizer(object): def __init__(self): self.romans = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000,'IV':4,'IX':9,'XL':40,'XC':90,'CD':400,'CM':900} def convert_word(self, word): if not re.match(r"^[I|V...
c346457c13e00ddbd637b46f6d147df20fdb1e65
yarbroughjm/Python
/strings2.py
271
3.828125
4
message = "welcome to Python! Thanks for taking my class!" message2 = "mark" message3 = "768345345" print(message.find('for')) print(message.find('xx')) if message.find('xx') == -1: print("Not found in message") print(message2.isalpha()) print(message3.isdigit())
132459a9a43dac4fee3dbcbf190bdbb121dcc727
nidhi99verma/Exercies-Python
/o7.py
208
3.78125
4
# * # *** # ***** print def print_t(n): x = '*' y = ' ' z = n-1 for i in range(1,n+1): print(f"{y*(z)}{x}{y*(z)}") z-=1 x += "**" return print_t(3)
2b791161de81aa867a7f251e9c32c46da9a787fd
ahartz1/project-euler
/python/e028number_spiral_diagonals.py
1,860
4.03125
4
""" Project Euler #28: Number Spiral Diagonals From the description: Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 ...
1e84b0e9be671d586c76f57555e25cd548474bf9
Palombredun/miniscript
/calcul_integral/left_rectangle.py
332
3.765625
4
from math import cos, pi def f(x): return cos(x) def left_rectangle(f, a, b, n): total = 0 step = (b - a)/n x = a for i in range(0, n): total += f(x) x += step print("Nombre de pas :", n) print("Longueur d'un pas :", step) print("Valeur de l'intégrale :", total*step) return total*step left_rectangle(f, ...
a2746e963cc4c32a24d5e743ee5abf0a0748c373
jiinso/In_Class_Exercises
/IP4CS_Exercise12.py
991
4.21875
4
# In Class Exercise 12 # Classes - object oriented programming # author: jiinso # date: 10/23/2014 # create a class "Animal" class Animal: # define attributes country = "Kenya" label = "Animals Found in Kenyan Safari" # define attributes that should be input initially with an instance def __i...
49bf83ab3eb645a06f83d2ecc1eb74545f3e6038
evinpinar/competitive_python
/leetcode/7.py
867
3.890625
4
import unittest class Solution: def reverse(self, x: int) -> int: ''' divmod divides the element and returns the remainder as mod. ''' k = 0 n = [1, -1][x<0] x = abs(x) while x != 0: x, mod = divmod(x, 10) k = k*10 + mod return n * k if -pow(2, 31) <= n * k <= pow(2, 31) - 1 else 0 def rever...
5a945c4a0c8ce71a06b057442a7678340832814f
synthetic-data/synthesis
/regression/generator_make_regression.py
3,213
4.46875
4
""" Generating data with datasets.make_regression function It creates a linear model y = w*X + b, then generates 'outputs' y and adds noise to X. https://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_regression.html#sklearn.datasets.make_regression https://github.com/scikit-learn/scikit-learn/tree/...
b385e0cc54df27d9c60aa82b5f59c1d2403e1381
devashish89/PluralsightPythonIntermediate
/Numeric.py
2,474
3.859375
4
import sys print(sys.float_info) print(sys.int_info) ####### IMP. ###################### print("0.8-0.7", 0.8-0.7) ### fix for above ############ from decimal import Decimal print(Decimal(Decimal(0.8)-Decimal(0.7))) ##same problem with float print(Decimal('0.8')-Decimal('0.7')) ##correct ###### IMP. ################...
144c70d1fbf089310211b95fd16a81aa5247a69c
santiago-1999-dev/Programaci-n-Ing-Bio-
/examenes/covid19.py
2,611
3.984375
4
#--------MENSAJES------- MENSAJE__BIENVENIDO ="Bienvenido a la clinica" presion = 0.0 #-----------CODIGO---------------- print (MENSAJE__BIENVENIDO) _decision = int (input(""" ingrese : 1- para mostrar en pantalla el peso y el valor de la presion calculada 2- para añadir peso de pacientes 3- para ver ...
269ede161c74a2603a5d8e11a9ff6cfce5d471e0
BryanKnightCode/Python-Learning
/Learning/Lessons/Chapter 3/C3_3-8_seeing_the_world.py
1,616
4.78125
5
# Store the locations in a list. Make sure the list is not in alphabetical order. # Print your list in its original order. Don’t worry about printing the list neatly, # just print it as a raw Python list. locations = ['disney', 'australia', 'houston', 'tampa', 'vegas'] print("\nOriginal order") print(locations) # Use...
ee8716769c7f9a5b2aad8fbd8033db3f5d5fd255
oluwatobi1/SCA-tutorial
/Alternative Execution.py
145
4.21875
4
number = int(input("Enter number here: ")) if number%2 == 0: print("This is an even number") else: print("This is an odd number")
75935c4843c9f32e1d43602fa23178631512ff15
sebigher/FMI
/Anul II/Semestrul II/Retele/Laborator2.py
1,153
3.703125
4
l = [1,3,7,10,'s','a'] def functie(lista): # comment pentru hello world variabila = 'hello "world"' print variabila # int: x = 1 + 1 # str: xs = str(x) + ' ' + variabila # tuplu tup = (x, xs) # lista l = [1, 2, 2, 3, 3, 4, x, xs, tup] print l[2:]...
aaf274551d952a66f71be9a42a6e7ccb71e058d7
akolzin/AKolzin_1
/human/Woman.py
1,322
3.734375
4
import random from .Human import Human class Woman(Human): def __init__(self, name='Ivan', soname='Ivanov', age=18, money=0): super().__init__(name, soname, age, money) self.sex = 'female' self.stamina = 100 @staticmethod def reproduce(fother=None, mother=None): if fothe...
1e302f2f558a340823408315b1a036d896e5dea5
aqing1987/s-app-layer
/python/samples/md5-tools/tidy.py
405
3.546875
4
#!/usr/bin/env python dict_file = "aa.txt" out_file = "common-dict.txt1" def main(): ftw = open(out_file, "w") with open(dict_file) as fileobj: for line in fileobj: line = line.strip() words = line.split(" ") for word in words: word = word.strip() if word.isdigit() == False:...
f4bdbc205e8106b585f1807a8d0a2ce42f40ca2a
LuisTavaresJr/cursoemvideo
/ex07.py
217
3.953125
4
nota1 = float(input('Digite sua primeira nota: ')) nota2 = float(input('Digite sua segunda nota: ')) s = (nota1 + nota2) / 2 print(f'Primeira nota foi {nota1} e sua segunda nota foi {nota2}!\nSua Média foi {s:.1f}')
5ca5b29b69d590522c8210d0658299e8067e30ee
lavanyachitra/be
/odd.py
92
3.53125
4
start,end = 4,6 for num in range(start,end+1): if num%2==0: print(num,end= " ")
bdb805138981a77e9cf6fc00c8c58a46af04733d
agrija9/Python-Fundamentals
/Python OOP Tutorial 5: Special (Magic Dunder) Methods.py
1,481
4.0625
4
# super module runs with Python 3 # Special methods are defined with underscores. Init is first and most common method when working with classes # Two more common special methods are repr or str # The three methods: init, repr and str are the most common ones class Employee: raise_amt = 1.04 def __init__(self, firs...
e066903d2ae48c4a833a88ccd060e28ecb221024
sensei98/py
/helloworld.py
147
3.890625
4
a = 1 b = 4 if(a+b==3): print("you are def right but ... sad") else: print("hello sir you are not right") # print (a+b) #first lesson
0103850b6b312638cbf26e9f76a170ffa90b7557
AlanVek/Proyectos-Viejos-Python
/161.py
392
3.640625
4
cadena=input("Ingrese cadena de palabras: ") n=int(input("Ingrese número entero: ")) suma=1 p=0 for i in range (0,len(cadena)): if cadena[i]==" ": subcadena=cadena[p:i] p=i+1 if len(subcadena)>=n: suma+=1 if i==(len(cadena)-1): subsubcadena=cadena[p:i+1] if len (subsubcadena)>=n: suma+=1 if suma>1: ...
1f0b7a79c7ac78aa2b80644d4f47aad309c20dbc
Krupa092/Data-Structures-And-Algorithms_Python
/Basic_Algorithms/Basic_algorithms/Contains_BS.py
1,031
3.96875
4
def recursive_binary_search(target, source): if len(source) == 0: return None center = (len(source)-1) // 2 if source[center] == target: return center elif source[center] < target: return recursive_binary_search(target, source[center+1:]) else: return recurs...
f143e4eab41ad6969552897842acec8367ec2906
miseop25/Back_Jun_Code_Study
/Programmers/기타문제/약수의개수와덧셈/divisor_nums_plus_ver1.py
868
3.796875
4
class Divisor : def __init__(self,left, right): self.left = left self.right = right self.answer = 0 def getDivisor(self,num) : result = set() if num == 1 : result.add(num) return result for i in range(1, int(num//2)+1 ) : if n...
61bcff6bfa670a40fc3466ec995dffab391d534c
georgelzh/Cracking-the-Code-Interview-Solutions
/recursionAndDynamicProgramming/towersOfHanoi.py
1,673
4.125
4
""" Towers of Hanoi: In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order of size from top to bottom (i.e., each disk sits on top of an even larger one). You have the following constraints: ...
f25d53f3aecb31c1fea490b50a61df95f6f203d3
dexbol/bomb
/bomb/utils.py
1,082
3.5
4
# coding=utf-8 import os import logging import re logger = logging.getLogger('bomb') def normalize_path(*path): '''Normally a path. If the path is a direcotry the last character is path separate. ''' path = os.path.normcase(''.join(path)) dirname, basename = os.path.split(path) ...
5949ee5ecb91c69dd3d8fa7b1b78c7991f521fa1
cVidalSP/pythonBasics
/src/listas.py
376
3.84375
4
lista = [1,4,7,"caina",23,14] print(lista) lista.append("python") print(lista) lista.append(20) print(lista) print(lista.index("caina")) print(lista.count(4)) lista.append(4) print(lista.count(4)) print(lista) lista.remove("python") lista.remove(4) print(lista) lista.reverse() print(lista) lista2 = [1,2...
7ea531ba8473b93fc09951dc4d7fc5f3c50c2e4b
huiyi999/leetcode_python
/Can Place Flowers.py
1,574
3.875
4
''' You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, return if n new flowers can be planted in the flowerbed wit...
5f1f408e9714a8da3e9af4eb7996047db5632d68
kmwestmi/Recitation1
/Recitation 1.py
292
3.765625
4
bunny=10.4 print(bunny*5) my_string='hi,how are you' print(my_string) print(type(bunny)) points_obtained=40 total_points=50 percentage=(points_obtained/total_points)*100 print(percentage) x='I am a UB Student','Krissy','Bunny' print(x[0]) print(x[1]) print(x[-1]) y='Turtle' print(y[3])
e2af476495bbb77224169d16e8127084c9201fe3
leo96tush/python-programs
/Weighted Graph.py
253
3.546875
4
n = int(input()) a = [ [ 0 for i in range(n)] for j in range(n)] for i in range(n): for j in range(n): if(i==j): a[i][j]==0 else: i,j,a[i][j] = int(input()),int(input()),int(input()) print(a)
e22f71e0f80dfa579d31d46d0cdce5443ac4c873
orkunkarag/py-oop-tutorial
/oop-py-code/class-attributes-oop.py
287
4.09375
4
#Class Attributes - attributes attached to classes that don't change from obj to obj class Person: number_of_people = 0 #class attribute def __init__(self, name): self.name = name Person.number_of_people += 1 p1 = Person("tim") p2 = Person("jill") print(p2.number_of_people)
234acfd8c30ae25b679d5f9dfcf63fe15426e0b4
quarkgluant/boot-camp-python
/day01/ex00/book.py
2,528
3.890625
4
#!/usr/bin/env python3 # -*-coding:utf-8 -* from datetime import datetime class Book: def __init__(self, name, recipe_list): self._name = name self._last_update = datetime.now() self._creation_date = datetime.now() self._recipe_list = recipe_list @property def name(self):...
de6f293720663f6f122908926f914d81a3a0cfd4
magedu-python22/homework
/homework/02/P22034-beijing-guanpenghui/homework-1.py
546
3.84375
4
#get number from random import randint ansnumber = randint(0,999) print('The answernumber is',ansnumber) #compare number while True: gusnumber = int(input('Pls input a number to compare:')) if gusnumber > ansnumber: print('You input number is larger than ansnumber,pls input again') continue ...
1ba50d3f7574aeef98069df5ce459e94b6ff545d
Ali-Parandeh/Data_Science_Playground
/Datacamp Assignments/Data Engineer Track/7. Command Line Automation in Python/30_readlines_script.py
1,172
4.46875
4
# Backwards day # A colleague has written a Python script that reverse all lines in a # file and prints them out one by one. This is an integration tool for # some NLP (Natural Language Processing) work your department is involved in. # You want to call their script, reverseit.py from a python program you # are wr...
a1e2fc8b4ff11289ce72e8ac6572a6756c38b5fd
L200180088/Algostruk_D
/modul8.py
4,259
3.875
4
##nomer1 class Stack(object): def __init__(self): self.items=[] def isEmpty(self): return len(self)==0 def __len__(self): return len(self.items) def peek(self): assert not self.isEmpty() return self.items[-1] def pop(self): assert not self....
fac0c3e3dbefcc4eef16ad6818d7303e7a402f3d
cbohara/automate_the_boring_stuff
/csv/random_students.py
1,011
3.9375
4
import sys import csv import random def main(args): """Read in csv file, grab student names, and choose random student names.""" try: number_of_winners = int(sys.argv[1]) except IndexError: print('python3 name_generator.py [number of winners]') else: with open('/Users/cbohara/c...
ce2af217d7b097c3017721007bb5813dbee1ab4a
falondarville/practicePython
/passwordGenerator.py
811
4
4
# Write a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your run-time code in a main met...
8e0a5df701af2ba80cb749e9bb8f3f80e288de15
AdamZhouSE/pythonHomework
/Code/CodeRecords/2462/61406/307553.py
286
3.546875
4
source = input().split(',') flag = False for a in range(1,len(source)-1): if int(source[a])>int(source[a-1]): if int(source[a])>int(source[a+1]): print(a) flag = True break if not flag: index=source.index(max(source)) print(index)
17856c2970b029695481229c09211ecd044c3c68
sandinocoelho/URI-Online-Judge
/1017.py
126
3.578125
4
# -*- coding: utf-8 -*- spentTime = int(input()) speed = int(input()) result = (spentTime*speed) / 12 print("%.3f" %result)
8af06e5994b12c4ac02f9e4d11eb0a690e98e36f
abhisheksingh75/Practice_CS_Problems
/Sorting/Chocolate Distribution.py
1,111
3.53125
4
""" Given an array A of N integers where each value represents number of chocolates in a packet. i-th can have A[i] number of chocolates. There are B number students, the task is to distribute chocolate packets following below conditions: 1. Each student gets one packet. 2. The difference between the number of chocolat...
a365a6c8ffa3a7bf462dfe20ddf414860c21281e
wscnm/PythonScript
/SocketChat/Server.py
1,227
3.625
4
#!/usr/bin/python # coding=UTF-8 '''Socket TCP服务端''' import socket import time, threading #启动一个socket对象,监听9999端口 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('0.0.0.0', 9999)) #调用listen()方法开始监听端口,传入的参数指定等待连接的最大数量: s.listen(5) print('Waiting for connection...') def tcplink(sock, addr): print(...
d10b3d51c1b416cc695d9f54c40e215a0980ec01
kunal121/ALL-Python
/file.py
397
3.578125
4
# file handling # open a file fo=open("foo.txt","w+") fo.write("python is awsome") fo.close() # modes in file a+ r+ rb+ w+ b+ # methods in file fo.close() fo.read(10) fo.tell() #gives position of the pointer fo.seek(0,0) fo.closed# file is closed or not fo.mode fo.name# give the file name #os import os os.rename('fo...
253e3db4bf00e3c94a99ca55f64d0a3639285713
allanstone/cursoSemestralPython
/TerceraClase/tareaIMC.py
587
3.984375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #Calculo del IMC while True: peso = float(input("Introduzca su peso")) altura = float(input ("Introduzca su altura")) IMC=peso/altura**2 print("IMC:",IMC) if IMC<=18.0: print("Peso demasiado bajo") elif IMC<=24.9: print("Su peso es normal feli...
baadfaacf4fa2b9e356f676f7375c4ec885f9f90
er3456qi/DjangoPolls
/polls/models.py
1,361
3.5
4
import datetime from django.db import models from django.utils import timezone # Create your models here. class Question(models.Model): """ Each field is represented by an instance of a Field class – e.g., CharField for character fields and DateTimeField for datetime. This tells Django what type of d...
fa6fbc06ad233eca5cafef667450bfc3194ddf2b
nimisha727/python-challenge
/pybank.py
2,308
3.890625
4
import os import csv # joining the path: pybank_csv_path = os.path.join("resources","budget_data.csv") # Assigning the file name: file = pybank_csv_path print(file) # Now opening a file with open(file, "r") as jumbled_data: unjumbled_data = csv.reader(jumbled_data, delimiter=",") # ski...
68fbe79e78575d44a6c82387fca5a286390d28ab
08zhangyi/Some-thing-interesting-for-me
/Python生物信息学数据管理/python-for-biologists/05-biopython/19-sequences/transcribe_translate.py
937
3.640625
4
''' Transcribe & translate a DNA sequence. ----------------------------------------------------------- (c) 2013 Allegra Via and Kristian Rother Licensed under the conditions of the Python License This code appears in section 19.2.2 of the book "Managing Biological Data with Python". ---------------------...
5c2bc6b20655557f027432cdf7ce5e763ae24851
maples1993/Strike-to-Offer
/q52.py
968
3.78125
4
""" Date: 2018/9/3 """ class Solution: def process(self, s, pattern): if not s and not pattern: # 匹配完成 return True if s and not pattern: # 有多余字符 return False # 处理'.'和字符 if len(pattern) == 1 or pattern[1] != '*': if s and pattern[0] == '....
b9476a58856716fc0ab946c308aac44c891db0c9
eduardopds/Programming-Lab1
/tiro/tiro.py
656
3.71875
4
# coding: utf-8 # Aluno: Eduardo Pereira # Matricula: 117210342 # Atividade: Tiro ao alvo lista = [] soma = 0 import math y1 = 0.0 x1 = 0.0 while True: x2 = float(raw_input()) y2 = float(raw_input()) distancia = math.sqrt((x2 - x1) ** 2 + (y2 -y1) ** 2) if distancia <= 200.0: soma += distancia lista.append(dis...
236ea5059a3b27cb774455cd794d3498ed243d16
pantDevesh/1ProblemEveryday
/Problem_037.py
1,014
3.640625
4
# Search in 2d Matrix # import numpy as np class Solution: def searchMatrix(self, matrix, target): if not matrix or not matrix[0]: return False nrows = len(matrix) ncols = len(matrix[0]) low = 0 high = nrows * ncols - 1 while low ...
d96a9573c935d6a50b5cac51f782e3cd056df0b2
im876/Python-Codes
/Codes/terms_of_AP.py
2,877
3.734375
4
''' Problem Statement Ayush is given a number ‘X’. He has been told that he has to find the first ‘X’ terms of the series 3 * ‘N’ + 2, which are not multiples of 4. Help Ayush to find it as he has not been able to answer. Example: Given an ‘X’ = 4. The output array/list which must be passed to Ayush will be [ 5, 11, 1...
ec483745fbf43aedfcab1573f9fc85c82265ac7f
roobixkub/Sushi-Stop
/Sushi-Stop/play.py
5,045
3.546875
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 26 01:40:09 2020 @author: Nate """ import random from deck import deck from scoring import Scoring from hands import Hands def player_reset(): player_set_up = [] player_count = range(0, players) player_num = 1 for player in player_count: pile = ...
dd027bb3616172d19b83a97223393882641af94a
stephen-lazaro/Misc
/py/GeneralField.py
5,240
3.53125
4
def Legendre(top, bottom): #This is defined field independently since the Legendre symbol is a morphism really. top = top%bottom if top==1 or top ==0: return 1 if top%2==0 and top!=2: return Legendre(2, bottom)*Legendre(top/2, bottom) if top == bottom-1: if bottom%4 == 1: ...
69e750b1ad5799d01511ce0cc4acc0a842560def
vash050/start_python
/lesson_1/shcherbatykh_vasiliy/z_4.py
566
4.03125
4
# 4) Пользователь вводит целое положительное число. # Найдите самую большую цифру в числе. # Для решения используйте цикл while и арифметические операции. # num = int(input('введите положительное число: ')) num = int('12459785') number_big = 0 while num > 0: number = num % 10 if number > number_big: ...
c7a83bf76bbc725472daf23b4d525c4a362d0dd3
Audarya07/Daily-Flash-Codes
/Week12/Day4/Solutions/Python/prog5.py
281
4.03125
4
n = int(input("Enter n:")) r = int(input("Enter r:")) def fact(num): fact = 1 for i in range(num,0,-1): fact *= i return fact combi = fact(n) / (fact(r) * fact(n-r)) print("There are",int(combi),"combinations to distribute",r,"medals amongst",n,"employees")
86ecede60f7577c87af7b9147930c34bddb3ecc6
cklein/magick
/examples.py
7,165
3.78125
4
# Examples from the PythonMagick tutorial # In general, ImageMagick commands that altered the images in place # are implemented as methods on the image object. # While commands that returned a new image are methods of magick # and can take any object that can be converted to an image as # the image argument. i...
b4d8662148961205066e5250974ebaf09df17ae2
Sreejakk/python_basics
/Projects/ITC558assignment3YourName.py
12,723
3.890625
4
def menu(): student_file = 'students.txt' try: stu_file = open(student_file, 'r') #reads students.txt file except IOError: stu_file = open(student_file, 'w') #creates students.txt file if not exists assessment_file = 'assessments.txt' try: marks...
83f140736044d75b4a7237213bee8d5fbffaa8ca
vishwanath79/PythonMisc
/Algorithms/dijkstras.py
1,537
3.875
4
# breadthfirst is the shortest segment # dijkstras algorithm path with smallest total weight graph = {} graph["start"] = {} graph["start"]["a"] = 6 graph["start"]["b"] = 2 #nodes and neighbors to the graph graph["a"] = {} graph["a"]["fin"] = 1 graph["b"] = {} graph["b"]["a"] = 3 graph["b"]["fin"] = 5 graph["fin"] =...
09ef091416d170c23881e1ee102787a8626ffecd
Mauzzz0/study-projects
/python/lab2_python/12.1.py
152
3.515625
4
white = list() for _ in range(int(input())): white.append(input()) for _ in range(int(input())): g = input() if g in white: print(g)
c6d44231d50ef32d7cd9d04e69ceda6cbff435dc
NishanthMHegde/DataStructuresInPython
/BST/bst.py
3,629
3.9375
4
class Node(object): def __init__(self, data): self.data = data self.leftChild = None self.rightChild = None class BST(object): def __init__(self): self.root = None def insert(self, data): if self.root: self.insertNode(data, self.root) else: ...
3a4a26d5f6e02f93257758f012ee593054cedfdb
ZhangNing777/LeetCode_Python
/215_findLthLargest.py
832
3.5
4
''' 在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。 示例 1: 输入: [3,2,1,5,6,4] 和 k = 2 输出: 5 示例 2: 输入: [3,2,3,1,2,4,5,5,6] 和 k = 4 输出: 4 说明: 你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。 ''' class Solution: def findKthLargest(self, nums: List[int], k: int) -> int: n = len(nums) index = 0 ...
5971590ef5c68729c4d3d7bd8c00a66a9a123272
Nilsonsantos-s/Python-Studies
/Mundo 1 by Curso em Video/Exercicios Python 3/ex033.py
524
3.90625
4
# leia 3 numeros e verifique o maior e o menor n1 = float(input('Digite um numero:')) n2 = float(input('Digite um numero:')) n3 = float(input('Digite um numero:')) p1, p2, p3 = 0, 0, 0 if n1 > (n3 and n2): p1 = n1 if n2 < n3: p2 = n2 else: p2 = n3 elif n2 > (n1 and n3): p1 = n2 if n...
5eb6f6e36a05ab4a56c5f7ffa39dc44433020a03
szyymek/Python
/print_formatting.py
348
3.828125
4
#Formatting with the .format() method print("This is first string {}, and second {}".format('inside1', 'inside2')) print("This is first string {0}, and first again {0}".format('inside1', 'inside2')) #Formatting floats with specific precision wynik = 100/33 print("Result is: {w:1.2f}".format(w=wynik)) print("Result is:...
0bb6cd9eed86e44cbddbd0f151a733c8e8aac7d9
Zhenjunwen/mohu_testcase
/TruncateDecimal.py
250
3.828125
4
def truncateDecimal(num,digits=0): num = str(float(num)) nummian = num.split(".")[0] numsub = num.split(".")[1] numsub = numsub[:digits] num = nummian+"."+numsub # print(num) return num if __name__ == "__main__": pass
805154b5c74ed26b90cd781b73550b179e5d7445
standeren/FileMeToTheMoon
/wordCounter.py
908
3.53125
4
import collections def countWords(filename): unique_words = {} textfile = open('static/' + filename, 'r') text_list = [line.replace(',', '').replace( '?', '').split(" ") for line in textfile] total_words = 0 for line in text_list: for word in line: word = word.lower() ...
d2bae640179b8fc29a5abbfa81095b5bff6ed67d
arnoldza/Euchre_April_2019
/players2.py
26,048
3.828125
4
import random import cards class AmazingPlayer(): """ Model a player that often makes decisions based on a better strategy. """ trump_clubs = [cards.Card(9,1),cards.Card(10,1),cards.Card(12,1 ),cards.Card(13,1),cards.Card(1,1),cards.Card(11,4),cards.Card(11,1)] trump_diamonds = [cards.Card(9,2)...
000e1349b700292ead80959f2782fc15870c247a
OliverDevon/pythonGAme
/PROPERGAME.PY.py
3,419
3.765625
4
import random from time import sleep def playAgansitAI(): #list start #player one list start player1 = {} player1['name'] = 'oliver' player1Heath = 100 player1Power = 10 player1['health'] = player1Heath player1['power'] = player1Power print(player1) #AI list start/pla...
1c75afe5de459fb8bd94c9c61b926779fb3a36a2
rafaelperazzo/programacao-web
/moodledata/vpl_data/88/usersdata/165/55971/submittedfiles/listas.py
451
3.625
4
# -*- coding: utf-8 -*- def degrau(a): b=[] for i in range(0,len(a)-1,1): x=abs(a[i]-a[i+1]) b.append(x) return(b) def maior(a): c=degrau(a) maior=c[0] for i in range(0,len(c),1): if c[i]>maior: maior=c[i] return(maior) n=int(input('digi...
7d6035edd8f702a5d5378cf46ba59b743a77e977
Jiang765/Hadoop_MapReduce
/temperature_reducer.py
675
3.53125
4
#!/usr/bin/env python import sys current_date = None current_temperature = 0 date = None for line in sys.stdin: line = line.strip() date, temperature = line.split('\t', 1) try: temperature = int(temperature) except ValueError: continue if current_date == date: ...
fd0924a724fe2c2b6c5c3a9a2f0d61f4f9784cbd
rohan-khurana/MyProgs-1
/RunningTime&ComplexityHR.py
1,345
4.25
4
""" Task A prime is a natural number greater than that has no positive divisors other than and itself. Given a number, , determine and print whether it's or . Note: If possible, try to come up with a primality algorithm, or see what sort of optimizations you come up with for an algorithm. Be sure to check out the...
e016f5fb97b09c403617ae98a5092b9c3f1351fe
thiagogmilani/ACO
/main.py
1,614
3.640625
4
#!/usr/bin/python 3 # coding: utf-8 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # MESTRADO EM CIENCIAS DA COMPUTACAO # # DISCIPLINA DE COMPUTACAO INS...
53ea6cbfb9e69bebd2b7dfa7bd0db3285c244694
sharathk91/Python-2018
/LabAssignment1/Source/ValidatePassword.py
1,493
4.375
4
import re #import regular expressions text = input("Enter the Password to validate: ") #take input password string from user flag = 0 #assign flag to zero while True: #loop until the value is false if (len(text) < 6): #check if the length of password is less than 6 chars flag = -1 print("Password...
2036b9cf29ed66f54221f18148d344c552ad540b
Nimisha500/Python_Projects
/5.Password_Generator.py
504
4
4
import random import string character=string.ascii_letters+string.digits+string.punctuation print(character) character=string.ascii_letters+string.digits+string.punctuation print(character) pass_length=int(input("Enter length of password : ")) password="" for i in range(pass_length+1): password+=...
1246f2f9c9d2be667fd2defce2c54a0355dcfe09
ctmakro/playground
/qython/skipfun.py
2,321
3.53125
4
class Node: pass def dummy(key=None): n = Node() n.key = key n.value = None n.forwards = [] # n.height=0 return n inf = float('inf') minf = float('-inf') import random class SkipList: def __init__(self): self.head = dummy() self.tail = dummy(inf) self.head.forw...