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 |
|---|---|---|---|---|---|---|
28ae380604ed93d5788f888ec56fe2972bcb9b58 | simonpf/bunny_lab | /bunny_lab/levels.py | 1,308 | 3.546875 | 4 | def print_bunnies(bunnies):
s = ""
for b in bunnies[:-1]:
s += b + ", "
if len(bunnies) > 0:
s += "and " + bunnies[-1]
return s
class Level:
def __init__(self,
msg_saved,
msg_dead):
self.msg_saved = msg_saved
self.msg_dead = msg_dead... |
368b8ede411e0adb638c4afcd1a0f725b8d9bb56 | nonatalies/second_one | /3.py | 120 | 3.546875 | 4 | r = int(input('Введите длину радиуса: '))
p = 3.14
print('Площадь круга:', p * (r ** 2))
|
ee9daa151b3f35ad7484f9133a3f8d400e019c6e | nfbarrett/CCIS-1505-02 | /Session12/P10A.py | 2,661 | 3.765625 | 4 | # Programer: Nick Barrett
# Date Written: Dec 3, 2019
# Program Name: P10.py
# Company Name: HTC-CCIS1505
class Checking(object):
def __init__(self, ID="C-1983", LOC="MN", items=0.00): #constructor method
self.ID = ID #public attribute for Checking id
self.Location = LOC #public attribute for Ch... |
d86894d4daef95f1143b2c2ab6a3a8eb366b29ad | nfbarrett/CCIS-1505-02 | /Session04/Session4 Inclass/inclass3.py | 252 | 3.71875 | 4 | intLC = 1 #initial loop counter (1)
while intLC <= 10: #test for completion (am I done yet?)(2)
print ("Loop Counter is:", intLC) #Body loop (3)
intLC += 1 #increment Loop Counter (4)
#intLC = intLC +1 #increment Loop Counter (4)
|
d77fa9359733e48ce482ea54eff4fccf96542c67 | nfbarrett/CCIS-1505-02 | /Session12/P10.py | 5,362 | 3.765625 | 4 | # Programer: Nick Barrett
# Date Written: Dec 3, 2019
# Program Name: P10.py
# Company Name: HTC-CCIS1505
class Checking(object):
def __init__(self, ID="C-1983", LOC="MN", items=0.00): #constructor method
self.ID = ID #public attribute for Checking id
self.Location = LOC #public attribute for Ch... |
78b6c9150a4804af6f60d62d040fc09c9f86d0a1 | nfbarrett/CCIS-1505-02 | /Session11/Test2-Q28.py | 549 | 4.21875 | 4 | blnDone = False # sets Boolean to false
while blnDone == False: # checks Boolean is still false
try: # repeats this until Boolean is true
num = int(input( "Enter your age" )) # asks for number, converts input into integer
blnDone = True # sets Boolean to true
except (ValueError): # if input is n... |
ba771d7f4f312d4276781c88642d7aae08baaf7d | nfbarrett/CCIS-1505-02 | /Session11/Test2-Q27.py | 837 | 4.46875 | 4 | def maximumValue( x, y, z ): # calls the function for maximumvalue
maximum = x # if position 1 is max this will be displayed
if y > maximum: # checks if position 2 is larger that position 1
maximum = y # if position 2 is larger, position 2 will be displayed
if z > maximum: # checks if position 3 is... |
dfc321e797972f83c637e08ca943ffa9568a3496 | nfbarrett/CCIS-1505-02 | /Session06/p6.py | 1,733 | 4.1875 | 4 | # Programer: Nick Barrett
# Date Written: Oct 01, 2019
# Program Name: P6.py
# Company Name: HTC-CCIS1505
#step 1
print("Step 1")
lstWeekDays = []
int_Counter=0
while int_Counter <= 6:
strWeekDay = input("Enter day of the week: ")
int_Counter += 1 # count up by 1
strWeekDay = strWeekDay.title()
lstWee... |
7a37c2579c763cd26fe7bc1cd2d2527098ebf709 | nfbarrett/CCIS-1505-02 | /Session10/P9.py | 1,679 | 4 | 4 | # Programer: Nick Barrett
# Date Written: Nov 12, 2019
# Program Name: P9.py
# Company Name: HTC-CCIS1505
class Employee:
def __init__(self,strName="",intHours=0,hourly_wage=0.0): #constructor
self.Employee_Name = strName #creat public Employee Name
self.Hours_Worked = intHours #creat public Hours ... |
1f5e0277a5e1a5ef648e70f3d807ceb4b2ba9f22 | adriano-uff/Lisp-like-python | /codigos/Lisp-Bubblesort.py | 725 | 3.921875 | 4 | def car(x):
return x[0]
def cdr(x):
return x[1:]
def cons(x, y):
return [x] + y
def quantidade(val):
if val == []:
return 0
else:
return 1 + quantidade(cdr(val))
def comparar(pivot,lista):
if pivot > car(lista):
return cons(car(lista),separar(cons(pivot,cdr(lista))))
... |
37a13e73405d1107ef559fc16ea99cf29a2c21c5 | nachom12/my_portfolio | /python_little_things/adivinaelnumero.py | 659 | 3.96875 | 4 | import random
def run():
print("Adivina el numero")
numero_generado = random.randint(1,100)
numero = 0
intentos = 5
while ((numero != numero_generado) and intentos > 0):
intentos = intentos - 1
numero = int(input("Ingrese un numero: "))
if (numero > numero_generado):
... |
a9c6d98acc7ab00f17cb97bb6c422e76c4cfd4dc | junyongk/precaution | /test/fixtures/python/sum.invalid.py | 299 | 3.78125 | 4 | # Copyright 2019 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
num = eval(input("Enter a positive number: "
if num < 0:
print("Non positive number")
else
sum = 0
# use while loop to iterate un till zero
whil num > 0):
sum += num
num -= 1
print("The sum is",sum)
|
dc19e33426e60d86b2f71556c9a22b0bf99f42ce | afrozhussain/Python-Tutorials | /covariance.py | 1,031 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Implementing Covariance and Correlation in Python
Created on Mon Jan 11 20:28:20 2016
@author: Afroz Hussain
"""
def cov(x,y):
if len(x) != len(y):
return
n = len(x)
xy = [x[i]*y[i] for i in range(n)]
mean_x = sum(x)/float(n)
mean_y = sum(y... |
7fc90fdcab27a73cfe850e91715dccf4ee27df55 | ReznikSM/task_1 | /prime.py | 441 | 3.828125 | 4 | while True:
try:
a = int (input("Введите число: "))
except ValueError:
print("Неверный формат")
continue
else:
break
if a < 2:
print("Число ни простое и ни сложное")
quit()
n=0
for i in range(2, a // 2+1):
if (a % i == 0):
n = n+1
if (n <= 0):
print("Ч... |
70c357190d1d46e60770619cff4d8c53932eaaa7 | miku/pyqueued | /setup.py | 1,826 | 3.5 | 4 | # coding: utf-8
"""
Python client for HTTP message queue Queued: https://github.com/scttnlsn/queued.
Usage
-----
>>> import pyqueued
Get a client.
>>> client = pyqueued.Client(host='localhost', port=5353)
Enqueue a message:
>>> loc = client.enqueue("q", "my message")
>>> loc
'http://localhost... |
d641199d76898197d56d6d77ca747031160d3140 | yzha3917/omooc.py | /11.0.py | 3,212 | 4.0625 | 4 |
import random
import math
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
minimum = 0;
maximum = 100;
picked = 0;
guessed = 0;
n = 0;
m = 0;
def new_game():
print "A new game has started! "
print "Choose the range you wanna play,"
print "and then, you guess an integer from this range."
prin... |
b95925b3ee017e8d011bc1f890bcfb12a9a43167 | blackdrifter-vix/knowledge-share | /data-structure/array_problem_1.py | 633 | 4.09375 | 4 | #!/usr/bin/env python3
#Rotate Array
# Input: [1,2,3,4,5,6,7] and k = 3
# Output: [5,6,7,1,2,3,4]
# Explanation:
# rotate 1 steps to the right: [7,1,2,3,4,5,6]
# rotate 2 steps to the right: [6,7,1,2,3,4,5]
# rotate 3 steps to the right: [5,6,7,1,2,3,4]
def rotate(arr, k):
step = 0
sto... |
9a39e603c2732f3eba45a682273cd2c741d3221c | JorG96/DataStructures | /kthSmallestInBST.py | 2,037 | 4.09375 | 4 | '''
A tree is considered a binary search tree (BST) if for each of its nodes the following is true:
The left subtree of a node contains only nodes with keys less than the node's key.
The right subtree of a node contains only nodes with keys greater than the node's key.
Both the left and the right subtrees must al... |
15b5733f80fddc8c8a22522ae0653f1de90546bf | liujiantao007/Perform-Object-Detection-With-YOLOv3-in-Keras | /Draw_rectangle/single_rectangle_cv2.py | 911 | 4.3125 | 4 | # Python program to explain cv2.rectangle() method
# importing cv2
import cv2
from matplotlib import pyplot as plt
path ='2.jpg'
# Reading an image in default mode
image = cv2.imread(path)
# Window name in which image is displayed
window_name = 'Image'
# Start coordinate, here (5, 5)
# represents the top ... |
feef8b9b50b709ffb91316002978834093eb8947 | Academia-Hacker/Security | /servidor.py | 859 | 3.53125 | 4 |
import socket
import threading
bind_ip = "localhost"
bind_port = 9999
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((bind_ip, bind_port))
server.listen(5)
print('[*] Listening on {}: {}'.format(bind_ip, bind_port))
def handle_client(client_socket):
# exibe o que o cliente enviar
requ... |
26b6e649ae48acd0f50a6feacc82e6b50de1327f | batra98/Mario_Testing | /20171114_assignment3/20171114_part1/Refactored/flag_1.py | 949 | 3.609375 | 4 | """gaurav"""
class Flag(object):
"""gaurav"""
def __init__(self, map_mario):
self.map_mario = map_mario
self.flag = [" ++-----", " ++-----", " ++-----", " ++ ", " ++ ",
" ++ ", " ++ ", " ++ ", " ++ ", " ++ ", "++++++ "]
def draw(s... |
0ac8ee75c140e24ac2470b9a23cc9bb07f6fd4af | batra98/Mario_Testing | /20171114_assignment3/20171114_part1/Refactored/start_screen.py | 2,200 | 3.78125 | 4 | """gaurav"""
import color
class Start(object):
"""gaurav"""
def __init__(self, height, width):
self.height = height
self.width = width
self.start_screen = \
[" ____ ___ ___ ___", \
"| | || || | | Instructions:", \
"|... |
493b7d31533eb0eee17671b2ec0cd5a86caac8ab | jennelba/advent-of-code-2016 | /day12_part1.py | 1,552 | 3.53125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 13 15:56:57 2016
@author: jbilbie
Advent of Code 2016
--- Day 12: Leonardo's Monorail ---
"""
def cpy(x, y, dict, index):
if x in dict:
dict[y] = dict[x]
else:
dict[y] = int(x)
index += 1
return dict, index
def... |
48c4c4b9e2e8c019cf5ad34a0556d468edb35d4d | NISHITZA/python | /Cakewalk.py | 557 | 3.765625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the marcsCakewalk function below.
def marcsCakewalk(cal):
total=0
cal.sort(reverse=True)
for i in range(0,len(cal)):
print(i,cal[i])
total = total + cal[i]*(math.pow(2,i))
return int(total)
if __na... |
829c220b9c7ecdd02356ccff250eb668c6bff0d0 | cmu-11791-s19/qa-pipeline-with-learning-Linyiii | /Featurizer.py | 350 | 3.578125 | 4 | import abc
from abc import abstractmethod
class Featurizer:
__metaclass__ = abc.ABCMeta
@classmethod
def __init__(self): # constructor for the abstract class
pass
# This is the abstract method that is implemented by the subclasses.
@abstractmethod
def getFeatureRepresentation(self, ... |
04705f2179e2f8a87fea769b027a754f15779fd0 | jacksonsbaycoders/BankABM | /institutions.py | 463 | 3.53125 | 4 | debug = False
class Bank:
def __init__(self,name):
if debug : print "init"
self.name = name
self.clients = {}
def add_client(self, id):
ac_id = "id"+str(id)
if debug : print "id:",id
self.clients[ac_id]=0
def list_clients(self):
s=""
for c in self.clients:
s+=c+","+str(self.clients[c])+","
ret... |
5d9b8983b5652dc449658873bfd8b237fdc57b64 | jsheridanwells/Python-Intro | /7_dates.py | 955 | 4.375 | 4 | #
# Example file for working with date information
#
from datetime import date
from datetime import time
from datetime import datetime # imports standard modules
def main():
## DATE OBJECTS
# Get today's date from the simple today() method from the date class
today = date.today()
print('la fecha es ', today... |
0e7c02b9900376d05eda8e7bc76b32787362758a | Andrewsyl/Python-Practice | /numbergame.py | 2,490 | 3.90625 | 4 | import random
import os
def want_to_play():
start = raw_input("Do you want to play? Yes or No? ").upper()
if start == "YES":
print "\n***Ok great, let's play!***\n"
guessing_game()
elif start == "NO":
print "Ok, maybe next time"
else:
print "Sorry, what?"
want_t... |
f90c6b492ac289b08fee6eeb07c9d14ed7084553 | NephthysSkh/PCBS-projet | /projet_PCBS.py | 2,952 | 4.09375 | 4 | # encoding utf-8
import os
alphabet = "azertyuiopqsdfghjklmwxcvbnéàçàâôöêë"
def empty_dictionnary():
""" Creates an empty dictionnary, no argument"""
dictionnary = {}
for i in alphabet :
dictionnary[i] = 0
return dictionnary
def create_dictionnary(text):
""" Creates a dictionnary to s... |
9bfe9ac0396135e849c109174bf205ffe00368a3 | MonLopy/ML.lab2 | /MamchakLab2.py | 980 | 3.53125 | 4 |
import matplotlib.pyplot as plt
def func(x):
y = (x - 5) ** 2
return y
def pohidna(y):
z = 2 * (y - 5)
return z
def plot():
a = []
b = []
for x in range(-50, 50, 1):
y = (x - 5) ** 2
a.append(x)
b.append(y)
plt.title("Our function")
plt.plot(a, b)
p... |
fc165492200f82190b46a80163e2deff0fcfb1a4 | pavan1126/python-1-09 | /L2 ASS 1-09 Arithmetic operations.py | 373 | 3.921875 | 4 | #A.pavan kumar - 121910313047
# Program on Five Arithmetic operations
a = int(input('Enter First number:'))
b = int(input('Enter Second number '))
add = a + b
dif = a - b
mul = a * b
div = a / b
power = a ** b
#Display result
print('Sum is :',add)
print('Difference is :',dif)
print('Product is :',mul)... |
a1a92e7de2c597aaa4d1a6443bc2354216c9f1f5 | pavan1126/python-1-09 | /L3 8-09 Reverse order.py | 379 | 4.25 | 4 | #copying elements from one array to another array in reverse order
a=[1,2,3,4,5]
b=[None]*len(a)
length=len(a)
#logic starts here
for i in range(0,length):
b[i]=a[length-i-1]
#printing output
print("the elements of first array is")
for i in range(0,length):
print(a[i])
print("the elements of reversed... |
dceae0ae4485933eedcc99b1e9e0145969f21c11 | niklasnson/TDP002 | /libs/asciiart.py | 1,740 | 4 | 4 | def frame(text):
"""
Skriv en funktion frame som accepterar en textsträng som indata och skriver ut
textsträngen inramad med asterisker.
"""
text = "* " + text + " *" # texten med inledande * och avslutande *
print_stars(len(text))
print(text) # texten
print_stars(le... |
794b01227b415328d41e5d54b1d8dc2b615d13f7 | Ed92/Python | /scraping/browsing.py | 487 | 3.6875 | 4 | """
Author: Erik Djamgarian
A little python script that asks the user for a url input (full url) and opens a Chrome webbrowser with the url input.
"""
import os
from selenium import webdriver
# pass the file path to a variable
chromedriver = "/usr/local/bin/chromedriver"
#using os module to compile path with drive... |
ed41e587b6fbf1e609fe7f50265ed110057a311d | Ed92/Python | /api/app.py | 2,093 | 3.53125 | 4 | from flask import Flask
from flask_restful import Api, Resource, reqparse
app = Flask(__name__)
api = Api(app)
#normally use a DB
users = [
{
"name": "Nicholas",
"age": 42,
"occupation": "Network Engineer"
},
{
"name": "Elvin",
"age": 32,
"occupation":... |
f559d8fadffabe59aa43fc6e68c2ef63ef5b96f2 | Ed92/Python | /exercises/random2.py | 180 | 3.546875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 27 16:36:18 2018
@author: ed
"""
dog = ['norris', 'bentley', 'iniaki']
dog1, dog2, dog3 = dog
print(dog1) |
6b85251f2ce798cf79cfe23ca929fdbe60d5e96b | vedant-milind/InstaGrow | /INSTABOT.py | 8,347 | 3.890625 | 4 | #The project is based on the instagram's "follow and unfollow and like" process. In one sense its an Instagram Bot.
#It makes use of functions and classes to carry out the task.
#We are using selenium webdriver in order to scrap and parse the information we are getting.
#Here, what exactly we are doing is that... |
1af8f4f82cb7ee096ec5c945af67585b9c772b11 | BrettGoreham/AdventOfCode2020 | /InstructionComputer.py | 1,199 | 3.5 | 4 | class InstructionComputer:
def __init__(self, instructions):
self.instructions = instructions
self.instructionCount = 0
self.accumulator = 0
self.setOfInstructionsRun = set()
self.isLooped = False
self.isTerminated = False
def run(self):
while not self.is... |
326dee4ed121124217507fe022e301f353b6fe8b | gkarumbi/password-locker | /user.py | 720 | 4.03125 | 4 | class User:
"""
Class that generates instances of a user
"""
user_list = []
def __init__(self,user_name,email,password):
"""
Init method to help us define the properties of our objects
"""
self.user_name = user_name
self.email = email
self.password ... |
722cc2d679b776d72bbe1df7f69c54f7a64eb8f1 | mumffy/HelloWorld | /CTCI/16_Moderate/Q16x01_Number_Swapper.py | 215 | 3.5 | 4 | """
16.1 Number Swapper: Write a function to swap a number in place (that is, without temporary variables).
"""
"""
Because of how Python's parameter passing works, this problem cannot be solved in a function
"""
|
790c3f53f9d6569b51c94ab68a3c3a322f53c090 | irvcov/exercises | /pythonFolder/dailyEx.py | 15,731 | 4.09375 | 4 | import functools as f
"""
Given a list of numbers and a number k, return whether any two numbers from the list add up to k.
For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.
"""
def is_k_sum_in_arr(arr, k):
nums = set()
for n in arr:
subk = k - n
if subk in nums:
... |
48784ce85ac8a8ce79dd42790846e894523904cf | eessm01/100-days-of-code | /e_bahit/wrappers_decorators.py | 1,341 | 4.53125 | 5 | """The Original Hacker. N.4. Wrappers y Decoradores.
Closure. Es una función que dentro de ella contiene a
otra función la cual es retornada cuando el closure es
invocado.
DECORADOR. Es aquel closure que cómo parámetro recibe
una función (llamada función "decorada") cómo único
argumento.
WRAPPER. No es más que la fu... |
dd9f0ef34231d01242086ef70453cb401ef37a77 | eessm01/100-days-of-code | /platzi_OOP_python/bubble_sort.py | 567 | 4.125 | 4 | from random import randint
def bubble_sort(one_list):
n = len(one_list)
limit = n - 1
for i in range(n):
for j in range(limit):
if one_list[j] > one_list[j+1]:
one_list[j], one_list[j+1] = one_list[j+1], one_list[j]
limit -= 1
return one_list
if __na... |
07521e78c14dd80a1f1575eb38527f41d31f31ae | eessm01/100-days-of-code | /platzi_comp_thinking/binary_search_s2.py | 638 | 3.546875 | 4 | """Obtiene la raiz cuadrada de un número
Este programa usa el algoritmos de búsqueda binaria
para obtener el resultado.
"""
objetivo = int(input('Ingrese un número: '))
epsilon = 0.0001
bajo = 0.0
alto = max(1.0, objetivo) #regresa el mayor de esos dos valores
respuesta = (bajo + alto) / 2
iteraciones = 0
while abs... |
84eb0afd3ad225fc0e23eb56292b845ed1d4e4ec | eessm01/100-days-of-code | /python_for_everybody_p3/files_exercise1.py | 348 | 4.375 | 4 | """Python for everybody.
Exercise 1: Write a program to read through a
file and print the contents of the file (line
by line) all in upper case. Executing the
program will look as follows:
"""
fname = input('Enter a file name: ')
try:
fhand = open(fname)
except:
print('File not found')
exit()
for line... |
95bc78b5021a0ee08c94fa92b58c8df9b9e237dc | eessm01/100-days-of-code | /data_structures_algorithms/minmax_R-1_3.py | 283 | 3.984375 | 4 | def minmax(data):
data = data.split(',')
data = [ int(element) for element in data ]
data.sort()
tup = (data[0], data[-1])
return tup
if __name__ == "__main__":
data = input('Ingrese los números separados por comas: ')
tup = minmax(data)
print(tup) |
c2516b677840cbb77294f74049e04bed243b559c | eessm01/100-days-of-code | /platzi_comp_thinking/dictionaries.py | 600 | 4.21875 | 4 | my_dict = {
'David': 35,
'Erika': 32,
'Jaime': 50
}
print(my_dict)
valor = my_dict.get('Juan', 99)
print(valor)
valor = my_dict.get('Jaime', 30)
print(valor)
my_dict['Jaime'] = 20
print(my_dict)
my_dict['Pedro'] = 42
print(my_dict)
del my_dict['Jaime']
print(my_dict)
for llave in my_dict.keys():
... |
e15125d249abd6b3b99e742a4fa03a3b6a9836ab | eessm01/100-days-of-code | /data_structures_algorithms/C-1_18_19_list_comprehensions.py | 753 | 3.921875 | 4 | # Demonstrate how to use Python’s list comprehension syntax to produce
# the list [0, 2, 6, 12, 20, 30, 42, 56, 72, 90].
# Demonstrate how to use Python’s list comprehension syntax to produce the
# list[ a , b , c ,..., z ],but without having to typea ll 26 such characters literally.
# Write a short Python program th... |
b01c74c82073bf2a8cfdbbba7ac08bfd433a4560 | eessm01/100-days-of-code | /platzi_OOP_python/insertion_sort.py | 799 | 4.21875 | 4 | from random import randint
def insertion_sort(one_list):
# iterate over one_list from 1 to list's length
for i in range(1, len(one_list)):
current_element = one_list[i]
# iterate over all elements in the left side (from i-1 to 0)
for j in range(i-1,-1,-1):
# compare cur... |
c6b08f5a59a5b39c7387a05382641c3f1b78eea3 | eessm01/100-days-of-code | /python_para_todos_p2/day19_lambda_functions.py | 381 | 4.09375 | 4 | """
El operador lambda sirve para crear funciones anónimas en línea.
Al ser funciones anónimas, es decir, sin nombre, estás no podrán
ser referenciadas más tarde.
lambda parameter_list: expression
Las funciones lambda están restringidas por la sintaxis a una sola
expresión.
"""
l = [1, 2, 3, 4, 5]
l2 = filter(... |
7dd1a4cc6c68bdb577c005b2dba515633bb563a6 | eessm01/100-days-of-code | /platzi_comp_thinking/scopes.py | 388 | 3.734375 | 4 | """Ejemplo sobre scope en Python
"""
def funcion1(un_argumento, una_funcion):
def funcion2(otro_argumento):
return otro_argumento * 2
valor = funcion2(un_argumento)
return una_funcion(valor)
un_argumento = 1
def cualquier_funcion(cualquier_argumento):
return cualquier_argumento + 5
re... |
2188d9d179796324f3643ff3876957b5a97ab445 | eessm01/100-days-of-code | /platzi_comp_thinking/for_loop_for_dict.py | 584 | 4.09375 | 4 | estudiantes = {
'mexico': 10,
'colombia': 15,
'puerto_rico': 4
}
# forma de iterar sobre las keys del diccionario
for pais in estudiantes:
print(pais)
for pais in estudiantes.keys():
print(pais)
# forma de iterar sobre los valores del diccionario
for numero_de_estudiantes in estudiantes.values():... |
7eb25cb4b6ef56abb9a9827351a9b45813615435 | eessm01/100-days-of-code | /practice_python/7_list_comprehensions.py | 341 | 4 | 4 | # Let’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100].
# Write one line of Python that takes this list a and makes a new list that has only the even elements of
# this list in it.
if __name__ == "__main__":
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
print([ e for e in ... |
3869deac3ad24925a63d2cdaeb4db9431e08a8af | eessm01/100-days-of-code | /real_python/day10_11_dear_pythonic_santa_claus.py | 1,732 | 4.28125 | 4 | #!/usr/bin/env python3
#-*- coding: utf-8 -*-
"""
Exercises from https://realpython.com/python-thinking-recursively/
The algorithm for interative present delivery implemented in Python
Now that we have some intuition about recursion, let's introduce the formal
definition of a recursive function. A recursive function ... |
e03dc739e577c6a9881b7ef94401ff4349c42220 | eessm01/100-days-of-code | /platzi_comp_thinking/factorial.py | 225 | 4.0625 | 4 | def factorial(n):
"""Calcula el factorial de n
n int > 0
returns n!
"""
if n == 1:
return 1
return n * factorial(n-1)
n = int(input('Escribe un entero: '))
fact = factorial(n)
print(fact)
|
a856343bc217c4d0e4e6b4fce3212d587cef5e38 | eessm01/100-days-of-code | /project_euler/5_smallest_multiple.py | 592 | 4.21875 | 4 | def get_smallest_multiple(max_divisor):
is_find = False
initial_smallest_number = 2520
while not is_find:
for i in range(max_divisor, 1, -1):
if initial_smallest_number % i > 0:
break
else:
if i == 2:
is_find = True
... |
c8d37091c9f5bf2e7422e73709fdcadb413531ee | eessm01/100-days-of-code | /platzi_comp_thinking/fibonacci.py | 266 | 4 | 4 | def fibonacci(n):
"""Calcula la serie de fibonacci para n
n int > 0
returns int
"""
if n == 0 or n == 1:
return 1
return fibonacci(n-1) + fibonacci(n-2)
n = int(input('Ingresa un entero: '))
result = fibonacci(n)
print(result) |
dd80baae850876b92c2f81cdf069d5a0f411cd2c | eessm01/100-days-of-code | /pythones/opp_user.py | 383 | 3.53125 | 4 | class Usuario:
def __init__(self, nombre, clave):
self.nombre = nombre
# protected
self._clave = clave
# private
self.__pass = clave # name mangling
if __name__ == "__main__":
usuario = Usuario('Roberto','querty')
print('{} {}'.format(usuario.nombre, usuario._cla... |
2d1f403ff0c81d35b06e2b022991a6c017f81844 | BitPunchZ/Leetcode-in-python-50-Algorithms-Coding-Interview-Questions | /Algorithms and data structures implementation/trees/binary search trees/deletion/index.py | 2,240 | 3.96875 | 4 |
class Node:
def __init__(self, value):
self.left = None
self.right = None
self.data = value
def insert(root, node):
if(root is None):
root = node
return
if(root.data < node.data):
if(root.right is None):
root.right = node
else:
... |
c2cde7223eafaf4d2c98b3bdef23a6653511f93e | BitPunchZ/Leetcode-in-python-50-Algorithms-Coding-Interview-Questions | /Algorithms and data structures implementation/binary search/index.py | 678 | 4.34375 | 4 |
def binarySearch(arr, target):
left = 0
right = len(arr)-1
while left <= right:
mid = (left+right)//2
# Check if x is present at mid
if arr[mid] == target:
return mid
# If x is greater, ignore left half
elif arr[mid] < target:
left = mid + ... |
bace04763d366465340c420f7b26f5747ac59de4 | jstettner/StetCala | /mancala.py | 7,486 | 3.78125 | 4 | """
Board for the Mancala game (2 Players).
Author: Jack Stettner
Date: 12 November 2018
"""
import pygame
import os
from enum import Enum
local_dir = os.path.dirname(__file__)
asset_path = os.path.join(local_dir, 'assets')
class Turn(Enum):
P1 = 1
P2 = 2
TIE = 0
class Block(pygame.sprite.Sprite):
... |
a4e6b874d050466e0e0c21621b6f343699221890 | MaxFallishe/Python__web | /Basic_python/Дз4/Dz4_8.py | 1,535 | 3.9375 | 4 | countries = {"Казахстан":{"Численность":"17","Столица":"Астана","Площадь":"2725000"},"Россия":{"Численность":"144","Столица":"Москва","Площадь":"17100000"},"США":{"Численность":"325","Столица":"Вашингтон","Площадь":"29834000"}}
def main():
while True:
switch = input("Введите комманду:\nadd - добавить стра... |
a4c9b8a46a6f975e951207cb8d16de868c98078d | MaxFallishe/Python__web | /Basic_python/Дз1/Dz1_3.py | 476 | 3.859375 | 4 | time = int(input("На сколько лет вы хотите офрмить кредит: "))
creditSum = int (input("Введите сумму кредита: "))
interestRate = int(input("Ваша процентная ставка: "))
firstContribution = int(input("Ваш первый взнос: "))
creditWithPercents = creditSum +(creditSum * interestRate/100)
monthlySum = creditWithPercents / t... |
fee00f5c187b2be1b097d5b04574c735ad8d3a05 | MaxFallishe/Python__web | /Basic_python/Дз4/Dz4_4.py | 1,206 | 4.03125 | 4 | list_of_students=[]
print('Чтобы вывести список студентов напишите inf')
while True:
cmd = ''
inf = 'inf'
student = input('Введите имя нового студента')
if student == inf:
print(list_of_students)
continue
for i in list_of_students:
if i == student:
print... |
7c96b28a5739207904103e2e07169dd1d3a633ff | MaxFallishe/Python__web | /Basic_python/Дз4/Dz4_1.py | 81 | 3.625 | 4 | numbers = list(range(1,25+1))
for i in numbers:
if i%2 ==0:
print(i)
|
501b8950c5d65d3678832c6eb046915bad342638 | MaxFallishe/Python__web | /Basic_python/Дз1/Dz1_7.py | 393 | 3.90625 | 4 | x = int(input("Введите натуральное число(В десятиричной системе): "))
n = ""
vrem=x
while x > 0:
y = str(x % 8)
n=y + n
x = int(x / 8)
print (n)
x=vrem
n=""
while x > 0:
y = str(x % 2)
n = y + n
x = int(x / 2)
print(n)
x=vrem
n=""
while x > 0:
y = str(x % 16)
n = y + n
x =... |
2ed7c2c6e4649e464527da216f9c51a6bca47ac1 | MaxFallishe/Python__web | /Basic_python/Дз1/Dz1_2.py | 564 | 4.125 | 4 | import math
a = int(input("Введите число a:" ))
b = int (input("Введите число b:"))
c = int (input("Введите число c:"))
D = b ** 2 - 4 * a * c
print(D)
if D < 0:
print("Корней нет")
elif D == 0:
x = -b / 2 * a
print ("Корень = ",x)
else:
x1 = (-b + math.sqrt(D)) / (2 * a)
x2 = (-b - math.sqrt(D)) / (2 * a)
... |
85f2d0ae87846ea9bc07ba61ce8841fcb5af5c55 | MaxFallishe/Python__web | /Basic_python/Дз4/Dz4_3.py | 327 | 4.0625 | 4 | list_of_students=[]
while True:
student = input('Введите имя нового студента')
for i in list_of_students:
if i == student:
print('Такой студент уже есть')
break
else:
list_of_students.append(student)
print(list_of_students)
|
efd43f194e740f108d25a1a7a8e3fce39e208d5a | DhananjayNarayan/Programming-in-Python | /Google IT Automation with Python/01. Crash Course on Python/GuestList.py | 815 | 4.5 | 4 | """
The guest_list function reads in a list of tuples with the name, age, and profession of each party guest, and prints the sentence "Guest is X years old and works as __." for each one.
For example, guest_list(('Ken', 30, "Chef"), ("Pat", 35, 'Lawyer'), ('Amanda', 25, "Engineer"))
should print out:
Ken is 30 years... |
c0c2b7624f830df5459e67e5a323754c4ff737bc | DhananjayNarayan/Programming-in-Python | /Python For Everybody (Coursera)/PY4EAssignment10_2.py | 846 | 3.890625 | 4 | """
Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages.
You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon.
From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008
On... |
9ca85f60b40e2d8657c7b75fbbf6e74d39dcbdc1 | toledoneto/Python-Computer-Vision-com-OpenCv | /05 Object Detection with OpenCV and Python/13 Assessement.py | 1,582 | 3.515625 | 4 | # Object Detection Assessment Project Exercise
# Russian License Plate Blurring
# Your goal will be to use Haar Cascades to blur license plates detected in an image!
import cv2
import matplotlib.pyplot as plt
def display(img, cmap='gray', title=''):
fig = plt.figure(figsize=(12, 6))
fig.canvas.set_window_ti... |
89433cb445affccb75dcc5ec1907116cbbfec39d | toledoneto/Python-Computer-Vision-com-OpenCv | /04 Video Basics with Python and OpenCV/04 assessment.py | 1,489 | 3.84375 | 4 | # Create a program that reads in a live stream from a camera on your computer
# (or if you don't have a camera, just open up a video file). Then whenever you click the left mouse button down,
# create a blue circle around where you've clicked
# Create a function based on a CV2 Event (Left button click)
import cv2
# m... |
422a198f1f5afd18b04ee38d824433c4ce674ed9 | KhushMody/Maachine_Learning | /Classification./Logistic_regression.py | 923 | 3.640625 | 4 | #logistic regression
import numpy as np #math fns
import matplotlib.pyplot as plt #plotting
import pandas as pd #import datasets
#importing dataset
dataset = pd.read_csv('Social_Network_Ads.csv')
X = dataset.iloc[:, [2, 3]].values
y = dataset.iloc[:,4].values
from sklearn.model_selection import train_test_split
X_tr... |
2b21279fdf831305837dd282c45cc626f2f0f325 | MilenaMaria/Uri-Python | /URI_1035 - (8142874) - Accepted.py | 197 | 3.671875 | 4 | lista = input().split()
a, b,c, d = lista
if int(b) > int(c) and int(d) > int(a) and (int(c) + int(d)) > (int(a) + int(b)):
print("Valores aceitos")
else:
print("Valores nao aceitos") |
5bd5dd5577e471b410dd3ca5ee0bb81db44b91f1 | tyler-simeone/Python-Student-Exercises | /reports.py | 8,358 | 3.65625 | 4 | import sqlite3
class Student():
def __init__(self, first, last, handle, cohort):
self.first_name = first
self.last_name = last
self.slack_handle = handle
self.cohort = cohort
def __repr__(self):
return f'{self.first_name} {self.last_name} is in {self.cohort}'
class Ins... |
70d76b4001ab3be766fc6b53096289e50e75d0fc | Frelofee/wystock | /gpyj/open-eastM.py | 1,552 | 3.78125 | 4 | # 王琰的python编写
# 开发时间:2021/4/22 9:48
from openpyxl import Workbook
from openpyxl import load_workbook
from pandas.io.excel import ExcelWriter
import pandas as pd
# 转格式
# pd.read_csv('D:/我的成长/2021开心的我/生活/股票池/early0422.csv').to_excel('D:/我的成长/2021开心的我/生活/股票池/early0422.xlsx')
# 实例化
wb = Workbook()
# active
ws = wb.activ... |
66c0d7be7743965df40103e99a61ff81779e6630 | Frelofee/wystock | /autosign.py | 929 | 3.5625 | 4 | # 王琰的python编写
# 开发时间:2021/3/26 13:20
#导入模块
import time
from selenium import webdriver
#实例化Chrome浏览器对象
edgedriver = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
driver = webdriver.Ie(edgedriver)
#准备url
url='http://www.baidu.com'
# 访问
driver.get(url)
#最大化窗口(默认不是最大化)
driver.maximize_window()
# 找到输入框 ... |
5dcc037562f709471964dbec448747393392b32d | rafaelcf13/CV-Python-Modulo1- | /ex034.py | 248 | 3.75 | 4 | sal = float(input('Digite o Salario do funcionario: '))
if sal <= 1250:
print('Seu salario era R$ {:.2f} e agora é R$ {:.2f}'.format(sal, sal * 1.15))
else:
print('Seu salario era R$ {:.2f} e agora é R$ {:.2f}'.format(sal, sal * 1.10))
|
8423862ee7fca4dee89ffcd0090724f9fe95b068 | rafaelcf13/CV-Python-Modulo1- | /ex010.py | 98 | 3.625 | 4 | r=float(input('Quantos reais voce tem? R$'))
d=r/5.13
print('Voce tem {:.2f} dolares!'.format(d))
|
15bdbeaaf3a152eb62c6f4aff8937fa18a997b6a | Hari-Nikesh-R/YouTubeDownloader | /youtubetkinter.py | 1,634 | 4.0625 | 4 | ''' Youtube downloader using python'''
#tkinter is the python GUI to execute the code in a user friendly mode
#It is the syntax means that we are impoting everything from tkinter module
from tkinter import *
import webbrowser
#We are importing Webbrowser to have access through the website.
def yt():
n=... |
9d750a86f11a46b0fd7ef02ed990bbca1c58f192 | TranDatDT/Project-Euler | /Python/PE-16.py | 257 | 3.828125 | 4 | '''2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2^1000?
'''
_str = str(2**1000)
total = 0
for i in _str:
if i == '0':
continue
else:
total += int(i)
print(total)
|
c09a154fd0a57603cc1ed84daf6155b5157f576d | yue-w/CommonFunctions | /ListComprehension_ForInSquare.py | 390 | 3.984375 | 4 | """
https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
List comprehensions provide a concise way to create lists
"""
#### Example 1
data = [(1,2,3),(4,5,6),(7,8,9),(10,11,12),(13,14,15)]
R = [pixel[0] for pixel in data]
G = [pixel[1] for pixel in data]
B = [pixel[2] for pixel in data]
####Exa... |
4af4fe30cac4b7a2e2573d23d075b107a7bb798d | Andy5847/UHD_MST_Final_Project | /test.py | 1,094 | 3.609375 | 4 | import networkx as nx
from functions.weighted_graph_drawings import draw_subtree
from functions.prims_functions import cost, min_prims_edges
G = nx.read_weighted_edgelist('data/G3.txt', nodetype = int)
def prims_algorithm(G, starting_node, draw = False, attrib = False):
T= nx.Graph()
T.add_node(starting... |
438d49e9b6cc36af660dd796584cbea9b3cc8e70 | pzar97/Trees-1 | /constructBinarytree.py | 969 | 3.71875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
"""
TC: O(2n*n) 2n for 'n' nodes
SC: O(depth*2n) depth --> recursive stack, 2n --> arrays
"""
... |
2da8531661f21ce84b762ff1ee3696a3a477e77c | poofcefnunsj/Unidad3POO | /clasePersonaHerenciaMultiple.py | 517 | 3.59375 | 4 | class Persona(object):
__dni=0
__apellido=''
__nombre=''
def __init__(self, dni, apellido, nombre, codigoCargo=0, agrupamiento=0,
catedra='', sueldo=0.0, fechaIngreso='', promedio=0.0, carrera=''):
self.__dni=dni
self.__apellido=apellido
self.__nombre=nom... |
17e837b78db9bc583003e58bac7391b424ed9dda | Megan-Houchin/Pendulum-Simulation | /Step 5/Simulation2.py | 3,304 | 3.875 | 4 | #Project 1 Part 5
#Numerical Simulation Model
#*****************************************
# YOUR NAME: Victoria Pontikes and Megan Houchin
# NUMBER OF HOURS TO COMPLETE: 2.5 hours
"""
Created on Sun Mar 22 14:03:04 2020
@author: Victoria
"""
#import statements
import numpy as np
import math
import matplotlib.pyplot as ... |
a08358f269f3148b13c7b2a0808cdcf59a449eca | AlyxMoon/Project-Euler-Solutions | /Python34/Problem19.py | 830 | 4.09375 | 4 | def getDayOfWeek(day, month, year):
# Use Gauss' method to determine day of week
'''
month is shifted by 2 (January is 11, December is 10, ect)
if month is January or February, year is shifted 1
'''
month = (month - 3) % 12 + 1
if month > 10: year -= 1
weekday = day % 7
weekday += (2.6 * month - 0.2) % 7
we... |
1bf31d944d5650e5c3c2bd35a75dbef782f24ec7 | ReDi-school-Berlin/lesson-6-exercises | /6-dictionaries/dictionaries.py | 1,298 | 4.5 | 4 | # What are some differences between dictionaries and lists?
# dict is not indexable
# lists are ordered and dictionaries aren't
# dictionaries cannot have duplicate keys
# --------------------
# How to create an empty dictionary
person = {}
# --------------------
# add values for this person, like name, phon... |
4943b18d6ec86b96a60b9813438f8ba23149eddd | BNuness/Lista-de-Exercicios-Atividade-01 | /Complementar/Ex 1 - Lista Comp.py | 179 | 4.03125 | 4 | nome = input('Digite o nome: ').upper()
invNome = nome[::-1]
print('O nome digitado de trás para frente e em letras maiusculas é: ')
print('{} ---> {}'.format(nome, invNome)) |
63e540fe871088626f39aaf12aa32768a39b060c | rubyspch/Python-Work | /pandas-practice/stat.pandas.py | 170 | 3.71875 | 4 | import numpy as np
import pandas as pd
X = pd.Series([3,5,6,7,2,3,4,9,4])
print(sum(X)) #prints sum of elements
print(X.mean()) #prints mean
print(X.max()) #prints max |
0697b26907d8e59da75a536b55e375205a615ab6 | rubyspch/Python-Work | /languages_function.py | 290 | 3.875 | 4 | def translate(lang):
if lang=="es":
return "Hola"
elif lang=="nl":
return "Hallo"
elif lang=="fr":
return "Bonjour"
else:
return "Hello"
uname= input("What is your name?")
ulang=input("What language do you speak?")
print(translate(ulang),uname)
|
62044f6241500eac89358ebc9f3953f96d75eb14 | davidzcondon/coder-dojo-basic-html | /python/tkcraft.py | 3,614 | 3.546875 | 4 | from tkinter import *
from dataclasses import dataclass
import logging
@dataclass
class Point:
x: int
y: int
def right(self, width):
return Point(self.x + width, self.y)
def left(self, width):
return Point(self.x - width, self.y)
def up(self, height):
return Point(self.x,... |
d55fac9146667bef4e37611766ec5274e328ae5a | rohinselva/pythonlite | /ADMIN.py | 9,580 | 3.734375 | 4 | import sqlite3
from tkinter import *
from tkinter import messagebox
def login():
username=input('Enter Admin Username : ')
password=input('Enter Password : ')
if username=='Admin' and password=='password':
print('Access Granted')
a=Admin()
a.start()
else :
print('Access ... |
9dc5d49761e60130666eb29c350de8612300e18e | Scimitarr/Python-scripts | /lab2.py | 1,630 | 4.125 | 4 | print("------------ZADANIE-1--------------------")
initialCapital = 20000
percent = 0.03
maxTimeYears = 10
year = 1
capital = initialCapital
while year <= maxTimeYears:
capital = capital * (1+percent)
print("Capital at the end of %d year is %d" % (year, capital))
year += 1
print("Through %d years ... |
1712db4b78fc0b13ba31206e2106c8c32f230267 | mossprescott/pynand | /project_04.py | 1,019 | 3.53125 | 4 | # Machine Language
#
# See https://www.nand2tetris.org/project04
# SOLVERS: remove this import to get started
from nand.solutions import solved_04
# SOLVERS: MULT_ASM and FILL_ASM should be a lists of strings, each one an assembly instruction.
#
# Multiplies R0 and R1 and stores the result in R2.
# (R0, R1, R2 refe... |
45058eeb42e7e32a78e1d62093b0ba9772bdef72 | tomdefeo/Self_Taught_Examples | /python_ex293.py | 853 | 3.671875 | 4 | # IMPORTANT. I recently changed this example in the book.
# I made changes so the example fits on smaller devices. If you have an older
# version of the book, you can email me at cory@theselftaughtprogrammer.io
# and I will send you the newest version. Thank you so much for purchasing my book!
import urllib.request
... |
ab6b55f6449daca29d836370a3d8108c2b1a1947 | tomdefeo/Self_Taught_Examples | /python_ex236.py | 726 | 3.8125 | 4 | # IMPORTANT. I changed many of the variable names in this example
# so the example fits on smaller devices. Old versions of the book have longer
# variable names. If you have an older
# version of the book, you can email me at cory@theselftaughtprogrammer.io
# and I will send you the newest version. Thank you so much ... |
9a27ab3cacd389a2bd69066a4241542185256072 | tomdefeo/Self_Taught_Examples | /python_ex284.py | 419 | 4.3125 | 4 | # I changed the variable in this example from
#
text in older versions of the book to t
# so the example fits on smaller devices. If you have an older
# version of the book, you can email me at cory@theselftaughtprogrammer.io
# and I will send you the newest version. Thank you so much for purchasing my book!
impor... |
9e0b1c48ac6e2cfbc4a56125a735d64ed3bc0608 | tomdefeo/Self_Taught_Examples | /python_ex212.py | 512 | 4.0625 | 4 | # I changed the variable in this example from
#
questions in older versions of the book to qs
# so the example fits on smaller devices. If you have an older
# version of the book, you can email me at cory@theselftaughtprogrammer.io
# and I will send you the newest version. Thank you so much for purchasing my book!
... |
5aa81536dc19812001ecbefd1082147fd859c307 | tomdefeo/Self_Taught_Examples | /python_ex269.py | 327 | 3.546875 | 4 | # parameter number in older editions of the book changed to n.
# Email cory@theselftaughtprogrammer.io for latest version
class AlwaysPositive:
def __init__(self, number):
self.n = number
def __add__(self, other):
return abs(self.n +
other.n)
x = AlwaysPositive(-20)
y = Al... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.