blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
dae1be25a15ae2270ebcd7f3595bf5affee9c8f1 | abhikot1996/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way- | /Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-/elifExsersize.py | 437 | 3.859375 | 4 | '''
elif Exercises
'''
amount = int(input("Enter amount: "))
if amount < 1000:
discount = amount * 0.05
print(f'Discount is {discount}')
elif amount < 5000:
discount = amount * 0.10
print(f'Discount is {discount}')
else:
discount = amount * 0.15
print(f'Discount is {discount}')
# o/p
# Enter a... |
74bff2e14dc504862c597880f6aeec91e3406fde | abhikot1996/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way- | /Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-/PracticeWebExersicesProgram.py | 965 | 4.21875 | 4 | # 1) Program to print twinkle twinkle little star poem
#print("""Twinkle, twinkle, little star,\n\t
#How I wonder what you are!\n
#\t\tUp above the world so high,\n
#\t\tLike a diamond in the sky.\n
#Twinkle, twinkle, little star,\n
#\tHow I wonder what you are!)
#""")
# 2) Program to print version of python installed... |
20cc6e8fc9941708c85808a5ef338417ad548696 | abhikot1996/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way- | /Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-/Phokat_Bank_Project.py | 1,944 | 4.0625 | 4 | """
Phokat Bank Project
"""
import datetime
class Account():
def __init__(self,name,balance): # Constructor / initializer
self.name = name
self.balance = balance
print(f'Account is cteated for {name}')
self.show()
self.trans_list = []
def deposit(self,amount):
i... |
62f570056a533dd8152b2139b28614486a79b7e1 | abhikot1996/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way- | /Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-/star_args_in_function.py | 514 | 4.28125 | 4 | '''
*args in Function
* '*args' is used in function when we want to assign argument as many as we want
then *args is used in function definition.
* '*ola' same as '*args'
'''
# E.g ,
# *args
def greet(*args):
print("Hello " +args[0]+" how are you")
print("Hello " + args[1] + " I don... |
07c1ed5ed93ba79ecedb4ba9aa85a6f66ed24cee | abhikot1996/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way- | /Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-/Prime_no.py | 304 | 4.125 | 4 | '''
Prime no
* Number which can divide only itself
'''
num = int(input("Enter no: "))
if num>1:
for i in range(2,num):
if num%i==0:
print(f"{num} is not a prime no")
break
else:
print(f"{num} is prime no")
else:
print(f"{num} is not prime no") |
09f66ce451d97189609b61122ac6dfc55885a622 | abhikot1996/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way- | /Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-/Logical_Operators_With_if_statement.py | 509 | 4 | 4 | '''
Logical Operators with if statement
'''
# # E.g 1),
# num = int(input("Enter No: "))
# if (num>5 and num < 10):
# print(f"{num} is in limit")
#
# # E.g 2),
# num = int(input("Enter No: "))
# if (num>5 or num < 10):
# print(f"{num} is in limit")
# E.g 3),
sentence = "A quick brown fox jumps on the lazy dog... |
b3ac469636224e227e3df2ad7e8f4d1e20bd02e1 | Agla666/Coding101 | /day2.py | 734 | 4 | 4 | #print("All around the world"[7].upper())
#variables_one + "apple, carrots, and turnips"
#print(variables_one)
#my_name = "jefferson"
#n = "jefferson"
#print(n)
#my_name = "Jefferson"
#my_age = 69
#student = True
#fave_drink = "Apple juice"
#fave_game = "F1"
#fave_driver = "L Hamilton"
... |
7b967fc9c21ae0dfc910b5de01adcfdf1ad06824 | michaesb/master_thesis_CPOS_System | /extra/time_date_conversion.py | 393 | 3.609375 | 4 | import numpy as np
import matplotlib.pyplot as plt
def date_to_days(dates, year=2018):
"""
A date in 2018 in to the number of day in the year by using the numpy
package datetime64
"""
doy = np.zeros(len(dates))
for i in range(len(dates)):
doy[i] = (dates[i] - np.datetime64(str(year) + ... |
83c20d6ba22147706e836cf9ca06a8df5db23a9f | capnomad/python-code | /email_by_hour_tuples.py | 842 | 3.96875 | 4 | '''
10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages.
You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon.
From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 ... |
24770d543966746746e33b9c4b9c9c32a8ab1967 | AlexandruCabac/Instructiunea-IF | /Pr12Margarete.py | 255 | 3.921875 | 4 | x=int(input())
if(x%5==0):
print("Mă iubește de loc")
elif(x%5==1):
print("Mă iubește un pic")
elif(x%5==2):
print("Mă iubește mult")
elif(x%5==3):
print("Mă iubește cu pasiune")
else:
print("Mă iubește la nebunie") |
e739f4c78dc7959a93e1cb79b42d9b5efbe2fb58 | AlexandruCabac/Instructiunea-IF | /Pr11Par Ori Imp.py | 238 | 3.65625 | 4 | a=int(input())
b=int(input())
c=int(input())
if(a%2==0):
print(a, "par")
else:
print(a, "impar")
if(b%2==0):
print(b, "par")
else:
print(b, "impar")
if(c%2==0):
print(c, "par")
else:
print(c, "impar") |
8ef1eb9cbb95d80a3eb422ba0d60d5ae38649851 | alexauritt/da-sci-backup | /assignment3/join.py | 948 | 4 | 4 | import MapReduce
import sys
"""
Word Count Example in the Simple Python MapReduce Framework
"""
mr = MapReduce.MapReduce()
# =============================
# Do not modify above this line
def mapper(record):
mr.emit_intermediate(record[1], record)
def reducer(key, list_of_values):
# extract order info from li... |
a25074bcf94fac40889ea754ebb8e47dc0eba703 | jecki/MetaInductionSim | /KommentarInduction.py | 70,915 | 3.609375 | 4 | # -*- encoding: UTF-8 -*-
# Induktionsalgorithmen
import random
########################################################################
#
# Global Parameters
#
########################################################################
ERROR_TOLERANCE = 1.0 / 1000000.0
first_from_left = lambda l:l[0]
f... |
08f6a8fdbcb706fce970fa49cc7d317748aeadc6 | carmelobuglisi/programming-basics | /projects/m1/001-area-of-a-room/solutions/enricozoboli/solution_area_of_a_room.py | 1,202 | 4.03125 | 4 | print("Welcome! Please choose the shape of your room from the following:")
room_shape =input("(circle, square, rectangle, triangle, tesseract) ")
if room_shape.lower() == "circle":
room_radius = float(input("Insert radius in meters: "))
room_area = (room_radius ** 2) * 3.1416
print(f"The room's area is {r... |
fc243f4ddc5a2da7b2385e7a09a2780f1f964d2a | carmelobuglisi/programming-basics | /projects/m1/005-units-of-time-again/solutions/pietrorosano/solution_005-againUnitsOfTime.py | 998 | 4.40625 | 4 | # In this exercise you will reverse the process described in Exercise 24. Develop a program that begins by reading a number of seconds from the user. Then your program should display the equivalent amount of time in the form D:HH:MM:SS, where D, HH, MM, and SS represent days, hours, minutes and seconds respectively. Th... |
252015cf9ef6da3f97fe6652bd2d924de8472658 | daniocen777/Proyectos-python | /01_practice/ejercicios/control_de_flujo/ejercicio_04.py | 372 | 3.78125 | 4 | ''' Realiza un programa que sume todos los números enteros
pares desde el 0 hasta el 100. '''
numero = int(input("Ingrese el número \n"))
suma = 0
''' conteo = 1
while (conteo <= numero):
if (conteo % 2 == 0):
suma += conteo
conteo += 1
print("La suma es:", suma) '''
''' Otra forma '''
suma = sum(ra... |
cac250740ee4e25dee623c499b6654bcf234a831 | daniocen777/Proyectos-python | /programacion_de_funciones/funciones_recursivas.py | 749 | 4.125 | 4 | def cuenta_atras(num):
num -= 1
if num > 0:
print(num)
cuenta_atras(num)
else:
print('Boooooooom!')
print('Fin de la función', num)
cuenta_atras(5)
''' result:
4
3
2
1
Boooooooom!
Fin de la función 0
Fin de la función 1
Fin de la función 2
Fin de la función 3
Fin de la función 4... |
324531b5625587243e27fc716137daa1d8027b8f | daniocen777/Proyectos-python | /colecciones_de_datos/conjuntos.py | 888 | 4.09375 | 4 | ''' Colección desordenada de elementos únicos '''
conjunto = set() # conjunto vacío
conjunto = {1, 2, 3}
conjunto.add(4) # añadir al final
grupo = {"Daniel", "Mario", "Lola", "Carla"}
flag = "Daniel" in grupo # true
print(flag) # Retorna un true
''' No elementos duplicados '''
test = {"Daniel", "Daniel", "Daniel", ... |
363bea7a6b63e651138099e4a455cad66b0eeee3 | daniocen777/Proyectos-python | /colecciones_de_datos/pilas_colas_con_listas.py | 897 | 4.21875 | 4 | ''' En python, se emulan las pilas con listas '''
# pila => sólo añadir o quitar (LIFO)
from collections import deque
pila = [3, 4, 5]
pila.append(6)
pila.append(7)
print(pila) # result => [3, 4, 5, 6, 7]
# Sacar el último elemento
pila.pop()
print(pila) # result => [3, 4, 5, 6]
''' Error si se quita el último elemen... |
2767d436eb1f50f6e4a5a87cd41f716a464d4746 | 6high/learningML | /KNN/MovieKNN.py | 344 | 3.5625 | 4 | # -*- coding: utf-8 -*-
import numpy as np
from sklearn import neighbors
# kkn算法库
knn = neighbors.KNeighborsClassifier()
# 电影分类
data = np.array([[3,104],[2,100],[1,81],[101,10],[99,5],[98,2]])
labels = np.array([1,1,1,2,2,2])
# 训练
knn.fit(data,labels)
# 预测
predictedLabel = knn.predict([18,90])
print predictedLab... |
65ed4b2c139e16f1a4fac42696bc1015349afda4 | CalidaPereira/python-programmes | /pythonOOP.py | 1,691 | 3.640625 | 4 |
class Book:
BOOK_TYPE = ("HARDCOVER","PAPERBACK","EBOOK")
@classmethod
def getBookTypes(cls):
return cls.BOOK_TYPE
__booklist = None
def __init__(self, title, author, pageCount, price, booktype):
self.title = title
self.author = author
self.pageCoun... |
5dabeecc6a936ec8c928f55aebc089e331da1584 | fmorris2/twitter-news-scraper | /backend/types/CachedTopicInfo.py | 878 | 3.625 | 4 | import time
class CachedTopicInfo:
"""A container containing information
about an entry in the topic cache.
Attributes:
timeCached (the time that this cache entry was last updated)
coordinates (tuple containing latitude and longitude for location)
newsEntries (list of news entr... |
7df9ce9bea3d3f2d3960db13c8c3ec21bc6eb09a | AllanStark/Projects_Python | /OperacionesFracciones.py | 1,689 | 3.8125 | 4 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
Created on Wed Sep 07 00:16:53 2016
Programa que por medio de funciones trabaja para realizar operaciones con fracciones
@author: Sorek
"""
def sumafr(x,y,w,z):
nom1 = int(x)
den1 = int(y)
nom2 = int(w)... |
c5d32f07c291eed19f8b7b188f7ba5f06b0e6ced | AllanStark/Projects_Python | /DiccionarioAlanTorres.py | 2,417 | 3.796875 | 4 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
'''
El siguiente programa es un diccionario de aleman a ingles y viceversa (Incompleto)
'''
#inglés a danés
en_de = {"red" : "rot", "green" : "grün", "blue" : "blau", "yellow":"gelb"}
#danes a frances
de_fr = {"rot" : "rouge", "grün" : "vert"... |
fc8dcadb60f63bf24d5e021291f58bbd7ea6817d | AllanStark/Projects_Python | /Fracciones_Operaciones.py | 3,327 | 4.3125 | 4 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from fractions import Fraction # La clase fraction utiliza varios metodos para realizar operaciones
#Ejemplo basico del uso de Fraction es: Fraction(1,2) >>> Fraction(1,2)
#Funcion Suma
def sumafrac(a,b,c,d):
# f1 = Fraction(a,b)
# f2 = Fraction(c... |
92f8d344893598a206b6924fbb5d60fd28b9225f | AllanStark/Projects_Python | /DragonFractal.py | 1,025 | 3.84375 | 4 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from turtle import *
def curva(n):
"""Devuelve una lista de caracteres con los giros
requeridos para dibujar la curva de dragón de orden
n. La letra 'I' significa girar a la izquierda,
mientras que la letra 'D' significa gi... |
98660087223f9259a300fdc535c0feddd8e01a8b | a3X3k/Competitive-programing-hacktoberfest-2021 | /CodeWars/Bit Counting.py | 442 | 3.953125 | 4 | '''
6 kyu Bit Counting
https://www.codewars.com/kata/526571aae218b8ee490006f4/train/python
Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative.
Example: The binary representation... |
5b68d03cacdf6f2e6ca4b090e5f6ec852fd384dc | a3X3k/Competitive-programing-hacktoberfest-2021 | /Hackerearth_codemonk/Basic Input Output/Zoo.py | 91 | 3.65625 | 4 | s = input()
z=s.count('z')
o=s.count('o')
if 2*z==o:
print('Yes')
else:
print('No') |
bf1e1b955ff8abd182bdd1a1ca5a4537e76c59a0 | a3X3k/Competitive-programing-hacktoberfest-2021 | /CodeChef/CUTBOARD_Cut_the_board.py | 635 | 3.515625 | 4 | #https://www.codechef.com/problems/CUTBOARD
'''
Problem:
Given N x M chessboard. Make cuts on some of the edges but don’t cut the board into pieces. How many maximum such cuts can you make?
Explanation:
Note that we can make cuts between every two consecutive row of cells. There will be N - 1. Such rows to be cut. Wit... |
b3431ea5240c1c9d5358ff021a1a4f2eb2df95e8 | a3X3k/Competitive-programing-hacktoberfest-2021 | /A2OJ/Extra/zigzag.py | 842 | 3.671875 | 4 | n=6
a,b=0,0
arr=[1,2,4,4,5,6]
for i in range(int(n-1)):
if arr[i-1]>=arr[i]<=arr[i+1]:
a=a+1
if arr[i-1]<=arr[i]>=arr[i+1]:
b=b+1
print(b if a>b else a)
def howMany(sentence):
i = 0
ans = 0
n = len(sentence)
while (i < n):
c = 0
c2 = 0
c3 = 0
... |
3bc0dc77311fc351ed1370d2a0faa8034d35af59 | a3X3k/Competitive-programing-hacktoberfest-2021 | /CodeWars/Complementary DNA.py | 838 | 3.609375 | 4 | '''
7 kyu Complementary DNA
https://www.codewars.com/kata/554e4a2f232cdd87d9000038/train/python
Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms.
If you want to know more http://en.wikipedia.org/wiki/DNA
In D... |
2c5b914c3aee2a770ad6592a8cbb3b888ab25190 | a3X3k/Competitive-programing-hacktoberfest-2021 | /Codeforces/131A cAps lOCK.py | 178 | 3.5 | 4 | # https://codeforces.com/problemset/problem/131/A
n = input()
if n==n.upper():
n=n.swapcase()
elif ord(n[0])>96:
if n[1:]==n[1:].upper():
n=n.swapcase()
print(n) |
90f62a8ec5f6cee9e9d88f5bfb8f36599ca33616 | a3X3k/Competitive-programing-hacktoberfest-2021 | /CodeWars/Calculating with Functions.py | 1,540 | 4.34375 | 4 | '''
5 kyu Calculating with Functions
https://www.codewars.com/kata/525f3eda17c7cd9f9e000b39/train/python
This time we want to write calculations using functions and get the results. Let's have a look at some examples:
seven(times(five())) # must return 35
four(plus(nine())) # must return 13
eight(minus(three())) # mu... |
481537d5d715298b4f112158bf257dd23967c5d5 | a3X3k/Competitive-programing-hacktoberfest-2021 | /CodeWars/Build Tower.py | 939 | 4.125 | 4 | '''
6 kyu Build Tower
https://www.codewars.com/kata/576757b1df89ecf5bd00073b/train/python
Build Tower
Build Tower by the following given argument:
number of floors (integer and always greater than 0).
Tower block is represented as *
Python: return a list;
JavaScript: returns an Array;
C#: returns a stri... |
acbd9763b782e52d22e79a169fde5c870516ecb8 | a3X3k/Competitive-programing-hacktoberfest-2021 | /Codeforces/166A Beautiful Year.py | 255 | 3.609375 | 4 | def run(y):
if y[1]!=y[2] and y[2]!=y[3] and y[2]!=y[0] and y[1]!=y[3] and y[1]!=y[0] and y[3]!=y[0]:
print(y)
else:
run(str(int(y)+1))
def main():
y=input()
run(str(int(y)+1))
if __name__=="__main__":
main()
|
4f5125edb4b28cc6e026ce9b29e9f0f8c4f7fb08 | a3X3k/Competitive-programing-hacktoberfest-2021 | /Hackerearth_codemonk/Basic Input Output/Friendship's Relationship.py | 169 | 3.625 | 4 | for _ in range(int(input())):
n=int(input())
s=''
for i in range(1,n+1):
s+=i*'*'
s+=(n-i)*'##'
s+=i*'*'
s+='\n'
print(s) |
fbf65b391b28aa62aa1e4e63fb67a34e36606cf3 | adit-gajjar/blocky-game | /block.py | 20,785 | 3.734375 | 4 | """ Assignment 2 - Blocky
=== CSC148 Fall 2017 ===
Diane Horton and David Liu
Department of Computer Science,
University of Toronto
=== Module Description ===
This file contains the Block class, the main data structure used in the game.
"""
from typing import Optional, Tuple, List
import random
import math
from ren... |
4d52095484532a638d5240f0ea4360f179858178 | squadran2003/lib-manage | /member.py | 629 | 3.515625 | 4 | class Member:
books_rented = []
def __init__(self, id, name, age, address, membership):
self.name = name
self.age = age
self.address = address
self.membership = membership
self.id = id
def checkout(self, book):
self.books_rented.append(book)
print("successfully checkout of {}".format(book))
def ch... |
a9e59242855ad2e394b51e876e0aeb6f0f85cb71 | mdunlap15/Python-Challenge | /Pybank/Analysis/PyBank_solution.py | 2,391 | 3.5625 | 4 | import os
import csv
budget_data = os.path.join("..","Resources","budget_data.csv")
with open(budget_data) as csv_file:
csv_reader = csv.reader(csv_file,delimiter=",")
next(csv_reader,None)
row1 = next(csv_reader,None)
# Print Rows, Header
# for row in csv_reader:
# print(row)
# Cal... |
4c2791c1518809c7029d1cfe965098abaf81c5ec | tsutaka/desktop | /gui.py | 1,744 | 3.78125 | 4 | from tkinter import *
from tkinter import ttk
# -function()
# from pythonlib.date import function
# -date.function()
from pythonlib import date
# pythonlib.date.function()
# import pythonlib
from weather import Weather
WEEK_DAYS = 7
def testprint():
print('Hello, %s!' % t.get())
if __name__ == '__main__':
... |
beb40dca77fc57d55f4c47becdb94c3a563ccee0 | nemcolas/Aulas-do-primeiro-semestre | /aprov.py | 215 | 3.90625 | 4 | def aprovacao (nota, faltas):
if nota > 7 and faltas < 5:
print ('aprovado')
else:
print ('reprovado')
return
n=float(input('nota: '))
f=int(input('faltas: '))
aprovacao(n, f)
|
f27ec17f52186e8a4b8ab19859e021e4b734cbd8 | nemcolas/Aulas-do-primeiro-semestre | /presença24_04.py | 186 | 4 | 4 | n = int(input('Digite um número para o calculo de Fatorial'))
cont=1
result=1
while cont <= n:
result *=cont
cont +=1
print ('o Fatorial desse numero é: ", result')
|
c471c4718de203aaf9dd6e80e92084120dd94cf1 | nemcolas/Aulas-do-primeiro-semestre | /def_mult.py | 202 | 3.8125 | 4 | def mult():
n1 = float (input("Digite o primeiro número"))
n2 = float (input("Digite o segundo número"))
m = n1*n2
print ("A multiplicação é:", m)
mult ()
mult ()
mult ()
|
4e9e82afd5b8dc974808190511866407998f9b84 | Sujitha03/sujitha | /Vowel.py | 90 | 3.734375 | 4 | n=input ()
c=["a","e","i","o","u"]
if n in c:
print ("vowel")
else:
print ("consonant")
|
cb1a541b30cec2a374ec146c53fcab3b074fbfdd | Jsmalriat/python_projects | /dice_roll_gen/dice_roll.py | 2,683 | 4.25 | 4 | # __author__ = Jonah Malriat
# __contact__ = tuf73590@gmail.com
# __date__ = 10/11/2019
# __descript__ = This program takes user-input to determine the amount of times two dice are rolled.
# The program then adds these two dice rolls for every time they were rolled and outputs how many
# times each number 2 - ... |
88efbabace97dda8d0ee8a65ffcabc7c5237e97b | mathieukapfer/lib | /parser.py/parser-smc.py | 950 | 3.53125 | 4 | import re
## syntaxe
sSpace = '\s+'
sName = '\w+'
sGuard='\[.*\]'
sActions='\{.*\}'
## grammar
sStateDef=[ sName, '{']
sState=sName
#sActions=[ '{', sName, sParam, ';']
sTransition=[ sState, sGuard, sState, sActions]
## read file
txt=file.read(open('sample.sm'))
print('file %s' % txt)
## parser
def search(phrase, p... |
f6864b31e3a0acea63bf3484c430461f8fc9368c | luk224/AUTORIGGER | /code/python/Escuela/create_curve.py | 715 | 3.90625 | 4 | def create_curve (
ls_guias =[],
degree = 2,
**args ):
''' Method to create a curve with points given
example use : create_curve (
ls_guias =cmds.ls(sl=1),
degree = 2,
name = 'spine'
)
ls_guias (list) : list of objects (points) t... |
a97595380fdabeec8b77204ceb8af01d7d2b8fd7 | wasimansari661/python | /number_digit_even.py | 488 | 3.90625 | 4 | #get the all number whose digit is all even
low_limit=int(input('Enter the low number : '))
up_limit=int(input('Enter the up number : '))
c=0
for i in range(low_limit,up_limit):
list=[]
flag = False
for j in str(i):
list.insert(c,j)
c+=1
for k in list:
#print (k)
... |
a19b4a5be20d5af5511fdd91ad1a273a6d303bdd | niksm7/Data-Structures-Implementation | /Sorting/SelectionSort.py | 690 | 4 | 4 | # This sorting takes the minimum from the sub lists and puts it in the front
# Time Complexity - O(n2)
# Space Complexity - O(1)
def sortIt(arr):
n = len(arr)
for i in range(n):
min_ind = i
# Getting the index of minimum number in the sub array
for j in range(i+1,n):
... |
d7095d103337612ab8cef93f24a6a152a645ecb0 | niksm7/Data-Structures-Implementation | /Linked Lists/CircularDoublyLinkedList.py | 2,169 | 4 | 4 | class Node:
def __init__(self,data,next=None,prev=None):
self.data = data
self.next = next
self.prev = prev
class LinkedList():
def __init__(self):
self.head = None
def insertAtBegin(self,data):
if self.head == None:
self.head = Node(data)
... |
c3a99f57dda3b63aa60931985ed7a88d1ee3fb05 | niksm7/Data-Structures-Implementation | /Queues/Queue.py | 1,134 | 3.96875 | 4 | class Queue():
def __init__(self,limit=10):
self.queue = []
self.limit = limit
self.length = 0
def enqueue(self,data):
if self.length >= self.limit:
print("Queue Overflow")
else:
self.queue.append(data)
self.length += 1
d... |
ae7c27ae73e4031a84bf98e1908c4844f44c6c15 | cezarfpek/political-data-builder | /classification.py | 3,532 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
The class classification implements sophisticated code that enables
imputation using machine learning, and dimension reduction using
Principal Component Analysis.
-- ADVISORY -----
As the dataset the user would be working with is immense,
the functions in this class for imputation (knn_i... |
63bb72fc6447ffd1365bb63a4d8a63e2a94dc00e | Marxinchina/FundamentalsOfPythonDataStractures | /test/dataStractures.py | 696 | 3.625 | 4 | class DataList:
def __init__(self, x, sample_name):
self.sentinel = None
self.sample_name = sample_name
self.data = x
self.next = None
self.last = self.sentinel
self.len = 1
def add(self, other):
self.next = other
other.last = self
self.le... |
2d292af3de46c6cd7cdf5e7bb3717227ebb1452f | Marxinchina/FundamentalsOfPythonDataStractures | /da.py | 367 | 3.78125 | 4 | import numpy as np
# def square(x):
# return x ** 2
#
#
# a = np.array(list(map(square, [2, 4, 5, 7, 10])))
# a = [i for i in a if i > 23]
# print(a)
def sum_odd(a,b):
a=int(a)
b=int(b)
S:int = 0
if a<b:
while a <= b:
if a % 2 == 1:
S += a
a += 1
... |
d9630b46886066ea9c30426a08e2edb4f4c41bd3 | tomekregulski/python-practice | /logic/bouncer.py | 276 | 4.125 | 4 | age = input("How old are you: ")
if age:
age = int(age)
if age >= 21:
print("You are good to enter and you can drink!")
elif age >= 18:
print("You can entger, but you need a wristband!")
else:
print("Sorry, you can't come in :(")
else:
print("Please enter an age!") |
87af3e5e17551af0dc4a5ed9f1b3f785e190b86b | rsoutelino/sandbox | /python/intdir2uv.py | 1,045 | 3.75 | 4 | def intdir2uv(int, dir, decl_mag=0, ang_rot=0):
"""
FUNCAO INTDIR2UV Decompoem o vetor corrente definido pela intensidade
e direcao (ref. Norte -> Este) considerando a
declinacao magnetica e a rotacao do sistema de coordenadas
Uso: entre com intensidade, direcao,declinacao magnetic... |
d48d4319c0f6fcea5d2c782334f96c879047ac65 | ashaheenp/Surround-View-System-using-4-Fisheye-Cameras-in-Raspberry-Pi-3 | /4. Stitching/4. Raspberry Pi - Stitching/Result_Images/Rename_Images - Stitching.py | 956 | 3.921875 | 4 | # Copy Images and Rename
import os
import glob
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
print(">"*50)
print()
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Function to rename multiple files
def main():
i,j = 0,0
print("==> Stitching")
for filenam... |
00e6a1e843fbfcc51605282bc50317e63a007a86 | SebastianMoralesMartin/Tarea_03-1 | /gasolina.py | 1,286 | 3.953125 | 4 | # encoding: UTF-8
# Sebastian Morales Martin
# Calculo de gasolina
def calcularKmPorLitro(distancia, gas):
rendimiento = distancia/gas
return rendimiento
def calcularMiPorGalon(distancia, gas):
rendimiento = (distancia * 1.6093) / (gas * 0.264)
return rendimiento
def calcularDistancia... |
40579d03848bb6674d4d8e4b9df9a08ed36146cb | VitamintK/AlgorithmProblems | /project-euler/e22.py | 303 | 3.515625 | 4 | s = input()
names = []
for name in s.split(','):
name = name.strip('"')
names.append(name)
names.sort()
ans = 0
def get_score(name):
return sum((1+ord(x)-ord('A')) for x in name)
print(get_score('COLIN'))
for i, name in enumerate(names):
i = i+1
ans += i * get_score(name)
print(ans) |
f07b87ffd2bad864f8b37398ae481ff6ff3ecc6a | VitamintK/AlgorithmProblems | /codeforces/round391/A.py | 145 | 3.625 | 4 | from collections import Counter
s = input().strip()
c = Counter(s)
word = Counter("Bulbasaur")
ans = min(c[i]//word[i] for i in word)
print(ans)
|
1eb62196211740c3715674313bbfe48b2009ee69 | VitamintK/AlgorithmProblems | /codeforces/edu_round123/b.py | 296 | 3.71875 | 4 | T = int(input())
for t in range(T):
n = int(input())
if n == 3:
print('3 2 1')
print('1 3 2')
print('3 1 2')
else:
l = list(reversed(range(1,n+1)))
for i in range(n):
print(' '.join(str(x) for x in l))
l = l[1:] + [l[0]] |
fac75df1cfd30678144467c3f56526cb161901d5 | VitamintK/AlgorithmProblems | /hackerrank/celebrate_neurodiversity_2021/c.py | 1,018 | 3.5 | 4 | # diverse groupings math contest
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'numberOfPartitions' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER_ARRAY arr as parameter.
#
MOD = 1000000007
def numberOfPartitions(arr):
... |
58593925b256fcf5b9128ebfb0039ca88328fafa | VitamintK/AlgorithmProblems | /facebook-hacker-cup/2018/qualification/B_interception.py | 228 | 3.53125 | 4 | T = int(input())
for t in range(T):
n = int(input())
for i in range(n+1):
input()
if n%2 == 1:
print("Case #{}: 1".format(t+1))
print("0.0")
else:
print("Case #{}: 0".format(t+1))
|
5a987f0a921265516eb3de7f1f0984227b164ca8 | VitamintK/AlgorithmProblems | /codeforces/round708/c_gen.py | 127 | 3.546875 | 4 | ans = []
for n in range(3,40):
for k in range(3,n+1):
ans.append((n,k))
print(len(ans))
for x in ans:
print(*x) |
4acd07b2506e0821202b90964316513aad618d65 | VitamintK/AlgorithmProblems | /codeforces/round410/a.py | 181 | 3.5 | 4 | s = input()
n = 0
for i in range(len(s)):
if s[i] != s[-i-1]:
n+=1
#print(s[i])
if(n == 2) or (n == 0 and len(s)%2 == 1):
print("YES")
else:
print("NO")
|
a2e0a2552faf1a9370eea468fd7e591e85023aa3 | VitamintK/AlgorithmProblems | /hackerrank/celebrate_neurodiversity_2021/a.py | 878 | 3.6875 | 4 | # Autism Screening Questionnaire
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'findOdd' function below.
#
# The function is expected to return a STRING.
# The function accepts STRING_ARRAY series as parameter.
#
from collections import defaultdict
def findOdd(series):
... |
c828cbd78332560d7fbbc3ee614661b89a7211ce | VitamintK/AlgorithmProblems | /google-code-jam/2016/qual/sheep.py | 357 | 3.515625 | 4 | k = int(input())
for i in range(k):
n = int(input())
digitset = set()
if n == 0:
print("Case #{}: INSOMNIA".format(i+1))
continue
else:
num = 0
while(len(digitset) < 10):
num = num + n
digitset.update(set(str(num)))
print("Case ... |
747de155dee1a928938e03625105d4cc88f5fbd2 | VitamintK/AlgorithmProblems | /miscellaneous/advent-of-code/2020/day_2.py | 1,072 | 3.703125 | 4 | from collections import defaultdict, deque, Counter
import re
# m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist")
# # or re.search
# >>> m.group(0) # The entire match
# 'Isaac Newton'
# >>> m.group(1) # The first parenthesized subgroup.
# 'Isaac'
# >>> m.group(2) # The second parenthesized subg... |
0f07288d67867f66493178b3d44e6400dbacb235 | VitamintK/AlgorithmProblems | /hackerrank/hourrank_24/A_password_check.py | 691 | 3.84375 | 4 | #!/bin/python3
import sys
def minimumNumber(n, password):
# Return the minimum number of characters to make the password strong
has_num = False
has_cap = False
has_low = False
has_spec = False
for i in password:
if 'z' >= i >= 'a':
has_low = True
if 'A' <= i <= 'Z':... |
0780ef7b697497f2953eaf7c75eb098f3272dce3 | marianoraulrodriguez/Weather_App | /main.py | 2,541 | 3.59375 | 4 | from tkinter import *
import requests
# db127015acc3512d1d23651766aaf9c9
# api.openweathermap.org/data/2.5/weather?q={city name}
def show_weather(weather):
try:
# tuve que imprmir el json antes, para ver la ubicacion de estos datos print(response.json). Se guardan en weather
# asignamos a variab... |
29e7b459ca79807dc28ea3919a14347de30e5a34 | vanceb/STEM_Python_Crypto | /Session3/decrypt.py | 1,127 | 4.15625 | 4 | ##############################
# Caesar Cypher - Decrypt
##############################
# Define the alphabet that we are going to encode
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
# Define variables to hold our message, the key and the translated message
message = 'This is secret'
key = 20
translated = ''
# Change the ... |
ac75e619313c33d933e9f08c14a111977127c74c | NiamhOL/pands-problem-set | /solution-4.py | 660 | 3.828125 | 4 | # Solution to problem 4#
#Student: Niamh O'Leary#
#ID: G00376339#
def collatz(number): # The collatz conjecture is that, no matter what number you start with, you will allways reach 1 #
if number % 2 ==0: # Even number #
print(number // 2) # number is even, divide by 2 #
return number ... |
729a50eb3a77ce6ea6aeaa5a0d5b08da0c8d5c70 | beerkeeper/python-ip-script | /main.py | 487 | 3.578125 | 4 | #!/usr/bin/python
# import depending packages
import json
import requests
# Ofcourse, no application is complete without Hello, world!
print 'Hello, world!'
# The page which provides our remote IP information
requestUrl = 'http://ipinfo.io'
# Fire the request
r = requests.get(requestUrl)
# Get the JSON date and pa... |
fa15853987ed939296be1e57923ec0cff6c3f3a8 | ZibKarolczuk/DataScience_Learn | /02_PythonOOP_SQL/z4_z8.py | 477 | 3.515625 | 4 | import math
name = "Zbyszek"
weight = 78.3
height = 178.5
def getBMI(w, h):
return w / math.pow((h/100),2)
def printBMI(name, bmi):
if (bmi > 25):
print(name + " twoje BMI wynosi " + str(bmi) + " i masz nadwagę!")
elif (bmi < 20.5):
print(name + " twoje BMI wynosi " + str(bmi) + " i masz... |
aaa476b3740b6c3597495b50ebd226555d745c46 | keerthanachinna/set-6 | /reverse.py | 75 | 3.921875 | 4 | print("enter the number:")
while(n>0):
r=n%10
sum=sum*10+r
n=n/10
print(n)
|
f77ace01de2743eb52716add6d2780c126d0e412 | sojapremkumar/TARENTO-BATCH-2020-2021 | /dice.py | 1,386 | 4.0625 | 4 | """
Question 1:
Write a program to design a Dice game. There should be two players. Ask the users to enter their names and roll the dice(four times each). Display the scores and calculate the final score and print the name of the winner.
"""
import random
player = ""
score = {}
names = {}
def get_name(name):
n = ... |
0eb5f8075a4ae0cb3d422bd8e42ef6d035dd823b | shoblin/my_projects | /random_walk/main.py | 1,248 | 3.546875 | 4 | #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Shoblin
#
# Created: 27.11.2019
# Copyright: (c) Shoblin 2019
# Licence: <your licence>
#-------------------------------------------------------------------------------
import ma... |
494543413c81795518cdf76d71bf8f9c70a54ce1 | notwilliamng/logic_conditional | /conditional.py | 415 | 3.578125 | 4 | def max_101(a,b):
float (a)
float (b)
if a > b:
return a
else:
return b
def max_of_three(a,b,c):
if a > b and a > c:
return a
elif b > a and b>c:
return b
else:
return c
def rental_late_fee(days):
days = int(days)
if days <=0:
return (0)
elif days <= 9 and days > 0:
return (5)
elif days <=15... |
a73812056090f30efeb62ac0f77d83f5783bf0ba | ikeliddle/Tic_Tac_Toe | /master.py | 12,152 | 4.09375 | 4 |
class Board():
counter = 1
player_turn = None
three_in_a_row = 0
over_9_turns = 0
computer_position = None
def __init__(self):
self.board = [["Y"],
["3 ", '-', '-', '-'],
["2 ", '-', '-', '-'],
["1 ", '-', '-', '-'],
... |
b41633d058af5b43d46f598687233f0f1ac91f9e | Sammitic/holbertonschool-low_level_programming-1 | /0x17-doubly_linked_lists/palindromex3.py | 256 | 3.65625 | 4 | #!/usr/bin/python3
def ispalindrome(n):
string = str(n)
return string == string[::-1]
list_num = []
for i in range (999,99,-1):
for j in range (i, 99, -1):
if ispalindrome(i * j):
list_num.append(i * j)
print(max(list_num)) |
dc3ddb3005f68fe2dd862b2cc70cdd2ba5c4fbbc | Stunt-Business/Py-BasicQ_As_Challenges | /Day10_oued.py | 1,267 | 4.21875 | 4 | # ---------------------------------------------------
# Author : Erwan Ouedraogo
# Community : Stunt Business
# Community website : www.stuntbusiness.com
#
# 30 Days - Q&A Python Basic
# Day 10 : 31-05-2020
# Day 10 | IG : https://www.instagram.com/stuntbusiness/
# Subject : Challenges II - Basic Calculator
#-----... |
eb4248c8a7a999c298dd5dba794e364cb9b9fad1 | delts-dev/Python | /Number Guessing.py | 337 | 3.84375 | 4 | import random
num = random.randrange(1, 100)
def guess():
print('Guess the number')
print 'Higher than ', int(num-random.randrange(5, 10))
print 'Lower than ', int(num+random.randrange(5, 10))
ans()
def ans():
if input('>>') == num:
print("Correct")
else:
print("Wrong")
... |
11b25b166242757c7adec55a6fca03e6e10060eb | LUDzik77/ST-Tournament | /StarCraftTournament/ST_classes.py | 12,398 | 3.65625 | 4 | #The file covers all funcions of the programme;
import random
from abc import ABC, abstractmethod
class creature:
def __init__(self,placement):
self.name = "<placeholder>"
self.dmg = 0
self.hp = 2
self.cost = (0,0,0) # population, minerals, gas
self.placement =... |
f67561016b5fedefc78f503c62389571e961fe88 | joel-dn/codepymaker | /ejercicios/python/resoluciones/autopista.py | 959 | 3.796875 | 4 | edad = int(input('Ingrese su edad:'))
saldo = 1500
viajes_gratis = 1
flag = True
while flag:
hora = input('Ingrese horario:')
if hora == "Bajo" and viajes_gratis > 0:
viajes_gratis -= 1
print('Peaje: $',0,'Saldo: $',saldo)
else:
if edad < 25:
costo = 400
... |
26e2665d008c1ed8211ebc85d6a8da78e32ab21d | carlhinderer/python-exercises | /daily-coding-problems/problem189.py | 298 | 3.890625 | 4 | # Problem 189
# Easy
# Asked by Google
#
# Given an array of elements, return the length of the longest subarray where
# all its elements are distinct.
#
# For example, given the array [5, 1, 3, 5, 2, 3, 4, 1], return 5 as the longest
# subarray of distinct elements is [5, 2, 3, 4, 1].
# |
461c936aa43dfc116d3a4e6bf313f171ee477ef0 | carlhinderer/python-exercises | /daily-coding-problems/problem140.py | 386 | 3.53125 | 4 | # Problem 140
# Medium
# Asked by Facebook
#
# Given an array of integers in which two elements appear exactly once and all other elements appear
# exactly twice, find the two elements that appear only once.
#
# For example, given the array [2, 4, 6, 8, 10, 2, 6, 10], return 4 and 8. The order does not matter.
#... |
402ab8bd3a04aa529cd0197c24c1d693a942133d | carlhinderer/python-exercises | /daily-coding-problems/problem046.py | 327 | 3.578125 | 4 | # Problem 46
# Hard
# Asked by Amazon
#
# Given a string, find the longest palindromic contiguous substring. If there are more
# than one with the maximum length, return any one.
#
# For example, the longest palindromic substring of "aabcdcb" is "bcdcb". The longest
# palindromic substring of "bananas" is "an... |
db1ba8d848acf949317d6fd1ac0f60f350df800b | carlhinderer/python-exercises | /daily-coding-problems/problem147.py | 141 | 3.5 | 4 | # Problem 147
# Hard
# Classic Problem
#
# Given a list, sort it using this method: reverse(lst, i, j), which reverses lst from i to j.
# |
a017181b14be72f04683eada182146c662f4f166 | carlhinderer/python-exercises | /daily-coding-problems/problem192.py | 520 | 3.734375 | 4 | # Problem 192
# Medium
# Asked by Google
#
# You are given an array of nonnegative integers. Let's say you start at the
# beginning of the array and are trying to advance to the end. You can advance
# at most, the number of steps that you're currently on. Determine whether you
# can get to the end of the a... |
5eb82c0b75ecd9125a10149ac70f7e9facbbf5c8 | carlhinderer/python-exercises | /reddit-beginner-exercises/ex03.py | 1,357 | 4.59375 | 5 | # Exercise 3
#
#
# [PROJECT] Pythagorean Triples Checker
#
# BACKGROUND INFORMATION
#
# If you do not know how basic right triangles work, read this article on wikipedia.
#
# MAIN GOAL
#
# Create a program that allows the user to input the sides of any triangle, and then return whether the triangle is a Pythagorean
# ... |
81b6f41cf4da9ba055fa5b1efd3ba7b6993f04d0 | carlhinderer/python-exercises | /daily-coding-problems/problem057.py | 729 | 4.125 | 4 | # Problem 57
# Medium
# Asked by Amazon
#
# Given a string s and an integer k, break up the string into multiple lines such that
# each line has a length of k or less. You must break it up so that words don't break across
# lines. Each line has to have the maximum possible amount of words. If there's no way t... |
abf9c2bafe50cbf6474aff93e70397c370317420 | carlhinderer/python-exercises | /daily-coding-problems/problem161.py | 251 | 3.515625 | 4 | # Problem 161
# Easy
# Asked by Facebook
#
# Given a 32-bit integer, return the number with its bits reversed.
#
# For example, given the binary number 1111 0000 1111 0000 1111 0000 1111 0000,
# return 0000 1111 0000 1111 0000 1111 0000 1111.
# |
ccafdc7819d1f61391fedf37d6bd4014fa18a7af | carlhinderer/python-exercises | /daily-coding-problems/problem165.py | 683 | 3.703125 | 4 | # Problem 165
# Medium
# Asked by Google
#
# Good morning! Here's your coding interview problem for today.
#
# This problem was asked by Google.
#
# Given an array of integers, return a new array where each element in the new
# array is the number of smaller elements to the right of that element in the
# ori... |
4bef3588349ae8b48cc9b0cea4b1da8d40e653e0 | carlhinderer/python-exercises | /daily-coding-problems/problem360.py | 597 | 3.53125 | 4 | # Problem 360
# Medium
# Asked by Spotify
#
# You have access to ranked lists of songs for various users. Each song is
# represented as an integer, and more preferred songs appear earlier in each list.
# For example, the list [4, 1, 7] indicates that a user likes song 4 the best,
# followed by songs 1 and ... |
302f0d574e9f89932865717ec1b9c0d145433a16 | carlhinderer/python-exercises | /daily-coding-problems/problem524.py | 423 | 3.5625 | 4 | # Problem 524
# Medium
# Asked by Amazon
#
# Given an array of numbers, find the maximum sum of any contiguous subarray of the
# array.
#
# For example, given the array [34, -50, 42, 14, -5, 86], the maximum sum would be 137, since
# we would take elements 42, 14, -5, and 86.
#
# Given the array [-5, -1, -8, ... |
e8ec7c1c8e7edd373c1a2dd59a98cb8444317c3a | carlhinderer/python-exercises | /ctci/code/chapter01/src/palindrome_permutation.py | 769 | 4.3125 | 4 | #
# 1.4 Palindrome Permutation:
#
# Given a string, write a function to check if it is a permutation of a palindrome.
# A palindrome is a word or phrase that is the same forwards and backwards. A
# permutation is a rearrangement of letters. The palindrome does not need to be
# limited to just dictionary word... |
d54738906ef9a4316d3a097a13a68b94630c78a6 | carlhinderer/python-exercises | /daily-coding-problems/problem293.py | 719 | 4.0625 | 4 | # Problem 293
# Hard
# Asked by Uber
#
# You have N stones in a row, and would like to create from them a pyramid. This
# pyramid should be constructed such that the height of each stone increases by
# one until reaching the tallest stone, after which the heights decrease by one.
# In addition, the start a... |
896f79cf4f97f3900f4eb655917ae0c5fe25e016 | carlhinderer/python-exercises | /daily-coding-problems/problem378.py | 365 | 3.828125 | 4 | # Problem 378
# Medium
# Asked by Coinbase
#
# Write a function that takes in a number, string, list, or dictionary and returns
# its JSON encoding. It should also handle nulls.
#
# For example, given the following input:
#
# [None, 123, ["a", "b"], {"c":"d"}]
#
# You should return the following, as a string:
... |
b71c3a5d197427bd3c9881eef3093deb84cbd5a8 | carlhinderer/python-exercises | /ctci/code/chapter01/src/unique.py | 702 | 3.953125 | 4 | #
# 1.1 Is Unique
#
# Implement an algorithm to determine if a string has all unique characters.
# What if you cannot use additional data structures?
#
def unique_(s):
return unique_with_set(s)
# With set, we make one pass, keeping track of characters we've seen
def unique_with_set(s):
seen = set()
fo... |
8bc07815ab7a29e1aa5b472bddaff588fc405cfa | carlhinderer/python-exercises | /zhiwehu/src/ex007.py | 1,033 | 4.21875 | 4 | # Question 7
# Level 2
#
# Question:
# Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in
# the i-th row and j-th column of the array should be i*j.
#
# Note: i=0,1.., X-1; j=0,1,¡Y-1.
#
# Example:
# Suppose the following inputs are given to the program... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.