blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
9d3cacac13b4a1e3e8b6c7d113c88e330dd2719e | ForgottenK/python_work | /fourth_chapter/pizza.py | 675 | 4.40625 | 4 | pizzas = ['pepperoni', 'hawaiian', 'cheese', 'seafood', 'meat', 'vegetable']
for pizza in pizzas:
print('I like ' + pizza + ' pizza')
print('I really love pizza!')
print('The first three items in the list are:')
for pizza in pizzas[:3]:
print(pizza)
print('The items from the middle of the list are:')
for pizza in piz... |
a6294fb0c2530e3b209226db852c53d2a2d7542e | brad-h/expy | /ExPy/ExPy/module36.py | 2,003 | 4.34375 | 4 | """ Computing Statistic """
from math import sqrt
def mean(numbers):
"""Find the mean using an iterable of numbers
Return None if the iterable is empty
"""
if not numbers:
return None
total = 0
count = 0
for number in numbers:
total += number
count += 1
return t... |
5e1d39dfa0d3d7ae0947aa0cc59eaa8a2126f32e | sendurr/spring-grading | /submission - Homework3/set2/DANIEL M HARPER_11090_assignsubmission_file_homework3/homework3/P5b.py | 1,290 | 4.125 | 4 | # Author: Daniel Harper
# Assignment: Homework 3 - P5b.py
# Original Date: 2/23/2016
# Last Updated: 2/23/2016
# Written using Python 3.4.3.7
# All rights reserved
#####################################################################
# Importation Section################################################
#from math impo... |
f2506872f005e8ce10c79c224b847a089d115c2e | tompsherman/cspt19long | /department.py | 387 | 3.59375 | 4 | class department:
def __init__(self, name, products):
self.name = name
self.products = products
def __str__(self):
output = f"{self.name}\n"
if len(self.products) > 0:
for product in self.products:
output += f"\t{product}\n"
else:
... |
d6ed65465de73d51dde6d2fd1c72ca1e54c57cc1 | Esaaj/Competitive_programming_codes | /CodeForces/CodeForces_Fake_News.py | 327 | 3.828125 | 4 | input_list=list(input())
flag=0
for a in input_list:
if(a=='h' and flag==0):
flag=1
elif(a=='e' and flag==1):
flag=2
elif(a=='i' and flag==2):
flag=3
elif(a=='d' and flag==3):
flag=4
elif(a=='i' and flag==4):
flag=5
if(flag==5):
print("YES")
else:
prin... |
4198fea560865e0c6776d1ee6414f7ccbae51587 | margaretlclark3/Python | /infiniteloop_input_continue_break.py | 451 | 4.21875 | 4 | #create an infinite loop that takes input from user. If name is in ACCEPTED_NAMES, print name. Otherwise prompt to enter valid name. If user chooses to exit, print See Ya!
ACCEPTED_NAMES = ['bob', 'larry', 'george', 'anna']
def check_name():
while True:
name = input("Please enter a name or exit: ").lower()
if nam... |
0481eab7d22ffea1baa254407b02aba50b05eef8 | cah835/Intro-to-Programming-1284 | /Classwork Programs/cookierecipe.py | 293 | 3.8125 | 4 | c = float(input('How many cookies would you like to make? '))
s = c * .03215
b = c * .0208
f = c * .0573
sugar = ('Cups of sugar = ' + format(s, '.2f'))
butter = ('Cups of butter = '+ format(b, '.2f'))
flower = ('Cups of flower = ' + format(f, '.2f'))
print(sugar)
print(butter)
print(flower)
|
ca59cd7d30b3c739229e4a61823f9e73d7e57def | Aliriss/PYTHON | /graphwins.py | 1,248 | 4.25 | 4 | from graphics import *
def main():
# Introduction
print('This program plots the growth of a 10-year investment.')
#Get principal and interest rate
principal = float(input('Enter the initial principal:'))
apr = float(input ('Enter the annualized interest rate:'))
#Craet a graphics window with... |
a6cc4805b7ed3a5ecfb45aea2c3bb2e6b09837bf | ichisadashioko/learning_repo | /opencv/02_core-operations/basic-operations/access_modify.py | 685 | 3.734375 | 4 | import cv2
import numpy as np
img = cv2.imread('shiroha.png')
px = img[100,100]
print px
# accessing only blue pixel
blue = img[100,100,0]
print blue
# modify the pixel values
img[0,0] = [0,0,0]
'''
Warning: Numpy as a optimized library for fast array calculations. So simply accessing each and every pixel values an... |
78bbd8f9efb7a6d9add6c5eae9119b8763a59050 | junaid238/class_files | /python files/demo.py | 311 | 4.09375 | 4 | # a = 10 #class int
# b = 3 #class float
# print(a%b)
# print(type(a))
# print(type(b))
# print(a+b) #120.5
# print(a-b) #79.5
# print(a*b )#2050.0
# print(a/b )#5.4
# print(a//b )#5.0
# print(a%b)#
# print(a**b)# a power b
x = 100
y = 200
z = 100
print(x>y)
print(y>z)
print(x==z)
print(x!=y) # not equals
|
27e44c45c672fffde61592b95ba6b8272f44326e | sirakfilho/projetopython | /ProjetoAlinne.py | 3,407 | 4.09375 | 4 | def UsuarioComum():
e = 0
while e <= 0:
print("entrou no academico: ")
print(" \n\n------------------ Menu ---------------")
print(" 1 - Cadastrar no Sistema ")
print(" 2 - Logar no Sistema")
print(" 3 - Confirmar ou Negar presença em uma reunião")
print(" 4 ... |
61ff35e40920d5c82599ac1f27b207bb474f04c1 | tuxi/video-hub | /extra_apps/DjangoUeditor/utils.py | 3,751 | 3.6875 | 4 | # coding: utf-8
# 文件大小类
class FileSize():
SIZE_UNIT = {
"Byte": 1,
"KB": 1024,
"MB": 1048576,
"GB": 1073741824,
"TB": 1099511627776
}
def __init__(self, size):
self._size = FileSize.Format(size)
@staticmethod
def Format(size):
import re
... |
a4d62113a606f1e6904c9e855cab440f40530622 | Sri-Vadlamani/Problems-Vs-Algorithms | /Problem_6.py | 669 | 4.09375 | 4 | def get_min_max(ints):
"""Return a tuple(min, max) out of list of unsorted integers.
Args:
ints(list): list of integers containing one or more integers
"""
if not ints:
return
max = ints[0]
min = ints[0]
for i in ints:
if i > max:
max = i
if i < min:
min = i
... |
400ad2904d759bc41a443aa811a87dd4c1a9cb5c | sunnysunny061/python-programs | /leap_year.py | 310 | 3.984375 | 4 | def leap_year(x):
if (x%4==0):
if(x%100==0):
if(x%400==0):
print('yes leap year')
else:
print('not a leap year')
else:
print('leap year')
else:
print('not a leap year')
x=int(input())
leap_year(x) |
edc06db14c7d42569a4446f679c840a488a8b52a | DanilWH/Python | /python_learning/chapter_09/m_homework_library_python.py | 1,746 | 3.859375 | 4 | from collections import OrderedDict
golossariy = OrderedDict()
golossariy['concatenation'] = 'line break'
golossariy['variable'] = 'place of memory'
golossariy['list'] = 'itemset'
golossariy['if'] = 'condition'
golossariy['tuples'] = 'an immutable list'
golossariy['dictionary'] = 'the creation of real objects'... |
917c34497b54c596c01e95468355290254e3956b | SaloniSaini02/Challenge | /challenge1/Flask-App.py | 1,692 | 3.59375 | 4 | #import packages
from flask import Flask
from flask import *
import pandas as pd
# Create Flask App
app = Flask(__name__)
# Create url routes
@app.route("/Titanic")
def function1():
""" Method reads the titanic dataset to a dataframe.The first half is stored in the first output(csv) file. The columns in the seco... |
953ed440d979b8d630b868bcbd004315bb14e26e | merrittd42/HackerRankCode | /PythonTut/Intro/ex6.py | 65 | 3.609375 | 4 | N = int(input())
x = 0
while(x<N):
print(x*x)
x = x + 1
|
8861eb718457af2881c8ca20632bfffcbf679512 | jmast02/PythonCrashCourse | /restaurant.py | 863 | 3.78125 | 4 | class Restaurants():
def __init__(self, restaurant_name, cuisine_type):
# initialize restaurant and cuisine attributes
self.restaurant = restaurant_name
self.cuisine = cuisine_type
def describe_restaurant(self):
print(f"{self.restaurant.title()} serves {self.cuisine.title()} foo... |
dbf890ce9deadadc29112cd46e24c6bb54af0922 | Venkataraman-Nagarajan/DAA- | /EX4/Inversions_v1.py | 661 | 3.671875 | 4 | def inversion_count(a):
count=0
for i in range(len(a)-1):
for j in range(i,len(a)):
if(a[i]>a[j]):
count+=1
return count
print("Enter the array elements : ",end="")
a=[int(x) for x in input().split()]
print()
print(a,end=" ")
print(" :",end="")
print(inversion_count(a))
"""
venky@venky-Inspiron-5570:~/D... |
44213bafe081b69d879a3208cccc5278e291a650 | LeqitSebi/sew4_sem1_python | /ue01_Bruch/Fraction.py | 5,175 | 3.984375 | 4 | # @author Sebastian Slanitsch, 4CN
from functools import total_ordering
@total_ordering
class Fraction:
"""
>>> Fraction.gcd(17, 21)
1
>>> Fraction.gcd(21, 7)
7
>>> Fraction.gcd(-1, 1)
1
>>> f1 = Fraction(1, 2)
>>> f1 # __repr__
Fraction(1, 2)
>>> print(f1) # __str__
1... |
a96d052bd515abb8cd270034147dab8246e349dd | DanGBat/mancDictionary | /mancDictionary.py | 3,725 | 3.96875 | 4 | dictionary = {
"Ave it": "Exclamation",
"Bobbins": "Nonsense",
"Brew": "Tea",
"Butty": "Sandwich",
"Buzzin": "Excited / Extreme Happiness",
"Cadge": "Freeload / Scrounge / Get Something Free",
"Chuddy": "Chewing Gum",
"Chuffed": "Happy",
"Do One": ... |
f5a87ae84cf16df45248e511c0eaa2eb3d809cfe | fransHalason/IndonesiaAI | /Basic Python/Part 7 - Python Advanced Topics/tuples.py | 252 | 3.71875 | 4 | '''
PYTHON: TUPLES
A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets.
'''
# Create a Tuple
thistuple = ("apple", "banana", "cherry")
print(thistuple)
# Access Tuple Items
print(thistuple[1])
|
0963940e0e0e87b073b77af8124d055dbd3fb93e | Kevinliaoo/Sorting-Algorithms-Visualizer | /widgets/spinner.py | 1,699 | 3.640625 | 4 | from widgets.button import Button
class Spinner (Button):
def __init__ (self, x, y, width, height, color, text, *args):
"""
:param *args: list or tuple
"""
Button.__init__ (self, x, y, width, height, color, text)
self.subButtons = []
self.showChilds = False
pos = 0
for btn in args[0]:
# Chang... |
cd968c7839d5923588b9266b94f9f9c90fe14894 | DanielZuerrer/AdventOfCode2018 | /1_2/solution.py | 457 | 3.75 | 4 | with open('input.txt') as input:
frequencyChanges = input.readlines()
frequencyChanges = [int(change.strip()) for change in frequencyChanges]
frequency = 0
knownFrequencies = {frequency}
searching = True
while searching:
for frequencyChange in frequencyChanges:
frequency += frequencyChange
if... |
79f92d0901770a3a7816d4db1284dd031163e2c3 | KratiAnu/LinearRegression | /MultipleRegression.py | 741 | 3.59375 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
data = pd.read_csv("C:/Users/Anu/Desktop/Advertising.csv.txt")
data.drop(['Unnamed : 0'], axis=1)
plt.figure(figsize=(16,8))
plt.scatter(
data['T... |
59633532405ba208fcc4d2392374351081095cbe | RomaTk/longNumber-operations | /longArithmetic/multiplication.py | 3,775 | 4.375 | 4 | from . import general
from . import summary
def multiplication(number1="0",number2="0"):
"""
This function multiplies numbers as float or int inputed as strings
multiplication(number1="0",number2="0")
arguments:
"number1":
type: string
"number2":
type: string
"""
result="0";
if (type(number1) is str)and(typ... |
cc1eed0c2752e81a015a7ffb2e43bf309432fb99 | AleByron/AleByron-The-Python-Workbook-second-edition | /Chap-2/ex42.py | 545 | 3.953125 | 4 | note = str(input('Insert a note:'))
ch = note[0]
n = note[1]
n = int(n)
if ch == 'C':
f = 261.63
f = f/(2**(4-n))
elif ch == 'D':
f = 293.66
f = f / (2 ** (4 - n))
elif ch == 'E':
f = 329.63
f = f / (2 ** (4 - n))
elif ch == 'F':
f = 349.23
f = f / (2 ** (4 - n))
elif ch ... |
a4a021329d50a448b0d1aa0562bde2cade5b4d36 | Keshav1506/competitive_programming | /Bit_Magic/019_EPI_Primitive_Multiply/Solution.py | 5,472 | 3.75 | 4 | #
# Time :
# Space :
#
# @tag : Bit Magic
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# EPI ( Elements Of Programming Interviews - Adnan Aziz ) : Primitive Multiply
#
# Description:
#
# Write a program that multiplies two non-negative int... |
ecbf7cdeca37a9fc800dbd674a92f5d9ae02ea95 | lilyandcy/python3 | /leetcode/mySqrt.py | 406 | 3.515625 | 4 | class Solution:
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
if x == 0:
return 0
l = 1
r = x
while l <= x:
num = (l + r) // 2
s = num **2
if s <= x < (num+1) **2:
return num
... |
3f33d2dd92ce920720df0d612454a94388867a0b | electricman991/cse210-student-hilo | /hilo/game/player.py | 623 | 3.734375 | 4 | class Player:
"""A code template for a person who guesses high or low. The responsibility of this
class of objects is to say high or low, keep track of the values, the score, and
determine whether or not it can throw again."""
def __init__(self):
self.points = 300
def get_points(self, was... |
1fc97f7b84a76f919529f389987e25f178c36bf2 | muokicaleb/Hacker_rank_python | /itertools/itertools_product.py | 767 | 4.28125 | 4 | """
You are given a two lists A and B. Your task is to compute their cartesian product AXB.
Example
A = [1, 2]
B = [3, 4]
AxB = [(1, 3), (1, 4), (2, 3), (2, 4)]
Note: A and B are sorted lists, and the cartesian product's tuples should be output in sorted order.
Input Format
The first line contains the space separa... |
fa8d7b677b1de852a65321b2eb9bd67fc5166ef6 | ilove52345234/while2 | /while2.py | 265 | 3.96875 | 4 | x = 3
pwd = 'a123456'
while x > 0:
password = input('請輸入密碼: ')
x = x - 1
if password == pwd:
print('登入成功')
break
else:
print('密碼錯誤')
if x > 0:
print('還有', x, '次機會')
else:
print('請聯絡客服人員!')
|
67e36de40909ec2527413d89351e933dbf524ab1 | AbhayPotabatti/Industrial-training | /forloop.py | 85 | 3.578125 | 4 | list = [1,2,3,4,5,6,7,8,9,10]
n = 5
for i in list:
c = n*i
print(c) |
384025db1f834ec77b432433eb499510d2b1a3fa | Andi-FB/Investigando-Python | /08_Guessing game & 11_Functions.py | 1,307 | 3.953125 | 4 | import random
random_number = random.randint(0, 10)
def validate_in():
input_ok = False
while not input_ok:
user_in = input("Try a number from 0 to 10")
if user_in.isnumeric():
return user_in
def play():
number_of_tries = 0
while number_of_tries < 3:
user_in = va... |
16256b544712a0d31400deb614cc9d69bd0839fb | wotanCode/4GA-Learn-Python-Loops-and-lists-Interactively | /exercises/08.2-Divide_and_conquer/app.py | 442 | 3.6875 | 4 | list_of_numbers = [4, 80, 85, 59, 37,25, 5, 64, 66, 81,20, 64, 41, 22, 76,76, 55, 96, 2, 68]
#Your code here:
def merge_two_list(arreglo):
odd = []
even = []
comb = []
for x in range(len(arreglo)):
if arreglo[x]%2!=0:
odd.append(arreglo[x])
elif arreglo[x]%2==0:
... |
e7086c914bb50eaa7e08f9c04952e16ccde7eb4b | robertcrowe-zz/OpenCV-Notes | /Shape_Detect/Contours/template_matching.py | 2,328 | 3.578125 | 4 | import cv2
import numpy as np
import os.path
"""
cv2.matchShapes(contour template, contour, method, method parameter)
Output – match value (lower values means a closer match)
Contour Template – This is our reference contour that we’re trying to find in the new image
Contour – The individual contour we are checking ag... |
496b942d9a1d3f9def09029cc5b42affd3f20482 | atasky/Python-data-structures-and-algorithms | /pair_sum.py | 611 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 26 20:24:37 2018
@author: Vaidehee
"""
# input
# arr=[1,2,3,4] k=5
# output -
# {(2,3),(1,4)}
#input
#arr = [1,2,3] k=3
#output -
# {(1,2)}
def pair_array(arr, k):
if len(arr)<2:
return
seen=set()
output=set()
... |
3eeaf60faf654b987baa7c6e74c0d70d5338d9f4 | here0009/LeetCode | /Python/MissingNumber.py | 1,132 | 4 | 4 | """
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.
Example 1:
Input: [3,0,1]
Output: 2
Example 2:
Input: [9,6,4,2,3,5,7,0,1]
Output: 8
Note:
Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra ... |
500aecbb9e4f04ae672eb46407012b1e7cea4d1f | sumalemambo/IWI-131-Programacion-de-computadores-USM | /Certamen 1/2019/Problema 2.py | 1,984 | 3.515625 | 4 | ################################################################
# Certamen 1 2019 Nombre: Ignacio Quintana ROL:201973610-8 #
# Mail: ignacio.quintana@usm.cl #
################################################################
###########################################################... |
d1effd84ed1541efa677a1285c2c95dc479e37fb | bwasicki/Github-Stuff | /BenWikiSearch/new project.py | 1,935 | 3.609375 | 4 | import time
import wikipedia
import xlsxwriter
from bs4 import BeautifulSoup
excel = xlsxwriter.Workbook('doc1.xlsx')
sheet = excel.add_worksheet()
wikipage = wikipedia.WikipediaPage('British Empire')
wikipages = list()
titles = list()
words = list()
nums = list()
def search():
page_title = ''
while page_ti... |
691be557fb9427678ddb5c7260374032b78b7545 | Programmer-Admin/binarysearch-editorials | /Trailing Zeros.py | 1,559 | 4.21875 | 4 | """
Trailing Zeros
The key insight to the types of problem asking for the trailing number of zeroes is the following.
The number of trailing zeroes is the number of times 10 can divide a number. The number of tens in a number can be found by doing its prime factorization: each ten is composed of prime factors 2 and 5... |
963ba197be2bd9fcaddab31f91dde54e985e6834 | hellodk/dumpyard | /hacker_rank/sock_merchant/sock_merchant.py | 446 | 3.5 | 4 | #!/bin/python3
def sockMerchant(n, ar):
di = {i: ar.count(i) for i in ar}
count = 0
for elem in di.values():
count = count + int(elem // 2)
return count
if __name__ == '__main__':
# fptr = open(os.environ['OUTPUT_PATH'], 'w')
# n = int(input())
n = 9
# ar = list(map(int, inp... |
383d63a82de30f33eed7aa149c326f7419cdb312 | GongFuXiong/leetcode | /topic12_backtrack/T131_partition/interview.py | 1,343 | 3.515625 | 4 | '''
131. 分割回文串
给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。
返回 s 所有可能的分割方案。
示例:
输入: "aab"
输出:
[
["aa","b"],
["a","a","b"]
]
'''
# from T_HeapSort.Heap import MaxHeap,MinHeap
class Solution:
# 回溯法
def partition(self, s):
s_len = len(s)
res = []
if s_len ==... |
e053922e4bcc83f7a9d227dfde9086b5b6448081 | bishii/QA_Scripts | /IoT/RaspberryPi/messing_around/Chapter1_Frozen_Working/counting.py | 2,021 | 3.578125 | 4 | import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
segments=(6,3,0,4,11,9,10,22)
led=17
for segment in segments:
print(segment)
GPIO.setup(segment, GPIO.OUT)
GPIO.output(segment, GPIO.LOW)
GPIO.setup(led, GPIO.OUT)
GPIO.output(led,GPIO.LOW)
GPIO.setup(26, GPIO.OUT)
GPIO.output(26,GPIO.LOW)
GPI... |
6a22eb7599cabf17db774428cda83352f6b55cca | julie98/Python-Crash-Course | /chapter_5/user_name_check.py | 356 | 3.84375 | 4 | current_users = ['admin', 'Julie', 'Angela', 'Eric', 'Karolina']
new_users = ['Gisele', 'Angela', 'Eugenia', 'Kate', 'John', 'eric']
current_users_lower = [user.lower() for user in current_users]
for new_user in new_users:
if new_user.lower() in current_users_lower:
print("This name has been taken!")
else:
pri... |
98317742cf0a6bcee89b1367f3c9d0ca80ac5123 | Kwasniok/ProjectEuler-Solver | /src/problem_012.py | 1,690 | 3.90625 | 4 | # coding=UTF_8
#
# problem_012.py
# ProjectEuler
#
# This file was created by Jens Kwasniok on 15.08.16.
# Copyright (c) 2016 Jens Kwasniok. All rights reserved.
#
from problem_000 import *
from ppe_math import number_of_divisors, list_of_divisors
class Problem_012(Problem):
def __init__(self):
... |
2f8ea48be807266dc0d42e5d762c0e1da75eda43 | Steuerwr/99-CapstoneProject-201930 | /src/m1_laptop_code.py | 3,605 | 3.96875 | 4 | """
Capstone Project. Code to run on a LAPTOP (NOT the robot).
Displays the Graphical User Interface (GUI) and communicates with the robot.
Authors: Your professors (for the framework)
and Will Steuerwald.
Spring term, 2018-2019.
"""
# Done 1: Put your name in the above.
import tkinter
from tkinter imp... |
7a7f8681a4c7b2acd275a605657e6cd3ba42319a | gonjay/leetcode | /problems/reverse-integer/path-sum/Solution.py | 1,065 | 3.71875 | 4 | # Definition for a binary tree node
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
arr = []
hasPath = False
# @param root, a tree node
# @param sum, an integer
# @return a boolean
def hasPathSum(self, root, sum... |
1a5d6a123c0740fb59ac1f89ac5db01104906908 | girishgupta211/algorithms | /python/multi_processing.py | 1,522 | 4 | 4 | # importing the multiprocessing module
import multiprocessing
import os
def cube(x):
print("Worker process id for {0}: {1}".format(x, os.getpid()))
return x ** 3
pool = multiprocessing.Pool(processes=4)
# results = [pool.apply(cube, args=(x,)) for x in range(1, 7)]
nums = [x for x in range(1, 7)]
results = ... |
c3c68b21fb3c6bdec5d21c9284898b857972cf73 | niteshsrivats/Labs | /5th Semester/Python/Sixth Lab/WordSplitter.py | 760 | 3.703125 | 4 | import math
def clean(list):
for i in range(len(list)):
list[i] = list[i].replace(" ", "").replace("\n", "")[
: math.ceil(len(list[i]) / 2)]
return list
def merge(list1, list2):
len1 = len(list1)
len2 = len(list2)
string = ""
for i in range(len1):
string += list1... |
edd7f5d0ef81a36d480a103ab1ff0b6cf6bb784e | EPCJC-LP10/02 | /Modulo9/projeto_new_/menu.py | 1,311 | 3.828125 | 4 | # -*- coding: utf-8 -*-
def principal():
print
print " +----------MENU--------+"
print " | |"
print " | 1. Gestão de Alunos |"
print " | 2. Salas / Horários |"
print " | 3. Registar Presença |"
print " | 4. Ver todas as presenças |"
print " +-----------------... |
eaa7385c8ddc75d4ef9cc684fb51cdcfcf58c1ea | victoruribehdz/programing-2 | /Python/Exercise_26.py | 3,694 | 4.375 | 4 | def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')
return words
def sort_words(words):
"""Sorts the words."""
return sorted(words)
def print_first_word(words): ## ":" Missing
#def print_first_word(words)
"""Prints the first word after po... |
9c971ee47bc7f4b1c10cb56e08a36ba48300371f | yiicao/final_project | /week 7/Authentication&CachingCodes/PersistCache.py | 1,737 | 3.71875 | 4 | import datetime
import json
CACHE_FILENAME = "cache.json"
def open_cache():
''' opens the cache file if it exists and loads the JSON into
a dictionary, which it then returns.
if the cache file doesn't exist, creates a new cache dictionary
Parameters
----------
None
Returns
-------
... |
12ec31232f018323b9777fb3148d06744e5546b2 | identor/code | /python/point_circle.py | 782 | 4.34375 | 4 | import turtle
import math
cx, cy = eval(input("Enter the center of a circle x, y: "))
radius = eval(input("Enter the radius of the circle: "))
x, y = eval(input("Enter a point x, y: "))
distance = math.sqrt(((x - cx) ** 2) + ((y - cy) ** 2))
inside = radius >= distance
# Draw the circle & the point
turt... |
78be22b581b4d7080b49749f7a6111f976ea6df8 | fztest/Classified | /2.Binary_Search/2.14_459_Closest_Number_In_Sorted_Array.py | 1,191 | 3.9375 | 4 | """
Description
__________
Given a target number and an integer array
A sorted in ascending order, find the index i in A
such that A[i] is closest to the given target.
Return -1 if there is no element in the array.
Example
________
Given [1, 2, 3] and target = 2, return 1.
Given [1, 4, 6] and target = 3, return 1.
Giv... |
1d40bdf15538d428f94f2a1fe75924ce48b1774f | boknowswiki/mytraning | /lintcode/python/0486_merge_k_sorted_array.py | 2,010 | 3.921875 | 4 | #!/usr/bin/python -t
# heap
# 使用 Heapq 的方法
# 最快,因为不需要创建额外空间。
# 时间复杂度和其他的算法一致,都是
# O(NlogK) N 是所有元素个数
import heapq
class Solution:
"""
@param arrays: k sorted integer arrays
@return: a sorted array
"""
def mergekSortedArrays(self, arrays):
# write your code here
ret = []
... |
5d93d1776d12f9f32f9184f595ff3ba192926fc7 | jmast02/PY4E_exercises | /EX_8.5.py | 767 | 4.28125 | 4 | '''8.5 Open the file mbox-short.txt and read it line by line. When you find a line that starts with 'From ' like the following line:
From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008
You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who se... |
54454034924ca8405acf7db2baa75ea50e382b32 | PrestonFawcett/Snake_Game | /highscore.py | 700 | 3.8125 | 4 | #!/usr/bin/env python3
""" File keeps track of score board and saves to pickle file """
import pickle
__author__ = 'Preston Fawcett'
__email__ = 'ptfawcett@csu.fullerton.edu'
__maintainer__ = 'PrestonFawcett'
def write(score):
""" Save top 5 scores to a list """
high_score = list()
high_score = list(read... |
8e8cfda7d8249e5ec0c43978b0c6370ba6528489 | navaniharsh31/blackjack-python | /blackjack.py | 3,456 | 3.90625 | 4 | #!/usr/bin/env python
import random
import sys
print("--------------------")
print(" BLACKJACK ")
print("--------------------")
print()
while True:
player_cards = []
dealer_cards = []
while len(dealer_cards) != 2:
dealer_cards.append(random.randint(1, 10))
if len(dealer_cards) == 2... |
7d0551d01440dc5cc351c2484936d09907197f45 | moyalopez/Python3 | /programa de notas.py | 769 | 3.53125 | 4 | #jairmoya
opcion = int(input("1.promedio de 4 notas\n2.division\n3.Salir\nIngrese su opcion:."))
promedio = 0
while opcion != 3:
if opcion == 1:
for i in range (4):
nota = int(input("ingrese primera nota"))
promedio = promedio + nota
div = int(promedio) / int(4)... |
d94abaf1e4bd24c870ef428c3a906eab95c8b8d5 | xuteng0220/python | /python_full_stack_s22/hw03.py | 11,008 | 3.609375 | 4 | ### 1.将今天的课上代码敲一遍,然后整理笔记
# a = 156
# # 二进制数
# print(bin(a))
# print(int('10011100', 2))
# name = 'absdefghijklmnopqrstuvwxyz'
# print(name[-2:])
# print(name[0:3:2])
# print(name[-2::-2])
# b = 'alex'
# print(b.upper())
# print(b)
# c = 'WUSIR'
# c = c.lower()
# print(c)
# d = 'asdf'
# print(d.startsw... |
111db966ce892f7711957ecba7e0c7c34c249708 | Vivek-M416/Basics | /Array/array6.py | 185 | 3.609375 | 4 | # slicing
from array import *
x = array('i', [10, 20, 30, 40, 50, 60, 70])
y = x[1:4]
print(y)
y = x[:4]
print(y)
y = x[-4:]
print(y)
y = x[-4: -1]
print(y)
y = x[0:7:2]
print(y)
|
7e60f4f89bac680fe3dbd98188ab869403d8feb9 | dbms-ops/learn_python_3 | /1_learn_python_3/3-数字日期和时间/12-基本的日期与时间转换.py | 980 | 3.53125 | 4 | #!/data1/Python-2.7.4/bin/python2.7
# -*-coding:utf-8-*-
# time: 2020-04-04 16:44
# user: lixun
# filename: 基本的日期与时间转换
# description: 执行简单的时间转换,天到秒,小时到分钟的转换
#
from datetime import timedelta
from datetime import datetime
def detetime_change():
a = timedelta(days=2, hours=6)
b = timedelta(hours=4.5)
c = ... |
05e6c34510a23ccd50bc3ffbc42eb964e4810179 | athinaangelica/Python-Programming-Exercises | /StrukDis_TuTam_1.py | 1,133 | 4.09375 | 4 | def adjacency_matrix(nodes, vertices):
adj_mtx = []
for a in nodes: #for every element in list nodes
adj_row = [] #create empty list
for b in nodes: #for every element in list nodes
if (a,b) in vertices or (b,a) in vertices: #if (a,b) or (b,a) is in list vertices
adj_row.append(1) #add 1 to empty l... |
af9e5910cbf58985eb3636120fd119ce6e507a09 | pkdism/leetcode | /july-leetcoding-challenge/d11-subsets.py | 510 | 3.515625 | 4 | """
Given a set of distinct integers, nums, return all possible subsets (the power set).
"""
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
n = len(nums)
ps = []
for binary in range(2**n):
temp = binary
val = []
pos = n-1
... |
d11603c5cdb65edf10c54cdb5fdd1e0877d5debf | tooskaocr/ocr-evaluation | /SpaceAlignment/SpaceAligner.py | 3,427 | 3.625 | 4 | import re
import argparse
from enum import Enum
class MatchCase(Enum):
""" Indicates match cases for LCS algorithm. """
NONE = 0
TARGET = 1
RETRIEVED = 2
BOTH = 3 # current characters match
SPACE = 4
def alignFiles(targetPath, retrievedPath, outputPath):
"""
Scans two input files l... |
5ba21575835c13f037861c23eb09bc95573161ea | ranfysvalle02/e2e-game-offers | /data_generators/initial/e2e_training_data_generator.py | 4,401 | 3.796875 | 4 | # importing the necessary libraries. Install sklearn, pandas and numpy first if you don't already have them
from sklearn.datasets import make_classification
import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
# In[ ]:
'''
Creating the dataset - a dataframe as "X" with all the data... |
438554eee5446338e28ca25fb14f17ff74556b88 | najuzilu/ucsd_algorithms | /Algorithmic_Toolbox/week3/assignment/6_maximum_number_of_prizes/different_summands.py | 462 | 3.5 | 4 | # Uses python3
import sys
import math
def optimal_summands(n):
summands = []
k = int(-1/2 + math.sqrt(1/4 + 2 * n))
if k == 1:
summands.append(n)
return summands
for each in range(1, k):
summands.append(each)
last_item = n - sum(summands)
summands.append(last_item)
return summands
if __name__ == '__mai... |
edcab377fe47ccda40631e5c4a906446972c0ca3 | nicowjy/practice | /Leetcode/101对称二叉树.py | 753 | 4.15625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# 对称二叉树
# 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 isSymmetric(self, root):
"""
:type root: TreeNode
... |
8f3edd19079d0850590a054361ac1a68ff058bd6 | onewns/TIL | /algorithm/leetcode/LinkedList/0024_SwapNodesInPairs.py | 1,369 | 3.578125 | 4 | class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def swapPairs(self, head: ListNode) -> ListNode:
# my style (new ListNode) 24ms 14.2MB
ans = h = ListNode()while head:
if head.next:
n1 = head.val
... |
417e153bb8a8453850d066442cde6788a2f1f7fa | constantlearning/uri-exercises-resolution | /01-INICIANTE/Python/1041.py | 336 | 3.796875 | 4 | # -*- coding:utf-8 -*-
numbers = map(float, input().split(" "))
x,y = numbers
if x == y == 0:
print("Origem")
elif x == 0:
print("Eixo X")
elif y == 0:
print("Eixo Y")
elif x > 0 and y > 0:
print("Q1" )
elif x < 0 and y > 0:
print("Q2")
elif x < 0 and y < 0:
print("Q3")
elif x > 0 and y < 0:
... |
5ba07b80011d04651b50ce1ef87d3157a4728636 | KOOKDONGHUN/trading | /python/005study_class4.py | 1,077 | 4.09375 | 4 | class Myclass:
def __init__(self): # 생성자 // 객체의 생성과 동시에 자동으로 호출되는 메서드이다 // initialize의 약어 (초기화하다)
print('create object!!')
inst1 = Myclass() # create object!!
name = 'kookdonghun'
email = 'dh3978@naver.com'
addr = 'Ilsan'
class BusinessCard:
def __init__(self, name, email, addr): # self를 쓰는 이유 일... |
619dd7ccb2600d2ca70eb6853c567bc67760d623 | joelper/MS-E346 | /modules/Option.py | 5,181 | 3.546875 | 4 | from typing import NamedTuple, Union
import numpy as np
class Option(NamedTuple):
call: bool # true if call option, false if put
american: bool # true if american option, false if european
S: float # underlying asset price
K: float # strike price
sigma: float # standard deviation of the return for ... |
3a8734c244cf83dee4183302c266cc0d68840261 | JAntonioMarin/restApisFlaskPython | /Section2/46.py | 734 | 3.765625 | 4 | def divide(dividend, divisor):
if divisor == 0:
raise ZeroDivisionError("Divisor cannot be 0.")
return dividend / divisor
def calculate(*values, operator):
return operator(*values)
result = calculate(20, 4, operator=divide)
print(result)
def search(sequence, expected, finder):
for elem in s... |
407113cb641bdd06d33a7adf768ab2dfa3ffb91f | WeiKunChina/CodingInterviews-Practice | /python/12.exist.py | 1,713 | 3.5 | 4 | class Solution(object):
# 定义上下左右四个行走方向
directs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
def exist(self, board, word):
"""
题目可以模拟为 DFS 的过程,即从一个方向搜索到底,再回溯上一个节点,沿另一个方向继续搜索,递归进行。
在搜索过程中,若遇到该路径不可能与目标字符串匹配的情况,执行剪枝,立即返回。
时间复杂度:O(3^k IJ)。 一次搜索完全部矩阵的时间复杂度为 O(IJ) ,共需要 3^ 次搜索。
空间复... |
38779fecf3d154f544b4e8785217f50948b7ed3d | msaitejareddy/Python-programs | /sep13/list.py | 175 | 3.671875 | 4 | list1=[1,2,3,4,5]
print(list1)
list2=['a','bc','def']
print(list2)
list3=['sai','[s,d,f,g]']
print(list3)
print(len(list1))
print(list2[2])
print(list2[2:])
print(list3[1]) |
398192f38525ab79e98fc1918b0a6a36a88857a1 | enderquestral/Reed-CSCI121 | /distance.py | 251 | 3.53125 | 4 | locx = float(input("Location x-coordinate? "))
locy = float(input("Location y-coordinate? "))
classx = float(input("Classroom x-coordinate? "))
classy = float(input("Classroom y-coordinate? "))
print( (((classx-locx)**2) + (classy - locy)**2) **0.5 ) |
f47a52a2d5ea15bf236f85ccbbd532ef97a19a53 | ReillyNelson/Python-Practice | /FizzBuzz_Test.py | 247 | 3.890625 | 4 | __author__ = 'Reilly'
x=range(1,101)
for number in x:
if number%3==0 and number%5==0:
print ("FizzBuzz")
elif number%3==0:
print("Fizz")
elif number%5==0:
print("Buzz")
elif number:
print (number)
|
e2493bdb93e8e3f8fef5cd91cfecd1f299cdf6f9 | Johnqiu123/PythonHighSkill | /PythonSkill/ObjectIterative2.py | 840 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 25 13:17:55 2017
@author: Administrator
问题:如何使用生成器函数构造可迭代对象?
将该类的__iter__方法实现生成器函数,每次yield返回一个值
"""
class PrimeNumbers:
def __init__(self, start, end):
self.start = start
self.end = end
def isPrimeNum(self, k):
"""judge a num whe... |
7f8e6b9b244ac7603036697b1ee96967c94e1ba4 | adamslab-ub/SCoPP | /environments.py | 29,890 | 3.671875 | 4 | """This code contains environment parameters to be loaded for use by the SCoPP algorithm. New classes should be created
and stored here for any new environments that the user wishes to use the algorithm on. Simply copy and paste one of the
environments below and alter the values to your liking. Each class follows the... |
cf0adeae78e423cad26d5ed0a24d6ac62e439ecf | boknowswiki/mytraning | /lc/python/2095_delete_the_middle_node_of_a_linked_list.py | 708 | 3.6875 | 4 | # linked list
# time O(n)
# space O(1)
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def deleteMiddle(self, head: Optional[ListNode]) -> Optional[ListNode]:
l = self.get_len(head)
... |
ee59e48191c2db6c26eda3f945a5416468a9d3b3 | wegar-2/number_theory_python | /tools/chinese_remainder_theorem.py | 1,774 | 3.796875 | 4 | import euclid_algorithm as ea
def crt_find_number_two_modules(n1, r1, n2, r2):
"""
Given two moduli n1, n2 that are relatively prime and given the remainders for these moduli, respectively, r1 and r2
this function finds a natural number in between 0 and (n1*n2 - 1) that is congruent to r1 modulo n1 and r2... |
efb48047a3f4cc3cd09606926750d5af94700a94 | jaeehooon/baekjoon_python | /단계별로 풀어보기/9. 수학 2/[1978] 소수 찾기.py | 469 | 3.625 | 4 | import sys
def find_decimal(num):
cnt = 0
for i in range(1, num+1):
if num % i == 0:
cnt += 1
if cnt > 2:
return False
else:
return True
if __name__ == "__main__":
num = int(sys.stdin.readline().rstrip("\n"))
num_list = list(map(int, sys.stdin.readline().r... |
03f015eb17db832cb6be4b9ab4743f872c38f709 | JakeRivett31/Year9DesignPythonJR | /Unit 1 Project/SleepCalc2.py | 979 | 3.515625 | 4 | from tkinter import *
import tkinter as tk
root = tk.Tk()
root.title("Sleep Calculator")
root.geometry("600x450")
root.configure(bg="#001245")
nameQuestion = tk.Label(root, text="What is your name?", font = ('Avenir',15), bg="#001245", fg="#0068f0").grid(row=0, padx=(80, 50))
e1 = Entry(root)
e1.grid(row=0, colu... |
9067bb04f141ad48133d8ff8cebc06274845b76d | byxm/learn-python | /function/basic-concept/f5.py | 291 | 3.5 | 4 | # 默认参数
def personInfo(name, age, sex, school, lessons = '数理化'):
print(name + str(age) + sex + school + lessons)
personInfo('席梦', 22, '男', '希望小学', '语数外')
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
personInfo('simone', 17, '男', '希望小学')
|
9dafd57b71478ad0b546efb8cb3266ff7d279d27 | farhanpro/Python_Workshop | /functions/Fahrenheit_converter.py | 189 | 4.15625 | 4 | def fahrenheit(fahrenheit = int(input("Enter the Temprature in Fahrenheit : "))):
return print("The temprature when converted into Celsius will be :",(fahrenheit-32)*5/9)
fahrenheit() |
815b41ef0803117c0515ff0b7c080bed63dbd1eb | Aasthaengg/IBMdataset | /Python_codes/p02265/s861967074.py | 416 | 3.53125 | 4 | from collections import deque
n = int(input())
output = deque()
for i in range(n):
li = input().split(' ')
if(li[0] == 'insert'):
output.appendleft(li[1])
elif(li[0] == 'deleteFirst'):
output.popleft()
elif(li[0] == 'deleteLast'):
output.pop()
elif(li[0] == 'delete'):
... |
7dbd3cf2752f03d1ca54e729fc3dd349ac3dc0b0 | Par1Na/Interview-Question | /9.py | 288 | 3.96875 | 4 | # Interview-Question
size = int(input("Enter the size of List: "))
List = []
for i in range(size):
List.append(int(input("Enter the element " +
str(i + 1) + " in the List: ")))
k = int(input("Enter the value of K: "))
print(sorted(List)[k-1])
|
a89bf48b546c6bae69103e0c578c26aa5fbbacec | frclasso/turma1_Python3_2018 | /cap09/exercicios/exercicio_9_31.py | 353 | 3.640625 | 4 | #!/usr/bin/env python3
"""Criem um programa que corrija o da listagem 9.20 de forma a
verificar se “z” existe e é um diretório.
"""
import os.path
if os.path.isdir("z"):
print("O diretório z existe.")
elif os.path.isfile("z"):
print ("z existe, mas é um arquivo e não um diretório.")
else:
print("O dire... |
1b8447a944eb05e2c8dfc8c574bc60918c0a6214 | HugoNgai/Leetcode | /Code/valid_palidrome.py | 232 | 3.671875 | 4 | #!/usr/bin/env python
# encoding: utf-8
class Solution:
def isPalindrome(self, s: str) -> bool:
import re
res = ''.join(re.findall(r'[a-zA-Z0-9]+', s))
res = res.lower()
return res == res[::-1]
|
8d901e286cedf5bcf9257c8ad8ba3318dd55b63a | xM4Rz/Password-Cracker | /PassCrack.py | 10,768 | 4.125 | 4 | '''
Project 9 CSE 231
-Prompts use to make a selection of given choices
-if users chooses first selection, passwords are cracked from given text files
by forming a hash and crossreferencing it with hashes create from common
passwords
-if the user chooses the second, common words within passwords are found by
inputting... |
96885b22d768db26c3a1857f679fae17bb87d119 | Chalmiller/competitive_programming | /python/algorithms/sliding_window/string_anagrams.py | 364 | 3.65625 | 4 | def find_string_anagrams(str, pattern):
result_indexes = []
match = 0
win_length = len(pattern)
counter_dict = {}
for s in pattern:
if s not in counter_dict:
counter_dict[s] = 0
counter_dict[s] += 1
for win_start in range(len(str) - win_length + 1):
sub_str = str[win_start : win_start + ... |
439ea8babb5822ddc617f120129386bf05579e8e | Dzenis-Pepic/OOP-zadatak | /oop.py | 1,873 | 4.4375 | 4 | #1. Create a Vehicle class with max_speed and mileage instance attributes.
class Vehicle:
def __init__(self,max_speed,mileage):
self.max_speed=max_speed
self.mileage=mileage
#2. Create a Vehicle class without any variables and methods.
class Vehicle1:
pass
#3. Create a child class Bus that... |
6333417e234d01bd560dce164281c6eddefece4b | aks789/python-code-basics-to-expert | /dictionary.py | 545 | 3.65625 | 4 | my_dict = {'a' : 'akriti', 'a' : 'akshay'};
print(my_dict);
print(my_dict['a']);
samp_dict = {'k1': 1 , 'k2': [0,1,2] , 'k3' : {'insideKey':100}}
print(samp_dict['k3']['insideKey'])
samp_dict['k4'] = 'New Val';
print(samp_dict.items())
print(samp_dict.values())
## Tuples
t=(1,2,3)
my_list=[1,2,3]
print(type(t)... |
0662429c7b9fc9bf46536fc8eb72e7bb885ce90a | simran135/CSSteminars | /CS2/Lesson1/quiz1.py | 291 | 3.625 | 4 | print("----------------")
print("QUIZ TIME:\n")
# Do the types match? Will these all compile?
print(3 * 2)
print(3 * "abc")
print(3 + 2)
print("abc" + "def")
print(3 + "def")
print("Precedence:")
print(2+3*4)
print(5+4%3)
print(2**3*4)
print()
print("Associativity:")
print(5-4-3) |
13cebb4b4a6d5561617b2049d664d0916d5b441a | mango0713/Python | /20191210-숫자 맞추기.py | 732 | 3.5625 | 4 | import random
def make_question() :
a = random.randint(1, 20)
b = random.randint(1, 20)
op = random.randint(1, 3)
q = str(a)
if op == 1 :
q = q + "+"
if op == 2 :
q = q + "-"
if op == 3 :
q = q + "*"
... |
195e0d2a73ad44dc4810f57a54461ff684d175b0 | bhudnell/Past-Work | /Python/binaryClass/binaryClass.py | 5,195 | 4.1875 | 4 | """
Brendon Hudnell
Section Leader: Will Zielinski
3/2/16
ISTA 350 Hw5
Contains the Binary class, which contains operator overload magic methods used to do
basic binary integer arithmetic.
"""
class Binary:
def __init__(self, bin_string=""):
"""
Takes a string of no more than 16 bits, converts it... |
2d8a4ec86718d281bc6e097164f7e744b29980d5 | erin-biard/TP11 | /Matrice.py | 1,061 | 3.71875 | 4 | class Matrice:
def __init__(self,data=[]):
self.__D = data
def getD(self):
return self.__D
def __add__(self, m2):
for i in range(0,4):
newMat = self.__D[i] + m2.__D[i]
print(newMat,end=' ')
def __sub__(self, m2):
for i in range(0,4):
... |
df672c118e479c3938746d6a9815e0f536b17709 | Renittka/Web_2020 | /week8/problems/informatics/while/B.py | 287 | 3.921875 | 4 | # Дано целое число, не меньшее 2. Выведите его наименьший натуральный делитель, отличный от 1.
from math import pow
a = int(input())
i = 2
while i < a+1:
if a % i == 0:
print(i)
break
i += 1 |
c1f462a7354819e316bce955ebca372a2e3f9fab | johnsjc/reverse-eng | /bomb/python/phase6.py | 2,068 | 3.546875 | 4 | #!/usr/bin/python
# Reverse engineering phase 6
import sys
class Node(object):
def __init__(self, number, value, next_node):
self.number = number
self.value = value
self.next_node = next_node
nodes = [
Node(1, 0x0fd, None),
Node(2, 0x2d5, None),
Node(3, 0x12d, None),
Node(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.