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 |
|---|---|---|---|---|---|---|
df2f9cfbaea7c4c7d8d5b7511a0597cb476a8e7f | techbees-consulting/datascience-dec18 | /exception_handling/userdefined.py | 741 | 3.8125 | 4 | #!python
# define your own exceptions
class NumberTooSmallError(Exception):pass
class NumberTooBigError(Exception):
def __init__(self):
print('\nException: NumberTooBigError:\nYour number is too big. \nTry a smaller one!')
class NumberThreeError(Exception):
def __init__(self):
print ('\nExcept... |
437eb92c7d868c9ad1c7c18b961e8ace1f1e425a | Arundeepmahajan/PerfectNumber | /perfectnumber.py | 234 | 3.953125 | 4 | n=int(input("Enter a number to check if it is perfect number or not: "))
sum=0
for x in range(1,n):
if n%x==0:
sum=sum+x
if(sum==n):
print(n," is a perfect number")
else:
print(n," is not a perfect number") |
1388d0abfeb65ba4f986fead9e686f006766d357 | YuriNem/Python-Tasks | /lab6/list2.py | 2,207 | 3.953125 | 4 | isCorrect = True
while isCorrect:
# Ввод строки
s = input('Input array in string: ')
# Проверка строки
for i in range(len(s)):
if not (
(57 >= ord(s[i]) >= 48) or
ord(s[i]) == 45 or
ord(s[i]) == 46 or
ord(s[i]) == 32
):
isCorrect = False
... |
52cb96b94b5248c77aeb3f3ffa6d335ed061e741 | trillianx/educative_notes | /Data_Structures/Problems_Bank/node_class.py | 2,188 | 4.0625 | 4 | class Node():
def __init__(self, data=None):
self.data = data
self.left = None
self.right = None
def insert(self, value):
if value < self.data:
if self.left is not None:
self.left.insert(value)
else:
self.left = Node(value)... |
254c9409e6d30f26839c60a500b4ffed1cf28626 | Elijah3502/CSE110 | /Programming Building Blocks/Week 1/02Teach.py | 1,117 | 4.125 | 4 | #ID badge program
#Get id card data
#Get First Name
first = input("What is your first name? : ")
#Get Last Name
last = input("What is your last name?: ")
#Get Email
email = input("Enter your email: ")
#get Phone Number
phone_number = input("Enter phone number : ")
#Get Job Title
title = input("Enter job title : ")
#G... |
e52536e18be7b3f9653e17a25fb3c430ffa201dd | njerigathigi/learn-python | /strip.py | 1,203 | 4.4375 | 4 | # The strip() method removes any leading (spaces at the beginning) and trailing (spaces at the end)
# characters (space is the default leading character to remove)
# Syntax
# string.strip(characters)
# Parameter Description
# characters Optional. A set of characters to remove as leading/trailing characters
txt = ",... |
8229c269b2723728f372b164633ac6bd96437a3b | AngelEmil/3ra-Practica---Condicionales- | /Ejercicio 3.py | 366 | 3.828125 | 4 | # 3. Pedir tres números por teclado e imprimir el mayor de ellos solamente
T = int(input("digite otro numero "))
P = int(input("digite otro numero "))
M = int(input("digite otro numero "))
if T > P and T > M:
print(f"El mayor es {T}")
elif P > T and P > M:
print(f"El mayor es {P}")
else:
M ... |
6d463c5a0012c7549a95c6437ec4ef69a76b418c | stummalapally/IS685-Week4 | /factorialrec.py | 198 | 4 | 4 | def factorialRecursive(n):
if n==1:
return 1
return n*factorialRecursive(n-1)
inputNumber=5
print("The factorial of {0} is {1}".format(inputNumber,factorialRecursive(inputNumber))) |
b01510ab82e92b490ef1e8ad3217760d95efe604 | zifengcoder/LeetCode-python | /easy/1比特与2比特字符.py | 1,408 | 3.59375 | 4 | # coding=utf-8
class Solution(object):
def isOneBitCharacter(self, bits):
"""
:type bits: List[int] 100
:rtype: bool
"""
stack = []
stack_2 = []
for i in bits:
if stack and stack[-1] == 1:
stack_2.append(str(1) + str(i))
... |
82ac83d2f1de10e1e08430ba57e7e73a38b6e1a5 | cosmosZhou/sympy | /axiom/algebra/min/to/floor.py | 1,182 | 3.53125 | 4 | from util import *
@apply
def apply(self):
args = self.of(Min)
x = []
for arg in args:
if arg.is_Floor:
arg = arg.arg
elif arg.is_Add:
flrs = []
non_flrs = []
for i, flr in enumerate(arg.args):
if flr.is_Floor:
... |
1561be5165baa902c1a5bb0ef4d74be14e957a8c | sauravsapkota/HackerRank | /Practice/Algorithms/Implementation/Append and Delete.py | 756 | 3.609375 | 4 | #!/bin/python3
import os
# Complete the appendAndDelete function below.
def appendAndDelete(s, t, k):
common_length = 0
for i, j in zip(s, t):
if i == j:
common_length += 1
else:
break
# CASE A
if ((len(s) + len(t) - 2 * common_length) > k):
return "N... |
5c4ebb60337d071e8ea0120fd685c99d48769348 | juniorboos/ChatbotIPB | /database.py | 2,288 | 4 | 4 | import sqlite3
conn = sqlite3.connect('tutorial.db')
c = conn.cursor()
def create_table():
c.execute("CREATE TABLE IF NOT EXISTS periodo(id REAL, nome TEXT, descricao TEXT, cod_escola REAL, ano_lect REAL, semestre REAL, inicio TEXT, fim TEXT)")
c.execute("CREATE TABLE IF NOT EXISTS sala(id REAL, cod_escola RE... |
eeca449cb2434be3e5e767c36b4658f613c8855c | lizejian/LeetCode | /python/456.py | 519 | 3.75 | 4 | class Solution(object):
def find132pattern(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
s3 = -2*31
stack = []
for s1 in nums[::-1]:
if s1 < s3:
return True
while stack and stack[-1] < s1:
s3 = ... |
1336255a7dd60a3369ed6472bf5de94e5c8b12a2 | woodfin8/sql-challenge | /EmployeeSQL/Bonus_SQLChallenge.py | 4,184 | 3.953125 | 4 | #!/usr/bin/env python
# coding: utf-8
# ## Bonus
# As you examine the data, you are overcome with a creeping suspicion that the dataset is fake. You surmise that your boss handed you spurious data in order to test the data engineering skills of a new employee. To confirm your hunch, you decide to take the following st... |
6af3585cb137af8658c150d5dd85c5ee30936562 | lxb1226/Leetcodeforpython | /中等/50-myPow.py | 712 | 3.578125 | 4 | class Solution:
def myPow(self, x, n):
"""
:type x: float
:type n: int
:rtype: float
"""
# if n<0:
# x = 1/x
# n = -n
# res = 1
# while n:
# if n&1:
# res *= x
# x *= x
# n >>=... |
642e5162347fbd6be644b287d7e9fcb76b080b55 | Diptiman1999/Data-Mining-Lab-Assignments | /Assignment 1/Q10.py | 373 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 11:46:44 2020
@author: DIPTIMAN
"""
n=int(input("Enter the number(greater than 2): "))
if n>=2:
factor=2
num=n
while(num>1):
if(num%factor==0):
print(factor)
num=num//factor
else:
factor+=1
... |
99dd2c4d851f6f0502e00fb87cd02e6a6743df56 | kaivantaylor/Code-Wars | /004_Regex Validate PIN Code/build2.py | 209 | 3.734375 | 4 | def validate_pin(pin):
length = len(pin)
if pin.isdigit() == True:
if length == 4 or length == 6:
return True
else:
return False
else:
return False
|
2cf231dcf560275602d7a1c045a89c9515d0fcdc | Mirabellensaft/DrawCircle | /MovingCircle.py | 1,403 | 3.765625 | 4 | import pyb
import lcd160cr
from math import sqrt # so we don't need to resolve math.sqrt on every loop iteration later
from random import randint
lcd = lcd160cr.LCD160CR('X')
def DrawCircle(r, dx, dy):
"""r = radius of the circle
dx and dy are offset in x and y
so the circle's center is not at 0,0"""
... |
d7d8a0f47e5edab6785608cf96c1090272669f9e | Wenda-Zhao/ICS3U-Unit3-06-Python | /number_guessing2.py | 787 | 4.125 | 4 | #!/usr/bin/env python3
# Created by: Wenda Zhao
# Created on: Dec 2020
# This program guessing random number
import random
def main():
# this function guessing random number
some_variable = str(random.randint(0, 1)) # a number between 0 and 1
# input
your_number = input("Enter your number (betwe... |
66204e27238179e5b4350a37eb7919e0ea7609de | edu-athensoft/stem1401python_student | /py201221a_python2_chen/day06_201229/except_8.py | 467 | 3.75 | 4 | """
to catch specific exception
"""
randomList = ['a', 0, 2]
for entry in randomList:
try:
print("The entry is", entry)
r = 1/ int(entry)
break
except ValueError as ve:
print(ve)
print("Please input a compatible literal for int()")
print()
except ZeroDiv... |
b516459c00c45469ed21ed3076f6d2fbeaa37bb4 | OuuGiii/AdventOfCode | /helper/int_code_helper/version7/op_code 2.py | 10,308 | 3.671875 | 4 | from helper.int_code_helper.version7.constants.modes import MODES
class OpCode:
# opcode = [store_at_position, second_attribute, first_attribute, code]
def __init__(self, number):
self.store_at_position = None
self.second_attribute = None
self.first_attribute = None
self.code ... |
3ce9348be6798e14827d4522e9ecb173278d0217 | Andromalios/practicepython.org | /1.CharacterInput.py | 542 | 4.15625 | 4 | # Create a program that asks the user to enter their name and their age.
# Print out a message addressed to them that tells them the year that they will turn 100 years old.
# Import date
import datetime
now = datetime.datetime.now()
#Name input
name = str( input("What is your name? "))
#Age input
age = int( i... |
d144f31ae3c1a4de8d94bfcf5fc9c5f372a661d9 | savaged/PyFun | /DogAgeToHumanAge.py | 222 | 3.90625 | 4 | dog_years_alive = int(input("Enter dog's years of life: "))
if dog_years_alive <= 2:
dog_years_age = dog_years_alive * 12
else:
dog_years_age = ((dog_years_alive - 2) * 6) + 24
print("Human age ", dog_years_age)
|
5d7ecd3f840eb1277f4effa5ae23d82e443a00b9 | orlyrevalo/Personal.Project.2 | /Project2.8.11.py | 1,028 | 3.828125 | 4 | '''Function'''
# Importing an Entire Module
print("Importing an Entire Module")
import pizza
pizza.make_pizza(16, 'pepperoni')
pizza.make_pizza(12, 'mushrooms', 'green peppers', 'extra cheese')
# Importing Specific Functions
# from module_name import function_name
# from module_name import function_name_0, ... |
7849dc6166b6cf6996f6977750df7478eb8ce984 | tcho187/huffmanTree | /puff | 2,850 | 3.6875 | 4 | #!/usr/local/bin/python
#Author:Thomas Cho
#Returns decoded file
from sys import *
import string, bit_io
codeList=list()
#Returns huff tree w/ freq
def buildTree(huffTree):
while len(huffTree)>1:
firstTwo = list(huffTree[0:2]) #Get the first two to combine
#print firstTwo
#print type(firstTwo)
remainder = ... |
75730fa52516cf63d570e45ffbefb35ca39b7fb3 | mykhamill/Projects-Solutions | /solutions/Pi_to_Nth.py | 600 | 4.53125 | 5 | # Finding Pi to the Nth digit
import sys
from math import factorial, ceil
def double_factorial(n):
return reduce(lambda x, y: x * y, [x for x in range(int(n + 1)) if x % 2 == n % 2 and x > 0], 1)
def pi_to_Nth(n):
return 2 * sum([factorial(x)/(double_factorial((2 * x) + 1) * 1.0) for x in range(int(n + 1))])
de... |
5410ce041cfe8bd908d7e7ba5ff2274448967d24 | acker241/codewars | /string repetition.py | 288 | 3.640625 | 4 | def prefill(n,v):
list = []
if n == 0:
return []
try:
for x in range(int(n)):
list.append(v)
return list
except ValueError:
return (str(n) + " is invalid")
except TypeError:
return (str(n)+" is invalid")
|
5dd1fed653b54c77e6507360ee37b4bee7e8ee9d | rising-entropy/Assignment-Archives | /DAA/Assignment 2/Q1.py | 509 | 3.640625 | 4 | # Q) Given an array A[0…n-1] of n numbers containing repetition of some number. Given an algorithm
# for checking whether there are repeated element or not. Assume that we are not allowed to use
# additional space (i.e., we can use a few temporary variable, O(1) storage).
A = [5, 6, 2, 1, 9, 3, 10, 4, 10, 3]
def areE... |
cfd2722b8f0b72062576c0e5c33885b6b0f37835 | ak-foster/Wi2018-Classroom | /students/kevin/session08/ultimate_circle.py | 571 | 4.21875 | 4 | #!/usr/bin/env python3
import math
class Circle(object):
"""Documentation for Circle
"""
def __init__(self, radius=4):
self.radius = float(radius)
@property
def area(self):
return math.pi * self.radius**2
@property
def diameter(self):
return 2 * sel... |
8c1664b59a1961db4535387ecf3efd527adda1ad | liushenghao/pystudy | /oop_test.py | 195 | 3.640625 | 4 | class Ball(object):
def __init__(self, name):
self.name=name
def kick(self):
print("who kicks me? I am %s" %self.name)
a= Ball('A')
a.kick()
c= Ball('李佳佳')
c.kick() |
e7e803fa5c15836ab3e1447ad9b8af8a06acfc3b | rafaelperazzo/programacao-web | /moodledata/vpl_data/177/usersdata/276/95539/submittedfiles/pico.py | 1,582 | 3.546875 | 4 | # -*- coding: utf-8 -*-
def crescente (lista):
cont = 0
if i==0:
if lista[1]>lista[0]:
cont = cont +1
elif i == len(lista)-1:
if lista[len(lista)-1] > lista[len (lista)-2]:
cont = cont +1
else:
if lista[i]<lista[i+1]:
... |
d3ee70eb5a5f45d892067dfa31629c230c587f1c | DmytroKaminskiy/currency_4 | /workua/writers/txt/writer.py | 425 | 3.515625 | 4 | class TXTWriter:
def __init__(self, filename=None):
if not filename:
filename = 'results.txt'
self._file = open(filename, 'w')
def write(self, item: dict):
# sort dict by key and transform to string
item = str(dict(sorted(item.items())))
self._... |
cfcd3e6a69f893caef178a43cdf806e616b55987 | michaeljwilt/email_verification_script | /verify.py | 2,170 | 3.96875 | 4 | import smtplib
from validate_email import validate_email
# inputs for verification
first_name_input = input(" Enter first name")
last_name_input = input(" Enter last name")
name = first_name_input + last_name_input
domain_input = input(" Enter an email domain(ex. ‘gmail.com’): ")
# email variations list
email1 = ... |
116ac1636bdf2a7c34022415c5cd924a3569c81f | kenzie28/Datathon-2020 | /fifa/Normalize.py | 948 | 3.578125 | 4 | import pandas as pd
import numpy as np
# Loads all datasets
players = pd.read_csv("all_players.csv")
goalies = pd.read_csv("all_goalies.csv")
# Places all columns to be normalized into a list
player_columns = ["overall", "age", "skill_moves", "pace", "shooting", "passing", "dribbling", "defending", "physic", "predict... |
4e822d9b825217528d0f3afe3c2fa11b6ae88b24 | DKCisco/Starting_Out_W_Python | /3_3.py | 316 | 4.0625 | 4 | """
Write an if-else statement that assigns 0 to the variable b if the variable
a is less than 10. Otherwise, it should assign 99 to the variable b.
"""
# Assign variables
a = int(input('Enter the value of a: '))
# Process
if a < 10:
b = 0
else:
b = 99
# Output
print('The value of b =', b) |
721ee94c121ddb1ab5a0662f59b66db5ffc7a193 | andressantillan/kata-codes | /kata-python/count_smileys.py | 807 | 4.09375 | 4 | # Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces.
# Rules for a smiling face:
# -Each smiley face must contain a valid pair of eyes. Eyes can be marked as : or ;
# -A smiley face can have a nose but it does not have to. Valid characters for a ... |
3f628bf39948e740bf32591480d3df4e25849bc2 | RicHz13/PythonExercices | /C27Diccionarios.py | 961 | 3.796875 | 4 | #se pueden recorrer por llave, valor y ambos.
#ejemplos
mi_diccionario = {}
mi_diccionario['primer_elemento'] = 'Hola'
mi_diccionario['segundo_elemento'] = 'Adios'
print (mi_diccionario['primer_elemento'])
calificaciones = {}
calificaciones['algoritmos'] = 9
calificaciones['historia'] = 10
calificaciones['calculo_int... |
4f7eb63169d534e0ebe31345d386afc3eeff3a95 | I-will-miss-you/CodePython | /Curso em Video/Aula 09 - Manipulando Texto/desafio04.py | 128 | 3.703125 | 4 | #Crie um programa que leia o nome de uma pessoa e diga se ela tem "Silva" no nome
nome = input("Nome: ")
print("Silva" in nome)
|
751b0a9c508710021ebcae59dbc3d6ea64fb840b | oscarDelgadillo/AT05_API_Test_Python_Behave | /AbnerMamani/practice3opetator.py | 1,662 | 4.15625 | 4 | #Practice 3 handling the oopertors.
numberFirst = 123
numberSecond = 321
print("Handling over comparison operators")
resultTheOperation = numberFirst == numberSecond
print(f"{numberFirst} == {numberSecond} is {resultTheOperation}")
resultTheOperation = numberFirst != numberSecond
print(f"{numberFirst} != {numberSeco... |
5ebc79cfc82b15ea05b24ff8815e25d71153fe60 | ekivoka/PythonExercises | /exceptionClasses.py | 1,463 | 3.515625 | 4 | def isParent(cl, parent):
global CTree
if cl in CTree:
if parent in CTree[cl]:
return True
elif cl == parent:
return True
else:
for node in CTree[cl]:
res = isParent(node, parent)
if res:
return True
... |
ff4f07ca6476ef721aae4c16e51eace5f754c6f6 | johnconnor77/holbertonschool-higher_level_programming | /0x0B-python-input_output/8-load_from_json_file.py | 249 | 3.734375 | 4 | #!/usr/bin/python3
import json
def load_from_json_file(filename):
"""creates an Object from a JSON file
Args:
filename: file that is read from
"""
with open(filename, mode="r") as a_file:
return (json.load(a_file))
|
9045c57cb58e3a92aba57d1cf9893e4b633c1296 | uhlerlab/server_tutorial | /conv_net.py | 6,102 | 3.5 | 4 | import torch.nn as nn
import torch
from copy import deepcopy
import torch.nn.functional as F
# Abstraction for using nonlinearities
class Nonlinearity(torch.nn.Module):
def __init__(self):
super(Nonlinearity, self).__init__()
def forward(self, x):
#return F.selu(x)
#return F.relu(x)
... |
a404d6b995c28ef324421ab5e28a5daf6a83c963 | usman353/python-analytics | /Week2 python basics-2/ex.py | 575 | 3.53125 | 4 | # a, b = 0, 1
# for i in range(1, 10):
# print(a)
# a, b = b, a + b
# x = [1, [1, ['a', 'b']]]
# print(x)
# def search_list(list_of_tuples, value):
# for comb in list_of_tuples:
# for x in comb:
# if x == value:
# print(x)
# return comb
# else:
# ... |
243a1b6defbb4f1dcd28e8dabdade072d4111f9f | PavlovAlx/repoGeekBrains | /dz01.py | 281 | 4.03125 | 4 | string1 = input("введите строчку 1 >>>")
string2 = input("введите строчку 2 >>>")
string3 = input("введите строчку 3 >>>")
print("строчка 1:", string1)
print("строчка 2:", string2)
print("строчка 3:", string3)
|
6f36d2b63778598d2d69026e4353342d64656499 | swatantragoswami09/Amazon_SDE_Test_Series_solutions | /Closet 0s 1s and 2s.py | 670 | 3.578125 | 4 |
''' Your task to is sort the array a of 0s,1s and 2s
of size n. You dont need to return anything.'''
def segragate012(a,n):
a.sort()
#{
# Driver Code Starts
#Initial Template for Python 3
import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
... |
f0a194716026c09eec83b46fb7985605e864bf1b | a19camoan/Ejercicios_Programacion_Python | /EstructurasRepetitivasPython/4.py | 899 | 4.125 | 4 | """
Escribir un programa que imprima todos los números pares entre dos números que se le pidan al usuario.
Autor: Andrés Castillero Moriana.
Fecha: 03/11/2020
Algoritmo:
Pedimos los 2 números al usuario.
Recorremos el rango entre ambos número (incluido el último).
Si es di... |
78e7b9dabacb78ab149fd68cf088895f8d30e07d | JKChang2015/Python | /w3resource/List_/Q030.py | 179 | 3.96875 | 4 | # -*- coding: UTF-8 -*-
# Q030
# Created by JKChang
# Thu, 31/08/2017, 16:35
# Tag:
# Description: 30. Write a Python program to get the frequency of the elements in a list.
|
0944dbe92a69283c9c0136ee431509ac0f8273b0 | jvalansi/word2code | /word2code/res/translations/PairingPawns.py | 1,754 | 3.8125 | 4 | from problem_utils import *
class PairingPawns:
def savedPawnCount(self, start):
input_array = start
# "Pairing pawns" is a game played on a strip of paper, divided into N cells.
# The cells are labeled 0 through N-1.
# Each cell may contain an arbitrary number of pawns.
# You are given a int[] start with ... |
d3560ee12c4dc9bba45c2ccaa2363e0c9705c8ce | bigrob21/LearningPython | /AutomateTheBoringStuff/chapter4/listSlicing1.py | 545 | 3.8125 | 4 | aList2 = [1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100]
startIndex1 = 10
print('Showing you the list - ' + str(aList2))
print('Showing the list via slicing from the 5th element to the end of it --> ' + str(aList2[startIndex1:len(aList2)]))
print('First element in the list is = ' + str(aList2[0]) + ' .Now changing ... |
7c108d5b644775efef244b70b81add9c9fa4f9fa | alexmiguez/Proyecto-Final.def-Alexandre-Dominguez- | /aplicacion.py | 15,310 | 3.6875 | 4 | import numbers
import math
import sys
from tools import ver_otro_barco,lee_numero,rango,numero_valido,lee_entrada,abrir_datos,abrir_json,guardar_datos,agregar_datos,verificar_archivo,esPrimo,esAbundante
class Aplicacion():
def barco(self,db):
#'Mostrar los barcos disponibles en base de datos""
... |
6056c85f2f2d41593aebd74a616965f462450e3e | faris-shi/python_practice | /remote_duplicate.py | 736 | 4.03125 | 4 | """
Removing Duplicates from a Sequence while Maintaining Order
"""
import collections
#to check if the item is hashable
def _is_hashable(item):
return isinstance(item, collections.abc.Hashable)
def dedupe(seq, key=None):
seen = set()
for item in seq:
is_hashable = _is_hashable(item)
if n... |
1f667c1192e34bbe77c5c19a9b6824c0f6dac66a | Kashishkd77/Arbitrary_Arguments | /maximum.py | 352 | 3.875 | 4 | # finding maximum no. among n passed numbers in a funtion i.e. usig keyword arguments
def maximum(*n):
large=0
for i in n:
if large==0:
large=i
else:
if large < i:
large = i
print("The maximum among all the numbers is :",large)
maximum(1222,8... |
bcdfe89fdba7ef330d911e54379cd9dcf874f14a | Zeroska/Vulkan0x1 | /ThingCouldSaveMe/KhuongOption.py | 475 | 3.578125 | 4 | #!/usr/bin/python3.7
import socket, sys
#create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#bind socket to the port
server_address = {'localhost', 10000}
print (sys.stder + "starting on port" + str(server_address))
sock.bind(server_address)
#listening for incoming connection
soc... |
d28ec23b5f4f816936bba8cff9a4ba33735baf62 | AsthaGarg16/North-Spine-Food-Canteen | /DataBase.py | 5,315 | 3.609375 | 4 | from func import toDict
class DataBase():
# Contructor of the class
def __init__(self):
self.day = "Monday"
self.stallName = ""
self.chickenRiceDetail = toDict("chickenRice.txt")
self.chickenRiceDetail_AM = toDict("chickenRiceAM.txt")
self.japaneseStallDetai... |
09d817fef0651bcabcd61699e52451fbc10c5304 | AmruthaRajendran/Python-Programs | /Encryption.py | 844 | 3.875 | 4 | # HackerRank Problem
''' Question:(https://www.hackerrank.com/challenges/encryption/problem)
Sample Input 0
haveaniceday
Sample Output 0
hae and via ecy
Explanation 0
L=12,sqrt(L) is between 3 and 4.
Rewritten with 3 rows and 4 columns:
have
anic
eday
Sample Input 1
feedthedog
Sample Output 1
fto ehg ee dd
Explana... |
129e7f85935fdae3c5b961284f9d49f89692e918 | pker98/HappyWheels | /Models/Customer.py | 592 | 3.53125 | 4 | from Person import Person
class Customer(Person):
def __init__(self, name, phone, email, creditcard):
Person.__init__(self, name, phone, email)
self.creditcard = creditcard
def __str__(self):
return "{},{},{},{}".format(self.name, self.phone, self.email, self.creditcard)
def _... |
e24cdcdbf712e8e9a2806ae57822ad48423eb34e | Pewww/python-learning-repo | /statement/for.py | 1,000 | 3.625 | 4 | arr = [1, 2, 3]
for i in arr:
print(i)
arr2 = [(1, 2), (3, 4), (5, 6)]
for (first, second) in arr2:
print(f'{first} - {second}')
scores = [90, 25, 67, 45, 80]
PASS_SCORE_CRITERIA = 60
for score in scores:
print('합격') if score >= PASS_SCORE_CRITERIA else print('불합격')
for score in scores:
if (score >= PASS... |
1c3b2bea6d633905f775fc4a95d251c5180dd7b1 | hqb324/hqb-guoya-1 | /text2.py | 1,761 | 3.609375 | 4 | # sc = 99
# if (sc>=0 and sc<60):
# print("不及格")
# if (sc>=60 and sc<=70):
# print("及格")
# if (sc>70 and sc<=80):
# print("良好")
# if (sc>80 and sc<=100):
# print("优秀")
#
# sc = 19
# if (sc >= 0 and sc<60):
# print("不及格")
# elif (sc >= 60 and sc<=70):
# print("及格")
# elif (sc >= 71 and sc<=80):
#... |
3273cfd1423066680053fd181e20357fd0e7d27e | dyyura/OOP | /oop2.py | 3,737 | 3.734375 | 4 | # 2
# class Airplane:
# def __init__(self,make,model,year,max_speed,odometer,is_flying,take_off,fly,land):
# self.make = make
# self.model = model
# self.year = year
# self.max_speed = max_speed
# self.odometer = odometer
# self.is_flying = is_flying
# self.take_off = take_off
# self.fly = fly
# se... |
ba0ffce4b11ecdba2ea620a0a6f2961a1fa57e10 | magdeevd/gb-python | /homework_1/second.py | 254 | 3.6875 | 4 | def main():
seconds = int(input("Enter time in seconds: "))
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
print("{:02d}:{:02d}:{:02d}".format(hours, minutes, seconds))
if __name__ == '__main__':
main()
|
aaeefe9da6f1f6e9a202d9637ffd040253ca637b | garderobin/Leetcode | /leetcode_python2/lc360_sort_transformed_array.py | 8,940 | 3.625 | 4 | from abc import ABCMeta, abstractmethod
from collections import deque
class SortTransformedArray:
__metaclass__ = ABCMeta
@abstractmethod
def sort_transformed_array(self, nums, a, b, c):
"""
:type nums: List[int]
:type a: int
:type b: int
:type c: int
:rtyp... |
880440dca29d2d0c79c25bdf4aac8da0c261f185 | joshdavham/Starting-Out-with-Python-Unofficial-Solutions | /Chapter 5/Q4.py | 370 | 4.15625 | 4 | #Question 4
def main():
speed = int(input("What is the speed of the veihicle in mp? "))
time = int(input("How many hours has it traveled? "))
print("Hour\tDistance Traveled", \
"\n----------------------------")
for hour in range(1, time+1):
distance = hour * speed
... |
4bc662ae96c71553dd251383d3bea3c17ce4a70e | rafaelperazzo/programacao-web | /moodledata/vpl_data/3/usersdata/123/634/submittedfiles/ex1.py | 256 | 4.03125 | 4 | # -*- coding: utf-8 -*-
from __future__ import division
a= input('Insira um valor para a:')
b= input('Insira um valor para b:')
c= input('Insira um valor para c:')
if a>b and a>c:
print (a)
if b>a and b>c:
print (b)
if c>a and c>b:
print (c) |
c9b077b1741569dc044e12e1b5fc78fd9a20e0b0 | whiterosess/PythonStudy | /script.py | 4,232 | 4.3125 | 4 | # Print 'Hello World'
print('Hello World')
# Print 7 as an integer
print(7)
# Print the sum of 9 and 3
print(9 + 3)
# Print '9 + 3' as a string
print('9 + 3')
# Print the result of 9 / 2
print(9 / 2)
# Print the result of 7 * 5
print(7 * 5)
# Print the remainder of 5 divided by 2 using %
print(5 % 2)
# Assign 'Bob' ... |
7901425945dbdde8c1b698ebb5369364bd2ae4e9 | AdamShechter9/adventofcode2016 | /day1/day1.py | 3,954 | 4.09375 | 4 | # Adam Shechter
# Solving for adventofcode challenge, day1 part 1
# Using input1.txt as data
# my solution uses an array of hash tables representing coordinates.
# this array gets scanned for previous coordinate to match current coordinate.
# if not, then traveled coordinate is added.
# an alternate solution is to cre... |
91c94fd9d0f4aeb73d5893b091281e6c1bfaaf50 | slpdavid/Project_Euler | /p040.py | 408 | 3.796875 | 4 | def DigitFinder(num):
digit=1
factor=1
while num>9*factor*digit:
num-=9*factor*digit
digit+=1
factor*=10
target=factor+int((num-1)/digit)
print(str(target)[(num-1)%digit])
return int(str(target)[(num-1)%digit])
result = DigitFinder(1)*DigitFinder(10)*DigitFinder(100)*Dig... |
f16c851ff8d14320d62e12ee623056442eb87260 | leelakrishna16/PythonPracticePrgs | /dict_inversy.py | 317 | 3.859375 | 4 | #! /usr/bin/python3
dict1 = {'book1':'pyton','book2':'java','book3':'shell','book3':'perl','book4':8777}
new_dict = dict(zip(dict1.values(),dict1.keys()))
print(new_dict)
#######2nd#########
dict1 = {'book1':'pyton','book2':'java','book3':'shell','book3':'perl','book4':8777}
print({v: k for k, v in dict1.items()})
|
44d8d9b8c07e0da73e400d44ee8c44e1995cab5c | hyelim-kim1028/lab-python | /LEC06_class/test.py | 656 | 3.90625 | 4 | """
what is overloading
"""
def test():
print('test')
def test(param = 0):
print(
'test param =', param
)
test() #얜 누구를 호출할까?
# 파이썬에서는 이름이 같은 두 함수를 만들 수 없다, 마지막에 온 아이가 전에 온 아이들을 모두 덮어써버린다
# C## 이나 java 와 같은 경우에 같은 이름으로 다른 파라미터를 가진 아이들을 만들 수 있다
# overload 과적하다
#overloading:
# 함수(메소드)의 파라미터가 다른 경우... |
2740949b392ec2677c2694311e5662e46bb82144 | naremanatrek/Embedded-linux | /Tasks/python/Task 3/task3.py | 761 | 4.1875 | 4 | import math
class shape:
def __init__(self,x):
self.x = x
def area (x):
return x
def perimeter(x):
return x
class circle(shape):
def area (self):
return (math.pi)*x*x
def perimeter(self):
return (math.pi)*2*x
class square(shape):
def area (self):
return x*x
def perimeter (self):
return 4*x
x = inp... |
f55465fadd625e0615a485d247b6f93777220fbe | DiegoMaraujo/100-exerc-cios-em-Python- | /100Exercicios em Python/ex24.py | 82 | 3.59375 | 4 | cid = str(input('Qual cidade voce naceu ? ')).strip()
print(cid[:5] == 'santo')
|
817770e354b12b625f4dee60c8e9ace823f95fd1 | EdgardoCS/PythonNeuro | /Tarea1/ejercicio4.py | 591 | 3.890625 | 4 | #jan ken pon
P1 = input('Jugador1: Jan, Ken, Pon? ')
# if (P1 != 'piedra' or P1 != 'papel' or P1 != 'tijera'):
# print('Solo puedes ingresar: piedra, papel o tijera')
P2 = input('Jugador2: Jan, Ken, Pon? ')
# if (P2 != 'piedra' or P2 != 'papel' or P2 != 'tijera'):
# print('Solo puedes ingresar: piedra, papel... |
97aae0d1f134c956bff067e88fe0e421d2bff864 | zhangruochi/leetcode | /play/first/14_Longest_Common_Prefix.py | 1,352 | 3.875 | 4 | #!/usr/bin/env python3
# info
# -name : zhangruochi
# -email : zrc720@gmail.com
"""
Write a function to find the longest common prefix string amongst an array of strings.
"""
class Solution(object):
def longestCommonPrefix_1(self, strs):
"""
:type strs: List[str]
:rtype: str
... |
973398c6a06f420668262e42ca9188645fe12e31 | hdcsantos/exercicios-python-secao05-41e-v2 | /10.py | 304 | 3.6875 | 4 | print("Peso ideal")
sexo = input('Qual seu genero (H ou M)? ')
h = float(input("Altura: "))
peso = float(input("Peso: "))
if sexo == 'H':
p_i = ((72.7 * h) - 58) // 1
print(f'Seu peso ideal é de {p_i} Kg!')
else:
p_i = ((62.1 * h) - 44.7) // 1
print(f'Seu peso ideal é de {p_i} Kg!')
|
bcb7788af7663d0e9c52057795c5f62acc349ba1 | mennanov/problem-sets | /other/strings/string_all_unique_chars.py | 1,371 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Implement an algorithm to determine if a string has all unique characters.
"""
def all_unique_set(string):
"""
Running time and space is O(N).
"""
return len(string) == len(set(string))
def all_unique_list(string):
"""
Running time is O(N), space is O(R) where R ... |
4c13f88ca3f68b9dd3b84895fcf00e69ef8a82dc | Laoudede/Laoudede.github.io | /Python 3/Python_Crash_Course/while_loops.py | 117 | 4 | 4 | guess = 0
answer = 5
while answer != guess:
guess = int(input("Guess: "))
else:
print("You guessed right!")
|
40f5fd524228904f7fdd2c41c2a1f435e129767b | kcarollee/Problem-Solving | /Python/9093.py | 797 | 3.53125 | 4 | class String:
def __init__(self, arr):
self._arr = arr
self._temp1 = []
self._temp2 = []
def flip(self):
L = len(self._temp1)
for i in range(L//2):
self._temp1[i], self._temp1[L-1-i] = self._temp1[L-1-i], self._temp1[i]
def index(self):
M = len(self._arr)
flag = 0
for j in range(M):
if self._... |
dcd01ec717ec88da94497dcedbc5c05bf41b937a | StephenMa88/leetcode_solutions | /Add_Two_Nums/solution.py | 3,460 | 3.6875 | 4 | # attempted in 2021
# 76ms, 14.6 MB
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def lnToList(self, listNode, lnlist =[]):
lnlist.append(listNode.val)
if listNode.next is not Non... |
4dc289d6a59e7f582d388fc3b54c76e5dd4f4d5a | JohnPDrab/Git-hub-project | /Snakify problems/2. Intergers and float numbers/First digit after desimal.py | 80 | 3.515625 | 4 | num = float(input())
import math
a = (num * 10)
b = math.floor(a % 10)
print(b) |
2bdcf83f4ae7a97cf7874afcb14e65588940238c | Bialomazur/3dProgrammierung | /unittests/Employee.py | 430 | 3.515625 | 4 | class Employee:
def __init__(self, salary, surname, age, salary_increase):
self.salary = salary
self.surname = surname
self.age = age
self.salary_increase = salary_increase
def increase_salary(self):
self.salary *= self.salary_increase
@property
def ... |
ad3c73f9b5766ec3f076a115fe90e14d55ba2977 | PrestonHicks26/secret-santa | /SecretSanta.py | 2,909 | 4 | 4 | # similar to doubly linked list, meaning has both 'next' and 'previous'
# each node represents a person taking part in exchange
# 'next' is written as 'giving,' the person that node n is giving a present to
# 'previous' is written as 'receiving,' the person that node n is receiving a present from
# code based on im... |
c92676b224bdf60b17b217045b527a46173964dc | luismontei/Atividades-Python | /atv003.py | 223 | 4.0625 | 4 | ##Faça um Programa que peça dois números e imprima a soma.
n1 = float(input('Informe um número: '))
n2 = float(input('Informe outro número: '))
soma= n1+n2
print('A soma dos números foram de {}'.format(soma))
|
d1e01ef176343d1bf992226f4785fb18fd0fd456 | pujkiee/python-programming | /player level/factorial.py | 116 | 4.09375 | 4 | num=int(input("enter the number")
n=1
while num<=20:
n=n*num
num=num-1
print ("factorial of the given number is",n)
|
0c375aeb7a50d4cc75897a2fb1f723f8e5f0dce7 | ChocolatePadmanaban/Learning_python | /Day11/part7.py | 705 | 4.09375 | 4 | # converting array to matrix for real
import numpy as np
# Numpy – matrices
# Numpy – matrices
a = np.array([[1,2],[3,4]])
m = np.mat(a) # convert 2-d array to matrix
m = np.matrix([[1, 2], [3, 4]])
print(a[0])
# result is 1-dimensional
print(m[0])
print(a*a)
# element-by-element multiplication
#array([[ 1, ... |
67bf3a860a88d71735afe315ecd2375ba3b1713d | b166erbot/300_ideias_para_programar | /tipo_de_triângulo3.2.9.py | 407 | 3.890625 | 4 | def main():
a, b, c = (float(a) for a in input('digite os lados: ').split())
if all((a + b >= c, b + c >= a, c + a >= b)):
if a == b == c:
print('equilátero')
elif a == b or b == c or c == a:
print('isóceles')
elif a != b != c:
print('escaleno')
el... |
11fdc96b4665ab80fcb0c8b21f03cdfa87b60aec | PallGudbrandsson/Skoli-2016V | /Forritun_3R/Tverk_1/Hluti_1.py | 93 | 3.53125 | 4 | x = "10010"
lengd = len(x)
if x[lengd-1] == "1":
print "oddatala"
else:
print "slett tala" |
a7799531035f9c67d11b84b314b781e9ccbdc4f7 | Hemant024/basic-python-programs | /reverse list 5 ways.py | 828 | 4.21875 | 4 | # REVERSE LIST
# case 1
#
# list1 = [1,2,3,4,5,6]
# list1.reverse() #using reverse method
# print(list1)
# case 2
#
# list1 = [1,2,3,4,5,6,7]
# y = list1[ ::-1] # using slicing
# print(y)
# ... |
d10fd0958740e1a5ad1e70c472141812e7e09a6f | kamkali/Kurs-Python | /week06_day02/zad2.py | 1,645 | 3.640625 | 4 | from typing import Dict
import pandas as pd
def read_file(file):
with open(file, 'r') as f:
text = f.read()
return text
def save_data(data: Dict[str, int], filename):
list_data = list(data)
list_data.sort()
with open(filename, 'w') as f:
for key in list_data:
line = k... |
512e0de83450b4b34f1f82b163e1076293ac0a4d | santhoshkumar2/Guvi | /natural.py | 70 | 3.71875 | 4 | usr=int(raw_input())
num=0
while (usr>0):
num+=usr
usr-=1
print num
|
8d940e73632d43502c9d8be8af23829a3ef9e44d | AsherThomasBabu/AlgoExpert | /Strings/Valid-IP-Address/solution.py | 1,934 | 4.34375 | 4 | # You're given a string of length 12 or smaller, containing only digits. Write a function that returns all the possible IP addresses that can be
# created by inserting threes in the string. sequence of four positive
# An IP address is a
# 0255
# Inclusive.
# integers that are separated by s, where each individual integ... |
ea5315986be53f87d1d9c1aa6f398b19000ccdca | soma2000-lang/web-app | /app.py | 1,864 | 4.1875 | 4 | import pandas as pd
import numpy as np
import streamlit as st
#import the dataset and create a checkbox to shows the data on your website
df1 = pd.read_csv("df_surf.csv")
if st.checkbox('Show Dataframe'):
st.write(df1)
#Read in data again, but by using streamlit's caching aspect. Our whole app re-runs every ... |
1a1817b6bda36a0c0296bfdeb4394a2512b6b177 | priitohlo/prog | /lisa/lisa1.py | 1,515 | 3.640625 | 4 | import turtle
from random import randint
s = turtle.Screen()
t = turtle.Turtle()
idx = 0
with open('lisa/lisa1.txt', 'r', encoding='utf-8') as f:
for r in f:
try:
idx += 1
print(idx)
cmd = r.strip()
if cmd == 'mine_otse':
repeat = int(next(f... |
9b483c89d5d20eaf377264eb17367e0105c62de3 | zhangcyril/linux_py | /trashcan/input_try.py | 266 | 4.3125 | 4 | #! usr/bin/env python3
# -*- coding: utf-8 -*-
#num = input('input any num: ')
#if int(num)%2:
# print('%s is a odd num' % num)
#else:
# print('%s is a even num' % num)
a,b,c=input('enter 3 nums:')
print('a=%s' % a)
print('b=%s' % b)
print('c=%s' % c)
|
805b6a7a48958962fc34ddcb77a5175894f77a17 | glredig/rosalind_challenges | /answer_compare.py | 960 | 3.671875 | 4 | def compare():
my_filename = raw_input("Your file: ")
other_filename = raw_input("Other file: ")
their_answers = []
my_answers = []
missing = []
extra = []
print "Comparing answers...\n"
with open(other_filename, 'r') as otherOpenFile:
for line in otherOpenFile:
their_answers.append(line)
with open(... |
436c2c8ca0d03a1b2fa5c8380dab17d66f4ba469 | AsayehegnMolla/alx-higher_level_programming-1 | /0x0F-python-object_relational_mapping/4-cities_by_state.py | 527 | 3.640625 | 4 | #!/usr/bin/python3
"""main file"""
if __name__ == '__main__':
import sys
import MySQLdb
conn = MySQLdb.connect(
user=sys.argv[1], passwd=sys.argv[2], db=sys.argv[3])
cur = conn.cursor()
# HERE I have to know SQL to grab all states in my database
cur.execute(
"""SELECT cities.id, ... |
4811d720ca22964372c42ae076a3df9d86bc0e0e | Ichtiostega/PythonLearning | /Scripts/p_wgtConv.py | 328 | 3.890625 | 4 | import myHeaders
myHeaders.printp("Weight Converter")
inWeight = input("Input your weight ")
wValue = int(inWeight.partition(" ")[0])
wType = inWeight.partition(" ")[2]
if wType.find("lbs") != -1:
print(f"{wValue * 0.45} kg")
elif wType.find("kg") != -1:
print(f"{wValue / 0.45} lbs")
else:
print("No such... |
e6d35fe1778ac718abac4c2a4d777bae33ea0977 | q654528967/Demo | /python/demo22_keywords.py | 188 | 3.59375 | 4 | #默认值参数
def myFunc(arg1,arg2=6):
print(arg1,arg2)
myFunc(2)
myFunc(5)
myFunc(6)
myFunc(2,5)
#g关键字参数
def keyWord(arg1,arg2):
print(arg1,arg2)
keyWord(arg2=10,arg1=2) |
aeb7215a6fa14bbb4d897d4cba0fa40a0dbc8e2d | griadooss/HowTos | /Python/07_python_dictionaries.py | 17,149 | 4.8125 | 5 | #!/usr/bin/python
# -*- coding: utf-8 -*-
#
'''Python dictionaries'''
#
# In this part of the Python programming tutorial, we will cover Python dictionaries in more detail.
#
# Python dictionary is a container of key-value pairs.
# It is mutable and can contain mixed types.
# A dictionary is an unordered collection... |
8423292763f235a7f82cf8393fced1450e1ba75b | saranraj-protection-kingdom/python-course | /numeric_range.py | 71 | 3.640625 | 4 | n=int(input())
if (1<n and n<10):
print "Yes"
else:
print "No"
|
196be42f60a3f61cde80d4f4406ec1420a7af3a5 | fjolladuraj/RPAzadace | /zadaca1.py | 3,177 | 3.78125 | 4 | IgracPrvi = input ('Unesi skare,papir,stijena,guster ili spock ')
IgracDrugi = input ('Unesi skare,papir,stijena,gusterili spock ')
if IgracPrvi =='skare' and IgracDrugi =='papir':
print ('Skare režu papir. \nIgrač prvi je pobjedio!')
elif IgracPrvi == 'papir' and IgracDrugi == 'skare':
print ('Skare rezu pap... |
b2b1ec63bc7a7117bae9e16112a729b71b8af7f4 | LittleSheepy/MyMLStudy | /ml05Python/01修饰器/06消除副作用.py | 605 | 3.53125 | 4 | def foo_no(a, b):
"""foo_no example docstring"""
return a + b
def namedDecorator(name):
def run_time(func):
def wrap(a, b):
'''my decorator'''
print('this is:{}'.format(name))
r = func(a, b)
return r
return wrap
return run_time
@namedDecor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.