blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
d42d003704978194870a93d3866225903ce9e71c | rifqirianputra/DSMLCourse-Module-1 | /12 May 2020 REVISI PR.py | 1,226 | 3.859375 | 4 |
# print("========SOAL 1=========")
# for baris in range(1,6):
# for kolom in range(1, baris+1):
# print(baris, end=" ")
# print("\n")
# print("========SOAL 2=========")
# for baris in range(1,6):
# for kolom in range(1, baris+1):
# print(kolom, end=" ")
# print("\n")
# print("=... |
a398e74dad709d7dd940d0a17320012ea49f204b | rifqirianputra/DSMLCourse-Module-1 | /5 May 2020 Test.py | 723 | 4.15625 | 4 | print("hello world")
print ('hello world')
print ("""hello world""")
name = "Bob Windcaller"
age = 25
height = 179.5
print(type(height))
print(type(age))
print(type(name))
print("name:", name)
print("age", age)
print ("height", height)
print("name:", name, "age:", age, "height:", height)
print("name: {}, age: {}, h... |
7f08d812c2f6dc20e1bf2a173a0a32a9224e594e | AlexFrancoCc/Curso-Python-Verano | /ClaseUNI2.py | 1,592 | 4.09375 | 4 | #----****** USANDO While : Bucles finitos o infinitos
while True:
num = int(input('Ingresa un numero entero para calcular su factorial: '))
if num < 0:
print('¡ERROR! El numero debe ser positivo o 0.')
elif num == 0:
print('0! = 1')
break
else:
factorial = num # Valor del factorial
... |
86392a6594aa0d7c7f8a84bb5189b04686b7de55 | leehonan/rfm69-pi-gateway | /src/pishutdown.py | 837 | 3.671875 | 4 | # script to implement RPi shutdown and reboot on GPIO-connected button press
from subprocess import call
import RPi.GPIO as GPIO
import os
import time
# Define a function to run when an interrupt is called
def shutdown(pin):
print("shutting down")
os.system("sudo shutdown -h now") # Shutdown command
def reboo... |
d3da79753e1f74a5c889eedf908456d7089c9c40 | Tsarcastic/Python-Mini-Projects | /diceSim.py | 726 | 3.8125 | 4 | import random
def diceRoller():
sides = int(raw_input("How many sides would you like the die to have?"))
rolls = int(raw_input("And how many times would you like to roll it?"))
totalRolls = rolls
runningTotal = 0
listOfNum = {}
while rolls > 0:
newNum = random.randint(1, sides)
... |
2093a3c406ae50247c1fb2784a440be4f3559712 | habibabdo/firstpython | /Globals.py | 440 | 3.53125 | 4 |
a=15
def something():
a=10
print (a)
x=globals()['a']
print (x)
globals()['a']=100
print('LOCAL:')
something()
print('GLOBAL:')
print(a)
def count(lst):
even=0
odd=0
for i in lst:
if i%2==0:
even+=1
else:
odd+=1
return even,odd
lst=[1... |
5a345ac83741facf36535c0c525e0cf931b58189 | habibabdo/firstpython | /Iterator.py | 482 | 3.6875 | 4 | nums=[1,3,5,7,4,2]
it=iter(nums)
print(it.__next__())
print(next(it))
for i in nums:
print(i)
class TopTen:
def __init__(self):
self.num=1
def __iter__(self):
return self
def __next__(self):
if self.num <= 10:
val= self.num
self.num+=1
r... |
6a14d0ad012457166fa8447d5976e37c86fb317b | habibabdo/firstpython | /Search.py | 284 | 3.6875 | 4 | pos =-1
def search(list,n):
i=0
while i< len(list):
if list[i]==n:
globals()['pos']=i
return True
i+=1
return False
list=[1,2,4,6,4,8,6,4,9,2]
n=2
if search(list,n):
print ('Found at ' ,pos+1)
else:
print('Not Found')
|
af39852d0bd6afc2dd61eda2215c4b8e8ccff7fb | habibabdo/firstpython | /Functions.py | 489 | 3.6875 | 4 | def person(name,age=12):
print(name)
print(age)
def mathimatics(x,y):
a=x+y
b=x-y
c=x*y
d=x/y
return a,b,c,d
def sum(*b):
c=0
for i in b:
c = c + i
print(c)
def person1(name, **data):
print(name)
for i,j in data.items():
print(i,j)
resul1,result2,re... |
3b80e66aa8b205cffc77d0c9e2bd3a90b5575c7a | Calcifer777/mit-6034 | /lab4/csp.py | 16,152 | 3.84375 | 4 | #!/usr/bin/env python
"""
A General Constraint Satisfaction Problem Solver
@author: yks
"""
class Variable:
"""
Representation of a discrete variable with a finite domain.
As used in our VD table.
A variable can be in the assigned state, in which v.is_assigned()
will return true.
"""
def __i... |
c75d00a72e18b5885b3cfa3226b5ffff06f2df20 | Calcifer777/mit-6034 | /lab2/lab2.py | 11,121 | 3.984375 | 4 | # Fall 2012 6.034 Lab 2: Search
#
# Your answers for the true and false questions will be in the following form.
# Your answers will look like one of the two below:
#ANSWER1 = True
#ANSWER1 = False
# 1: True or false - Hill Climbing search is guaranteed to find a solution
# if there is a solution
ANSWER1 = False
#... |
b9e10a6be968fa04ea22ecadf841c59f590caf77 | mingyyy/basics | /Structure/Array_FindPosition.py | 1,605 | 4.0625 | 4 | # given an ordered array (ascending) and a target value, return the position of the item if it's equal to target value,
# otherwise add it in and return position. all items in array are integers and target value is also integers.
def find_position(array, target):
# method 1. go through the list from left to right... |
a8d094e823d57b980ff6756a92b7d22e14c14d56 | mingyyy/basics | /Structure/Array_List.py | 400 | 3.734375 | 4 | # Leetcode: 189. Rotate Array
class Solution:
def rotate(self, nums: list[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
# option1
if len(nums)>1:
if len(nums)<=k:
k= k % len(nums)
# nums[:] create ... |
3a26ea0916c145df2110a20d31dd750548d5bc70 | mingyyy/basics | /Structure/Stack_Queue.py | 1,259 | 4.25 | 4 | # implement a stack
class stack:
def __init__(self):
self.stack = []
def isEmpty(self):
if len(self.stack) == 0:
return True
else:
return False
def pop(self):
if len(self.stack) == 0:
return "Stack is empty"
else:
x=... |
124705468f8ec93ef6e1b0758f7a1c3caf06bb0f | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex051.py | 168 | 3.890625 | 4 | p1 = int(input('Digite o primeiro termo'))
r = int(input('Digite a razão'))
for c in range(p1, p1 + (10* r), r):
print('{} '.format(c), end='-> ')
print('ACABOU') |
71f042601b4cb9e1ba815c75a73185896816feb8 | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex020.py | 277 | 3.703125 | 4 | #sortear e aparecer uma list
import random
nome1 = input('Digite o nome 1')
nome2 = input('Digite o nome 2')
nome3 = input('Digite o nome 3')
nome4 = input('Digite o nome 4')
ale = [nome1, nome2, nome3, nome4]
print('A ordem Dos alunos é {}'.format(random.sample(ale, k=4)))
|
ec0a5d6b456abc8d6fe78f70ce327a931a0ea238 | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex085.py | 355 | 3.875 | 4 |
numeros = [[], []]
valor = 0
for c in range(0, 7):
valor = int(input(f'Digite o valor {c + 1} '))
if valor % 2 == 0:
numeros[0].append(valor)
else:
numeros[1].append(valor)
print(f'Os valores pares digitados foram {sorted(numeros[0], key=int)}')
print(f'os valores imapres digitados fora... |
f9e490947699c46bcff4192315ea349440d4fac6 | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex039.py | 373 | 3.875 | 4 | from datetime import date
data = date.today().year
nasci = int(input('Digite sua data de nascimento'))
idade = data - nasci
if idade == 18:
print('Você tem 18 anos, é hora de se alistar')
elif idade > 18:
print('Você ja passou do tempo do alistamento, ja faz {} anos'.format(idade - 18))
else:
print('Você ... |
9ab83427a93a7299137b8f2ccbf8b30bf4406263 | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex058.py | 269 | 3.8125 | 4 | from random import randint
n1 = 0
n2 = 1
i = 0
while n1 != n2:
n1 = int(input('digite um numero de 1 a 10 : '))
n2 = randint(1, 10)
print('Você escolheu {} e o computador {}'.format(n1, n2))
i += 1
print('Foram necessarias {} tentativas'.format(i))
|
ff1c3ce8dbcd3641fc54a262694a9315812428a3 | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex022.py | 302 | 3.84375 | 4 | n1 = input('Digite Algo')
print('A frase em maisculo {} '.format(n1.upper()))
print('A frase em minusculo {}'.format((n1.lower())))
n2 = n1.replace(" ", "")
n3 = n1.split()
print('A frase sem espaços tem o tamanho de {} '.format(len(n2)))
print('a primeira palavra da frase é {}'.format(n3[0])) |
02ce24cde2801a9503522e4774131a008ffd6eb7 | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex094.py | 893 | 3.53125 | 4 | dados = list()
pessoa = dict()
mulher = list()
cont = ''
contator = media = 0
while True:
pessoa['nome'] = str(input('Nome:'))
pessoa['sexo'] = str(input('Sexo [M/F]: ')).upper()
pessoa['idade'] = int(input('Idade:'))
cont = str(input('Continuar? [S/N]')).upper()
dados.append(pessoa.copy())
cont... |
ab3085a74a328ce0dc773b414ef6021a51327b9d | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex054.py | 351 | 3.53125 | 4 | from datetime import date
ano = date.today().year
i = 1
cont = 0
for c in range(1, 8):
n1 = int(input('Digite a data de nascimento da pessoa {}: '.format(i)))
vl = ano - n1
i = i + 1
if vl < 21:
cont = cont + 1
print('{} pessoas ja atingiram a maior idade e {} pessoas não atingiram a maior id... |
1dbc8527794eba86943d66de79816ae6d82c29a2 | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex025.py | 109 | 3.875 | 4 | n1 = str(input('digite o seu nome')).upper().split()
print(' Há silva no nome ? {}'.format('SILVA' in n1)) |
f039e1a6cbbca344ec81e29ea0e14084650e1c7d | VitorAlvess/Estudos | /Arquivos/Curso Python Gustavo Guanabara/ex045.py | 803 | 3.734375 | 4 | from random import randint
from time import sleep
itens = ('Pedra', 'papel', 'Tesoura')
print('Escolha:')
print('[ 0 ] Pedra')
print('[ 1 ] Papel')
print('[ 2 ] Tesoura')
n1 = int(input('Digite aqui :'))
n2 = randint(0, 2)
print('JO')
sleep(1)
print('KEN')
sleep(1)
print('PO')
sleep(1)
print('-_-' * 11)
print('Você esc... |
0dbabdc64329135618cf875b6df48128c31a02d6 | phaukaa/Web-scraping-NBA | /filter_urls.py | 2,746 | 3.90625 | 4 | from requesting_urls import get_html
import re
def find_urls(html, base_url=None):
"""
Method for finding links to other web pages in a web page
param1: the html of the page you want to find urls in
param2: the base url you want to add to the relative urls found, default None
return: a list of all ... |
d85bb165c2c16bafa350f4b31d15ab2b96995e93 | sitnikovi/dev-sprint1 | /exercise54.py | 294 | 3.984375 | 4 | # This is where Exercise 5.4 goes
# Name: Ilya Sitnikov
def sticks_length(stick1_length, stick2_length, stick3_length):
if stick1_length == stick2_length + stick3_length:
print "We certainly can form a triangle"
else:
print "We absolutely cannot form a triangle"
sticks_length(12,1,1)
|
d3f5e599ad986e25d3e51da6c4472722a742edc3 | neemiasbsilva/coding-questions-company | /heaps/sorted-merged-list.py | 892 | 3.90625 | 4 | ########################################################################
# return a new sorted merged list from k sorted list, each with size N #
########################################################################
import heapq
def merge(lists):
merged_list = []
heap = [(lst[0], i, 0) for i, lst in e... |
0d8fb716e17d2d46738edd837580cb31db4fe2f7 | neemiasbsilva/coding-questions-company | /stack-and-queue/parenthesis-checker.py | 668 | 3.734375 | 4 |
def parenthesis(s):
stack = []
s_temp = list(s)
stack.append(s_temp[0])
for i in range(1, len(s_temp)):
if s_temp[i] == ')' and stack[-1] == '(':
stack.pop()
elif s_temp[i] == ']' and stack[-1] == '[':
stack.pop()
elif s_temp[i] == '}' and stack[-1] =... |
4f73de8dbef38c04e0d73e7adc3fb994fe3c9402 | vbongulwar/pratice_module | /group_anagrams.py | 1,404 | 3.765625 | 4 | # Time Complexity : O(n*k) n = number of elements in strs array and k is largest size a word in strs
# Space Complexity: O(n*k) n = number of elements in strs array and k is largest size a word in strs
# Did this code successfully run on Leetcode : Yes
# Any problem you faced while coding this : No
class Solution:
... |
f2b377116be937b0ea39b35a0be757df45543b9b | honeyaya/PythonProject | /exercises/class_03/654_Maximum_Binary_Tree.py | 985 | 3.765625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def constructMaximumBinaryTree(self, nums):
"""
:type nums: List[int]
:rtype: TreeNode
""... |
928715a8225f312de4dd843a1d0a7cbcc491b3ee | honeyaya/PythonProject | /exercises/contest_144/1110_Delete_Nodes_And_Return_Forest.py | 1,919 | 3.5625 | 4 | class Solution(object):
def delNodes(self, root, to_delete):
"""
:type root: TreeNode
:type to_delete: List[int]
:rtype: List[TreeNode]
"""
ans = []
if root == None:
return ans
ans.append(root)
def find(tree, value):
i... |
7df829ac24630bedb8a52d15d5fb06b2874a535c | jltichy/python_practice | /bday.py | 336 | 4.03125 | 4 | #!/usr/bin/env python
import sys
import datetime
bday = input('Please input your birth day: DD ')
bmonth = input('Please input your birth month: MM ')
byear = input('Please input your birth year: YYYY ')
bday = datetime.datetime(int(byear), int(bmonth) , int(bday), 0, 0, 0)
now = datetime.datetime.now()
diff = now-b... |
0250a3978e1950e1c997db8346cbd353bcf16a2c | jltichy/python_practice | /encapsulation.py | 2,067 | 4.8125 | 5 | #!/usr/bin/env python
# tutorial on encapsulation (object oriented programming) from https://www.youtube.com/watch?v=5oeitr6fBBQ
'''
class bankAccount():
# This is a bank account class
def __init__(self, account_name = "Current Account", balance = 200):
self.account_name = account_name
self.ba... |
dbc8878ab81cf4936bc995a15eafceac67d65f43 | jltichy/python_practice | /optimization_routine.py | 4,933 | 4.3125 | 4 | #!/usr/bin/env python
# Optimization routine
from scipy.optimize import fmin
#scipy is a package for high level scientific computing, such as interpolation, integration, optimization, image processing, and statistics
#Optimization is the problem of finding a numerical solution to a minimization or equality.
#fmin is ... |
2f6ce0d87806df2c39e020fbd07c92dcc58c34ed | BICTS-Ghana/guess_my_number_starter | /guess_my_number_starter.py | 1,086 | 4.40625 | 4 | """
File: guessmynumber.py
----------------------
This program checks if a user's guess of a number matches that guessed by the computer
"""
# use code below to generate a random integer between 1 and 99 for example
# ********************************** YOUR CODE GOES BELOW HERE **************************... |
7c792119c9ac9c5d92e0dfab1f54d63c5dc0ccfc | Rafal-Maszlej/advent-of-code | /2020/puzzle_02/solver.py | 1,942 | 3.671875 | 4 | from dataclasses import dataclass
class PasswordValidationError(Exception):
...
@dataclass
class PasswordSchemaValidator:
letter: str
index_low: int
index_high: int
@staticmethod
def get_letter(index, password):
try:
return password[index - 1]
except IndexError:
... |
5e937ee6d2bac60ab1ff010bfae80ee2ce2c994f | Rafal-Maszlej/advent-of-code | /2015/puzzle_02/solver.py | 821 | 3.5 | 4 | def get_dimensions(data):
return [int(i) for i in data.strip().split("x")]
def get_paper_surface(data):
l, w, h = get_dimensions(data)
area_1 = l * w
area_2 = w * h
area_3 = h * l
return 2 * sum([area_1, area_2, area_3]) + min(area_1, area_2, area_3)
def get_ribbon_length(data):
l, w, ... |
f6df9406082aca085112983bae6aa8816808230e | XuanZzz/foobar | /level 1/prime.py | 383 | 3.625 | 4 | from math import sqrt
def answer(n):
p = "2357111317192329"
for i in range(31, 30000):
if len(p) > n + 5:
return p[n:n+5]
isPrime = True
for j in range(2, int(sqrt(i))+1):
if i % j == 0:
isPrime = False
break
if isPrime:
... |
9845380a526b27dea42f92e424a691bb666be2d2 | ezhang7423/gcj-practice | /2018/v.py | 883 | 3.53125 | 4 | # 3
# 4
# 1 2 3 4
# 2 1 4 3
# 3 4 1 2
# 4 3 2 1
# 4
# 2 2 2 2
# 2 3 2 3
# 2 2 2 3
# 2 2 2 2
# 3
# 2 1 3
# 1 3 2
# 1 2 3
'''
1
4
1 2 3 4
2 1 4 3
3 4 1 2
4 3 2 1
'''
def process(matrix):
rr = 0
rc = 0
tr = 0
columns = []
for i in range(len(matrix)):
columns.append([])
for i, r in enumer... |
b232a00e88d744ac64a7388e3b5aa3fe91cfedb2 | Florball/Introduccion-a-python | /src/hello.py | 1,702 | 4.3125 | 4 | # Introduccion a python
# Declarando variables
name = 'Flor'
surname = 'Ballinas'
value1 = 20
value2 = 7
birthday = '27 de agosto'
age = value1 + value2
# Listas en Python
from collections import deque # Usando collections.deque
weekdays = deque(['strawberry', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
... |
03e555c9886ad61f807af277cd23a51a45ccc193 | pkitutu/salary_calculator | /salary_calculator.py | 1,402 | 3.71875 | 4 | """
Author: Kitutu Paul
August, 2017
"""
class SalaryCalculator(object):
""" SalaryCalculator is able to calculate the net salary of a person
after deducting the Pay As You Earn (PAYE) and Social Security contribution (NSSF)"""
NSSF_RATE = 0.05
def __init__(self, gross_salary):
super(SalaryCalculator, self).__i... |
7bb79a7dd5557d4127e6550232f53f22ea607476 | Deepikap7801/the-united-sparks | /addition/addition.py | 77 | 3.859375 | 4 | addition function
def addition():
a=5
b=10
add=a+b
print(add) |
8bd02433a94b869055c75aa13b31e2d92227c18b | Tarth/praticepython.com | /exercise4.py | 187 | 3.890625 | 4 | number = input("Pick a number: ")
divisors = range(1, int(number))
result = []
for element in divisors:
if int(number) % element == 0:
result.append(element)
print(result)
|
c62dd6207eeb4453c510eddb9eb48dd0adb5a26b | Adam7m8o/CSE | /notes/Adam Skibicki - Mad Lib.py | 618 | 4 | 4 | # ten input words
adj1 = input("type in adj1")
adj2 = input("type in adj2")
adj3 = input("type in adj3")
vrb1 = input("type in vrb1")
vrb2 = input("type in vrb2 past tense")
vrb3 = input("type in vrb3 ending in ing")
noun1 = input("type in noun1")
noun2 = input("type in noun2")
noun3 = input("type in noun3")
name = inp... |
40b010204f4901ce98089743cd9b8f9cb2c588f3 | Adam7m8o/CSE | /notes/Dictionary world map - Adam S.py | 2,692 | 3.609375 | 4 | States = {
"CA": "California",
"VA": "Virginia",
"MD": "Maryland",
"RI": "Rhode Island",
"NV": "Nevada"
}
print(States["CA"])
print(States["NV"])
nested_dictionary = {
"CA": {
"Name": "California",
"Population": 39557045,
"Cities": [
"Fresno",
"S... |
d2144435de2948192bf260a75e8c55d6a21dc127 | sigstart/jenni | /modules/happy.py | 1,568 | 3.984375 | 4 | #!/usr/bin/env python
"""
happy.py - Happy module
Copyright 2012 - Jan Vermeulen, entropy.co.za
Licensed under the Apache-2.0 license
"""
import re
def isHappy(n):
"""
Returns whether a number is happy or not.
This was gratuitously stolen from Rosetta Code: http://rosettacode.org/wiki/Happy_Number#Python... |
f2c8eba2523102a29241b951f7e2b1cd703d1ae5 | josazuwa/gitclass1 | /auth.py | 2,782 | 3.90625 | 4 | #Initialize the system
import random
database = {}
def init():
print("Welcome to bankPython")
haveAccount = int(input("Do you have an account with us? 1 (yes) 2 (no)\n"))
if(haveAccount == 1):
login()
elif(haveAccount == 2):
register()
else:
print("Invalid Option\n")
... |
3ec423c8126220856306268c2dc450cc61a79e48 | dobots/workshops | /python_oops/employee_example/Object-Oriented/3-Class-Static-Methods/oop.py | 2,116 | 4.0625 | 4 | #Class variables are variables shared by all instances of a class.
#regular method - Takes the instance as the first argument
#class method - uses @classmethod (A decorator). Takes cls as first argument
#static method - static methods dont pass anything like class (cls) or instance (self)
class Employee:
num_of_em... |
fb05618e5829fc4db892c00709eae1abfef9b47f | clebercasagrande/Pyton | /ex0013.py | 201 | 3.734375 | 4 | salario=float(input('Qual é o salario do funcionario? R$ '))
print('Um funcionario que ganhava R${:.2f},com 15% de aumento passa a ganhar R${:.2f} '.format(salario, (salario+(salario * 15 / 100))))
|
b75a91dba606ed7d28bc6ac1f0ba2df13d76c96a | clebercasagrande/Pyton | /ex004.py | 400 | 3.859375 | 4 | nome = input('digite aqui algo!')
print(nome)
print('o tipo primitivo é ', type(nome))
print('só tem espassos?', nome.isspace())
print('só tem numeros?', nome.isnumeric())
print('É alfabetico?', nome.isalpha())
print('É alfanumerico?', nome.isalnum())
print('esta em maiuscula?', nome.isupper())
print('esta em m... |
cd1da4d9d811517f8bbefd285ccb88982fd1987f | ZY1N/Grokking_Algorithms | /ch1/binarysearch2.py | 1,754 | 3.625 | 4 | # **************************************************************************** #
# #
# ::: :::::::: #
# binarysearch2.py :+: :+: :+: ... |
7a8aade95714409663f2282b568badb537872cbc | pauldraper/advent-of-code-2020 | /problems/day-02/part_2.py | 299 | 3.625 | 4 | #!/usr/bin/env python3
import sys
def passes(line):
first, second, password = line.split()
start, end = map(int, first.split("-"))
letter = second[:-1]
return (password[start - 1] == letter) != (password[end - 1] == letter)
print(sum(passes(line) for line in sys.stdin if line))
|
38f81769349c3c531a2c013d3f28f2c77be76b24 | spohlson/Exercise01a | /gg2.py | 567 | 3.921875 | 4 | from random import randint
print "Welcome! Get ready for a guessing game!"
name = raw_input("What's your name? ")
number = randint (1,100)
tries = 0
print "%s, I'm thinking of a number between 1 and 100. Try to guess my number." % name
while True:
tries = tries + 1
guess = int(raw_input("Your guess? "))
... |
51e267d8b60d60f65b8f2d3ce4cd58a680e7a90c | RaymondKlass/golf-reinforcement | /golf/unit_tests/test_hand.py | 8,161 | 4.0625 | 4 | ''' Unit Tests for Hand Logic '''
import unittest2
from random import shuffle
from golf.hand import Hand, GolfHandOutOfIndexError
class TestHand(unittest2.TestCase):
''' Unit tests for the hand class '''
def setUp(self):
''' Bootstrap a deck and a standard hand of cards '''
print 'Running th... |
d47f19748388b86d769a2c2bb38543c8d396ac6c | RaymondKlass/golf-reinforcement | /golf/players/player_base.py | 1,060 | 3.765625 | 4 | # Base player class
class Player(object):
def __init__(self, verbose=False, *args, **kwargs):
self.verbose = verbose
def __repr__(self):
return 'Player'
def turn_phase_1(self, state, possible_moves=['face_up_card', 'face_down_card', 'knock']):
""" Phase 1 of the turn - needs to... |
61a78a2d438e3e71ab1efcdcf9605ee9bd895a37 | domkozz/Repozytorium | /Lista zaliczeniowa/zadanie 1.py | 4,150 | 3.515625 | 4 | def skladki_spoleczne(kwota):
emerytalna = kwota * 0.0976
rentowa = kwota * 0.015
chorobowa = kwota * 0.0245
skladka1 = emerytalna + rentowa + chorobowa
print("\nWyliczenie składek społecznych:")
print("Składka emerytalna(9,76%) wynosi:", emerytalna, "zł")
print("Składka rentowa(1,5%)... |
90035cfe08b8fbb6a68cf49de4cdb330b6cbe723 | domkozz/Repozytorium | /laboratoria/Nowy folder/zad5.py | 250 | 3.75 | 4 | tup1 =[]
tup2 =[]
a = (input("Podaj 1 słowo: "))
b = (input("Podaj 1 słowo: "))
tup1 = ''.join(sorted(a))
print(a)
tup2 = ''.join(sorted(b))
print(b)
if tup1 == tup2:
print("Słowa są anagramami")
else:
print("Słowa są nie anagramami")
|
78e77d7587e9994b9153aa9a5c67dce17bc519e1 | domkozz/Repozytorium | /laboratoria/LAB1-zad/zad1.py | 182 | 3.546875 | 4 | a=int(input("Podaj 1 liczbe:"))
b=int(input("Podaj 2 liczbe:"))
print("ich suma to =",a+b)
print("ich różnica to =",a-b)
print("ich iloczyn to =",a*b)
print("ich iloraz to =",a/b)
|
ee1b4aca93b6448d3107e50a26b8dcb577076064 | domkozz/Repozytorium | /laboratoria/LAB12-zad/zadanie 4.py | 251 | 3.59375 | 4 | def wysokosc(a):
b=a/1000
if a<5000:
print(b,"km TO za nisko")
else:
print("Na tej wysokości jesteś bezpieczny")
return(" ")
a=int(input("Podaj w metrach wysokość na jakiej lecimy: "))
print(wysokosc(a)) |
c063efeb9843c4f24ced05b926153bbfbd5faf96 | domkozz/Repozytorium | /laboratoria/LAB2-zad/zad6.py | 374 | 3.859375 | 4 |
a=int(input("Podaj a: "))
b=int(input("Podaj b: "))
c=int(input("Podaj c: "))
d=int(input("Podaj d: "))
if a>b and a>c and a>d:
print("Największą liczbą jest a: ",a)
elif b>a and b>c and b>d:
print("Największą liczbą jest b: ",b)
elif c>a and c>b and c>d:
print("Największą liczbą jest c: ",c)
elif d>a and d>b and d... |
788f6327ac69d92227039d7f4a4b4af182633a7d | domkozz/Repozytorium | /laboratoria/LAB4-zad/zad 4.py | 575 | 3.625 | 4 | while True:
a = int(input("Podaj liczbe: "))
b = int(input("Podaj liczbe: "))
c = int(input("Podaj liczbe: "))
d = int(input("Podaj liczbe: "))
if a == 0:
print("liczba a to 0")
break
else:
if b == 0:
print("liczba b to 0")
break
else:
... |
cad627e9bf22cd73dd63f2cbecce0c998fdb991b | Vigneshwaran123/largest | /greater.py | 151 | 3.734375 | 4 | a,b,c=input().split()
a=int(num1)
b=int(num2)
c=int(num3)
if(a>b):
if(a>c):
print(a)
else:
print(b)
elif(b>c):
print(b)
else:
print(c)
|
833c52bc509f5a7ce81032605959574a7e97bfe8 | Indra-Ratna/CS1134 | /HW/hw01/ir867_hw1_q2b.py | 244 | 3.65625 | 4 | #question 2b
def shift(lst,k,position = "left"):
move = len(lst)-1
place = 0
if(position =="left"):
move = 0
place = len(lst)-1
for i in range(k):
lst.insert(place,lst.pop(move))
return lst
|
34da0e18afda0e758dcfa1778c43469708159315 | Indra-Ratna/CS1134 | /HW/hw01/ir867_hw1_q3.py | 156 | 3.90625 | 4 | #question 3
def sums_n (n):
return sum([i**2 for i in range(n)])
def sums_n_odd(n):
return sum([i**2 for i in range(n) if i%2!=0])
|
05a6a8d7f1b86ec62227a6841d982151f7fed361 | Indra-Ratna/CS1134 | /HW/hw01/hw1_q2.py | 3,118 | 3.671875 | 4 | #question 2
def shift(lst,k,position = "left"):
move = len(lst)-1
place = 0
if(position =="left"):
move = 0
place = len(lst)-1
for i in range(k):
lst.insert(place,lst.pop(move))
return lst
#question 3
def sums_n (n):
return sum([i**2 for i in range(n)])
... |
27ed6a87d90f0d50c4a0890f72adf9a192322afe | meetmaru0810/PYTHONE_ASSIGNMENT | /ASSINGMENT/MODULE_1/Assignment Level Advance/A5.py | 225 | 4.0625 | 4 | #A5:- Write a python program to sum of the first n positive integers
n=int(input("enter the no:"))
sum1=0
if n>0:
for i in range(1,n+1):
sum1=sum1+i
print("sum of n no=",sum1)
else:
print("invalide input") |
90264190089aa2c4452a3d941017cc2fa27b84bb | meetmaru0810/PYTHONE_ASSIGNMENT | /ASSINGMENT/MODULE_1/Assignment Level Basic/b11.py | 261 | 4.21875 | 4 | #B11:- Write a Python program to get the Fibonacci series of given range
no=int(input("range of fibonaci series:"))
a1,a2=0,1
print("fibonacci no",a1)
print("fibonacci no",a2)
for i in range(2,no+1):
a3=a1+a2
print("fibonacci no",a3)
a1=a2
a2=a3 |
6e4daee81b7a012d3953ddce6c14462ad6f81b92 | meetmaru0810/PYTHONE_ASSIGNMENT | /ASSINGMENT/MODULE_1/Assignment Level Intermediate/I5.py | 249 | 3.609375 | 4 | #I5:-Write a Python program to compute the value of a specified principal
#amount, rate of interest, and a number of years
n=int(input("enter n:"))
p=int(input("enter p:"))
r=int(input("enter r:"))
i=(n*p*r)/100
print("the simple intrest is",i)
|
ac10e85089e21bfe55956dff6c4b28e5ab3fee95 | neo000111/neo-s-file | /Leetcode/155#_Min Stack_06170207.py | 1,245 | 3.9375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
class Node:
def __init__(self, val, next = None):
self.val = val
self.next = next
class MinStack:
def __init__(self):
"""
initialize your data structure here.
"""
self.head = None
def isempty(self):
... |
09649ca36e4fcc04cd6d4d876c979fd1b76012e7 | ur59/multiple-button-in-python | /maltpol.py | 552 | 3.59375 | 4 | import tkinter
from tkinter import *
import tkinter as tk
root=tk.Tk()
c= tk.Canvas(root, height=500, width=600,bg="#000990")
f=tk.Frame(root,bg="#FF0000")
f.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
def a(e):
if e == 1:
print("123456789")
print ("hi i'm ",e)
def d(g,x1,y1,e):
... |
8e6804945c32ca6248a67849b3e3ffd640fc4385 | HeithRobbins/python_notes | /lists/list-query-len()-negative-indexes-index().py | 1,430 | 4.25 | 4 | tags = ['python', 'development', 'tutorials', 'code']
number_of_tags = len(tags)
last_item = tags[-1]
index_of_last_item = tags.index(last_item)
print(number_of_tags)
print(last_item)
print(index_of_last_item)
tags = ['python', 'development', 'tutorials', 'code']
number_of_tags = len(tags) # this will return 4 ele... |
e26943f40d2b47fea827efd92ed8201e89d451dd | HeithRobbins/python_notes | /advanced-ranges-and-slices.py | 1,087 | 4.46875 | 4 | tags = [
'python',
'development',
'tutorials',
'code',
'programming',
'computer science'
]
tag_range = tags[:-1:2] # This is used to grab EVERY OTHER index
reversed_tag_range = tags[::-1] # This [::-1] is used to reverse a list
print(tags)
print(tag_range)
print(reversed_tag_range)
# NOTION NOT... |
2659117146b16771186c652bdcba8de560648d28 | HeithRobbins/python_notes | /dictionaries/using-lists-of-nested-dictionaries.py | 816 | 4.40625 | 4 | '''Guide to Working with Lists of Nested Dictionaries'''
'''this is original code'''
# teams = [
# {
# 'astros': {
# '2B': 'Altuve',
# 'SS': 'Correa',
# '3B': 'Bregman',
# }
# },
# {
# 'angels': {
# 'OF': 'Trout',
# 'DH': 'Pujols',
# }
# }
# ]
# # print... |
ecbef1c6a022e44d52459cc91e281d8aaaccf42d | HeithRobbins/python_notes | /math-functions.py | 729 | 3.5 | 4 | import math
loss = -20.25
product_cost = 89.99
print(abs(loss))
print(math.floor(product_cost))
print(math.ceil(product_cost))
print(abs(math.floor(loss)))
print(round(product_cost))
print(math.sqrt(product_cost))
print(math.pow(5, 2))
print(5 ** 2)
'''REPL note'''
# import math
# loss = -20.25
# product_cost... |
2757c1bbd2a8d86b86d8cf3f40de415d92210e94 | HeithRobbins/python_notes | /tuples/nested-lists-tuple.py | 430 | 4.0625 | 4 | '''Working with Lists Nested in Tuples'''
# post = ('Python Basics', 'Intro guide to python', 'Some cool python content')
# tags = ['python', 'coding', 'tutorial']
# post += (tags, )
# print(post[-1][-1])
post = ('Python Basics', 'Intro guide to python', 'Some cool python content')
tags = ['python', 'coding', 't... |
f615017951ce88e5be6abb7ef45073bb878f0270 | IgorRuiz123/CursoPython | /PythonExercicios/ex024.py | 97 | 3.6875 | 4 | cid = str(input('Qual o nome da cidade? ').split()).lower()
print('santo' in cid[:cid.find(' ')]) |
bd4bd88d7bc61f4d0cfe24805ef775c715bc4eb1 | IgorRuiz123/CursoPython | /PythonExercicios/ex008.py | 112 | 3.84375 | 4 | m = float(input('Metros: '))
cm = m * 100
mm = cm * 10
print('Centímetros: {}\nMilímetros: {}'.format(cm, mm)) |
edb4294c8b263511dae5ac87f34c0558fc9d2263 | aoschwartz7/HackerRank | /WarmUpChallenges/fibonacci/fibonacci.py | 399 | 4.28125 | 4 | # https://www.hackerrank.com/challenges/ctci-fibonacci-numbers/problem
def fibonacci_number(n):
# Base case:
if n <= 1:
return n
fib_sequence = [0,1]
for i in range(2,n+1):
new = fib_sequence[i-1] + fib_sequence[i-2]
fib_sequence.append(new)
return fib_sequence[-1]
... |
378a9048d36d25bb71457bcb416309a8b9b98fd0 | rheehot/Sparta-Algorithm | /week_1/04_is_number_exist.py | 247 | 3.734375 | 4 | input = [3, 5, 6, 1, 2, 4]
def is_number_exist(number, array):
for n in array: #array 길이만큼 연산
if n==number: #1번 연산
return True
return False
result = is_number_exist(9, input)
print(result) |
82bcde265a1055941618a01bd0893c1700194186 | rheehot/Sparta-Algorithm | /week_2/00_study_class.py | 623 | 3.828125 | 4 | class Person:
def __init__(self,param_name): #클래스 내부의 함수가 메소드
print("i am created !",self)
self.name = param_name
def talk(self):
print("안녕하세요, 제 이름은",self.name)
person_1=Person("유재석") #i am created ! <__main__.Person object at 0x000001F68802DFD0>
print(person_1.name) #유재석... |
c19c8819704103f97f84c86655948cc96ea2c692 | temptemp3/rps-1 | /rock_paper_scissors/league/rando.py | 622 | 3.546875 | 4 | import random
from rock_paper_scissors import ROCK, PAPER, SCISSORS, BasePlayer
class Player(BasePlayer):
player_name = 'Rando'
author = 'Brenton C'
def __init__(self):
self.history = []
self.current_choice = None
def play(self):
"""
Must return a single var for the ... |
5d590773e948a8fe8ce2c00a0705958e7c71fa38 | temptemp3/rps-1 | /rock_paper_scissors/league/daymoo.py | 1,726 | 3.546875 | 4 | import random
from rock_paper_scissors import ROCK, PAPER, SCISSORS, BasePlayer
class Player(BasePlayer):
player_name = 'Daymoo'
author = 'Daymon'
def __init__(self, start_play=PAPER):
self.next_play = start_play
self.their_history = []
def play(self):
if len(self.their_his... |
8960a448f3bf87e6270be114bb66ddc8a64a66c8 | evogul/Hometask_01 | /task_06.py | 1,006 | 4.125 | 4 | '''
Спортсмен занимается ежедневными пробежками. В первый день его результат составил a километров.
Каждый день спортсмен увеличивал результат на 10 % относительно предыдущего.
Требуется определить номер дня, на который общий результат спортсмена составить не менее b километров.
Программа должна принимать значения пара... |
4ec6737fccb94cd1098debe5e0d128e15d566377 | id-gue/practice-django | /oop/oop.py | 2,946 | 4.03125 | 4 | # object oriented programming / tutorial by anandology
# 1__ global state
# simple bank account model
balance = 0
def simple_deposit(amount):
global balance
balance += amount
return balance
def simple_withdraw(amount):
global balance
balance -= amount
return balance
"""
in the shell:
... |
d71440317cf22a119981bdfe81e36974af94c6b0 | sombriyo/Leetcode-_questions | /sliding_window/Subarray Product Less Than K.py | 1,440 | 3.9375 | 4 | ''''
Given an array of integers nums and an integer k, return the number of
contiguous subarrays where the product of all the elements
in the subarray is strictly less than k.
'''
def efficient_apporach(nums, k):
'''
We initialised two pointers at 0 index
we the right pointer to traverse the array and
... |
bb728ace9286902f692115543b8d07ac9b71d3ae | sombriyo/Leetcode-_questions | /random/Count the Number of Consistent Strings.py | 829 | 4.15625 | 4 | '''
You are given a string allowed consisting of distinct characters and an array of strings words.
A string is consistent if all characters in the string appear in the string allowed.
Return the number of consistent strings in the array words.
-------------------------------------------------------------------------
... |
ba6720be596a28902939840c191952d5f67a9c94 | sombriyo/Leetcode-_questions | /random/Find the Highest Altitude.py | 618 | 4.03125 | 4 | '''
The question is to find the highest altitude
of the biker to travel
Input: gain = [-5,1,5,0,-7]
Output: 1
Explanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1.
Runtime: 36 ms, faster than 63.69% of Python3 online submissions
Memory Usage: 14.1 MB, less than 68.66% of Python3 online submissions
'''
c... |
0f68f2eaf4b6a38553b37e41b3e1ea00e371af75 | RhysMurage/alx-higher_level_programming | /0x0A-python-inheritance/2-is_same_class.py | 368 | 3.703125 | 4 | #!/usr/bin/python3
"""This module contains a function that returns True if an object is
exactly an instance of the specified class"""
def is_same_class(obj, a_class):
"""Determines if the object is an instance of the specified class
Args:
obj: object
a_class: Classs
"""
if type(obj) =... |
4792e002a85e57b6901877af2903d9beaee59c5d | RhysMurage/alx-higher_level_programming | /0x0C-python-almost_a_circle/models/square.py | 1,838 | 3.828125 | 4 | #!/usr/bin/python3
"""
This module represents a Sqauare
"""
from models.rectangle import Rectangle
class Square(Rectangle):
"""This is a Square class
Attributes:
id: id of object
size: this is the size of square
x: x coordinate of rectangle
y: y coordinate of rectangle
"""
def __ini... |
f611100ca9d35232b8d510e700f2430e6029a7b1 | RhysMurage/alx-higher_level_programming | /0x0A-python-inheritance/11-square.py | 691 | 4.1875 | 4 | #!/usr/bin/python3
"""
Module: 10-square
defines a class Square that inherits from
Rectangle (9-rectangle)
"""
Rectangle = __import__('9-rectangle').Rectangle
class Square(Rectangle):
""" Inherits from rectangle"""
def __init__(self, size):
""" Instatiation with size"""
self.integer_valida... |
344f42c5042d4d503fbd50be2ea697215dc5e592 | RhysMurage/alx-higher_level_programming | /0x07-python-test_driven_development/2-matrix_divided.py | 803 | 3.890625 | 4 | #!/usr/bin/python3
"""
Module contains matrix_divided function
"""
def matrix_divided(matrix, div):
"""Divides the elements of a matrix with div
Args:
matrix (nested list): an nxm matrix
div (int): value matrix to be divided by
"""
item = 0
new_matrix = []
while item < len(mat... |
2213ac0ee0fd2d33981e732005215ed9c4f6eba9 | RhysMurage/alx-higher_level_programming | /0x0A-python-inheritance/4-inherits_from.py | 518 | 3.609375 | 4 | #!/usr/bin/python3
"""This module has a function that returns True if the object is an instance
of a class that inherited (directly or indirectly) from the
specified class ; otherwise False"""
def inherits_from(obj, a_class):
"""Determines if object is an instance of a class that inherited
directly of indirec... |
da6dd59df05592658e3c453b18260085a805c334 | RhysMurage/alx-higher_level_programming | /0x03-python-data_structures/7-add_tuple.py | 654 | 3.828125 | 4 | #!/usr/bin/python3
def add_tuple(tuple_a=(), tuple_b=()):
if tuple_a or tuple_b:
results = []
if len(tuple_a) == 0:
tuple_a = tuple_a[:2]
return tuple_b
if len(tuple_b) == 0:
tuple_b = tuple_b[:2]
return tuple_a
if len(tuple_a) == 1:
... |
6d3960a0e2544e4f1a36f4b18e5c8e926988cfcd | GugapriyaKarthikeyan/CodingExercise | /Classes and Dictionaries Assignment in Python.py | 1,073 | 4.375 | 4 | #Python class to store the details of the students of a class
class Students:
id
total_marks = 0
average_marks = 0
name_email = {}
marks = {}
#Acts as a setter function to set the values to objects
def input(self):
self.id = 1
self.name_email = {"GugaPriya":"Gug... |
84d013839caff3344f2675bd6cc0e3bc6d52ffe4 | RKiddle/Time-Series-with-Python | /Manipulating _Time_Series_Data_in_Python/Working_with_Time_Series_in_Pandas/Compare_annual_stock_price_trends.py | 389 | 3.5 | 4 | # Create dataframe prices here
prices = pd.DataFrame()
# Select data for each year and concatenate with prices here
for year in ['2013', '2014', '2015']:
price_per_year = yahoo.loc[year, ['price']].reset_index(drop=True)
price_per_year.rename(columns={'price': year}, inplace=True)
prices = pd.concat([pric... |
dd931c9cb3ee080ceefbc53e14afe68d71b039e3 | RKiddle/Time-Series-with-Python | /Manipulating _Time_Series_Data_in_Python/Basic_Time_Series_Metrics_&_Resampling/Interpolate_debt_GDP_and_compare_to_unemployment.py | 308 | 3.640625 | 4 | # Import & inspect data here
data = pd.read_csv('debt_unemployment.csv', parse_dates=['date'], index_col='date')
print(data.info())
# Interpolate and inspect here
interpolated = data.interpolate()
print(interpolated)
# Plot interpolated data here
interpolated.plot(secondary_y = 'Unemployment')
plt.show()
|
269bffdefd02b40841c48aa909c3fd5a5010c99c | medy7/Basic-codes | /Image template matching.py | 878 | 3.703125 | 4 | '''
link: https://www.tutorialspoint.com/template-matching-using-opencv-in-python
'''
import cv2
import numpy as np
#open the main image and convert it to gray scale image
main_image = cv2.imread('image')
gray_image = cv2.cvtColor(main_image, cv2.COLOR_BGR2GRAY)
#open the template as gray scale image
template = cv2.i... |
025a10ff66ce161786009aebac43046ecb53df00 | shDupont/pythonsList.py | /11.py | 180 | 4.1875 | 4 | quantidade = int(input("Digite o número desejado:"))
def funcao(quantidade):
for x in range(0,quantidade,1):
print("*" * (x+1))
print("\n")
print(funcao(quantidade))
|
bfc1022b6810eebd3e2fcca7c72e9546341ee007 | JimHaughwout/teaching_tools | /ex_07/fun_with_lists.py | 2,128 | 4.46875 | 4 | #!/usr/bin/python
from random import uniform
# Lists can hold anytihing
int_list = [1, 2, 3]
text_list = ['this', 'is', 'a', 'list', 'of', 'strings']
print int_list
print text_list
# You can make a list bigger or smaller
int_list.append(4)
int_list.remove(1)
print int_list
# You directly access a list's element ... |
01c68c8706341925d25e12c0b30ff75cb84a4952 | JimHaughwout/teaching_tools | /ex_04/ex04_TODOs.py | 3,335 | 3.875 | 4 | #!/usr/bin/python
from sys import argv, exit
from datetime import datetime
### TODO: Make this whole program PEP-08 compliant
def isotime_from_strings(yyyymmdd, hhmmss):
"""
Generates and returns IS0-8601 compliant date-time string (in UTC)
from two input strings:
- YYYYMMDD
- HHMMSS
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.