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 |
|---|---|---|---|---|---|---|
02234574399517d3716ee9db17225765ae862379 | wmcknig/pynigma | /src/components/Rotor.py | 1,481 | 3.8125 | 4 | class Rotor:
ROTOR_LENGTH = 26
def __init__(self, t, offset = 0):
"""
Requires: a valid sequence of ROTOR_LENGTH, containing
every integer from 0 to ROTOR_LENGTH - 1 inclusive.
Ensures: this is at the given rotor state (0 by default)
"""
self.t = t
self.o... |
c4c44139b1ded9455fdf467d9f4ad43091569c27 | nanrak/210CT | /Task3_4.py | 2,853 | 3.96875 | 4 | '''
Task 3 - 4
------------------
Adapt your graph structure from the previous week to support weights for the edges and implement Dijkstra's algorithm.
The output of the program should be the total cost and the actual path found.
'''
import sys
class Node:
def __init__(self, label):
... |
3eeb1699971abe0a7994f63a5fe95fe06a713847 | pprobst/ELC117-2018a | /extras/OOP1_python/test_circle.py | 250 | 3.6875 | 4 | from circle import Circle
c1 = Circle()
c2 = Circle()
print("Area C1: {}".format(c1.area()))
print("Area C2: {}".format(c2.area()))
c1.r = 5.0
print(c1.r)
circulos = []
for i in range(10):
circulos.append(Circle())
print(circulos[0].area())
|
fecfa629838dd438eede4ce891d085d53470f61c | AronDJacobsen/Algo_Data_Project | /3_closest.py | 3,271 | 3.8125 | 4 |
import numpy as np
from collections import deque
#we want to create the vertex to hold vales like neighbours, depth etc.
class vertex:
def __init__(self, i, j, char):
self.position = (i, j) #up/down, left/right respectively
self.depth = None # to be updated
self.neighbours = []
se... |
303ba987eeb196baf6e950ff63372a693bb52e91 | LugBastos/Projetos-Faculdade | /votacaoPremio.py | 2,737 | 3.65625 | 4 | #Entrade de valores
coloborador1 = int(input("Primeiro colaborador, escolha o console de última geração: (1)PLAYSTATION / (2)XBOX / (3)NINTENDO "))
coloborador2 = int(input("Segundo colaborador, escolha o console de última geração: (1)PLAYSTATION / (2)XBOX / (3)NINTENDO "))
coloborador3 = int(input("Terceiro colabor... |
dc048905570ea63e95032108822934f60bb4c77b | Caizhiwen/Image-based-Reminder | /openCv/hello_world.py | 724 | 3.921875 | 4 | #Load up a color image in grey scale and save it as black&white
import numpy as np
import cv2
# cv2.IMREAD_COLOR : Loads a color image. Any transparency of image will be neglected. It is the default flag.
# cv2.IMREAD_GRAYSCALE : Loads image in grayscale mode
# cv2.IMREAD_UNCHANGED : Loads image as such includi... |
09188ac7a45e50d7be77836d0ae423b5ad79c64b | abalarajendrakumar/Resumeparser | /db.py | 2,282 | 3.75 | 4 | # -*- coding: utf-8 -*-s
"""
Created on Fri Feb 14 13:05:41 2020
@author: User
#cursor.execute("DROP TABLE Candidate")
#cursor.execute("DROP TABLE Recruiter")
#cursor.execute("DROP TABLE CandidateDetails")
#cursor.execute("DROP TABLE JobPostings")
#conn.execute("CREATE TABLE Candidate (USER_NAME TEXT NOT NULL,EMAIL TE... |
932755c39862cf98d39a5edaf5f2dc03dcf758b2 | howard199113/Python-Assignments | /Making Dctionaries.py | 157 | 3.59375 | 4 | howard = {"name":"Howard","Age":"26","country of birth":"Taiwan","favoirte language":"Python"}
for obj in howard:
print "My "+ obj + " is " + howard[obj] |
074e4dcc4968b670b3c161d2ccca0b3239179f9a | moniqueds/FundamentosPython-Mundo1-Guanabara | /ex012.py | 272 | 3.53125 | 4 | preco = float(input('Informe o valor do produto: R$ '))
novo = preco - (preco * 5 / 100)
print('O valor do produto sem desconto era de R$ {:.2f}, mas com desconto de 5% irá custar R$ {}'.format(preco, novo))
#para calcular percentual precisa ser:
# 5/100 = 0.05
|
02cdf23d234d56f3de0f9af1fed602ecaeb3046e | moniqueds/FundamentosPython-Mundo1-Guanabara | /ex033.py | 733 | 4.3125 | 4 | #Faça um programa que leia três números e mostre qual é maior e qual é o menor.
from time import sleep
print('Você irá informar 3 números a seguir...')
sleep(2)
a = int(input('Digite o primeiro número: '))
b = int(input('Digite o segundo número: '))
c = int(input('Digite o terceiro número: '))
print('Analisand... |
c3e7f465cceb9c3ca3e692b21539554ba1729747 | Keng-Hwee/flask-restful | /basics/basic_flask_app.py | 2,178 | 3.5 | 4 | from flask import Flask, jsonify, request, render_template
app = Flask(__name__)
stores = [
{
'name': 'My Wonderful Store',
'items': [
{
'name': 'My Item',
'price': 15.99
}
]
}
]
@app.route('/')
def home():
return render_tem... |
22602a8aef57ff7508cb189a6516a2fe05e5910c | srikoder/CryptoStuff | /CryptoPals/2018csb1098_15.py | 456 | 3.6875 | 4 | def pad(m, blength):
numPad = (blength - len(m))
paded = (chr(numPad)*numPad).encode()
ans = m.encode()+paded
return ans
def main():
c = input()
count = 0
for ch in c:
if ch=='\\':
break
else:
count = count+1
unpad = c[1:count]
print(len(c))
... |
671b743b1a208bb2f23e00ca96acad7710bd932f | slutske22/Practice_files | /python_quickstart_lynda/conditionals.py | 1,192 | 4.21875 | 4 | # %%
raining = input("Is it raining outside? (yes/no)")
if raining == 'yes':
print("You need an umbrella")
# %%
userInput = input("Choose and integer between -10 and 10")
n = int(userInput)
if n >= -10 & n <= 10:
print("Good Job")
# %%
def minimum(x, y):
if x < y:
return x
else:
retu... |
c8d2b0438078200fdede0fac7ad74dac1394ca42 | slutske22/Practice_files | /python_misc/cells.understanding.py | 415 | 3.609375 | 4 | from heapq import heappop
# %% Understanding zip: create tuples from zipped lists
dxs = [-1, -1, 0, 1, 1, 1, 0, -1]
dys = [ 0, -1, -1, -1, 0, 1, 1, 1]
zipped = zip(dxs, dys)
print(list(zipped))
# %% Typings?
g: int
g = 'j' #like wtf does this mean
# %%
from heapq import heappop
stuff = list(['a', 'b', 'c', 'd']... |
337573761ea3f446741271a7a4629229562bcf7f | davidgamero/terminal-gatech-2019 | /line_fuctions.py | 588 | 3.71875 | 4 | def get_line_points(start, end):
line_points = []
# Flip so we always go the right
if start[0] > end[0]:
temp = start
start = end
end = temp
x1 = start[0]
y1 = start[1]
x2 = end[0]
y2 = end[1]
slope = (y2-y1)/(x2-x1)
x = x1
y = y1
print('X = ' + st... |
4a669abe46dc9db2dc55070d6034574901859fa2 | ccamargo8/Mi-primer-repositorio | /Ejemplo matriz.py | 539 | 3.65625 | 4 | import random
estrella="\u2605"
filas=int(input("Ingrese el numero de filas: "))
columnas=int(input("Ingrese el numero de columnas: "))
#Matriz construida por comprensión
cielo=[[" " for i in range(columnas)] for j in range (filas)]
for i in range(filas): #Se recorren filas
for j in range(columnas): #Se recorr... |
cbb2f5554253520124a6a7541e9852d00839251a | ccamargo8/Mi-primer-repositorio | /POO.py | 1,216 | 3.5 | 4 | import random as rd
#Clase estrella. Si se crea una clase sin atributos, se usa pass
class estrella():
lugar="Espacio"
#Self quiere decir que el constructor le pertenece a la clase definida
def __init__(self,
color="Blanca",
edad=0,
constelacion="nula"
... |
0a218975ac821d79a7df598d3ecec85fcf212d21 | ccamargo8/Mi-primer-repositorio | /Ejemplo matriz 2.py | 1,031 | 4 | 4 | f = int(input("Cuantas empresas? "))
c = int(input("Cuantos empleados por empresa? "))
matriz=[[0]*c for i in range (f)]
print(matriz)
for i in range(f):
suma=0
for j in range(c):
valor = int(input(f"Ingrese el valor para la empresa {i}, empleado{j}: "))
matriz[i][j]=valor
suma=suma+ma... |
529a258ef79a5194d1f3a49c570076464334b744 | ccamargo8/Mi-primer-repositorio | /funOpVectores.py | 714 | 3.84375 | 4 | def buscarDato(V,d):
"""Programa para buscar un dato en un vector"""
i=1
while i<=V[0] and V[i]!=d:
i=i+1
if i <= V[0]:
return i
return -1
def borrar(V,i):
"""Programa para borrar un dato de un vector"""
for j in range(i,V[0]):
V[j]=V[j+1]
V[0]=V[0]-1
... |
f4a153a819c9bd6aeeed4347cc6ff2cef4be6db2 | chen-alain/Algorithm-Fight-Club | /Round-5/LUKE GUERDAN quicksort.py | 1,446 | 4.0625 | 4 | def quicksortRecur(array, low, high):
print "Entering quicksort: " + str(array) + " low: %d - high: %d" % (low, high)
if (low > high):
return
pivot = array[(low + high) / 2]
print "pivot: %d\n" % pivot
i = low
j = high
while(i <= j):
while(array[i] < pivot):
i += 1
... |
9b2defe6842ac55e6b0c1157f04da230f3d33bb4 | LuisDiego10/Circuit-Designer | /src/graph/__init__.py | 7,766 | 3.5625 | 4 | import json
from typing import List, Any
from graph.Node import Node
class Graph:
paths: List[List[int]]
nodes: List[Node]
def __init__(self):
"""
create a empty graph class
"""
self.nodes = []
self.paths = []
self.sorted_up = []
self.sorted_down = []
pass
def insert_node(self, node: Node):
... |
2ac0f93a0ade5c1f9b151df58fce8ca7deee3c11 | gsharansingh/easygplot | /easygplot/read.py | 5,137 | 3.9375 | 4 | import numpy as np
import csv
from sklearn.impute import SimpleImputer
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
class CSV:
"""
This module will read the csv file and create an object containing data and labels.
Parameters
----------
filename: str
Input ... |
19830b17fe1289929e9d9d7f6312715ea6cafeb7 | SDSS-Computing-Studies/006b-more-functions-ye11owbucket | /problem2.py | 774 | 4.125 | 4 | #!python3
"""
##### Problem 2
Create a function that determines if a triangle is scalene, right or obtuse.
3 input parameters:
float: one side
float: another side
float: 3rd side
return:
0 : triangle does not exist
1 : if the triangle is scalene
2 : if the triangle is right
3 : if the triangle is obtuse
Sam... |
d0c11c50751edd87834d175c3da469dd5798f009 | kathmandu777/CompetitiveProgramming | /AtCoder/ABC/47/A47.py | 109 | 3.71875 | 4 | a, b, c = map(int, input().split())
if a + b == c or a+c==b or b+c==a:
print("Yes")
else:
print("No") |
d65975d3639c3217e144c20f710bda998a3a022c | kathmandu777/CompetitiveProgramming | /AtCoder/typical90/38.py | 189 | 3.78125 | 4 | from math import gcd
def lcm(a, b):
return a // gcd(a, b) * b
a, b = map(int, input().split())
ans = lcm(a, b)
if ans > 1000000000000000000:
print("Large")
else:
print(ans)
|
5acf15ce3fb66c989ad18a538fa76d10c40c0d23 | Soojin-C/Soft_Dev_Work | /18_listcomp/pyth.py | 222 | 3.953125 | 4 | # Soojin Choi
# SoftDev1 pd08
# K18 -- Getting Clever with List Comprehensions
# 2019-04-15
def triple(num):
return [(c, b, a) for a in range(num) for b in range(a) for c in range(b) if a*a == b*b + c*c]
print(triple(19)) |
110ee696b9aaca673716a87b62859a9189ec2f82 | Soojin-C/Soft_Dev_Work | /23_memoize/fib.py | 947 | 3.578125 | 4 | #
import random
def make_HTML_heading(f):
txt = f()
def inner():
return '<h1>' + txt + '</h1>'
return inner
# equiv to greet = make_HTML_heading(greet)
@make_HTML_heading # v1
def greet():
greetings = ["Hello","Welcome","AYO!", "Hola", "Bonjour", "Word up"]
return random.choice(greetings... |
35bbf1589f356460621c1b30e7e0767ad44dca92 | MacLure/python-basics | /strings.py | 890 | 4 | 4 | print('Malcolm MacLure')
print("o----")
print(' ||||')
print('*' * 10)
price = 10
rating = 4.9
name = "Malcolm"
is_published = True
print(price)
name = input("What is your name? ")
print("Hi " + name)
fav_color = input("What color do you like? ")
print(name + " likes " + fav_color)
print("first letter is " + name[0]... |
f48d66b2f5160b271af8e24c4d458656d0cbd571 | Cliedy-s/AIclass | /1911/1119/1119/_1119_02_DBConnect_SelectToDic.py | 435 | 3.8125 | 4 | import sqlite3
import sys
from datetime import datetime
def main():
conn = sqlite3.connect('database.db')
conn.row_factory = sqlite3.Row # 딕셔너리 구조로 컬럼을 접근하는 옵션
cursor = conn.cursor()
cursor.execute("SELECT * FROM books;")
rows = cursor.fetchall()
for row in rows:
print(row, row['title... |
d0cdb4adfa23380fe67475b546ec6b4d6bcb743d | Cliedy-s/AIclass | /1911/1114/1114_01_함수/_1114_02_FileReadWrite.py | 1,242 | 3.640625 | 4 |
# dir
import os
# mkdir
if(not os.path.isdir('data')):
os.mkdir('data')
# file
import sys
print(sys.stdin.encoding)
print(sys.stdout.encoding)
# create file
f = open('data/test.txt', 'w', encoding='utf-8')
f.close()
# with
with open('data/test.txt','w', encoding='utf-8') as f:
f.write('wri... |
303d8a6188befcd79bfc7540d919c60b5635ab7f | Cliedy-s/AIclass | /1911/1118/1118/_1118_01_basicclass_property.py | 1,857 | 3.578125 | 4 | class TestClass:
memberCnt = 0
#def __init__(self, name='홍기롷' , phone='010-1111-1111'):
# self.name = name
# self.phone = phone
# print('생성')
#def __init__(self, **kwargs): # 많이 쓰는 방법
# self.name = kwargs.get('name', '홍길동')
# self.phone = kwargs.get('phone','010-1111-1111... |
f4739ff93399de8d4e4700bc743959737bac6a18 | Cliedy-s/AIclass | /1911/1113/1113_01_몸풀기/_1113_02_elif.py | 403 | 3.953125 | 4 | a = int(input('a : '))
if a%2 : # 1 => 홀수 : 참, 0 => 짝수 : 거짓
print('홀수')
else :
print('짝수')
if a > 0 :
print('양수')
elif a < 0 :
print('음수')
else :
print('0')
if a :
print('양수')
elif a <0 :
print('음수')
else :
print('0')
if 0:
pass
elif 3:
pass
else :
print('4')
3 in [1,2,3... |
b983feb44b8289edfb1a208ab90faa693c8007ff | gangys0411/python | /day02/for_04.py | 110 | 3.75 | 4 | for j in range(2, 10):
for i in range(1, 10):
print('{}X{}={}'.format(j, i, j*i))
print("\n")
|
11afcc9e6d5d4568a481cf9bccea8f2cb523f62e | gangys0411/python | /day02/while_01.py | 77 | 3.671875 | 4 | count = 0
while count < 3:
print("횟수 : ", count)
count +=1
|
96c16c6f7147474b895edc5234691a4caeba8471 | MarvickF/Coding-from-School-2020 | /CH5 LAB.py | 790 | 4.09375 | 4 | """
Program: sentence generator.py
Marvick Felix
This program generates sentences using grammar and simple vocab and prints them.
"""
import random
prepositions = ("WITH", "BY")
articles = ("A", "THE")
nouns = ("DOG", "MOUSE", "CAR","KEYBOARD")
verbs = ("RAN","SAW","LEFT")
def sentence():
return noun... |
f9b4912d65ffb4d7d088bb1a5508ccf50d96dcdf | nickstoian/LanguageModeling | /CompareCorpora.py | 2,841 | 3.53125 | 4 | # Nicolas Stoian
# CS780 Natural Language Processing
# Homework - Language Modeling
textFile = open('brown-train-padded.txt', 'r')
unigramDict = dict()
for line in textFile:
for word in line.split():
if word not in unigramDict:
unigramDict[word] = 1
else:
unigramD... |
9a266880216cdf3a9c10495912467403e69cc5a0 | tony-blake/MultiUserBlog3 | /helpers/form_data.py | 704 | 3.953125 | 4 | """ Handles hashing and verification of user passwords
Examples:
username("some_username")
password("some_unencrypted_password")
email("some_email")
* Returns a Match object if valid, otherwise returns None
"""
import re
USER_RE = re.compile(r"^[a-zA-Z0-9_-]{3,20}$")
PASS_RE = re.compile(r"^.{3,2... |
e935b348e9f40316060ccab9f045ce3b7151a1fe | scriptedinstalls/Scripts | /python/strings/mystrings.py | 574 | 4.25 | 4 | #!/usr/bin/python
import string
message = "new string"
message2 = "new string"
print message
print "contains ", len(message), "characters"
print "The first character in message is ", message[0]
print "Example of slicing message", message, "is", message[0:4]
for letter in message:
print letter
if message == m... |
ceb846a43c34cfa75d688986d1f3b2a24a8875aa | evvanErb/DailyDigest | /sendMail.py | 1,278 | 3.5 | 4 | """Send Mail"""
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
with open ("passwords.txt", "r") as myfile:
keysAndPasses = myfile.read()
keysAndPasses = eval(keysAndPasses)
EMAIL_PASSWORD = keysAndPasses["EMAIL_PASSWORD"]
SENDER_ADDR = keysAndPasses["SENDER_ADD... |
e05c5f29757947574b0ed92d3bab95678b489cdf | lisiur/leetcode | /tests/test_implement_strstr.py | 1,435 | 3.5625 | 4 | import unittest
from solutions.implement_strstr.solution import Solution
class TestStrStr(unittest.TestCase):
def test_1(self):
u_input = {
'haystack': 'hello',
'needle': 'll'
}
u_output = 2
solution = Solution()
u_result = solution.strStr(**u_inpu... |
753ac65d90f255043c2c7db008fb11f9783c746d | lisiur/leetcode | /solutions/reverse_integer/solution.py | 564 | 3.546875 | 4 | class Solution:
def larger(self, a: str, b: str):
if len(a) > len(b):
return True
elif len(a) < len(b):
return False
else:
return a > b
def reverse(self, x: int) -> int:
maxN = '2147483647'
if x == -2147483648: # 把边界条件剔除,则后面 x = -x ... |
db8303b93df50c980a95e58b8ed00df139718cff | dongshuicen/py_practice1 | /practice/TimeTest.py | 357 | 3.703125 | 4 | # -*- coding: utf-8 -*-
import time
print(time.localtime(time.time()))
print("格式化后当前日期:" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
import calendar
months = {1,2,3,4,5,6,7,8,9,10,11,12}
years = [2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020]
for y in years:
for i in months:
print(cal... |
09f88fe9c8285725678f93ebacf9a9544184d6ce | Dairo01001/python_URI | /URI_1021.py | 504 | 3.640625 | 4 | def main():
billetes = [100, 50, 20, 10, 5, 2]
monedas = [100, 50, 25, 10, 5, 1]
n = float(input())
print('NOTAS:')
for billete in billetes:
ans = n // billete
n = n - (ans * billete)
print(f'{int(ans)} nota(s) de R$ {billete:.2f}')
print('MOEDAS:')
n = n * 100
... |
355f4f4f88df99e546aa8dd06ac4ffb957430a81 | Dairo01001/python_URI | /URI_1118.py | 497 | 3.65625 | 4 | def solve():
suma: float = 0.0
cont: int = 0
while cont < 2:
score = float(input())
if 0 <= score <= 10:
suma += score
cont += 1
else:
print('nota invalida')
print(f'media = {(suma / cont):.2f}')
def main():
solve()
while True:
... |
63dc2d245a9951bac2d9b12df9ac94cea24ff252 | Dairo01001/python_URI | /URI_1133.py | 284 | 4 | 4 | def swap(a: int, b: int):
if a > b:
return b + 1, a
return a, b
def main():
x = int(input())
y = int(input())
x, y = swap(x, y)
for i in range(x, y):
if i % 5 == 2 or i % 5 == 3:
print(i)
if __name__ == '__main__':
main()
|
82b342be159fdbf98ded99bab601f79a90bbc300 | sanyaverma/shipdesigns.github.io | /hmw-generator.py | 2,386 | 3.734375 | 4 | import random
#Fun How Might We statements
actions = ["design ", "build ", "create ", "invent ", "make "]
objects = ["a bed", "an ice cream cone", "shoes", "music player", "an ecosystem", "a new planet", "a coffee shop", "a new tea flavor", "a bottle of wine", "the Shift house"]
subjects = ["dragons", "a tent", "hum... |
49a1ffd693a73f5e6d0f271b28e877fd051eab1e | Serikaku/Treinamento-Python | /CursoemVideo/ex057.py | 223 | 3.953125 | 4 | sexo = str(input('Digite seu sexo [M/F]: ')).strip().upper()
while sexo not in 'MmFf':
sexo = str(input('Dados invalidos. Digite seu sexo [M/F]: ')).strip().upper()
print('Sexo {} registrado com sucesso'.format(sexo))
|
a86d25ff9597219c946ce2a6ae6701ea6a874b56 | Serikaku/Treinamento-Python | /CursoemVideo/ex084.py | 779 | 3.625 | 4 | lista = []
pessoa = []
pesado = leve = 0
while True:
pessoa.append(str(input('Nome: ')))
pessoa.append(float(input('Peso: ')))
if len(lista) == 0:
pesado = leve = pessoa[1]
else:
if pessoa[1] > pesado:
pesado = pessoa[1]
if pessoa[1] < leve:
leve = pessoa[... |
cece13bc067a242963346a7b85203eab0a9c16a1 | Serikaku/Treinamento-Python | /CursoemVideo/ex038.py | 255 | 4.03125 | 4 | x = int(input('Digite um numero inteiro: '))
y = int(input('Digite outro numero inteiro: '))
if x > y:
print('O primeiro valor eh maior')
elif x < y:
print('O segundo valor eh maior')
else:
print('Nao existe valor maior, os dois sao iguais')
|
126a2ce7838ca8ffa13f21e9ad5edaad0871653e | Serikaku/Treinamento-Python | /CursoemVideo/ex049.py | 137 | 4.03125 | 4 | x = int(input('Digite um numero inteiro para saber sua tabuada: '))
for i in range(0, 11):
print('{} x {:2} = {}'.format(x, i, x*i))
|
a166ad36b59f7a81590b48df9349a7352952cbaa | Serikaku/Treinamento-Python | /CursoemVideo/ex098.py | 609 | 3.765625 | 4 | from time import sleep
def contador(x, y, z):
if z < 0:
z = z * -1
elif z == 0:
z = 1
print(f'Contagem de {x} ate {y} de {z} em {z}')
if x < y:
for j in range(x, y + 1, z):
print(f'{j} ', end='')
sleep(0.25)
else:
for j in range(x, y - 1, -z)... |
5e4509c1c093e67f3a225e156b7496b9de66ac2c | Serikaku/Treinamento-Python | /CursoemVideo/ex044.py | 533 | 3.765625 | 4 | x = float(input('Digite o valor da compra: '))
y = int(input('''Forma de pagamento
1 a vista dinheiro/cheque
2 vista no cartao
3 2x no cartao
4 3x ou mais no cartao
'''))
if y == 1:
print('O valor a ser pago eh: R${:.2f}'.format(x*0.9))
elif y == 2:
print('O valor a ser pago eh: R${... |
9765d97890708ad90aa79dc6246f1892d91ada0f | Serikaku/Treinamento-Python | /CursoemVideo/ex010.py | 134 | 3.921875 | 4 | x = float(input('Digite quantos reais você possui na carteira: R$'))
print('Você pode comprar US${:.2f} Dólares'.format(x / 3.27))
|
f7978987760c18c4645ef89b6981d10125dc91ab | Serikaku/Treinamento-Python | /PythonTeste/aula09a.py | 256 | 3.71875 | 4 | frase = 'Curso em Video Python'
print(frase[::2])
print(frase.count('o'))
print(len(frase.strip()))
print(frase.replace('Python', 'Android'))
print(frase)
print('Curso' in frase)
print(frase.find('aaaa'))
dividido = frase.split()
print(dividido[2][3]) |
d3f7f5eaa8d5d72840df9d59033a421a01dc871e | maricielo935/trabajopurihuaman | /ejercicio6.py | 311 | 3.625 | 4 | #Teorema de Poncelet
cateto1,cateto2,hipotenusa,radio=0.0,0.0,0.0,0.0
#Asignacion de valores
cateto1=30
cateto2=40
hipotenusa=50
#Calculo
radio=(cateto1+cateto2-hipotenusa)/2
#Mostrar valores
print("cateto1 = ", cateto1)
print("cateto2 = ", cateto2)
print("hipotenusa =", hipotenusa)
print("radio =", radio)
|
1f8b658b51a25b6fb9d7009766dcdff44f5a6da9 | namaslay33/digitalCrafts | /python-exercises/W1/Thur/TurtleExercises/Square.py | 489 | 4 | 4 | from turtle import *
import matplotlib
import matplotlib.pyplot as plot
def square() :
forward(50)
right(50)
forward(50)
right(50)
square()
# plot.show()
# from turtle import *
# import matplotlib
# import matplotlib.pyplot as plot
# def turtocta():
# for i in range(8):
# forward(100)
... |
b71f6bd7944952554f9369bdb51a6e372110ff16 | jzagozda/Incu2020 | /PyWebinar1/FunctionsFix.py | 444 | 3.875 | 4 | def test_function(a,b):
""" Why result1 is None? :(
"""
result = a*b
print('Result: {0}'.format(result))
return result
result1 = test_function(2,4)
print(result1)
#######################################
def test_function2(a,b):
""" Why do we have only 15 instead of Result: 15 as well? :(
... |
6835453a527ac9ada2daf07f8d4694d9352ebb86 | hboonewilson/IntroCS | /DAs/WilsonBooneDA9.py | 2,088 | 3.765625 | 4 | #Boone Wilson
#DA 9
#Section A04
#11/7
def getHawkID():
return ['hbwilson']
#write function that takes as an argument either a 12-digit positive integer or
#string consisting of 12 digits and calculates the 13th digit
def calculatgeCheckDigit(n):
#create a list to hold all of the digits as strings
myList... |
e6b681234935ea15b7784a76d9921a900e137e7f | hboonewilson/IntroCS | /Collatz Conjecture.py | 885 | 4.46875 | 4 | #Collatz Conjecture - Start with a number n > 1. Find the number of steps it...
#takes to reach one using the following process: If n* is even, divide it by 2.
#If *n is odd, multiply it by 3 and add 1.
collatz = True
while collatz:
input_num = int(input("Give me a number higher than 1: "))
if input_... |
4107ba5e1bad42808d61e400d5da73ba46befcdf | hboonewilson/IntroCS | /base10base2converter.py | 1,149 | 3.96875 | 4 | #create a function that takes a number and a letter as an argument and converts
#the number into the opposite base (2==>10) (10===>2)
def binaryTenConverter(num, base):
#decide which way to convert
if base.lower() == "b":
#count length of binary string
s_num = str(num)
long = len(s_num)... |
106bad049c8f2140ee27ef5e798d8c4b7c0a90f3 | hboonewilson/IntroCS | /DAs/WilsonHenryDA2.py | 1,090 | 4 | 4 | #Henry Wilson
#Discussion Assignment 1
#Section 0A04
# Aug/29/19
#getHawkID
def getHawkID():
return ['hbwilson']
#write a function with 3 arguements, all of which are numbers.
#return the three arguments' average rounded to the nearest THENTH
def calculateAverage(n1, n2, n3):
#find mean
mean = (n1 + n2 +... |
abedcc99b6929f548c4b50b5f1f622a7ae7a6349 | bibanon/macrochan-scraper | /utils.py | 781 | 3.578125 | 4 | # handy file interfacing utilities
import os
import requests
def mkdirs(path):
"""Make directory, if it doesn't exist."""
if not os.path.exists(path):
os.makedirs(path)
def download_file(local_filename, url, clobber=False):
"""Download the given file. Clobber overwrites file if exists."""
dir_name = os.path.di... |
bbeb369e80c881f49f839022a68466650810bdda | ScottSko/Python---Pearson---Third-Edition---Chapter-9 | /Chapter 9 - Algorithm Workbench #6 - 10.py | 140 | 3.515625 | 4 | def main():
set1 = set([1, 2, 3])
set2 = set([3, 4, 5])
set3 = set1.symmetric_difference(set2)
print(set3)
main() |
8e6a9f4ffb5d58bf653ecaaba0b73a3e53642a8c | ScottSko/Python---Pearson---Third-Edition---Chapter-9 | /Chapter 9 - Programming Exercises #9 - Blackjack Simulator.py | 3,751 | 3.5625 | 4 | import random
def create_deck():
deck = {"Ace of Spades": 1, "2 of Spades" : 2, "3 of Spades": 3, "4 of Spades": 4, "5 of Spades" : 5,
"6 of Spades" : 6, "7 of Spades" : 7, "8 of Spades": 8, "9 of Spades": 9, "10 of Spades": 10,
"Jack of Spades": 10, "Queen of Spades": 10, "King of S... |
db066f582ca23bce7f1f7285ed984130ec617517 | Sabin-Gurung/RecordVisualizer | /Record.py | 566 | 3.59375 | 4 | #!/usr/bin/python3
class Record():
def __init__ (self, name, surname, dateOfBirth, address, occupation):
self.__name = name.upper()
self.__surname = surname.upper()
self.__DOB = dateOfBirth.upper()
self.__address = address.upper()
self.__occupation = occupation.upper()
def getData (sel... |
8e0ad0188d8c57078f4df07b3633cd79d296b03f | ramo16/algorithms | /plus minus.py | 1,391 | 3.9375 | 4 | """
Given an array of integers, calculate which fraction of its elements are positive, which fraction of its elements are negative, and which fraction of its elements are zeroes, respectively. Print the decimal value of each fraction on a new line.
Note: This challenge introduces precision problems. The test cases are... |
f25620d50790ea9ea3d83d519ed5c014dd7defb9 | ShinSnap/Coursera_Coursework | /PythonForEveryone/py4e_assign_4_6.py | 294 | 4 | 4 | def computepay(hours,rate) :
if hours <= 40 :
return hours * rate
elif hours > 40 :
return (40 * rate) + ((hours - 40) * (rate * 1.5))
rawhrs = input("Enter Hours: ")
rawrate = input("Enter Rate: ")
hrs = float(rawhrs)
rate = float(rawrate)
print(computepay(hrs,rate)) |
2820f6b37bebf0ff0389259ce640b22ac19f0117 | watchbutdonotlearn/PySharedclipboard | /client.py | 2,413 | 3.78125 | 4 | import socket # Import socket module
from pynput import keyboard
import tkinter as tk
host = ""
def saveip():
while True:
saveyn = input('Do you want to save your ip for next time? yes/no ')
if saveyn == "yes":
h = open('ipname', 'w')
h.write(host... |
e4412ee5916c086afa98285337bbad4ef7c37d0f | UF-Elektron/HelloWorld | /ETH_Aufgaben/poker.py | 1,810 | 3.578125 | 4 | print("*********")
print("P O K E R")
print("*********")
print("EINGABE IHRER KARTEN")
print("Geben Sie alle Karte in absteigender Wertigkeit ein: ")
print()
#Einlesen der Karten
card = [[0 for x in range(2)] for y in range(5)]
for cardId in range (0, 5):
for cardEl in range (0, 2):
print("Karte Nr ", car... |
8619c9355a1bfde0b4fdacf73c09b95edaa30128 | salma-nyagaka/golclinics-dsa | /classwork/01-arrays-and-strings/alternating_characters.py | 178 | 3.734375 | 4 | def alternatingCharacters(s):
result = 0
for i in range(len(s) - 1):
if (s[i] == s[i + 1]):
result += 1
return result |
568cdf4684e99910da53da82228d8d93320bc82c | salma-nyagaka/golclinics-dsa | /classwork/01-arrays-and-strings/minimum_swaps.py | 355 | 3.515625 | 4 | def minimumSwaps(arr):
swaps = 0
tmp = {}
for i, val in enumerate(arr):
import pdb
pdb.set_trace()
tmp[val] = i
for i in range(len(arr)):
if arr[i] != i+1:
swaps += 1
t = arr[i]
arr[i] = i+1
arr[tmp[i+1]] = t
... |
4063cecbd1eee1918db71b5c7ad10460cb8f83a6 | L-dongkyung/study_Numpy | /tuple.py | 466 | 3.890625 | 4 | a = (1, 2, 3)
b = (1, 2, 4)
c = (1, 2, 3)
# print(type(a))
# print(type(a[0]))
# print(type(a[1]))
# print(type(a[2]))
# a[0] = -1
# print(a)
# print(a[0:2])
# print(a == b)
# print(a is b)
# print(a == c)
# print(a is c)
d = list(a)
d[0] = -1
e = tuple(d)
# print(e)
f = (1, 'abc', [1, 2, 3])
before_id = id(f[2])
... |
6fb5fb5dc3264574117b16d3deffdad25885c0fa | ajamanjain/AI-Python_Program | /Cannibals_and_Missionaries.py | 2,521 | 3.765625 | 4 | m1 = 3 # int(input("Enter the number of the missionary: "))
c1 = 3 # int(input("Enter the number of the Cannibal: "))
m2 = 0
c2 = 0
print("Intially m&c at bank 1: ")
print(m1, c1)
print("Intially m&c at bank 2: ")
print(m2, c2)
# place1=[m1,c1]
# place2=[m2,c2]
# print(place1)
# print(place2)
while(1):
r = int(in... |
31fe48fb9839914dcfdb510de5b6a56923fd26a6 | objarni/kyh-practice | /vecka_3_uppg_20till28/uppgift26.py | 1,884 | 3.5 | 4 | '''
Nu ska vi leka med att skicka parametrar till en databas!
OMDB är en IMDB-liknande hemsida på nätet, som också tillhandahåller
ett API där man kan göra sökningar.
26.1 Jag har fixat en API-nyckel åt oss! Därför kan vi använda detta
webb-API (som är ett REST-API) och leka. Testa att skriva följande
i en ... |
e28cd7478454ac6a826a8aa0b3164c6cbd830a99 | objarni/kyh-practice | /vecka_8/upg51_8.py | 1,463 | 3.9375 | 4 | '''
51.1 Skriv om funktionen add_as_def som lambda, och lagra i en variabel
def add_as_def(a, b):
return a + b
# add_as_lambda = ???
51.2 Skriv om obj som en funktion "upper"
obj = lambda s: s.upper()
51.3 Översätt denna lambda till en vanlig def funktion
join_as_lambda = lambda strings, inbetween: inbetwee... |
a761e59f300f440a39f7f3d01fef601ee11c8815 | objarni/kyh-practice | /mix/for_loops.py | 539 | 4.03125 | 4 | print('\nMed range(0, 5):')
for i in range(0, 5):
print(i)
print('\nMed listor:')
min_lista = ["abc", "def"]
for elem in min_lista:
print(elem)
print('\nMed enumerate och lista:')
min_lista = ["abc", "def"]
for num, elem in enumerate(min_lista):
print(num, elem)
print('\nMed dict:')
min_dict = {
"Olo... |
48e2d703aa29d67354173182b16e097b84a82ad3 | objarni/kyh-practice | /vecka_2_uppg_12till19/uppgift15_1.py | 358 | 3.71875 | 4 | # 15.1 Implementera "wordcount" som jag och Christoffer byggde
def wordcount(text):
# 1. Dela texten i mellanrum (med split)
# 2. Beräkna längden på resultatlistan
# 3. Profit
return len(text.split())
if __name__ == '__main__':
text = input("Skriv in en text:")
print(f"I den texten hittade ja... |
3cdefa5fc0556e48dd29d897ab81119e71969efb | zooo1/algorithm | /boj/14890.py | 1,589 | 3.71875 | 4 | import sys
input = sys.stdin.readline
def makeSlope(n):
global N, L
slope = [0]*N
i, j = 0,0
while(i<N-1):
# 다음 index와 같은 값
if (board[n][i] == board[n][i+1]):
i += 1
# 다음 index에서 높이가 1 클 때
elif (board[n][i] +1 == board[n][i+1]):
j = i
... |
c69b825497b92d2132ef34700f6581edd1d72049 | laurentlam/labyrinth_solving | /Main_Code/environment.py | 18,030 | 4.25 | 4 | # '''''' Environment and state classes ''''''
# Numpy is needed for matrix operations
import numpy
# Random is needed for random initialisations
import random
# Restrictions for states in the maze:
# - A "start" or an "arrival" state is on the border of the maze.
# - an "arrival" state is unique in a maze.
# Rem... |
bb14f56c650407842332f6effded0f1825b8f245 | valeria-chemtai/Checkpoint1-Amity | /Amity.py | 16,702 | 3.53125 | 4 | """Class Amity is the controller of the app using
the Models Views Controller concept i.e. MVC"""
import random
from sqlalchemy.orm import sessionmaker
from Models.person import Person, Fellow, Staff
from Models.room import Office, LivingSpace
from Models.database import People, Rooms, Base, engine
# Initiate link to... |
9b3ddd5ee73a2ffc0e2e9f790f4b5b6a6aaa36ac | adamcristi/TheHatefulMemesChallenge-ASET | /Implementation/classifiers/classifier.py | 454 | 3.53125 | 4 | import abc
class Classifier:
def __init__(self):
pass
@abc.abstractmethod
def load_data(self, args): # load the images and texts
pass
@abc.abstractmethod
def preprocess(self, *args): # preprocess the images and texts
pass
@abc.abstractmethod
def train(self, ar... |
de3a8f6ebe60273e6bf7cb9224bf7ad3ee4a6a98 | TomButts/Lichen-Project | /feature-extraction/tools/parsers/csv/parse.py | 423 | 3.625 | 4 | import csv
def parse(targets_path):
"""Parse a csv containing an ordered list of targets on the first row.
Args:
targets_path: The path to the csv file
Returns:
row: A list of targets from the first row of the csv.
"""
with open(targets_path, 'rb') as csvfile:
reader = csv... |
2aac3019d09b202cd50e62bea9eb294be8cbd0aa | davethedave41/ALprogramming | /crypto/encryption.py | 2,457 | 3.703125 | 4 | from cryptography.fernet import Fernet
import io
#Function which generates our key (AES)
def keyGen():
key = Fernet.generate_key()
# with open('key.key','wb') as f:
# f.write(key)
file = open('key.key', 'wb')
file.write(key)
file.close()
#Function which reads the key
def keyRead():
try:
... |
85299f7db32018c1b3be12b6ebdae3c521fe3842 | HenriqueSamii/TP1-Fundamentos-de-Programa-o-com-Python | /tp1IntroPiton11.py | 285 | 4.40625 | 4 | #11. Faça uma função no Python que, utilizando a ferramenta turtle, desenhe um triângulo de lado N.
import turtle
def triangulo(n):
for target_list in range(3):
turtle.forward(int(n))
turtle.left(120)
x = input("Tamanho do triângulo - ")
triangulo(x) |
84e2b62c922b04f427741fd805c3705f657783ea | HenriqueSamii/TP1-Fundamentos-de-Programa-o-com-Python | /tp1IntroPiton5.py | 2,316 | 4.375 | 4 | #5. Trabalhar com tuplas é muito importante! Crie 4 funções nas quais:
#
# 1.Dada uma tupla e um elemento, verifique se o elemento existe na tupla
# e retorne o indice do mesmo
# 2.Dada uma tupla, retorne 2 tuplas onde cada uma representa uma metade da tupla original.
# 3.Dada uma tupla e um elemento, elimine esse el... |
8583ef2b7d2bb5ea062a32df0220426a4e9a51b1 | Valay/Learning-Java | /goldmine/goldmine.py | 8,103 | 3.515625 | 4 | #!/usr/bin/python
import sys
import argparse
import time
import random
parser = argparse.ArgumentParser(description='Get the test file')
parser.add_argument('--testfile', type=str, help="path to save the alignemnts to direcotry")
dr = ['l','d','u','r']
# Direction of movement
d = {
'l' : [0,-1],
'r' : [0, 1... |
fa7d390f1021e66a2ec287ea0fb15568f2ab4361 | durbonca/python-basic-exercises | /ejercicios python basicos/2.py | 116 | 3.5625 | 4 | base = float(input('base: '))
altura = float(input('altura: '))
print('area de cuadrado: {}' .format (base*altura)) |
2a251fb6764b5d54e052d754a0931951e0c590a7 | AWOLASAP/compSciPrinciples | /python files/pcc EX.py | 343 | 4.28125 | 4 | '''
This program was written by Griffin Walraven
It prints some text to the user.
'''
#Print text to the user
print("Hello!! My name is Griffin Walraven.")
#input statement to read name from the user
name = input("What is yours? ")
print("Hello ", name, "!! I am a student at Hilhi.")
print("I am in 10th grade an... |
6f13837ea35bbec037f9bc7144f7ff634268ba44 | AWOLASAP/compSciPrinciples | /python files/assingment7.py | 215 | 3.96875 | 4 | def convert_to_dec(b):
value, total = 1, 0
for i in reversed(str(b)):
if i == '1':
total += value
value *= 2
return total
binary = input("Give me an 8-bit binary number: ")
print(convert_to_dec(binary))
|
3bc172ed239a7420049479378bc660dab7ce772e | ambikeshkumarsingh/LPTHW_ambikesh | /ex3.py | 477 | 4.25 | 4 | print("I will count my chickens:" )
print("Hens", 25 +30/6)
print("Roosters",100-25*3 %4)
print("Now I will count the eggs")
print(3 + 2 + 1- 5 + 4 % 2-1 /4 + 6)
print("Is is true that 3+2<5-7")
print(3+2<5-7)
print("What is 3+2 ? ", 3+2)
print("What is 5-7 ?", 5-7)
print("Oh! that's why It is fa... |
78bf22ce561d77a45d54a4e144da53c37f84e6e7 | AbeJLazaro/MetodosNumericos | /RK2y4.py | 7,939 | 3.75 | 4 | import matplotlib.pyplot as plt
class RK2:
Zderivada='24*x**2'
Yderivada='z'
#valores que se inician al crear un objeto nuevo
x=[]
y=[]
z=[]
F=[]
h=0.3
#valores dinamicos, estos son auxiliares para encontrar a y
x=0
k1=[]
k2=[]
#k3=[]
#k4=[]
#valores para gra... |
4648766292cce07ebc5dffcb9b3ff5758e2d7faa | AbeJLazaro/MetodosNumericos | /newtonCriterioParo.py | 4,339 | 3.765625 | 4 | # Autores: Mercedes Miranda
# El nombre de tu amigo
# Fecha; 9 de septiembre de 2019
# Metodo Newton Raphson
import sympy as sym
#se define el simbolo variable principal, no mover
x = sym.Symbol('x')
#se define la funcipon para desarrollar el metodo
#funcion es la función en terminos de sympy, trataré de agr... |
cffc2440c9d7945fe89f9cc7d180ee484f0a7689 | bartoszkobylinski/tests | /tests/tests.py | 1,544 | 4.3125 | 4 | import typing
import unittest
from app import StringCalculator
'''
class StringCalculator:
def add(self, user_input: str) -> int:
if user_input is None or user_input.strip() == '':
return 0
else:
numbers = user_input.split(',')
result = 0
... |
27e3f72da48f727adedef391c7011bd0ffd82f67 | minrat/AI | /stage1/tkinter/Cal_GUI_demo.py | 1,451 | 3.65625 | 4 | from tkinter import *
class GUICal:
def __init__(self):
self.root = Tk()
self.root.title("计算器")
fm1 = Frame(self.root)
Entry(fm1).grid(row=0, column=0, columnspan = 4)
Entry(fm1).grid(row=1, column=0, columnspan=4)
fm1.pack(side = TOP, expand = YES)
fm2 = Fram... |
66a7e79ba8462ebcfb8cb2c2a4159b475736e56d | slamatik/codewars | /5 kyu/Double Cola 5 kyu.py | 644 | 3.75 | 4 | data = ["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"]
def who_is_next(names, r):
if r <= 5:
return names[r - 1]
start = 1
letter_count = 1
while start < r:
start += len(names) * letter_count
letter_count *= 2
letter_count //= 2
cnt = len(names)
if start == r:
... |
e3359660fa9fd421ca4d1340872afd89fd4f8bf2 | slamatik/codewars | /5 kyu/Vecotr Class 2 5 kyu.py | 1,330 | 3.546875 | 4 | class Vector:
def __init__(self, *args):
if len(args) == 1:
self.x = args[0][0]
self.y = args[0][1]
self.z = args[0][2]
self.magnitude = (self.x ** 2 + self.y ** 2 + self.z ** 2) ** 0.5
else:
self.x = args[0]
self.y = args[1]
... |
350983b69426ad8ec696f51dd9ca04f0387afdd0 | slamatik/codewars | /4 kyu/Sudoku Solution Validator 4 kyu.py | 874 | 3.5 | 4 | def valid_solution(board):
for i in board:
if len(set(i)) != len(i):
return False
for x in range(9):
temp = []
for y in range(9):
temp.append(board[y][x])
if len(set(temp)) != len(temp):
return False
for i in range(9):
row = 3 * (i ... |
d86b9bf29c50110b1d882a681ac4e130880fa70a | slamatik/codewars | /6 kyu/Pyramid Array.py | 107 | 3.53125 | 4 | def pyramid(n):
sol = [[1 for n in range(m + 1)] for m in range(n)]
return sol
print(pyramid(3))
|
4d736b85b8483afdc011e62aafca69dbbcc683f3 | slamatik/codewars | /5 kyu/Maximum subarray sum 5 kyu.py | 314 | 3.78125 | 4 | def max_sequence(arr):
if not arr:
return 0
if all(i < 0 for i in arr):
return 0
table = [arr[0]]
for i in range(1, len(arr)):
table.append(max(table[-1] + arr[i], arr[i]))
return max(table)
print(max_sequence([]))
print(max_sequence([-2, 1, -3, 4, -1, 2, 1, -5, 4]))
|
95822ffd1d75b64b794edc2ea215a5c964b8d85e | slamatik/codewars | /5 kyu/Pete, the baker 5 kyu.py | 293 | 3.671875 | 4 | recipe = {"flour": 500, "sugar": 200, "eggs": 1}
available = {"flour": 1200, "sugar": 1200, "eggs": 5, "milk": 200}
def cakes(recipe, available):
try:
return min([available[i] // recipe[i] for i in recipe])
except KeyError:
return 0
print(cakes(recipe, available))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.