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 |
|---|---|---|---|---|---|---|
d50edd8e4ac84fb1f3e2d588baed6d5bb3013bfc | ashevchenko90/breakout_game | /main.py | 1,744 | 3.546875 | 4 | from turtle import Turtle,Screen
from ball import Ball
from paddle import Paddle
import time
from score import Score
import random
colors = ['white', 'green', 'red', 'blue', 'yellow', 'purple', 'grey', 'cyan', 'coral', 'brown', 'cornsilk']
WIN_POINTS = 2
WIDTH = 800
HEIGHT = 600
screen = Screen()
screen.bgcolor('blac... |
5c41e6086136f68f881e2e9ffaae8a310e4d3405 | huangtao36/ImageCaptionTutorial | /utils/util.py | 647 | 3.5 | 4 | # -*- coding: utf-8 -*-
# @Time : 2018/10/22 16:50
# @Author : Tao
# @Project : ImageCaption
# @File : util.py
"""
Use for
"""
class Vocabulary(object):
def __init__(self):
self.word2idx = {}
self.idx2word = {}
self.idx = 0
def add_word(self, word):
if word not in self... |
53255ace53f8e0265529c46a5bcacee089a7d404 | Patrick-Ali/PythonLearning | /Feet-Meters.py | 381 | 4.15625 | 4 | meterInches = 0.3/12
meterFoot = 0.3
footString = input("enter feet: ")
footInt = int(footString)
inchString = input("enter inches: ")
inchInt = int(inchString)
footHeightMeters = meterFoot*footInt
inchHeightMeters = meterInches*inchInt
heightMeters = round(footHeightMeters + inchHeightMeters, 2)
pri... |
91fc0187c4fec2f4be921deac47324043768c121 | Patrick-Ali/PythonLearning | /Time_V4.py | 57,436 | 4.40625 | 4 | # Time.py - Version 4 - Patrick Ali - 12/10/15
# Records the hour the user imputs
Hour = int(input("What is the hour? (Goes up to 23): "))
#Check that the hour they entered is acceptable
if Hour <0 or Hour >=24:
# If not then this line is printed
print ("This is not right, as this hour is not recogni... |
0c1a68f30cf48e220d8923110bbcefc5b049bba1 | deriksson/repols | /repols/insort.py | 411 | 3.921875 | 4 | def insort_any_type_left(sorted_list, list_item, less_than=lambda lhs, rhs: lhs < rhs):
"""Insert a list item into a sorted list, keeping the list sorted."""
low = 0
high = len(sorted_list)
while low < high:
mid = (low + high) // 2
if less_than(sorted_list[mid], list_item):
... |
b48bffc03e656eea4c9a49df5af4ca6aae157f97 | OsProgramadores/op-desafios | /desafio-04/alexandrempierre/python/main.py | 672 | 3.734375 | 4 | #!/usr/bin/env python3
'''main module
'''
__author__ = 'Alexandre Pierre'
def readline():
'''Read one line of chess squares.'''
return map(int, filter(lambda x: x in '0123456789', input().split(' ')))
def readboard(lines=8):
'''Read the squares corresponding to the board.'''
while lines > 0:
... |
96fcbf3714bd86d8d3c569da752b6ddd4fb12242 | OsProgramadores/op-desafios | /desafio-03/Nilsonsantos-s/python/palindromos.py | 3,091 | 4.25 | 4 | """
Autor: Nilsonsantos-s
Propósito: Desafio 3
"""
def gerar_positivo(numero, inicial=False, final=False):
"""
:param numero: Pega um número para ser verificado
:param inicial: Verifica se o número é um número inicial
:param final: Verifica se o número é um número final
:return: Retorna um número ... |
d8c657c2933ebaa7a1314f855dc86cf28e57cbfb | OsProgramadores/op-desafios | /desafio-03/rochamrcs/python/desafio-3.py | 208 | 3.828125 | 4 | """Minha solução para imprimir todos palindromos de 1 a 64"""
palindromos = []
for p in range(1, 65):
p_str = str(p)
if p_str[::-1] == p_str:
palindromos.append(p_str)
print(palindromos)
|
c9dbab1169ba86d4bf814b757ffd6948be6b7f0c | OsProgramadores/op-desafios | /desafio-04/karinnecristina/python/xadrez.py | 841 | 4.0625 | 4 | '''Descrição: Solução do desafio-04 - osprogramadores.com
Autor(a): karinnecristina
Linguagem: Python'''
print()
TABULEIRO = {1: ['Peão', 0],
2: ['Bispo', 0],
3: ['Cavalo', 0],
4: ['Torre', 0],
5: ['Rainha', 0],
6: ['Rei', 0]
}
MATRIZ = [[... |
589e295a65784853e206e14ee694bee631538e69 | OsProgramadores/op-desafios | /desafio-02/paullomarttins/python/desafio-02.py | 813 | 3.875 | 4 | #!/usr/bin/python3
'''
Desafio 02, listando números primos de 1 até 10000.
Para otimizar o loop e não percorrer todos os números do range utilizei um while.
Optimized School Method [6n + 1 or 6n – 1]
'''
def num_primo(num):
'''Função verificar se número é primo.'''
if num <= 1:
return False
#if nu... |
e3448e8a65288f34347ebb9f5d2bb8d3d3b69342 | OsProgramadores/op-desafios | /desafio-04/jeffteixeira/python/main.py | 6,470 | 4.0625 | 4 | '''Count the occurrences of each piece on the board'''
from os import system
PIECES = [
{'code': 1, 'name': 'Peão', 'quantity': 16},
{'code': 2, 'name': 'Bispo', 'quantity': 4},
{'code': 3, 'name': 'Cavalo', 'quantity': 4},
{'code': 4, 'name': 'Torre', 'quantity': 4},
{'code': 5, 'name': 'Rainha... |
35ed7d962099ca611f535487f870ac7275348912 | OsProgramadores/op-desafios | /desafio-12/R0drig/python/desafio12.py | 937 | 3.90625 | 4 | #encoding utf-8
'solução desafio 12'
def is_powered_2(number):
'checks if the number is powered by 2 and if is returns the number'
count = 0
while number>=1:
if number %2==0:
pass
elif number == 1:
return ('true',count)
elif number % 2 != 0:
return... |
3fe9767e58487ef6e3a9a6cb7bf31115cbf7334d | OsProgramadores/op-desafios | /desafio-04/g4br13lr0ch4/python/xadrez.py | 678 | 3.703125 | 4 | """
Resolucao Desafio 4
por: Gabriel Rocha
github: G4BR13LR0CH4
"""
tabuleiro = []
peca = {"Peao" : 1, "Bispo" : 2, "Cavalo" : 3, "Torre": 4, "Rainha" : 5, "Rei" : 6}
def criacao():
"""Posiciona as pecas do tabuleiro"""
for x in range(64):
print("Casa: " + str(x))
arm_peca = int(in... |
e38a94b1176d2dd1855d29e2ed7a7f2cb352bee4 | OsProgramadores/op-desafios | /desafio-04/devmmaia/python/xadrez.py | 557 | 3.734375 | 4 | # -*- coding: utf-8 -*-
from collections import Counter
print("digite os numeros de cada linha, separados por espaco")
num = 1
tabuleiro = list()
while num < 9:
linha = input(f"linha {num} >>>" )
tabuleiro.extend(linha.split(" "))
num +=1
counter = Counter(tabuleiro)
#0 0 0 0 0 0 0 0
pecas =(
('Cava... |
21bd8642f4b1c392d4dc764373f03a4347a73fe7 | OsProgramadores/op-desafios | /desafio-04/Nilsonsantos-s/python/xadrez.py | 2,240 | 4.125 | 4 | """
Autor: Nilsonsantos-s
Propósito: Desafio 4
"""
def verifica_string(numero):
"""
:param numero: Exclui qualquer número que não se encaixe
no padrão correto.
:return: retorna um número no padrão.
"""
contador_de_erros = 0
dicionario = {1: numero.isnumeric(), 2: len(numero)... |
e6c2fca2c92a634d6eeb40502223902a575c93ef | OsProgramadores/op-desafios | /desafio-02/leonardohenrique/python/desafio02.py | 766 | 3.640625 | 4 | #função onde irá verificar se a lista de numeros determinados no argumento da função são primos
def numsprimos(n):
#cria uma lista e define como verdadeira
primos = [True] * (n + 1)
#define os números 0 e 1 como falso já que não são primos
primos[0] = primos[1] = False
#utiliza o algorítimo "Crivo de Eratósten... |
fbb99b9a121414684b31482b21e8041006858d70 | OsProgramadores/op-desafios | /desafio-02/otaru1921/python/desafio02.py | 350 | 3.71875 | 4 | """Função que fala se numero é primo feita por @otaru1921"""
def primo_numero(num):
"""Diz se é número primo"""
if num < 1:
return False
for x in range(2, num):
if num % x == 0:
return False
print(num, "é um número primo")
return True
for number in range(1, 10001):
... |
b917070584c084ed55e5a34822698da98ed9307f | OsProgramadores/op-desafios | /desafio-07/guiribeirodev/python/main.py | 1,257 | 3.953125 | 4 | """
Main module
Lê o texto invertendo as linhas (igual o comando tac)
autor: guiribeirodev
versão: 1.0
"""
import sys
def python_tac(file_path):
"""Função principal tac
Args:
file_path (txt): recebe como argumento o arquivo a ser lido
"""
with open(file_path, 'rb') as file:
file.... |
96bd7cf3b01c88c7faa2c6eeaaa0fb469c6d4eb5 | OsProgramadores/op-desafios | /desafio-03/edipocba/python/desafio-03.py | 844 | 4.1875 | 4 | """Algoritmo para identificação de números
palíndromos em um intervalo de valores digitados pelo usuário."""
def palindromo(vi, vf):
"""Função que identifica quais números são
palíndomos em um intervalor de valores."""
for numero in range(vi, vf+1):
aux = str(numero)
if aux == aux[::-1]:
... |
c2df4be33c481829a3d83a6d4298b86ec11354b9 | OsProgramadores/op-desafios | /desafio-03/rafaeldss/python/palindromes.py | 156 | 3.90625 | 4 | inicio = int(input())
fim = int(input())
for numero in range(inicio, fim+1):
numero = str(numero)
if numero == numero[::-1]:
print(numero)
|
95b1186e9ed087445b4bf5346b5c6eee221df1b4 | OsProgramadores/op-desafios | /desafio-02/bessavagner/python/desafio02_osprimos.py | 1,836 | 4.25 | 4 | """Desafio 02 de https://osprogramadores.com/desafios
Escreva um programa para listar todos os números primos
entre 1 e 10000, na linguagem de sua preferência.
"""
import argparse
def seive_eratosthenes(num) :
"""Uses the seiv of Eratosthenes to map primes.
The returned list is a mask of True/False values,
... |
fb600243b8aadcbee5885af6e4d4c82ba615553e | OsProgramadores/op-desafios | /desafio-04/nkborba/python/desafio04-chess.py | 1,712 | 3.875 | 4 | # Desafio 4 - OsProgramadores
# Nicholas Borba
# 12/07/2018
qtdP = {"Pawn":0, "Rock":0, "Knight":0, "Bishop":0, "Queen":0, "King":0}
board = [[4,3,2,5,6,2,3,4],
[1,1,1,1,1,1,1,1],
[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0],
[1,1,1,1,1,1,1,... |
2fcf20d6896386ec21561bf8438b44d197342704 | OsProgramadores/op-desafios | /desafio-03/Mekylei-Belchior/python/desafio3.py | 316 | 4.03125 | 4 | """
Desafio 3 - Números palindrômicos
"""
def palindromo(valor_inicial=1, valor_final=100):
"""
Retorna o número se ele for um palindrômo.
"""
for i in range(valor_inicial, valor_final + 1):
if i == int(str(i)[::-1]):
print(i)
if __name__ == '__main__':
palindromo()
|
b5ec3c794340498b2f9a476035e021d616dc9740 | OsProgramadores/op-desafios | /desafio-08/RecursiveError/python/main.py | 1,586 | 3.671875 | 4 | """
Solução Desafio-08
Author: Guilherme Silva Schultz
Data: 28-01-2023
le um arquivo de texto contendo uma lista de frações
e aplica regras matematicas para simplificar
"""
import sys
from math import gcd
if len(sys.argv) < 2:
print("chame este programa passando um arquivo de fraçoes")
print("Ex python mai... |
a092e63cdfed3394aae4902d689b13140d1e42b9 | sarahsweeney5219/Python-Projects | /dateDetectionRegex.py | 1,663 | 4.75 | 5 | #date detection regex
#uses regular expression to detect dates in the DD/MM/YYYY format (numbers must be in min-max range)
#then tests to see if it is a valid date (based on number of days in each month)
import re, calendar
#creating the DD/MM/YYYY regex
dateRegex = re.compile('(3[01]|[12][0-9]|0?[1-9])\/(0?[1-9]|1[0... |
312dc873dfb36e40d370382743303b4070fafede | shubhamsemwal10/competitvecoding | /permutationbin.py | 234 | 3.671875 | 4 | def printar(a):
for i in a:
print(i)
def bin(A,n):
if(n<1):
printar(A)
else:
A[n]=0
A[n-1]=0
bin(A,n-1)
A[n-1]=1
bin(A,n-1
bin(s,10)
|
70680c6b1fa287388ab362bc4ca1e508d8555b04 | c-ko/bootcamp | /.ipynb_checkpoints/seq_features_and_tests-checkpoint.py | 802 | 3.890625 | 4 | def number_negatives(seq):
"""Number of negative residues in a protein.
Parameters
----------
seq : str
Input sequence of protein using one-letter AA code.
Returns
-------
output : int
Number of negative residues in the protein
"""
seq = seq.upper()
... |
bbd8b86df2563f6a94601772a4bb0b9ddc959418 | rutawheelock/QA_System | /qa-system.py | 9,321 | 3.65625 | 4 | #!/usr/bin/python
"""
CS 5761 PA 5 "Question Answering System"
Author: Ruta Wheelock
Date: 12/06/2017
Description:
This program answers simple Who, What, When and Where
factual questions using Wikipedia as a source.
A user can enter a question and the program
will generate and display an answer.
In cases when the an... |
b57508d03d751342283e0b740a424e12c3bb5041 | RewoundVHS/pyhangman | /hangman.py | 1,665 | 3.984375 | 4 | #! /usr/bin/env python3
import hangmanart
from wordlist import words
import random
import os
def ClearScreen():
os.system('cls' if os.name == 'nt' else 'clear')
ClearScreen()
findWord = words[random.randrange(len(words))]
hidden = list('_' * len(findWord))
wrongLetters = list()
wrongCount = 0
maxWrong = 7
gue... |
37451ff59f87ccea0f8096540701afeffac2cfe9 | hayanleee/CodingTest | /programmers/hash2.py | 577 | 3.734375 | 4 | # 전화번호 목록 [효율성테스트 - 통과 (3.29ms, 15.3MB)]
# sort : 원본 리스트 변환 / sorted : 새로운 리스트 반환
# sort() 더 빠름
phone_book = ['119', '97674223', '1195524421']
phone_book.sort()
for i in range(len(phone_book)-1):
if phone_book[i] == phone_book[i+1][:len(phone_book[i])]:
print("False")
print("True")
# 베스트 풀이
# def soluti... |
508e3dda13adf85a8d7e4c5c13e7aaa17d866cc1 | hayanleee/CodingTest | /programmers/stack_queue4.py | 680 | 3.640625 | 4 | from collections import deque
priorities = [2, 1, 3, 2]
location = 2
rotate = deque(list([i, p] for i, p in enumerate(priorities)))
# 재밌는거
# print(list(map(max, zip(*tmp))))
# print([max(ele) for ele in zip(*tmp)])
# print(list(map(list, zip(*tmp))))
stack = []
while True:
if len(stack) > 0 and stack[-1][0] == l... |
02d496ef2cb6397f104bcedb0266805d08938e9f | JohnAdriaan/uPHue | /light.py | 12,808 | 3.53125 | 4 | # -*- coding: utf-8 -*-
from uPHue import *
class Light(object):
""" Hue Light object
Light settings can be accessed or set via the properties of this object.
"""
class Bridge(object):
"""
You can obtain Light objects by calling the get_light_objects method:
>>> ... |
0984038b9fbc796a0dc5120a7bc0f5e36f100869 | Albertpython/lessonspython | /lesson6.py | 1,239 | 3.78125 | 4 | # age = int(input("Tariq: "))
# Ser = input("Ser: (F/M) ").upper() == 'F'
# Krt = input("Krtutyun: (B/M) ").upper() == 'B'
# res_age = age > 18 and age <= 40
# RES = Ser and Krt and res_age
# print("You entered", RES)
# x = 4
# res = x < 5 or x > 10
# print(res)
# x = 4
# res = not(x < 5 or x <10)
# print(res)
# a =... |
a7a490386b0798266d31ce54a5296c809643340f | Albertpython/lessonspython | /lesson9.py | 1,301 | 3.609375 | 4 | # from random import randint as r
# pc = r(0,5)
# user = int(input("User: ( 0-5"))
# user_point, pc_point = 0,0
# if pc == user:
# user_point += 1
# print(pc, user, "good user", user_point)
# else:
# pc_point += 1
# print(pc, user, "good pc", pc_point)
# pc = r(0,5)
# user = int(input("User: ( 0-5"))
# if pc ==... |
38a526852b3f2819c1c59053a0a1b40038adb113 | MrLotU/SecretMessagesTH | /secret_message.py | 3,942 | 3.90625 | 4 | import os
import sys
from random import randrange
from Ciphers import Affine, Atbash, Caesar, Polybius
### Initial startup message
WELCOME_MESSAGE = '''
Hi there!
Welcome to the MrLotU Encryption tool!
To start, please choose a chiper from the list below:
1. Caesar
2. Affine
3. Atbash
4. Polybius
E... |
c9ea6ff0e28c432574e6270c302788157be48145 | pkaran57/Tutorials | /Python/miscellaneous.py | 3,383 | 4.0625 | 4 | a,b = 2,3 # multi assignment in one line
print(a," ", b)
"""
TOPIC : Variables and Objects
A variable never has any type information or constraints associated with it.
Variables are generic in nature; they always simply refer to a particular object at a particular point in time.
Each object also has two standa... |
1f1c47fc9e844ab67bb248502b1d7e532bf10f31 | pkaran57/Tutorials | /Python/fucntions and generators/functions.py | 3,153 | 4.25 | 4 | """
The def statement creates a function object and assigns it to a name
Below, function object is created and name "twice" is assigned to it
the return statement consists of an optional object value expression that gives the function’s result. If the
value is omitted, return sends back a None.
"""
def twice(a):
... |
ba6a9ff7b9d9e3d7fe962a5152395cab52f4893c | kshitijalwadhi/COL100 | /ArraysPractice/binsort.py | 1,320 | 3.875 | 4 | import numpy as np
def mergesort(arr):
# assert: arr[0...n-1] is established
# assert: if only one element then array is already sorted
if(len(arr) == 1):
return arr
mid = len(arr) // 2
arr1 = arr[:mid]
arr2 = arr[mid:]
# comment: recursively sorting both the partitions of the a... |
bfd6f3a1c6cadc8354d5a4aaf8516e825ec6032c | kshitijalwadhi/COL100 | /Assignment6/q3.py | 1,752 | 3.65625 | 4 | def kth(arr, k):
# assert: arr[1..n] is established with n>0 and 1<=k<=n
l = 0
u = len(arr)-1
# INV: all elements in arr[1...l-1] <= all elements in arr[u+1....n] and l<= k+1 and k-1>=u
while(l < u):
i = l
j = u
x = arr[k-1]
# INV: all elements in arr[l...i-1] <= all ... |
c2a08d7467b7a614a02992d5e8d958a78aac3cb6 | kshitijalwadhi/COL100 | /Assignment6/q1.py | 1,835 | 4.0625 | 4 | # assert: for n>1, elements of arr[1...n] are in ascending order
def removeduplicates(arr, n):
if (n == 0 or n == 1):
return n
temp = list(range(n))
temp[0] = arr[0]
count = 1
for i in range(1, n):
# INV: after the ith iteration (count<=i), temp[1...count] contains all unique element... |
7044bd200aa356bd69860c2aac4e2097b53f9b7f | kshitijalwadhi/COL100 | /Test_2/q2aliter.py | 957 | 4.0625 | 4 | def groupNumbers(arr):
# assert: arr[1..n] of size N is establised having elements as 1, 2, 3 only
N = len(arr)
cur_ini = 0
cur_end = N-1
i = 0
# INV: In every iteration,
# if the element is equal to 1, it is pushed/swapped to the left side of the array(position maintained by cur_ini)
... |
a81f75716a805fd7e6e402e8eb496bc444f834bd | poohsun/CS235-Data-Mining | /naiveBayes/bayes.py | 7,770 | 3.5 | 4 | """
bayes.py
by Josiah R. Anderson
An implementation of a Bernoulli Naive Bayesian classifier for website phishing data
University of California, Riverside
Winter 2020
CS 235 Data Mining Techniques
Bayes' Theorem:
P(class∣data) = (P(data∣class) * P(class)) / P(data)
Step-by-Step Bernoulli Naive Bayesian classifier... |
94ca69edc3b35ae5df681c91879e9adcead5e537 | viveknathani/pps-labwork | /21-02-20/marks.py | 599 | 3.9375 | 4 | data={'java programming':0,
'data structures':0,
'oop':0,
'operating systems':0,
'networking':0
}
sum=0
# each subject carries a maximum of 50 marks
for subject, subject_marks in data.items():
print("Enter marks obatined in ", subject, end=" ")
subject_marks=float(input(" : "))
... |
a235690ed6710748ccb66eb3257aa2e2c3197db2 | viveknathani/pps-labwork | /31-03-20/modules/fib.py | 329 | 3.5625 | 4 | def fib(n):
if n<1:
return -1
elif n==1:
return 1
elif n==2:
return 1
else:
return fib(n-1)+fib(n-2)
def fib_series(m):
series=[]
for var in range(1, m+1):
x=fib(var)
if x==-1:
break
else:
series.append(x)
retur... |
358837e8c015929ff4850c864bc6c5617bfa53a1 | Aliendreamer/PythonDataScienceAndMore | /MashineLearningSoftuni2019/02. Linear-and-Logistic-Regression-Lab/labRegresion.py | 9,929 | 3.5 | 4 | # To add a new cell, type '#%%'
# To add a new markdown cell, type '#%% [markdown]'
#%%
from IPython import get_ipython
#%%
get_ipython().run_line_magic('matplotlib', 'inline')
#%%
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from nose.tools import *
from sklearn.linear_model import Logi... |
b3f9ebee8580cd7d82e7db4969bb4892dba9548a | rakati/competitive-programming | /codeforces/26_june_div3_r/a.py | 166 | 3.5 | 4 | s = int(raw_input())
def count(s):
d = 0
for i in str(s):
d += int(i)
return d
d = count(s)
while d % 4 != 0:
s += 1
d = count(s)
print(s) |
770605d82d498ee4dad02ea4f8d74f94a1387105 | santhoshmani888/pytorch_caption | /Dic2Obj.py | 657 | 3.515625 | 4 | class Dic2Obj(object):
def __init__(self,map):
self.map = map
def __setattr__(self, name, value):
if name == 'map':
object.__setattr__(self, name, value)
return;
print 'set attr called ',name,value
self.map[name] = value
def __getattr__(self,name):... |
0c468539c35d7cb5043d109dc2955c9d7c71112c | dheidenr/ipavlov_course | /coursera/DS/tutor.py | 1,653 | 4.21875 | 4 |
# Так было бы в 2-й версии python: print 'Hello'
print('Hello')
# Во втором python необходимо самостоятельно привести одно из пременных деления к float
# в третьем автоматически при делении получается тип float
print(10/2)
ll = []
ll.append(1)
print(ll)
ll.insert(0, 3)
print(ll)
ll.pop()
print(ll.pop())
print('Hell... |
3a73c20533041b147059f544a5c92de475389ea6 | dheidenr/ipavlov_course | /derivative.py | 10,833 | 3.75 | 4 | # 6.2 Лекция: Производная, градиентная оптимизация.
import numpy as np
import matplotlib.pyplot as plt
import math
import sys
def f(x):
return x ** 4 + 5 * x ** 3 - 10 * x
x = np.linspace(-5, 2, 100)
y = list(map(f, x))
plt.figure(figsize=(10, 7))
plt.plot(x, y)
plt.ylabel("Y")
plt.xlabel("X")
plt.scatter([-3.... |
42320bc81ebd2f7229334f481bcba254a7d51635 | dheidenr/ipavlov_course | /coursera/python/week4/home_task_2/test.py | 312 | 3.5625 | 4 | from coursera.python.week4.home_task_2.solution import Value
class Account:
amount = Value()
def __init__(self, commission):
self.commission = commission
bobs_account = Account(0.1)
bobs_account.amount = 100
print(bobs_account.amount)
# with open('log.txt', 'r') as f:
# print(f.read())
|
57c6471f2a518768befe39648b6c399c93de111d | crizzy9/Algos | /leetcode/tree_from_inorder_preorder.py | 1,334 | 3.90625 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def __repr__(self):
return "{}->({}, {})".format(self.val, self.left, self.right)
class Solution:
def buildTree(self, preorder, inorder):
"""... |
6c1ca71424137fc2100602ca39f480bd41fc2711 | crizzy9/Algos | /Sorting/merge_sort.py | 674 | 3.53125 | 4 | import random
arr1000 = [random.randint(0, 1000) for _ in range(1000)]
arr10000 = [random.randint(0, 10000) for _ in range(10000)]
def merge_sort(seq):
if len(seq) < 2:
return seq
mid = len(seq)//2
left = merge_sort(seq[:mid])
right = merge_sort(seq[mid:])
res = []
i, j = 0, 0
wh... |
d4fb10c937969f9268911e86931a297efb6fdcab | crizzy9/Algos | /leetcode/rotate_image.py | 1,664 | 3.6875 | 4 | # https://leetcode.com/problems/rotate-image/
class Solution:
def rotate(self, matrix):
"""
Do not return anything, modify matrix in-place instead.
"""
n = len(matrix)
print("Before transformation")
print(matrix)
for layer in range(n//2):
for i ... |
4030656d31accb86a80d2e7a56979e6073e50b15 | crizzy9/Algos | /data_structures/rb_tree.py | 12,246 | 3.640625 | 4 | from enum import Enum
class Color(Enum):
BLACK = 'BLACK'
RED = 'RED'
class RBNode:
def __init__(self, value, color=Color.RED, parent=None, left=None, right=None):
self.value = value
self.color = color
self.parent = parent
self.left = left
self.right = right
d... |
e44d86aa34e7241dc77f60a6cba3857b71202a95 | crizzy9/Algos | /leetcode/reach_num.py | 551 | 3.53125 | 4 | class Solution:
def reachNumber(self, target):
"""
:type target: int
:rtype: int
"""
# tuple structure (curr, step)
# starts at 0 at step 0
queue = [(0, 0)]
while queue:
curr, step = queue.pop(0)
if curr == target:
... |
7fb11b6f76bb5f44af0b047fec62430819a158dc | David-Wobrock/sqlvalidator | /sqlvalidator/grammar/tokeniser.py | 5,481 | 3.578125 | 4 | from typing import Optional
STRING_SPLIT_TOKENS = ("'", '"', "`")
WHITESPACE_SPLIT_TOKENS = (" ", "\n", "\t")
KEPT_SPLIT_TOKENS = (
",",
";",
"(",
")",
"[",
"]",
"+",
"-",
"*",
"/",
"=",
"<",
">",
".",
)
MERGE_TOKENS = ("<>", "<=", ">=", "<<", ">>", "||", "!=")
... |
7931d71ad4cd54bc27dc7bbef3c6fabd0ce7e83e | connorkeevill/Snake | /src/objects/items/Item.py | 781 | 3.609375 | 4 | # CK
import pygame
from resources import colours
# | Item()
# |--------------------------------------
# | The parent class for an item that
# | can fill a Space() object.
# |---------------------
class Item():
def __init__(self, column, row):
self.column = column
self.row = row
self.colour = colours.white
... |
370034509b756826a311a3a253e24e61c9159932 | mashd3v/inteligencia_artificial | /Inteligencia Artificial y Machine Learning/Python/Básico/011 - Programa 4.py | 646 | 3.875 | 4 | # Programa 4: Adivina el numero
'''
Problema:
Realizar un "videojuego"en el cual la computadora genere un numero random y nosotros tratemos de adivinar cual genero.
'''
import random
def main():
numero_aleatorio = random.randint(1, 100)
numero_elegido = int(input('Elige un numero del 1 al 100: '))
... |
e3f79676946c1033ea1fe9d58bfbd310ff011a69 | mashd3v/inteligencia_artificial | /Inteligencia Artificial y Machine Learning/Python/Básico/013 - Tuplas.py | 976 | 4.65625 | 5 | # Tuplas
'''
En Python, una tupla es un conjunto ordenado e inmutable de elementos del mismo o diferente tipo.
Las tuplas se representan escribiendo los elementos entre paréntesis y separados por comas. Una tupla puede no contener ningún elemento, es decir, ser una tupla vacía.
Funciones que aplican a tupl... |
017d36315fb6435fd2c7ae2d2bbefc8454baa5b2 | mjmiossec/BasicNeuralNetwork | /ANN_digitos.py | 3,982 | 3.765625 | 4 | #Adventures in learning about artificial neural network...
#Originally for UNAB course => spanglish variable names.
#The data and the methods to convert it and display it at the end come from:
#https://www.python-course.eu/neural_network_mnist.php
import time
import numpy as np
import pickle
import matplotlib.py... |
24a641e403665a482915938c60b5b98d59854eea | dishant888/Python-Basics | /questions/Febonacci.py | 219 | 3.84375 | 4 | #Febonacci 0,1,1,2,3,5,8,13,21 (recursion)
range = int(input('Enter range: '))
def febo(a,b,range):
if range == 1:
return 1
else:
print(a+b,end=",")
febo(b,a+b,range-1)
febo(0,1,range) |
91bcd6e319e0a33d1cef4dd42bf860df9a0529f5 | dishant888/Python-Basics | /OOP/oop1.py | 4,656 | 4.25 | 4 | # Classes = Template
# object = Instance of class
# DRY = Do not Repeat Yourself
# 1. Basic concepts of OOP
# 1.1 Class
# 1.2 Object
# 1.3 Data Abstractiona and Encapsulation
# 1.4 Inheritance
# 1.5 Polymorphism
# 1.6 Message Passing
# 1.7 Data Binding
# 2. Python
# 2.1 Instance Variab... |
9d198260182aba109dcc476cb4c03a3ead13ed57 | dishant888/Python-Basics | /OOP/polymorphism.py | 3,223 | 4.1875 | 4 | # polymorphism (Many behaviours)
# Operator overloading
# print(3+4)
# print(int.__add__(3,2))
# print('3'+'4')
# print(str.__add__('5','6'))
# print(int.__add__(5,'6')) # Synthetic Sugar
# print(int.__sub__(5,'6')) # Synthetic Sugar
# object + object
# class Student:
# def __init__(self,a,b):
# self.... |
668ad30aa1f83949b47022cfab2e8f92a3938af3 | dishant888/Python-Basics | /questions/FarToCel.py | 214 | 4.15625 | 4 | #Convert Fahrenheit to Celcius
#F to C
f = float(input('Enter Fahrenheit: '))
print('%.2f'%eval('(f-32)*5/9'),' Celcius')
#C to F
c = float(input('Enter Celcius: '))
print('%.2f'%eval('(c*9/5)+32'),' Fahrenheit') |
cfeff107e17507decb4d3f6350ab85895338fde3 | dishant888/Python-Basics | /voiceNotes.py | 627 | 3.59375 | 4 | from AssistantModule import Recognize, Speak, Greet
Greet()
Speak('Welcome! Add note, Show note or exit.')
choice = Recognize().lower()
while choice != 'exit':
if choice == 'add':
file = open('files/voiceNotes.txt', 'w')
Speak('What should I add ?')
note = Recognize()
print(f'Inp... |
5f8b55cb7a4133e7513c058f1c182580da805e84 | cvillan223/BlackJack | /main.py | 3,189 | 3.578125 | 4 | import random
def drawCard():
cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
randomCard = random.randint(0, len(cards) - 1)
return cards[randomCard]
def CheckBust(Cards):
Sum = sum(Cards)
if Sum > 21:
if 11 in Cards:
Cards.remove(11)
Cards.append(1)
... |
1cbb8f0fcc3bb187fa454f71c3996ba256d3b30f | psonH/hackerrank-codes | /repeated_string.py | 827 | 3.75 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the repeatedString function below.
def repeatedString(s, n):
st_len = len(s)
count_a_st = 0
for i in s:
if i == 'a':
count_a_st = count_a_st + 1
f = n//st_len
total = f * st... |
f450da107cf85e925b6a91cad7f8123efb6eea68 | ImSmehta/Python | /Python 10.py | 918 | 3.90625 | 4 | a= int(input("Inter first number"))
b= int(input("Inter second number number"))
c=a+b
print("Original Value of c: ", c)
d=int(input("Choose\n 1->ADD\n 2->SUB\n 3->Multiply\n 4->Divide\n 5->MOD\n 6->Expo\n 7->FloorDivision"))
if 0<d<8:
if d==1:
c +=a
print("Addition using assignment ope... |
fa04281fe072893449db9d49c0780a48dbb7f1b5 | ImSmehta/Python | /Python 6.py | 406 | 4.0625 | 4 | str1= str(input("Enter the string "))
string= str(input("Enter the string "))
for i in range(0,len(str1)):
print(str1[i],end=" ")
print("Original string is :",str1)
str2=str1[1:-1]
print("Sliced string is :",str2) #printing sliced string
print("Repeted String is: ",str1*100) #printing repeted ... |
2c775f3eb43326b921b19baccc4832a74a4bde6f | JarrodFinnis/Maximal_Munch | /src/Node.py | 721 | 3.953125 | 4 | # Nodes that make up the tree structure
class Node:
def __init__(self, value):
self.value = value
self.parent = None
self.children = []
def set_value(self, value):
self.value = value
def get_value(self):
return self.value
def set_parent(self, par):
se... |
a8606e3731c7ed250281416f4518ffb09be1b5d2 | EunHyeJung/AlgorithmStudy | /BOJ/BOJ5597.py | 165 | 3.8125 | 4 | # https://www.acmicpc.net/problem/5597
list = []
for _ in range(0,28):
list.append(int(input()))
for i in range(1,31):
if i not in list:
print(i)
|
d7828f33382af43f071431a7496bacf65c8bdf50 | xiaofeifeiglp/pc_example | /http/tcp_server.py | 1,319 | 3.515625 | 4 | # 初始化
# 绑定端口与地址
# 被动模式
# 接收客户端的请求
# 处理客户端的请求
# 关闭
import socket
def client_exec(client):
'''处理客户端的请求'''
# 接收数据
while True:
# 如果tcp客户端关闭了会自动发送空的字符给我们
data = client.recv(1024)
# print(data)
# print('编码:', data.decode('utf-8'))
# 判断我们的数据如果接收到的是空的数据,那么推出循环
if data... |
601bb264779912738b91b4238679184f31518330 | xiaofeifeiglp/pc_example | /Algorithm/time_time.py | 422 | 3.625 | 4 | import time
class main(object):
def fun1(self):
strart = time.time()
for a in range(101):
for b in range(101):
for c in range(101):
if a+b+c == 1000 and a**2+b**2 == c**2:
print('a={} b={} c={}'.format(a, b, c))
end = ... |
96675aaf1ba8ba45e8635ac2eba7066dc74df603 | DanielMcCrystal/ProjectEuler | /py/40-49/Problem41.py | 506 | 3.59375 | 4 | from sympy import sieve
def is_pandigital(number, n):
n_str = str(number)
if len(n_str) != n:
return False
seen = [False] * n
for c in n_str:
digit = int(c)
if digit == 0 or digit > n or seen[digit - 1]:
return False
else:
seen[digit - 1] = True
return True
primes = [x for x in sieve.primerange(1,... |
5dfa2a687c4b472139624cd9108a538c276bf80a | DanielMcCrystal/ProjectEuler | /py/30-39/Problem38.py | 579 | 3.5625 | 4 |
def is_pandigital(n):
n_str = n
if len(n_str) != 9:
return False
seen = [False] * 9
for c in n_str:
digit = int(c)
if seen[digit - 1]:
return False
else:
seen[digit - 1] = True
return True
def concat(k, n):
cat = ""
for i in range(1, n+1):
cat += str(k * i)
return cat
max = -1
k = 1
while Tru... |
161788bb7ab611d98e6dba9f17aefa5b1032cd7f | DanielMcCrystal/ProjectEuler | /py/30-39/Problem34.py | 458 | 3.796875 | 4 | import math
factorials = [math.factorial(x) for x in range(10)]
def fact_sum(n):
x = n
sum = 0
while x > 0:
sum += factorials[x%10]
if sum > n:
return -1
x //= 10
return sum
sum = 0
#print(factorials)
i = 10
while i <= 100000000:
if fact_sum(i) == i:
print(i)
sum += i
print("new sum: " + str(su... |
7c625441e6b713b8f47cec59f1e5483e99847c47 | tobardaniel/Congreso | /Generar Diplomas/Diploma participacion/GenerarDiplomas.py | 2,809 | 3.765625 | 4 | # importamos os para usar la consola desde el programa
import os
# Convierte el cvs a un arreglo que luego usará la función para generar diplomas
def LeerDatos(archivo):
arreglo = []
f = open(archivo, 'r+', encoding = 'utf-8')
for line in f:
arr = line.rstrip('\n').split(",")
arr = [x.replace('"','').rstrip(' ... |
fddeebbea3053161023fd87dceb04ce500268136 | raquigomes/p1---Python | /Main Trabalho.py | 395 | 4.0625 | 4 | def menu():
print('0 - Sair')
print('1 - Humano vs Humano: modo texto')
print('2 - Humano vs Humano: modo gráfico')
print('3 - Humano vs Computador')
def loop():
menu()
i=int(input())
if(i==0):
return
elif(i==1):
return
elif(i==2):
return
e... |
bfe33889a934f475b2b902d67df1bf6d2f8e4300 | raquigomes/p1---Python | /Pratica 5.py | 1,411 | 3.609375 | 4 | #1
def compara(x,y):
if x>y:
return 1
elif x==y:
return 0
elif x<y:
return -1
else:
return None
#2
import math
def hipotenusa(cateto1,cateto2):
return round((math.sqrt(cateto1**2+cateto2**2)),2)
#3
def ack(m,n):
if isinstance(n, int) and i... |
143973c0832d9bbe478dc587af416f27c0207004 | raquigomes/p1---Python | /Pratica1.py | 269 | 3.671875 | 4 | #Partica1
#Exercicio3
tf=float(input('Qual é a temperatura?'))
tc=5/9*(tf-32)
print(tc)
#Exercicio4
dollar=float(input('Quantos dolares?'))
euro=(1/1.35)*dollar
print(euro)
dollars=float(input('Quantos dollares?'))
euros=0.79*dollars
print(int(euros))
|
0d3363db84219eeb32153e2773e1e97814643446 | MeliusEstRegnet/simpleRSA | /math_RSA.py | 3,553 | 3.9375 | 4 | """
Daniel Haller
12/23/16
A first attempt at the math behind RSA.
The intent for this file is to create a library of functions to use in a main script that will import
this file.
"""
"""Python library imports."""
import math
import random
import logging
"""Adjacent file includes."""
import prime_generator
""" T... |
4e4a95ea23bb6f90086bbdb987b8fa70142b1973 | JeffreybVilla/100DaysOfPython | /Beginner Day 14 Higher Lower Game Project/HigherLower.py | 1,956 | 3.984375 | 4 | from art import logo, vs
from game_data import data
from replit import clear
import random
def format_data(account):
"""
Takes the account data and returns the printable format.
"""
insta_name = account["name"]
insta_descr = account["description"]
insta_country = account["country"]
return... |
76330f9dfd49d09599509e9909d2ef0715eeb9c3 | JeffreybVilla/100DaysOfPython | /Beginner Day 13 Debugging/debugged.py | 1,709 | 4.1875 | 4 | ############DEBUGGING#####################
# # Describe Problem
# def my_function():
# """
# Range function range(a, b) does not include b.
# 1. What is the for loop doing?
# The for loop is iterating over a range of numbers.
#
# 2. When is the function meant to print 'You got it'?
# If... |
50862957a6dc3e70dabe1754056e9c40f91a8b5c | vijendraRaghuwanshi/NEW_FRLLAB2_SE | /New Text Document.txt | 276 | 3.53125 | 4 | print("1 for Addition \n2 for Subtraction \n3 for Multiplication \n4 for Division")
n = int(input("Enter your input in Integer: ")
if n==1:
execfile('addition.py')
elif n==2;
execfile('subtraction.py')
elif n==3:
execfile('multiplication.py')
else:
execfile('division.py') |
d5d574ba640ff4b12ec36cf018c863b45a72cd87 | t-tsekov/codefights-solutions | /interview/simplifyPath.py | 363 | 3.8125 | 4 | def simplifyPath(path):
path = path.replace("//", "/")
dirList = path.split("/")
dirStack = []
for dir in dirList:
if dir == "" or dir == ".":
continue
if dir == "..":
if len(dirStack) > 0:
dirStack.pop()
continue
dirStack.appe... |
67972aed616c42b031a8a9334b773963c3e8e29b | t-tsekov/codefights-solutions | /arcade/the-core/at-the-crossroads/metroCard.py | 220 | 3.515625 | 4 | def metroCard(lastNumberOfDays):
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
b = set()
for i in range(11):
if a[i] == lastNumberOfDays:
b.add(a[i + 1])
return sorted(list(b)) |
fc01518f2d2919b38addf0ab9da7ad11784cfe18 | t-tsekov/codefights-solutions | /arcade/the-core/loop-tunnel/rounders.py | 449 | 3.71875 | 4 | def rounders(value):
plusone = False
res = ""
digits = len(str(value)) + 1
for i in range(1, digits):
num = int(str(value)[-i]) + plusone
if i != digits - 1:
res += "0"
else:
if num != 10:
res += str(num)
else:
... |
51aa1cf92ff87b4985202337fbf16b1ec409a691 | t-tsekov/codefights-solutions | /arcade/the-core/lab-of-transformations/cipher26.py | 249 | 3.5 | 4 | def cipher26(message):
message = list(message)
currsum = 0
outmessage = ""
while message:
x = message.pop(0)
outmessage += chr(97+(ord(x)-97-currsum)%26)
currsum += ord(outmessage[-1])-97
return outmessage |
f9035d2c6118c118c91d63b4fac4cca9f63ebf3d | t-tsekov/codefights-solutions | /interview/textJustification.py | 1,064 | 3.53125 | 4 | def textJustification(words, L):
begin, end = 0, 0
result = []
while True:
wordsLen = 0
while end < len(words):
if wordsLen + len(words[end]) + (end - begin) <= L:
wordsLen += len(words[end])
end += 1
else:
break
... |
c0b096fa60b91b859fac13c0bf6a804116140dfc | hlainghpone2003/SFU-Python | /Sets.py | 2,214 | 4.15625 | 4 | #Sets
includes a data type for sets.
Curly braces or the set() fuction can be used to create sets.
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
print(basket) #show that duplicates have been removed
'orange' in basket # fast member testing
'crabgrass' in basket
Demonstrate set operation on unique ... |
98ab9afaaf96a3c95a13b0dea3315f9268f3212f | lang98/adaptive-algorithm | /6-mux/if_node.py | 1,432 | 3.703125 | 4 | from node import Node
class IfNode(Node):
def __init__(self, order, x=None, y=None, z=None):
Node.__init__(self, order)
self.x = x
self.y = y
self.z = z
def build(self, depth):
self.x = self.generate_random_child(depth)
self.y = self.generate_random_child(depth... |
c7caa4fad14395f3f1c2b2c3fe1c3f7e9af9ccfc | juliuso/exercises | /sudokuSolver2.py | 1,590 | 3.5 | 4 | #!/usr/bin/env python
# AUTHOR: jo
# DATE: 2019-10-29
# DESCRIPTION: "Sudoku Solver" problem from codewars v2
# PROBLEM: https://www.codewars.com/kata/sudoku-solver/train
import numpy as np
puzzle = np.array(
[
[5, 3, 0, 0, 7, 0, 0, 0, 0],
[6, 0, 0, 1, 9, 5, 0, 0, 0],
[0, 9, 8, 0, 0, 0, 0, ... |
d2c8b360ad39e3b21b8747a15171a3de8b21ec20 | lets-code-together/lets-code-together | /BaekjoonAlgorithms/06-OneDimensionalArray/Python/8958.py | 748 | 3.5 | 4 | # OX퀴즈의 결과가 주어졌을 때, 점수 구하기
# O가 연속으로 나오면 점수는 연속된 O의 개수가 된다.
test_count = int(input()) # 테스트 개수
test = [] # 각 테스트의 OX 입력
for i in range(test_count):
test.append(list(input()))
def ox_score(test):
each_score = [] # 각 테스트 점수
for i in range(len(test)):
score = 0 # 점수
x = 0 # O가 나오면 +1, X... |
70547dd5b4f42db27757d6095176a6c09ad21ff6 | lets-code-together/lets-code-together | /BaekjoonAlgorithms/09-Sort/Python/2750.py | 304 | 3.78125 | 4 | # N개의 수를 오름차순으로 정렬하기
num_nums = int(input()) # 수의 개수
def ascending(num_nums):
num = [] # 수 입력
for i in range(num_nums):
num.append(int(input()))
num.sort()
num = map(str, num)
return num
print("\n".join(ascending(num_nums)))
|
2da1e76bdbdf4dab16f120ffa4d27118803e9071 | lets-code-together/lets-code-together | /BaekjoonAlgorithms/04-IfLoop/Python/9498.py | 333 | 4 | 4 | # 시험 성적에 따라 등급 매기기
test_score = int(input())
def grade(x):
if 90 <= x <= 100:
grade = 'A'
elif 80 <= x < 90:
grade = 'B'
elif 70 <= x < 80:
grade = 'C'
elif 60 <= x < 70:
grade = 'D'
else:
grade = 'F'
return grade
print(grade(test_score))
|
25916f8c95c49108d69c94fe0e2efb8c7c23cb80 | lets-code-together/lets-code-together | /SamsungAlgorithms/6718_2.py | 519 | 3.703125 | 4 | # 어떤 물체와의 거리가 주어질 때, 수치를 매기는 프로그램을 작성하라.
T = int(input()) # 테스트 케이스의 수
def distance(d) : # 물체와의 거리
if d < 100 :
d = 0
elif 100 <= d < 1000 :
d = 1
elif 1000 <= d < 10000 :
d = 2
elif 10000 <= d < 100000 :
d = 3
elif 100000 <= d < 1000000 :
d = 4
else... |
d8359e7af5010bb374b4043f7d984909f43bcb82 | lets-code-together/lets-code-together | /BaekjoonAlgorithms/13-Deque/10866_2.py | 1,142 | 4.09375 | 4 | # 정수를 저장하는 덱을 구현한 다음, 입력으로 주어지는 명령을 처리하는 프로그램을 작성하시오.
a = int(input())
Deque = []
def push_front(n):
Deque.insert(0, n)
def push_back(n):
Deque.append(n)
def pop_front():
try:
print(Deque.pop(0))
except:
print(-1)
def pop_back():
try:
print(Deque.pop(-1))
except:... |
2afa566421f3d1cf7a38eb9aba4812e4c7f29ffd | lets-code-together/lets-code-together | /BaekjoonAlgorithms/03-ForLoop/python/11721.py | 320 | 3.578125 | 4 | # 10개씩 끊어 출력하기
word = list(input()) # 단어 입력
def printing_breaks(word): # 몇 줄에 걸쳐 출력할 것인가
N = len(word)
if N % 10 == 0:
re = N
else:
re = int(N / 10) + 1
for i in range(re):
print(word[10*i:10*(i+1)])
printing_breaks(word)
|
776ede07ef058c8545d96fc7c1f03f7f3366070b | lets-code-together/lets-code-together | /AlgorithmsBasic/4-Math1/1373_3.py | 344 | 3.546875 | 4 | # 2진수 8진수
# 2진수가 주어졌을 때, 8진수로 변환하는 프로그램을 작성하시오.
Base2 = input()
Base8 = []
while len(Base2) % 3 != 0 :
Base2 = '0' + Base2
for i in range(0, len(Base2), 3):
sum = int(Base2[i]) * 4 + int(Base2[i+1]) * 2 + int(Base2[i+2]) * 1
Base8.append(str(sum))
print("".join(Base8))
|
9eb7ad66b216861acc3f101a86945471b4bc6020 | lets-code-together/lets-code-together | /AlgorithmsBasic/4-Math1/10872_3.py | 296 | 3.828125 | 4 | # 팩토리얼
# 0보다 크거나 같은 정수 N이 주어진다.
# 이때, N!을 출력하는 프로그램을 작성하시오.
def factorial(N):
factorial = 1
while N > 0:
factorial = factorial * N
N -= 1
return factorial
N = int(input())
print(factorial(N))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.