blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
84d5ce51a314fa5bd4d42bd5081878b916f9a786
tejas2008/Pycodes
/python codes/sorting codes/ssort.py
313
3.59375
4
s = input("enter numbers:\n") n = list(map(int, s.split())) for i in range (0, len(n) - 1): minIndex = i for j in range (i+1, len(n)): if n[j] < n[minIndex]: minIndex = j if minIndex != i: n[i], n[minIndex] = n[minIndex], n[i] print ("Sorted array:") for i in range(len(n)): print ("%d" %n[i])
fc53e299edebae02a5295b4da5a3c20605f1ca23
MaxASchwarzer/RepresentationLearningHW
/Q_1/Plot_Utilities.py
954
3.625
4
# Dependencies import numpy as np import matplotlib.pyplot as plt # Define a function to plot functions and lists of numbers def PlotFunction(x_, y_, c_ = 'red', label_ = 'Function', alpha_ = 0.75) : plt.plot(x_, y_, c = c_, label = label_, alpha = alpha_) # Define a function to plot functions and lists of numbers...
41689a2f19370d29bf5a6c64e788068fef006478
Mikecast/python-maquina-registradora
/a.py
5,098
4.03125
4
#coding: utf-8 "Este programa simula una máquina registradora" print " Bienvenido a Tienda KAM\n" print " Seleccione la opción que desea.\n" precios = {} inventario = {} lista = [] #inventario def limpiar(): del lista[:] return lista def funcion_uno(): while True:...
67c93bc96c460d9dbeba9ad4b2d39483fa531609
PedroGal1234/Unit3
/squares.py
151
3.953125
4
#Pedro Gallino #9/27/17 #squares.py - prints out number of squares num = int(input('Enter a number: ')) for i in range(1,num+1): print(i**2) i += 1
cb64b4fb7982f48c30fb535b84ab0217b743cc7e
lesage20/happy_birthday_Mr_Soro
/exoparrain2.py
580
3.734375
4
point_depart = 100 victime_poulet, victime_chien, victime_vache, victime_ami = int(input("Combien de poulet avez vous tué: ")), int(input("Combien de chien avez vous tué: ")), int(input("Combien de vache avez vous tué: ")),int(input("Combien de ami avez vous tué: ")) amende = ((victime_poulet + victime_chien * 3 + vic...
54ffa529b0da9558bef0119262ce6da16bd5a092
sidhumeher/PyPractice
/DataStructures/variousOperationsOnLinkedList.py
3,507
3.78125
4
''' Created on Jun 27, 2019 @author: siddardha.teegela ''' class Node: def __init__(self,data): self.data = data self.next = None def display_elements(Node): current = Node while current is not None: print(current.data) current = current.next def re...
701df7af43f0904417d3ab3389c9fa2a2313c704
adolph58/python_practice
/chapter9/practice14.py
223
3.65625
4
from random import randint,choice my_ticket = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e'] print("本期彩票中奖号码是:") s = '' for i in range(1, 5): s += choice(my_ticket) print(s)
c4af10cd77e5aec32279f43a5943305d858f5ff8
ronidad/mosomi
/streamlit-app.py
1,107
3.75
4
import streamlit as st import pandas as pd import plotly.express as px st.title("Smart Farmer Group Project") st.subheader( "This is a project undertaken to help farmers know the average prices of various commodities, the time they can sell their products, wheere to grow specicic commodieits and time to sell them...
79f1a1d3bd3b3c8740f8920bf80c2746a85f41cd
Neiloooo/PythonBasics
/01-Python基础/18-设置变量的列表.py
294
3.65625
4
# coding=utf-8 # E = 3 # F = 0 # grade_list = range(E, F) # print grade_list B = 10 C = 20 D = 2 A = range(B, C, D) print A # 横坐标 03 start = 0 end = 3 # step=1 也可以设置步长 grade_list = range(start, end) grade_list.reverse() print grade_list print b.decode('unicode_escape')
287c5c8385423f46ab072ef0fd0f1ac53466f47d
mtouhidchowdhury/CS1114-Intro-to-python
/Homework 2/hw2q2.py
590
4.15625
4
#takes 3 digit positive integer and prints the sum user = int(input("please input a three digit positive number")) #getting user input firstDigit = user // 100 #first digit attained by dividing by 100 without remainder secondDigit = (user // 10) % 10 #second digit attained by dividing by 10 without remain...
391f1fdf0e30f00e2de004de8d0aee3e1adeef95
larikova/python-practice
/lacey-book/059.py
793
4.03125
4
import random colour = random.choice(["red", "White", "black", "green", "blue"]) print("red, white, black, green, blue") tryagain = True while tryagain == True: theirchoice = input("Pick the color: ") theirchoice = theirchoice.lower() if colour == theirchoice: print("Well done") tryagain = ...
7e50a3b1e1d36837aec170e17e3cd60428eca6ed
benlincoln/Programming-Tests-Python
/Palindromic Substring.py
1,047
4.15625
4
""" Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd" Output: "bb" """ def longestPalindrome(s): """ :type s: str :rtype: str """ ...
9c403e69afc62047e34544d3d03a2b03ea5a8a84
1Allison/python-
/代码/max.py
337
3.84375
4
N=int(input("请输入需要比较大小的数字个数:")) print("请输入需要对比的数字:") # 获取需要比较的一段数字,存入数组num中 num=[] for i in range(1,N+1): temp=int(input('输入第%d个数字:' %i)) num.append(temp) print('您输入的数字为:',num) print('最大值为:',max(num))
5ebc2f2232996e7169d58831ded72f67695eecb5
amaner/Thinkful-Data-Science-w-Python
/statistics-master/chi_squared.py
861
3.75
4
# chi_squared.py # Andrew Maner # data source: https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv # reads in data from the lending club, cleans it, and loads it into # a pandas dataframe # for challenge 2.2.3 in Thinkful data science with python class from scipy import stats import collections import pan...
73dc3fdcc9051631b7d2ee995d2d02e60b0aa9ba
Hgazibara/coding
/codewars/python/5kyu/primes_in_numbers.py
822
3.65625
4
def primeFactors(n): factors = findFactors(n) return stringifyFactors(factors) def findFactors(n): factors = {} for p in xrange(2, n + 1): if not isPrime(p): continue if n <= 1: break while n > 1 and n % p == 0: factors[p] = factors.get(p,...
c66b7bcd418c4b6a4df4572dd41599aaea586edd
dffischer/argparse-manpager
/manpager/structure.py
2,313
3.734375
4
""" manual page sectioning structure The classes in this module model the headers, sections and subsections a manual page is composed of, so that they can be dynamically created and modified, mainly by adding subelements. """ from datetime import date class Container(list): """ Element containing further ele...
7cc0c30ea03032c9f0c09db6f652ad9e10cb3dbb
widiasto/IF-dan-ELSE
/IF dan ELSE.py
415
3.578125
4
nama = "Gama Widiasto" nim = "04217017" umur = 18 print("Namaku :" + nama) print("Nim :" + nim) print("Umur") print(umur) if(umur < 35): print("Umurku : ", umur, "tahun -> Masih Muda") else: print("Umurku : ", umur, "tahun -> Sudah Tua") umur+=20 if(umur <= 35): print("Umurku 20 Tahun ke Depan :", u...
c8093626eba2bafc3da1053e62163d893d7e343d
Junohera/Learning_Python
/property-descriptor-equiv.py
1,881
3.84375
4
""" 프로퍼티와 디스크립터의 연관 관계 - 프로퍼티와 디스크립터는 강하게 연관되어 있다. - 내장된 프로퍼티는 디스크립터를 만드는 편리한 방법일 뿐이다. - 위의 두 요인을 알았으니 디스크립터 클래스로 내장된 프로퍼티를 구현하는 것이 가능하다. """ class Property: def __init__(self, fget=None, fset=None, fdel=None, doc=None): self.fget = fget self.fset = fset self.fdel = fdel ...
817e964a09d2a101a97684ce7eb8f01de5c99528
akhoronko/adventofcode2019
/advent23.py
1,624
3.59375
4
from itertools import combinations INPUT = """ <x=17, y=-12, z=13> <x=2, y=1, z=1> <x=-1, y=-17, z=7> <x=12, y=-14, z=18> """ # INPUT = """ # <x=-1, y=0, z=2> # <x=2, y=-10, z=-7> # <x=4, y=-8, z=8> # <x=3, y=5, z=-1> # """ INPUT = tuple( tuple(int(x.split("=")[1]) for x in s[1:-1].split(", ")) for s in INPU...
f0fd0d4983b102159f6d3d5c26b19e48ea8a8c7e
Anjaneyavarma/Python
/python-practice/while1.py
339
3.71875
4
name = str(input()) x = 0 for i in name: x+=1 print(name[0:x]) for i in name: x-=1 print(name[0:x]) # x = int(input()) for i in range(0,5): for j in range(i): print("*", end=" ") print() for i in range(5,0,-1): for j in range(i): print("*", end=...
955aa650829c230ad2bec9d3ae3674a1fc108889
M0673N/Programming-Fundamentals-with-Python
/07_dictionaries/exercise/05_softuni_parking.py
708
3.828125
4
n = int(input()) data = {} for i in range(n): command = input().split() if command[0] == "register": username = command[1] plate = command[2] if username not in data: data[username] = plate print(f"{username} registered {plate} successfully") else: ...
d9e9a890072569f59ea727893a1a3cf287aa81d4
bguayante/FileSystem
/filesystem.py
3,967
4
4
import sys # File explorer's default location # current_dir = "root/" # To hold "files" and "directories" as dictionaries in a list # fileList = [] # For creating "files" and "directories" when the touch and mkdir commands are used # class Link: def __init__(self, name, parent_directory, is_directory=False): ...
4d14cfcdecf2c8c8b27ba03bd46915cc15fe1241
XjyaWs/XjyaWs-s-Space
/Day7/homework/basic_ex3.py
1,806
3.96875
4
""" 3.定义一个时间 Timedate 类 一个初始化方法,可以初始化对象属性datetime,属性类型就是datetime类型,如果外界传了就是外界传入的时间,如果没有传入默认就采用当前系统时间 一个绑定给对象的方法get_season,可以得到当前对象所在时间对应的季节(1~3月代表春季) 一个静态类(普通函数)方法get_now_season,获取当前系统时间所存的季节 一个绑定给类的方法get_next_season,利用get_now_season方法得到即将到来的季节 """ import datetime class Timedate(object): dtime = d...
c32334eb9083740b27a9c6862bb88f1873474ae5
kangnamQ/I_Do
/code/AI/F_F_7_1.py
591
3.515625
4
import numpy as np from sklearn.datasets import load_iris from sklearn.linear_model import Perceptron iris = load_iris() #MLP로 다시 시도이므로 조건을 그대로 주겠습니다. X = iris.data[:, (0, 1)] #꽃의 너비와 높이만을 입력으로 함 y = (iris.target ==0).astype(np.int) #출력은 "Iris Setosa인가 아닌가" 이다. print("y 값 : \n", y) percep ...
f30ae91ea1e4e72d1ab8162a3618815ccb2d8bda
Kou839/los-webos-de-oro2020-1
/Examenes/qui_cuarentena.py
1,459
4.09375
4
#--------------Mensajes----------- MENSAJE_BIENVENIDO= "bienvenido al programa" #--------------Codigo------------- print (MENSAJE_BIENVENIDO) pesosPacientesIniciales = [32,64,74,85,98,115,122,127,137,148] def mostrar_lista (pesosPacientesIniciales): if (len(pesosPacientesIniciales)): for i in ra...
96bffd9e34ad9167d563490d405e2d7b4cfea9f1
AstridCaballero/CS50
/pset6/credit/credit.py
1,990
3.6875
4
import cs50 import math def main(): card = get_card_number() l = get_length(card) luhns = luhns_alg(card, l) if (luhns == 0): print("INVALID\n") else: get_brand(card, l) def get_card_number(): while True: n = cs50.get_int("Number: ") if n > 1: brea...
25ee42712c40fd833f05b945c79a0b508fe4c5fe
Chen-Jingkai/IBI1_2019-20
/practical 5/practical 5(3).py
378
3.5625
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 24 19:19:12 2020 @author: 16977 """ import random x = random.randint(1,8192) x1 = x print(x,"is",sep=" ",end="") for i in range(0,14): j = 13 - i if x > 2 **j: print("2**",j,sep=" ",end="") print("+",end="") x = x - 2 ** j elif x == 2 ...
c6e2fcc274fd5a5081afc56e5ee9c028a65a82e0
BrunoDuzanjo/bruno-dos-anjos-poo-python-ifce-p7
/Atividades[Presença]- Etapa 1/E1-Atividade-03/MegaSena.py
374
3.578125
4
import random def repetido(): if len(sorteadoLista) != len(set(sorteadoLista)): sorteadoLista2 = set(sorteadoLista) sorteadoLista = [] sorteadoLista2 = [] while len(sorteadoLista2) < 6: sorteado = random.randrange(1,61) sorteadoLista.append(sorteado) repetido() sorteadoLista2...
77ccdbb840c640d24b9106f0545ff7d35f9ce0ac
FBarto/WorkSpace-AED-1-Irems-
/Integrador/principal.py
926
3.703125
4
from Integrador import metodos def menu(): alumnos=[] a=False while (a!=0): print("ingrese opcion 1 para cargar notas \n " "ingrese opcion 2 para mostrar las notas cargadas \n " "ingrese opcion 3 para ver alumnos promocionados \n " "ingrese opcion 4 para ve...
f714f6fd048b223dc4793624b1dcfaf5a30d93b6
thuurzz/Python
/curso_em_video/mundo_01/desafios/usando_modulos_do_python/ex019+.py
357
3.78125
4
# Um professor quer escolhar uma de duas aluna para apagar a lousa. # Escreva um programa que gere um número aleatório que corresponda # ao sorterio de uma das alunas para executar a tarefa! import random a = random.randint(1,4) if a == 1: print('Mia Kalifah') elif a == 2: print('Vivi Fernandes') elif a == 3...
837c22e77c0aca427cae6c0d3c83a103759163d5
rafaelpellenz/Curso-de-Python-exercicios
/ex052.py
246
3.921875
4
num = int(input('Digite um número inteiro: ')) op = 0 for x in range(1, num+1): if num%x == 0: op += 1 if op == 2: print('O número {} é primo.'.format(num)) else: print('O {} número não é primo.'.format(num))
915ce265ca7edf2ef468c5b45b501ac24135e043
m-farooqui/python-examples
/cubic calculator.py
112
4.125
4
#enter a data type for x x = int() #write a definition for the cubic function def cubic(x): return(x,x**3)
45d4368244860e1f0d510d1a8853b1ddc1e764f4
nRookie/python
/effectivePython/Item21.py
1,220
4.15625
4
def safe_division(number,divisor,*,ignore_overflow=False, ignore_zero_division=False): try: return number / divisor except OverflowError: if ignore_overflow: return 0 else: raise except ZeroDivisionError: if ignore_zero_division: ...
3866c4c04b8669e3727ccc381b9fea356f6098d9
shravankumar0811/Coding_Ninjas
/Introduction to Python/4 Patterns 1/Number Pattern 2.py
354
3.703125
4
##Print the following pattern for the given N number of rows. ##Pattern for N = 4 ##1 ##11 ##202 ##3003 ## Read input as specified in the question. ## Print output as specified in the question. n=int(input()) for i in range(1,n+1): if i==1: print("1") elif i==2: print("11") else: p...
32643e05528e3c66e6c5437bdff4f6688ef502a8
fjdurlop/TallerArduinoPython2020-1
/Tkinter/Tkinter/imagen.py
386
3.640625
4
##Insertar imagen from tkinter import * ventana=Tk() logo=PhotoImage(file="python-image.png") label1=Label(ventana,image=logo).grid(row=2) texto="Solamente podemos utilizar imagenes GIF o PNG para la funcion PhothoImage, para otro formato utilizamos el modulo PIL" label2=Label(ventana,justify=LEFT,padx=10,text=t...
2dd4a35e25818082aed6dddddcb6e98305c60cca
nitish-shankar/practice-notes
/41argskw.py
1,661
4.0625
4
#41 def function_name_print(a,b,c,d,e): print(a,b,c,d,e) function_name_print('Harry','Rohan','Skillf','Harshad',4) # The no. of variables in line2 must be equal to this line arguments function_name_print('Harry','Rohan','Skillf','Harshad','Shivam') #not less niether more print(2) def funargs(*args): ...
e1dc9bbb4e5f92561827f86ac173df02cd688ee3
jonsmartins52/cev
/sorteia_aluno.py
194
3.90625
4
from random import choice lista = [] for i in range(1, 5): lista.append(input('Digite o {}º nome da lista: '.format(i))) print('O grande vencedor foi... {}'.format(choice(lista)))
a8670c81ee49c94b1f455976cfdffd3b182cc7b9
mahesdwivedi/CS101-building-a-search-engine
/first.py
164
3.921875
4
def factorial(n): i = 1; f = 1; while (i <= n): f = f*i; print f; print i; i = i+1; return f; print factorial(5);
ef3fc59bcb52eb39f2f4d5bf4f415f1d34b6d941
CMPUT-291-Miniproject/MiniProject-1
/Vote.py
2,084
3.9375
4
import sqlite3 class Vote: def __init__(self, dbName): """ Class to interact with votes. Parameters: dbName: String. Name of database. Returns: N/A """ self.__dbName__ = dbName def check_vote(self, pid, uid): """ Checks to see if a user has already voted on a post. Parameters: ...
c4fb4d70de11cd4da1aca0cb675c20bdb53e1d9a
erjan/coding_exercises
/most_frequent_even_element.py
1,410
3.765625
4
''' Given an integer array nums, return the most frequent even element. If there is a tie, return the smallest one. If there is no such element, return -1. ''' class Solution: def mostFrequentEven(self, nums: List[int]) -> int: nums = list(filter(lambda x: x % 2 == 0, nums)) if ...
9c8d5d3882b5a33daad056a4e85f033e3dc25d51
jboddey/iGCSE-2017
/program.py
3,310
3.90625
4
## Functions ## def isName( string ): return len(string) > 0 and all(c.isalpha() or c.isspace() for c in string) def isNumber( string ): try: number = int(string) return True except: return False def toBoolean( string ): if (string.lower() in ("y", "yes", "true", "1")): ...
7f28ae548845751e80458013beca76e07d2c00b4
Jenni1985/DI
/Week_5/Day 3/class.py
1,293
3.78125
4
# class Writer: # # def __init__(self, name, n_books, genre): # self.name = name # self.n_books = n_books # self.genre = genre # # def write(self): # self.n_books +=1 # print(f'{self.name}wrote a book') # # # # if __name__ == '_main__': # albert ...
e7f67062f359b1f78414a66ff89b19e1a4d7892e
kimotot/aizu
/alds/alds1_11_c.py
905
3.5625
4
class Node: def __init__(self, n, l): self.n = n self.next_list = l self.depth = -1 self.visited = False def disp(self): print("{0} {1}".format(self.n, self.depth)) def bfs(nodes, s_list, d): next_node = set() for n in s_list: if nodes[n].visited: ...
d5eef0bb21168dd770ee31fdcc62ec183697f64b
Davidkrmr/AoC
/aoc4_1.py
823
3.6875
4
import unittest def line_is_valid(line): l = list(line.split(' ')) return False if len(l) != len(set(l)) else True def check(data): result = 0 for line in data.split('\n'): if line_is_valid(line): result += 1 return result class Test(unittest.TestCase): def test_shoul...
b8baca99ed340aa95de578f7d7b4be9b9ad0297f
narayana1043/Algorithms
/legacy/iub/product_of_other_numbers.py
1,162
4.0625
4
""" You have a list of integers, and for each index you want to find the product of every integer except the integer at that index. Write a function get_products_of_all_ints_except_at_index() that takes a list of integers and returns a list of the products. For example, given: [1, 7, 3, 4] your function would retu...
b2a6fcaef8a0835da30e10201718c50ec922a961
BholaNathSarkar/python-test-intern
/9.py
402
3.671875
4
def readText(txtFile): NUMBER_OF_WORDS = 0 NUMBER_OF_LINES = 0 f = open(txtFile, "r") NUMBER_OF_LINES = len(f.readlines()) f = open(txtFile, "r") for lines in f.readlines(): lines = lines.replace('\n','') NUMBER_OF_WORDS = NUMBER_OF_WORDS + len(lines.split()) return [NUMBER_...
03f3fc6e6d679a5bd5a1bf09e87ef4d59cf4923b
w0jtech/python_udemy
/18_while.py
114
3.75
4
i = 1 imax = 10 while i <= imax: print(i, "I like python") i = i + 1 else: print("Now i =", i)
a61801c64abd31458053529cc5ee107238229944
hyj1116/LeetCode-HYJ
/2-Medium/5317. Delete Leaves With a Given Value/5317. Delete Leaves With a Given Value.py
1,380
3.984375
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x, name): self.val = x self.left = None self.right = None self.name = name class Solution: def removeLeafNodes(self, root, target): if root.left: root.left = self.removeLeafNodes(root.left, target) ...
ffce5debd1255c63069b7f362f9e4aa87d6cb3b6
ladyinblack/text-based-hangman-python
/hangman.py
2,175
3.890625
4
import random # Write your code here words = ['python', 'java', 'kotlin', 'javascript'] guess = random.choice(words) incorrect_letters = [] correct_letters = [] your_guessed = [] chances_left = 8 # Number of chances left correctly_guessed = 0 # Letters correctly guessed by player current_guesses = 0 # All lette...
16d2de056e4a7ae96284fd65e1ed78398ef78818
put-tzok/sorting-zi-4b-piotr-swiatek
/generators/fill_decreasing.py
172
3.609375
4
def fill_decreasing(size): array = [] actual_size = size if size >= 0 else size * -1 for i in range(actual_size): array.append(i * -1) return array
437e2ac9ecd83a210c375e9fcc5231e8a877b73f
ramona-2020/Python-OOP
/03. Encapsulation/Lab_ 02. Email Validator.py
1,333
3.578125
4
class EmailValidator: def __init__(self, min_length, mails=[], domains=[]): self.min_length = min_length self.__mails = mails self.__domains = domains def __validate_name(self, username): """" returns whether the name is greater than or equal to the min_length (True/Fals...
e01fb54fbb0fca14a6804d9dcc1b3821194510d0
minhle20001998/special_subject_1
/HW/HW-02/prblm2.py
248
3.796875
4
month = ['Janruary', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] arr = list(map( int, input().split('/') )) res = "{0} {1}, {2}".format(month[arr[0] - 1], arr[1], arr[2]) print(res)
9248166ac95a3b867794e7308456a5fd33ef69fc
wilfredlopez/python-exersises
/shape_calculator.py
1,590
3.84375
4
# https://repl.it/repls/ShrillDarkcyanVirtualmachine#main.py import math class Rectangle: def __init__(self, width: int, height: int): self.width = width self.height = height def set_width(self, width: int): self.width = width def set_height(self, height: int): self.heigh...
fae47213120bec372a279d011b5124ccb0b111ba
anastasiiavoronina/python_itea2020
/py_itea2020_classes/lesson06/shelve_example.py
409
3.734375
4
import shelve FILE = 'COUNTRIES' def add_country_and_capital(country, capital): with shelve.open(FILE) as db: db[country] = capital def get_capital_by_country(country): with shelve.open(FILE) as db: return db.get(country, 'No such country in th DB') #add_country_and_capital('Ukraine', 'Kyiv...
30baebd2b960427f4f15cf6504f66e8a45e9293d
DevelopGadget/Basico-Python
/Taller 2/1.py
174
3.8125
4
Rango1 = int(input("Limite Inferior: ")) Rango2 = int(input("Limite Superior: ")) a = Rango1 while a <= Rango2: if a % 2 == 0: print(a) pass a = a + 1
59f289e7a2addce8d5fc2eda1aa7dafe9770a943
theobinomy/Mechanics
/geom2d/open_interval.py
1,874
3.984375
4
from .nums import are_close_enough class OpenInterval: """ An open interval is one where both ends aren't included. For example, the range (2, 7) includes every number between its two ends, 2 and 7, but the ends are excluded. """ def __init__(self, start: float, end: float): if start...
23ff60264a9e2fefbd69f69179baeb7c9764508d
q2806060/python-note
/a-T-biji/day20/code/mylist3.py
734
3.859375
4
# 此示例示意复合赋值算术运算符的重载 class MyList: def __init__(self, iterable=()): self.data = list(iterable) def __repr__(self): return "MyList(%s)" % self.data def __mul__(self, rhs): print("__mul__被调用") return MyList(self.data * rhs) def __imul__(self, rhs): print("__i...
88a8ac290b38d13c85136df069a8b2138bf47eb2
007vedant/Nand2Tetris
/06/Lexer.py
3,789
4
4
"""Python script for reading .asm(assembly files) and matching lexical expressions and tokens using regular expressions """ import re NUM = 1 LABEL = 2 OP = 3 UNKNOWN = 4 class Lex(object): """ Matches lexical expressions and tokens using regex. Attributes: lines: string read from file ...
6611d1e3a9884af8f04bd3fbe40fa4ef770334c5
SanchezProgramming/Story-Generator
/10 - Story Generator.py
335
4.3125
4
print("Hello my name is _____, I am going to the ______ for the day.\nAfterwards I would like to eat _____.\n") name = input("Enter name: ") place = input("Enter place: ") food = input("Enter food to eat: ") print(f"\nHello my name is {name}, I am going to the {place} for the day.\nAfterwards I would like t...
213b45cdb664bbe7c31e165073be88a3d46aa1e0
baibhab007/Python-Numpy-HandsOn
/ndarray.py
324
3.75
4
#### Try it Out - ndarray Import numpy package as np Define a ndarray x1 from list, `[[[-1,1],[-2,2]],[[-3, 3], [-4, 4]]] Determine the following attributes of x1 Number of dimensions Shape Size #### import numpy as np x1 = np.array([[[-1,1],[-2,2]],[[-3, 3], [-4, 4]]]) print(x1.ndim) print(x1.shape) print(x1.si...
806d40150b1f8fbf22190e53e645378e1a8f641d
uniqstha/PYTHON
/questions of day2/Q1.py
172
4.15625
4
# Print "1" if a is equal to b, print "2" if a is greater than b, otherwise print "3". a=10 b=11 c=3 if a==b: print('1') elif a>b: print('2') else: print ('3')
655ff8bcaf3512df8e3fb54007cfc1ba2cb1646e
italoh623/Food_Collector
/Food.py
1,286
3.59375
4
# The "Food" class import math class Food(): def __init__(self, x, y): self.position = PVector(x, y) self.r = 20 self.f_color = color(255,0,0) def getPosition(self): return self.position # Method to update location def changePosition(self, mapa): PositionX...
ecdb89e57cd5a3fc3df95821490aeac2cef656dc
leanton/6.00x
/Week 2/P01.py
482
3.859375
4
balance = 5000.0; annualInterestRate = 0.18; monthlyPaymentRate = 0.02; sumPayment = 0.0; for i in range(12): payment = round(monthlyPaymentRate * balance, 2) balance = round((balance - payment) * (1 + annualInterestRate / 12), 2) print("Month: " + str(i+1)) print("Minimum monthly payment: " + str(payment...
fc73720417638b58b98734d482817018155c45ca
SatyaAccenture/PythonCodes
/Inheritence.py
530
3.546875
4
class A: def __init__(self): print("In A Init") def feature1(self): print("Feature 1-A Working") def feature2(self): print("Feature 2 Working") class B: def __init__(self): print("Inside init B") def feature1(self): print("Feature 1-B Working") def ...
28e83f0374a143650e8db8c77de3ec1ba3090046
cirosantilli/python-cheat
/issubclass.py
399
3.59375
4
#!/usr/bin/env python3 class Base: pass class Derived(Base): pass base = Base() derived = Derived() assert issubclass(Derived, Base) assert not issubclass(Base, Derived) # True for same object. assert issubclass(Base, Base) # Cannot use object of class. try: issubclass(derived, Base) except TypeError:...
08f87c980e54fe93ffd0174837f0d35bbf6caff3
jeremypashby/PythonLearning
/PyhtonChallenges/Challenge19/Challenge19.py
350
3.921875
4
def bottles_of_beer(): bottles = range(100, -1, -1) for bottle in bottles: nextbottle = bottle - 1 if nextbottle > -1: print "{0} bottles of beer on the wall, {0} bottles of beer. Take one down, pass it around, {1} bottles of beer on the wall".format(bottle, nextbottle) def main(): bottles_of_beer() if _...
0ecbb540b62512c9bab99b27e20b5a2342376e51
ViMitre/sparta-python
/1/test_tdd/calculator.py
487
3.5
4
import math class SimpleCalculator(): def add(self, num1, num2): return num1 + num2 def sub(self, num1, num2): return num1 - num2 def mult(self, num1, num2): return num1 * num2 def div(self, num1, num2): return num1 / num2 class SciCalculator(SimpleCalculator): ...
fe65a02de2860e1d39b11f408ec29f61435f220a
liwengyong/p1804_workspace
/p1/p17/life.py
217
3.515625
4
a = '人生苦短,我用python,life is short' print(a.count('p')) print(a.count('i')) print(a.rfind('s',0,len(a))) print(a.rindex('s',0,len(a))) print(a.upper()) print(a.lower()) print(a[7::]) print(a[7:len(a)])
0cb9dbd2051790e0992b5a5c55456efe184911d3
Jethet/Practice-more
/python-katas/EdabPalin.py
778
4.3125
4
# A palindrome is a word, phrase, number or other sequence of characters which # reads the same backward or forward, such as madam or kayak. # Write a function that takes a string and determines whether it's a palindrome # or not. The function should return a boolean (True or False value). # Should be case insensitive ...
624a4bc27d322745c4e6d878b9e4fa47f86b861b
ashmorecartier/synchrofiles
/synchrofiles.py
12,073
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Demonstration program matching two files with a key standalone program ------------------ output produces : filec: a file given in parameter which contain the result. The format is the fileb format each lines of file contain : ...
f950bd06bbff142e443bad791473da02b2b693c0
caitaozhan/LeetCode
/linked-list/160.intersection-of-two-linked-lists.py
922
3.578125
4
# # @lc app=leetcode id=160 lang=python3 # # [160] Intersection of Two Linked Lists # # @lc code=start # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None from collections import Counter class Solution: def getIntersectionNode(self...
7b09a56438bed97b72c65d5d3f125db76f4be424
jacosta4/useful_python
/most_frecuent.py
289
4.0625
4
# Vamos a encontrar el elemento mas frecuente en una lista # Utilizamos la funcion max() # Si solo se le pasa u argumento, retorna el elemento mayor. numbers = [1,2,3,7,5,4,6,8,7,5,2,1,4,6,8,0,7,5,3,6,9,0,8,5] most_fr = max(numbers, key=numbers.count) print(most_fr) print(type(most_fr))
9f94bc1cb15bd4430423ce0cbf75c6512ea6da1a
tabrezi/OSTL
/Exp301.py
1,349
4.125
4
#Experiment 3, Program 3.1 #Program to implement Class, objects and static method class Student: ''' A student class to manage students. ''' no_of_courses=5 #class var credits=25 #class var def setval(self,r,n,a,m): ''' Method to set the properties of the objec...
6406ca189e2d46a218c453251e09a591660a4010
cbgoodrich/Unit3
/fives.py
202
4.21875
4
#Charlie Goodrich #09/27/17 #fives.py - prints out the number of multiples of 5 in a number number = int(input("Enter a number: ")) amountLeft = number//5 i = 1 while i <= amountLeft: print(i*5) i += 1
6e9242a1ae59a498516788cefe6b48b5d18f4cfd
mypythoncourse/first
/roman_to_int.py
1,744
3.53125
4
class Solution(object): def __init__(self): ONE_SYMBOL_TO_VALUE = {} ONE_SYMBOL_TO_VALUE[1] = 'I' ONE_SYMBOL_TO_VALUE[5] = 'V' ONE_SYMBOL_TO_VALUE[10] = 'X' ONE_SYMBOL_TO_VALUE[50] = 'L' ONE_SYMBOL_TO_VALUE[100] = 'C' ONE_SYMBOL_TO_VALUE[500] = 'D' ONE...
a6bc32ec260763debe2ea27407ad04a1a6fd9c9d
danielmendozapupo/ScriptingLangPython
/Assign01/Proj01.py
737
3.515625
4
#DO NOT MODIFY THE CODE IN THIS FILE #File: Proj01.py from Proj01Runner import Runner import turtle window = turtle.Screen() turtle.setup(450,450) aTuple = (turtle.Turtle(),turtle.Turtle(),turtle.Turtle()) result = Runner.run(aTuple) window.title(result[3]) #display your name result.append(turtle.T...
c9c6c05335ea4ac7cd19ad6cc49c2bb682863cbb
denemorhun/Python-Problems
/Hackerrank/Recursive and DP/factorial_calculation.py
472
4.25
4
''' Python3 code to calculate factorial ''' def calculate_factorial(n) -> int: # base condition if n < 2: return 1 else: return n * calculate_factorial(n-1) def calculate_factorial_iterative(n) -> int: i = 0 fact = 1 while i < n: fact *= n-i ...
6d3bf76977316610855ff5a054ede321587f81ac
vikaslakshya/Basics-of-Python
/vikas_subplot.py
996
3.90625
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 21 19:48:25 2020 @author: vikas """ import numpy as np #call numpy library import matplotlib.pyplot as plt #call matplot library x1 = np.linspace(0.0,5.0); #defining x-axis with line spaceing x2 = np.linspace(0.0,2.0); #defining x-axis with line spaceing y1 ...
9bd838a0de2d8d3494ac67beaecba6f8f1ed8038
CauchyPolymer/teaching_python
/python_intro/16_break_cont.py
642
4.09375
4
print('Testing break statement in for loop...') print() for x in range(10): if x == 5: break #아예 끝나버림. else: print(x) print() print('Testing break statement in for loop...') print() for y in range(10): if y == 5: continue #그 회차가 끝남. cont는 별로 쓰지 않음 ㅎ #while loop 할때 조심해야 할 점이 있음...
77f53bcb4066d84ee6af5b11ee8fd7ce5a551639
KritiKAl7/lintCode
/lcprefix.py
511
3.625
4
def longestCommonPrefix(strs): if not strs: return "" if len(strs) == 1: return strs[0] first = strs[0] count = compare(first, strs[1]) for s in strs[1:]: count = min(count, compare(first, s)) return strs[1][:count] def compare(a, b): length = min(len(a), len(...
432fd58c9f233f2439b2576f9a35056e7dbbd350
NEPDAVE/hackerrank
/algorithms/staircase.py
357
4.09375
4
print "Build a staircase! Type a number and press Enter:" n = int(raw_input().strip()) def space_maker2(n, staircase): space = n - len(staircase) space_string = "" for i in range(space): space_string += " " return space_string staircase = "" for i in range(n): staircase += "#" print sp...
5d9e87a2834235c730832f5822eeb306fcac00bf
Steven-Efthimiadis/AIforGames
/TicTacToe/TicTacToe/TicTacToe.py
6,584
3.828125
4
'''Tic-Tac-Toe Created for HIT3046 AI for Games, Lab 02, By Clinton Woodward cwoodward@swin.edu.au Notes: * This simple function based implementation does not use an OO design. * Each function has a description string -- read to know more. * Overall game flow follows a standard game loop trinity: - process_inpu...
e1adc99e72954e2008abb2a5d4fa17ed9f2d24b0
Gowtham-R03/Computer-Vision
/CV-6.py
1,981
3.515625
4
# CV-6 # Shape Detection import cv2 import numpy as np import stack def getContours(img): contours, hierarchy = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) # retrevel method - external :Retrives only outer extreme contours # retrevel - Tree : Retreves and constructs fully ...
ca55bc88f55b7bd814eefddccfcf772adab3dd1f
chirag111222/Daily_Coding_Problems
/DailyCodingProblem/216_roman_to_numeral.py
881
4.1875
4
''' This problem was asked by Facebook. Given a number in Roman numeral format, convert it to decimal. The values of Roman numerals are as follows: { 'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10, 'V': 5, 'I': 1 } In addition, note that the Roman numeral system uses subtractive notatio...
5f44b32c53e9d32eef50f98bf5cbca58e7599ede
Nev-Iva/algorithms-python
/hw2/hw2_2.py
590
4.15625
4
# 2. Посчитать четные и нечетные цифры введенного натурального числа. # Например, если введено число 34560, # в нем 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5). n = (input('Введите число: ')) even_num = 0 uneven_num = 0 for i in range(len(n)): num_int = int(n[i]) if num_int % 2 != 0: uneven_num += 1...
ab4ae95d2da5dacde4a4e9395df275b3d9431d9d
lorena-lo/Python_scripts
/cnp_validator.py
1,890
3.8125
4
""" CNP validator. Expects a 13 digit number as user input. It will return a message that says if the input is valid/invalid.""" from datetime import datetime def check_date(aa, ll, zz): month_no_of_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] if aa % 4 == 0 and (aa % 100 != 0 or aa % 400 =...
0adbc9e316a73cace187fe8a35935eeb3ef09eda
gradampl/MONTY
/Lab_1/aad_File_7.py
266
3.796875
4
number1 = int(input('Podaj pierwszą liczbę \n')) number2 = int(input('Podaj drugą liczbę \n')) number3 = int(input('Podaj trzecią liczbę \n')) product = number1 * number2 * number3 print('Pomnożyłem liczby, które podałeś. Wynik mnożenia to ', product)
4b64b1c0e648968df89ddee89f5b57bf999428af
zhuwenzhang/Python-base
/python获取当前时间.py
335
3.578125
4
import time currentTime = time.time() totalSeconds = int(currentTime) currentSecond = totalSeconds % 60 totalMinutes = totalSeconds // 60 currentMinute = totalMinutes % 60 totalHours = totalMinutes // 60 currentHour = totalHours % 24 print("当前时间是:", currentHour, ":", currentMinute, ":", currentSecond, "GMT") ...
d4c5eab218d76f0419343ae29260880244534b4e
boberrey/sequence_analysis
/check_sanger_sequencing.py
8,005
3.609375
4
#!/usr/bin/env python """ Note: Python 3 Check a directory of sanger sequencing outputs against a file of known sequences. Inputs: directory containing sanger sequencing outputs in fasta format A tab-delimited 2-column text file of known sequences Outputs: prints out results of sanger sequencing alignment...
a66698632bf195cafe1e8c63743ffb8fef7c740c
ajeshsebastian/allpythonprogram
/FlowControls/Forloop/lower to upper even numbers.py
160
3.984375
4
#even numbers low=int(input("Enter lower limit")) upp=int(input("Enter upper limit")) for num in range(low,upp+1): if num %2==0: print(num,end=" ")
2e8ab692ad49aed2088d76a7a3309256f48dd572
ruan1998/Design_Pattern_in_Python
/src/SOLID/lsp.py
1,682
3.859375
4
from abc import ABC, abstractmethod class BaseHuman(ABC): def __init__(self, hp=100): self._hp = hp @property def hp(self): return self._hp @abstractmethod def be_attacted(self, demage): pass class ChangableState(ABC): @property def state(self): return self...
e908541c52ead6ee7c4d06dc9310f7614a8113d1
sumi419/Algorithms
/stock_prices/stock_prices.py
2,418
4.0625
4
#!/usr/bin/python import argparse # max profit variable start at inital index and compare # min price make it index independent import math def find_max_profit(prices): max_profit = -math.inf # or float("-inf") min_price = math.inf for price in prices: print(f'This is the old max profit {max_profit}') ...
8d11fb0965ce53f862014e56e0adebb8705a950c
priyankakumbha/python
/laraPython/day25/test8.py
484
3.5625
4
''' A B B C C C D D D D E E E E E F F F F F F G G G G G G G ''' ''' char = 'A'; print(char) # A print(chr(ord(char) + 1) ) # B print(chr(ord(char) + 2) ) # C print(chr(ord(char) + 3) ) # D ch = 'f' print(chr(ord(ch) + 1)) #g print(chr(ord(ch) + 2)) #h print(chr(ord(ch) + 3)) #i print(chr(or...
33475ef16b8d31a99ad6563df763386b16e72a89
szazyczny/MIS3640
/Session05/turtle-demo.py
3,256
4.46875
4
#TURTLE MODULE # import turtle # jack = turtle.Turtle() #importing module and using class called turtle # jack.fd(100) #call a method, this means forward 100 pixels, draw a horizontal line # jack.lt(90) #lt means left turn 90 degrees # jack.fd(100) # jack.lt(90) # jack.fd(100) # jack.lt(90) # jack.fd(100) #to draw a ...
cce0be8607dcd8eb11d921b341da76586256e612
nischalshk/pythonProject2
/5.py
806
4.6875
5
""" 5. Create a tuple with your first name, last name, and age. Create a list, people, and append your tuple to it. Make more tuples with the corresponding information from your friends and append them to the list. Sort the list. When you learn about sort method, you can use the key parameter to sort by any field in th...
33e4eab1d082e25fcc00b05e95eca7780fa61b4b
AzaKyd/homework_python_chapter2
/task19.py
170
3.796875
4
weight = int(input("Input your weight: ")) for i in range(weight, weight + 15): weight = weight + 1 print(weight) weight_moon = weight * 0.165 print(weight_moon)
7c781a3924dbdbe1497310ab62c487e5a0a87394
neilpradhan/Advent-of-code-2020
/day6/day6.py
537
3.625
4
def read(input = "input.txt"): with open(input, "r") as f: arr = f.read().split('\n\n') return arr def part1(arr): count = 0 for x in arr: count+= len(set("".join(x.split()))) return count def part2(arr): count = 0 for x in arr: arr_inter= list(...
58d6a9e5126feb2593bee2a23445b47925c4d445
nakoyawilson/one-hundred-days
/rock_paper_scissors/main.py
1,529
4.40625
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) ...
840b6e63172de5399e4fd10e54099b804d66d7c2
soufal/some_note
/code/class/defin.py
408
3.984375
4
#!/usr/bin/env python3 #create a bird class class Bird(object): have_feather = True way_of_reproduction = 'egg' #class attribute: chirp def chirp(self, sound): print(sound) #object attribute: set_color def set_color(self, color): self.color = color summer = Bird() print(summer.way_o...
6660334885d1acafd551a629efdf7ef983d98926
trey5299/project3-1
/phonecall.py
774
3.5625
4
from datetime import date from cis301.phonebill.abstract_phonecall import AbstractPhoneCall class PhoneCall(AbstractPhoneCall): def __init__(self, caller, callee, startdate, enddate, endtime, starttime): self.__caller = caller self.__callee = callee self.__startdate = startdate ...