blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
59f433735cee173fe74b129c407412c5061e4464 | chursunov/GB-python-homework | /lesson4/homework4_1.py | 1,079 | 3.640625 | 4 | """
Реализовать скрипт, в котором должна быть предусмотрена функция расчета заработной платы сотрудника.
В расчете необходимо использовать формулу: (выработка в часах*ставка в час) + премия.
Для выполнения расчета для конкретных значений необходимо запускать скрипт с параметрами.
"""
import sys
try:
file, hour_job... |
dd84ae2d957617072f57a8ee3030158ea4c88120 | davidokun/python-blockchain-app | /basics/lists.py | 187 | 3.625 | 4 | my_list = [1, 'Hi', 2.54]
print(my_list)
print(my_list[1])
my_list.append(3)
print(my_list)
print(my_list.pop())
print(my_list)
def my_function():
print('Hallo')
my_function()
|
bca52cd29a2e410354b7facb22d898867fdb0ca6 | nirantak/programming-exercises | /Misc/street_lights.py | 1,491 | 3.75 | 4 | """
Street Lights, refer street_lights.md for the question.
"""
from itertools import combinations
from typing import Dict, List, Tuple
def main(data: List[List[Tuple[int, int]]]) -> List[float]:
result: List[float] = []
for d in data:
total_area: float = 0.0
int_area: float = 0.0
li... |
aa760d5a732aac746505c5c57e1467eeabffae39 | ChenQianPing/PythonDay1 | /py01.py | 1,141 | 4 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
# 根据给定的年月日以数字形式打印出日期
months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'Auguest',
'September',
'October',
'November',
'December'
]
print months
# 以1~31的娄字作为结尾的列表
endings = ['st','nd','rd'] +... |
59921ebd28ce025bb54f70528de2ae475931d046 | 9886767077/python_tutorial | /Class 5/whileloop_n_times.py | 181 | 3.875 | 4 | fruit name = input("enter your favo fruit : {}")
n = int(input("Enter loop no u wana print: "))
i=0
while(i!=n)
i=i+1
print("loop is no:{}".format(i))
print(fruit name) |
66e5844390dcc52a12be41649e35a0eab66cd40c | haekyu/python_tutoring_kh | /0919/hw_sol/0919_4_stars.py | 470 | 3.546875 | 4 | def prt_stars():
# For upper triangle
for i in range(1, 6):
# For the left triangle
prt_str = (' ' * (5 - i)) + ('*' * i)
# For the right triangle
prt_str += ('*' * i) + (' ' * (5 - i))
print(prt_str)
# For the lower triangle
for i in range(4):
# For the left triangle
prt_str = (' ' * (i + 1)) + ('*... |
3a3ffc3fcde756b1d488b1e9acd7dbb5f128423c | malwadkarrk/Python | /stringslicing.py | 167 | 4.09375 | 4 | string = input("Enter string: ")
firsttwo = string[:2]
lasttwo = string[-2:]
print(firsttwo)
print(lasttwo)
print("Firsttwo + lasttwo is: ", firsttwo + lasttwo)
|
9d0233194ae77e157c6bf9e8684c9a826017ff53 | Geeoon/PythonSorting | /PythonSorting/PythonSorting.py | 3,919 | 4.0625 | 4 | import random
import math
from timeit import default_timer as timer
comparisons = 0
swaps = 0
def getSize():
size = int(input("Size of list: "))
while (size <= 1):
print("The list must have a size greater than 1")
size = int(input("Size of list: "))
return size
def printElements(list):
for index in list:
p... |
5cd74493c20ff43bdb73f2a62e8f38ceb8621532 | neapps/Python-3-Tutorial | /2. Control Structures/lists.py | 1,171 | 4.34375 | 4 | # ================================================== #
# Materi 1 : Lists #1
words = ["Hello","world","!"]
print(words[0])
print(words[1])
print(words[2])
# Hello
# world
# !
# Soal 1 : What is the result of this code?
nums = [5,4,3,2,1]
print(nums[1])
# Jawaban 1 : 4
# ============================================... |
18d31941f1320516cab508a8b81ef27cd608f0e9 | jingwang622/AID1909 | /day06/thead_event.py | 512 | 3.65625 | 4 | """
event 线程互斥方法
× 解决对共享资源的无序使用
"""
from threading import Thread,Event
# 用于线程间的通信
s = None
e = Event()
def yang():
print("样子荣前来拜山头")
global s
s = "天王盖地虎"
e.set()
t = Thread(target=yang)
t.start()
print("说对口令就是自己人")
print(e.is_set())
e.wait()
print(e.is_set())
if s == '天王盖地虎':
print("宝塔真和要")
pri... |
618ba8c0a838b8e93bbe0b557db3216ca93c108a | tamatskiv/python | /task9_2.py | 3,052 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
amount = input("Enter amount of money with dot): ")
def num_to_words(amount):
""""This function returns amount of money in words"""
digits = {
0: 'нуль', 1: 'одна',
2: 'дві', 3: 'три',
4: 'чотири', 5: 'п\'ять',
6: 'шіс... |
1ff58a7ff50aeb919becbec28232b09150be47b4 | give333/UnivLic | /PIntegrado/factorial.py | 233 | 3.875 | 4 | def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
def factorial_i(number):
product = 1
for i in range(number):
product = product * (i + 1)
return product
|
f423f940022a991fd8fe6746091abb58014b5038 | kiranani/playground | /Python3/0222_Count_Complete_Tree_Nodes.py | 597 | 3.765625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def countNodes(self, root: TreeNode) -> int:
if root is None:
return 0
l = 1
left, right = root.left,... |
9d02f83a5287c07682b2e1c030a888dc3278f495 | sonalipat1/sonalipat1 | /square.py | 112 | 3.859375 | 4 | square_of_rec= int(input("enter the number to find square"))
square= square_of_rec * square_of_rec
print(square) |
a6c0ec8d5dc6e63dffd8d0778d225c9a4ec05247 | arthur-bryan/python-data-structures | /classes/banco/contas/conta_corrente.py | 1,231 | 3.75 | 4 | from contas.conta_bancaria import ContaBancaria
class ContaCorrente(ContaBancaria):
def __init__(self, numero, saldo, taxa_de_operacao):
super().__init__(numero, saldo)
self.__taxa_de_operacao = float(taxa_de_operacao)
def __str__(self):
return f"Conta Corrente: Número: {self.numero}, Saldo: {self.saldo}, T... |
4eb652fc79a6f0f966b09b11a6ed588ef093a737 | makarenko093/Python | /makarenko_eugene_dz_3/task_3_3_4.py | 2,929 | 3.921875 | 4 | """3. Написать функцию thesaurus(), принимающую в качестве аргументов имена сотрудников и возвращающую словарь, в котором ключи — первые буквы имен, а значения — списки, содержащие имена, начинающиеся с соответствующей буквы. Например:
#>>> thesaurus("Иван", "Мария", "Петр", "Илья")
{
"И": ["Иван", "Илья"],
"М"... |
0b69299b47cfc341f427a407cc013bf54c89beaa | manlyjpanda/Primary-Seven-Python | /fortune bot.py | 3,748 | 4.40625 | 4 | #fortune cookie bot
#before we start the programme, we ask python to get all the packages we need
#random allows us to pick a random fortune later
#time allows us to pause between outputs
#pyttsx3 is the package that does speech for us. We will ask it to start up and will close it down later
import random
import ... |
cf5ce7a77e6af1617435b9c298397147fd8374f1 | tkhunlertkit/cs361f18 | /Lab 3/Quiz/quiz.py | 172 | 4.1875 | 4 | prime = int(input('Enter a number: '))
for i in range(2, prime):
if prime % i == 0:
print('this not is prime, it is divisible by: ', i)
print('this is prime') |
5c1b5030e9ae2d605824743ffa92901f4033e052 | leandro-hl/python | /tp_integrador/EjAdicionales/Ej1Prog2.py | 483 | 3.796875 | 4 | # Programa 2: Crear una lista al azar, luego informar para cada valor, cuántas veces se repite.
# El informe No debe repetir el número. (Aca si se debe usar count)
import FnGenLst
def main():
lista = FnGenLst.generarLista(20, 1, 10)
listaInformados = []
for x in lista:
if x not in listaInformados:
... |
293515a4b6e8f29a06c153a90f7a12420edbd63b | arpansahu/LinkedListPython | /singly linked list/Remove_duplicates_from_a_Unsorted_linked_list.py | 2,312 | 3.921875 | 4 | class node:
def __init__(self, data):
self.data = data
self.next = None
class linkedList:
def __init__(self):
self.head = None
def insertAtStart(self, data):
temp = node(data)
if self.head is None:
self.head = temp
else:
temp.next = ... |
a5fd8ba2026eefb23246235d530069999fe5ccc3 | henkess/pycookbook | /tricks.py | 470 | 3.75 | 4 | # # create a list of numbers with comprehention
# numbers = [n for n in range(1,10)]
# print(numbers)
# # list comrehention with condition
# numbers1 = [n for n in range(1,10) if n % 2 == 0]
# print(numbers1)
# # comprehention dictionary
# w = "mohammed ali"
# lt = {l:w.count(l) for l in w if l !=' '}
# print(lt)
# ... |
4b1705579e11960b9fce8bdeec98b73e9ae866b3 | arshadumrethi/Learn-Python-the-hard-way | /ex7.py | 565 | 3.984375 | 4 | print "Mary had a little lamb"
print "Its fleece was white as %s." % 'snow' #Snow is in inverted commas to denote it is a string otherwise it would be a Variable
print "And everywhere that Mary went."
print "." * 10 #this will print out 10 dots
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "... |
80b3caecf9ba23be12d9864632257cebed431284 | Maryanushka/MITx-6.00.1-2017- | /week6/11. Computational Complexity.py | 161 | 3.625 | 4 | def linearSearch(L, x):
for e in L:
if e == x:
return True
return False
print(linearSearch([21, 1, 25, 22, 30, 13, 7, 24, 12], 24))
|
b9d90c3b597f40439cbd0188f6062b3a1205d0d4 | ellenlawrence/algorithm-practice | /string_perms.py | 530 | 3.96875 | 4 | import unittest
def find_string_perms(s, b):
'''Finds all the permutations of smaller string s inside bigger string b.'''
for i in range(len(b) - len(s) - 1):
class TestStringPerms(unittest.TestCase):
def test_find_string_perms(self):
'''Test that the string permutation function is retu... |
0e8f0190415e79ea097bf9725fa5258fd690c6f8 | iamaaditya/Project-Euler | /027.py | 1,327 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 14 20:13:05 2014
@author: aaditya prakash
"""
import utilities
import math
import time
problem_number = '027'
problem_statement = """
Find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of primes for consecutive v... |
caf985ee4dd1d8ce25dd65947282d8e2b1522ff6 | gonsva/Python-week | /entertemp.py | 146 | 4.0625 | 4 | T=input("Enter today's Temperature:")
temp=int(T)
if temp>40:
print("It is extreamly warm my friend! How warm?")
if temp<40:
print("It is cold") |
199672ace9991c63e76cd2c4b2dfa970a9482fb5 | GlassWall/leetcode | /graphs/bfs/robot_in_maze.py | 1,019 | 3.796875 | 4 | def robot_traverse(maze,a,b,k1):
maze = [[0 for i in range(b)] for i in range(a)]
q = [[0,0,0]]
visited = [[False for j in range(b)] for i in range(a)]
visited[0][0] = True
path_dict = {}
while q:
x,y,k,px,py = q.pop(0)
if k==k1 and x==a-1 and y == b-1:
ret... |
92280f864aaf2ab0fb3923dce4cbf3ef6dba8570 | Liu-Maria/ISAT252 | /lec8.py | 2,190 | 4.59375 | 5 | """
Week 3, lecture 8
"""
def my_function(a, b): #you can give them a default value
result = a + b #when you see variables a and b, add them together and store the sum in result
print('a is', a)
print('b is', b)
return result #returns the 'result', MUST BE LAST STATEMENT
# print(my_func... |
b7a58c372b5a5417e8905a526bce64fdefd2d9e3 | Pratik-sys/Coding-Problems | /CodingBat/Warmup-2/array123.py | 301 | 3.921875 | 4 | #Given an array of int, return True if
# ..1, 2, 3 appears in the array somewhere
def array123(nums):
for i in range(len(nums) - 2):
if nums[i] == 1 and nums[i + 1] and nums[i+2]==3:
return True
return False
print(array123([1,2,3,5,5,4]))
print(array123([1,2,5,5,5,4]))
|
b2096b4d233004bd4754aa9fa8ad2a6b90b7fee1 | m4ttbr3da/python-challenge | /PyBank/PyBankBreda.py | 3,619 | 3.9375 | 4 | # Modules
import os
import csv
# Establish file path to budget_data.csv
csvpath = os.path.join('Resources', 'budget_data.csv')
# Open the budget_data.csv file using CSV module
with open(csvpath) as csv_file:
budget_data = csv.reader(csv_file, delimiter=',')
# Sets the header row
header_row = next(budget_data... |
660ab2e660a7d235561156484c6635927e035330 | superyideng/ee595_software_design_labs | /Lab9/lab9_part1.py | 2,726 | 3.640625 | 4 | import math
def read_from(path):
"""
:param path: str, path of file to be read
:return: int, number of nodes
list, position information of each node
"""
f = open(path, 'r')
result = list()
num = int(f.readline().strip())
for line in f.readlines():
line = line.strip... |
e8673bafdfaa29c0a008e857a71d1cc413921d1e | ianhom/Python-Noob | /Note_2/fordict.py | 206 | 4 | 4 | #!/usr/bin/python
d = {'x':1, 'y':2, 'z':3};
for key in d:
print key, "corresponds to ", d[key];
# result
'''
y corresponds to 2
x corresponds to 1
z corresponds to 3
'''
# Why is y-x-z order???
|
48e8a24441f9ca9a9614220f7b24fb13a67a1e58 | HS1VT/graph-processing-with-python-mapreduce-parallel-bfs | /Part_3/a_[20_points]/plot.py | 387 | 3.546875 | 4 | import matplotlib.pyplot as plt
x=[1,0,2.14,3.17,1.67,1.43,2.6,2.9,4.2,1.2,1.96,3.58]
y=[5,3,8,9,6,5,8,7,15,5,7,12]
for i in range(1,89):
x.append(int(0))
for j in range(1,45):
y.append(int(3))
for j in range(45,54):
y.append(int(2))
for j in range(54,89):
y.append(int(4))
plt.scatter(x,y,c="blue")
plt... |
c3842ea30cc12e0ad6aa3ac9f432f22483c29ba8 | MD6338/Python | /tut15.py | 437 | 3.78125 | 4 | # File IO
"""
"r" - Used to read file - default mode
"w" - Used for writing in file
"x" - Used to create file if not exists
"a" - Used for appending content in file
"t" - Text mode - default mode
"b" - Binary mode
"+" - Read and write
"""
from os import path
f = open("ch.txt")
# co = f.read(6)
# print("haha", co)... |
de9259b5fba14e66a90e145bebda2799cb73b15e | anton2mihail/Country-Catalogue | /country.py | 1,560 | 4.25 | 4 | """This class creates a country object with attributes that include name, population, and area"""
# Programmer: Anton Mihail Lachmaniucu
# Date: 2017-11-28
# Creation of the class and the instance variables
class Country():
def __init__(self, name="", pop = 0, area=0.00, continent=""):
self._name = name.ti... |
42e6290e9a0bca8ebe43550b6f8bc9b8a2f1f440 | Jangwoojin863/python | /sort.py | 1,110 | 3.90625 | 4 | # 버블 정렬 구현 및 사용 예제
#-------------------------------------------------------
# 버블 정렬 함수
# 전달 인수:
# list = 정수형 배열
# cnt = 배열의 요소 개수
# 반환값: -1 = 정렬 안함, 0 = 정상 수행
def bubble_sort(list_data):
cnt = len(test_list)
# 원소 개... |
f507a5c480c637b28c1806585241564f508998bb | Gio1609/Python_Basic | /chap-8_Recursion_and_Dynamic_Programming/8.9.py | 1,387 | 3.828125 | 4 | # Implement an algorithm to print all valid combinations of n pairs of parentheses.
# Time: O(n^2) (string concatation takes n time)
def parens(n):
combinations = list()
_parens(n, 0, 0, '', combinations)
return combinations
def _parens(n, l, r, s, combinations):
if len(s) == 2*n:
combinations... |
5303f5b3c94c33b8d772229c14a01213da53aa45 | xukangjune/Leetcode | /solved/238. 除自身以外数组的乘积.py | 1,526 | 3.609375 | 4 | """
我自己写的比较拖沓,原本是想准备两个数组来存储原数组每一位左边的数累积和右边的数累积,到那时这样就不满足题意了。因为返回
数组不计入额外空间,所以这个条件可以利用。所以我就将左边数的累积计算到返回数组,然后将反向乘上右边数的累积。
新的解法比较流畅,只需要两遍遍历数组,只需要两个遍历来记录当前左边和右边数累乘的结果。
"""
class Solution:
def productExceptSelf(self, nums):
#新的解法
n = len(nums)
ret = [1] * n
left = 1
for i in range... |
780d8e855f1963347397f2a2c2b3e2b3c4a49681 | Almas-Ali/Gender-Guise-App | /main.py | 4,268 | 3.6875 | 4 | from tkinter import *
from tkinter.messagebox import *
root = Tk()
def about():
showinfo("About","Guise Your Gender version 1.0")
def author():
showinfo('Author','This App is made by Md. Almas Ali\n\tin Bangladesh')
mainmenu = Menu(root)
mainmenu.add_command(label='About', command=about)
#mainmenu.add_separator()... |
647f9060af245c4ebf34b577ead5d29d944f0df4 | gholden3/problem_practice | /chapter10/q3_search_in_rotated_array.py | 2,435 | 4.09375 | 4 | # Given a sorted array of n integers which has been rotated an unknown
# number of times, write code to find an element in that array. you may assume
# the array was originally sorted in ascending order
import unittest
from math import floor
def run_search_in_rotated_array(array, value_to_find: int) -> int:
''' se... |
749dc368583441998389e585bcbd23cd4fbb707d | EdgarLozano185519/AudioGame-Sample-with-Pyglet | /src/enemy.py | 561 | 3.546875 | 4 | import math
class Enemy:
def __init__():
self.x = 0
self.y = 0
self.z = 0
self.max_distance = 0
self.step_volume = 0
def spawn(self):
self.spawn = 1
# Defines the minimum distance for an enemy to spawn
def define_distance(self, distance):
self.... |
37ce8cd18a3a6168fae84dc24290f8096677dfea | yhelen-stuy/softdev-03 | /hw03.py | 1,390 | 3.5625 | 4 | #Helen Ye, Jennifer Zhang
#SoftDev1 pd7
#HW03 -- StI/O: Divine your Destiny!
#2017-09-15
import random
def read_occupations():
# Read the file
# 'U' is the universal newline (in case the csv file was made in Windows)
source = open('occupations.csv', 'rU')
# Strip of newlines at the beginning of end of ... |
a2b2700b0505eb19db95e02d0514d4ee7420ecbd | dimosp/grades-report | /grades_report/stats.py | 6,655 | 4.28125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright (c) 2020 KAUTH
"""
from statistics import mean, stdev
def mean_grade(parsed_list, passing_grade, overall_mean=True):
"""
This function calculates the arithmetic mean of the given grades.
:param parsed_list: the parsed list of the grades
:pa... |
fa8ab3a99392e57cac7cd1e56f457faaf9662c4f | liaison/LeetCode | /python/236_lowest_common_ancestor_of_a_binary_tree_no_parent_pointer.py | 2,640 | 3.84375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
def dfs(node, path, target, resul... |
836cea47bc707db9eed05f23cfe8565d4818a301 | praneetharra/projectEuler | /3_lrgst_prme_fctr.py | 352 | 3.546875 | 4 | import math
def isPrimme(a):
for i in range(2,int(math.sqrt(a))):
if a%i == 0:
return False
return True
primes = []
n = 600851475143
if not isPrimme(n):
for i in range(1,int(math.sqrt(n))):
if n%i == 0:
if isPrimme(i):
primes.append(i)
if isPrimme(int(n/i)):
primes.append(int(n/i))
print... |
23fb7e5ef53edd67f29ce1138f5f13b191f20978 | khizarhussain19/Two-way-communication-between-normal-and-deaf-people-using-Speech-Recognition-and-Image-Processing | /SpeechToText.py | 1,397 | 3.5625 | 4 | #!/usr/bin/env python3
# Requires PyAudio and PySpeech.
import speech_recognition as sr
import cv2
import time
import numpy as np
capture_duration = 4
font = cv2.FONT_HERSHEY_SIMPLEX
while True:
# Record Audio
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something... |
6073106405914e23cbdd69b4c5371d5e6ca7a973 | ChyngyzOsmonov/part4_tasks | /part4_task6.py | 886 | 3.671875 | 4 | class Home:
def __init__(self, type_, bed, wardrobe, table):
self.type_ = type_
self.bed = bed
self.wardrobe = wardrobe
self.table = table
def desc(self):
print('Home type: {}, in the home: {}, {}, {}'.format(self.type_,self.bed,self.wardrobe,self.table))
class Furnatur... |
df9aa230178dc0932a62c76e4350f25306baaa2a | sbcshop/Raspberry-Pi-Webinars | /GUI Development/Example codes/Example13.py | 358 | 4.375 | 4 | '''
Example to learn about button widget
'''
from tkinter import *
# function bind with button
def press():
print('Button pressed')
window = Tk()
# to change the title of window
window.title('My GUI')
# to create a button
b = Button(window, text='Button', height=4, width=4, command=press)
b.grid(row=0, co... |
c0f78e21f89345e522bc0965692c8b727a38f1b3 | Yeasayer/Random-Exercises | /Python/operators.py | 470 | 3.640625 | 4 | a,b,c = 1,2,3
plus = a+b+c
minus = c-b-a
multi = a*b*c
divide = multi/plus
mathList = []
mathList.append(plus)
mathList.append(minus)
mathList.append(multi)
mathList.append(divide)
superList = mathList*10
if plus == multi:
print (mathList)
print (superList)
print "\"mathList\" has %d objects!" % len(mathList)
print... |
6ebe6c04722f95e5de6241eab6c901d1bfa108ef | Nithinkumar-s/Python | /tst2.py | 1,360 | 3.6875 | 4 | from os import system
import random
from time import sleep
t = 1
f = 0
c = 0
r = 0
x = 0
y = 0
def loop():
global r,f,c,x,y
w=62
f = 0
if(f == 0):
if(r == 0 ):
r=random.randrange(1,30)
elif(c==10):
r=random.randrange(5,30)
... |
d8df169e5c4669286885707b4f149d2f5d7cea60 | aronnax77/python_uploads | /bubble_sort.py | 657 | 4.09375 | 4 | """ Author: Richard Myatt
Date: 14 February 2018
The function below represents the implementation of the 'bubble sort'
algorithm. This is demonstrated with the list [33, 20, 12, 31, 2, 67]
but should work with any other list.
"""
def bubbleSort(l):
"""
An implementation of the bubble sore wit... |
e9eb2b4427ba60dabcb3b0d7265b67eda930c31f | DonJames0214/ENED | /ENED_ToolKit/forces.py | 3,312 | 3.578125 | 4 | from math import sin, cos, radians, atan, sqrt, pi
class Force:
conv = {'N':1.,'LBF':4.448,'KGF':9.807}
def __init__(self, magnitude, direction, units="N", rad=False):
self.mag = magnitude
self.ang = direction
self.units = units.upper()
if self.units not in Force.conv:
... |
b0901e599ce592fb16c823d09ec2d1d02f524990 | lvbenson/Neural_Reuse_New | /Eduardo/Figures/Company_Size/Impact.py | 10,294 | 3.625 | 4 |
"""
Given the set of company projects and a fixed total employee count, how many important employees are required for the success of those projects?
Importance defined as: removing the employee would cause project failure to some extent
Options
Option 0 -- None of the employees are important
Option 1 -- All of the e... |
331ba25d4f34c30d1ac418c0d05a0b9b1cce35bb | MarcoHuXHu/learningpython | /Function/filter.py | 1,520 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# filter传入一个返回True或False的函数,与一个Iterable对象,返回经过函数筛选为True的元素
# filter返回为iterator
def is_odd(n):
return n % 2 == 1
print(list(filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15])))
# 结果: [1, 5, 9, 15]
# 例1:筛选回文数
def is_palindrome(n):#0123456
digits = str(n)
length = le... |
b359fe0634c39c6d223483dcee3be952f0155e34 | Nagomez97/Hackmadrid_Crypto | /Retos/ECDH-AES/encryption.py | 1,299 | 3.609375 | 4 | #################################
# #
# ECDH KEY EXCHANGE #
# #
#################################
import Crypto
from Crypto import *
from Crypto.Util import *
message = ??????????????????
# Private keys
Alice_priv = Crypto.Util.number.getPrime(16)
Bob_priv = Crypto.Util.number.getPrime(16)
# The curve is y^2 =... |
47e2d734bbb2b7297ee4441e41c3c97b67e62cea | washiz99/solid-principles | /examples/isp/isp_good.py | 381 | 4.03125 | 4 | from abc import ABCMeta, abstractmethod
class Shape(metaclass=ABCMeta):
@abstractmethod
def draw(self):
pass
class Circle(Shape):
def draw(self):
print('まるを描きます')
class Square(Shape):
def draw(self):
print('しかくを描きます')
circle = Circle()
circle.draw()
s... |
9cd2278b7a6ca8cd2ec03bf03681e15dbd78bfd2 | apulijala/python-crash-course-3 | /ch9/inheritence.py | 2,006 | 4.25 | 4 | from restaurant_with_served import *
"""
9-6. Ice Cream Stand: An ice cream stand is a specific kind of restaurant.
Write a class called IceCreamStand that inherits from the Restaurant class
you wrote in Exercise 9-1 (page 162) or Exercise 9-4 (page 167).
Either version of the class will work; just pick the one yo... |
cd3cc56dcdb9d50e3ada36e9458a08662378b6a6 | SquireGeli/m02.boot_0 | /p1.py | 306 | 3.59375 | 4 | def sumaTodos(limitTo):
resultado=0
for i in range (0, limitTo+1):
resultado +=i
return resultado
print (sumaTodos(100))
def sumaCuadrados(limitTo):
resultado=0
for i in range(limitTo+1):
resultado += i*i
return resultado
print(sumaCuadrados(3))
|
1fd0fce7d0377c2ff3a1ca91aa738f426ecb10b1 | xiaochenchen-PITT/CC150_Python | /cc150/c5.py | 2,812 | 4.0625 | 4 | '''5.1 You are given two 32-bit numbers, N and M, and two bit positions,
i and j Write a method to set all bits between i and j in N equal to M
(e g , M becomes a substring of N located at i and starting at j)
EXAMPLE:
Input: N = 10000000000, M = 10101, i = 2, j = 6
Output: N = 10001010100
'''
# def SetBit(N, M, i, j... |
5a1915f8abf3b9dbf51e4385fda88a133162cfd3 | ischang/Practice-CS-Problems | /MiscInterview/nonrepeatCharStr.py | 473 | 3.921875 | 4 | # Find the first non-repeated character in a String
# "call me ishmael" -- should be 'c'
# "albus percival wulfric brian dumbledore" - should be 's'
def nonRepeatChar(arr):
repeatDict = {}
for item in arr:
if item in repeatDict.keys():
repeatDict[item] += 1
else:
repeatDict[item] = 1
for item in arr:
i... |
da53016fc0297eaa8e5b2e4b919b0895bd04db7f | syurskyi/Algorithms_and_Data_Structure | /_algorithms_challenges/exercism/exercism-python-master/largest-series-product/series.py | 797 | 4.25 | 4 | """Finds largest product of slices of digits of a give size"""
def largest_product(digits, size):
"""Finds the largest product of slices of a given size"""
# Why does a blank set of digits have a maximum product of 1?
slice_list = slices(digits, size)
def mult_reduce(items):
total = 1
f... |
d60afba1bcf6630885e5a8e36a783edf9dc6cba7 | ChangRui-Yao/pygame | /LINUX系统/linux实战/8.0/06--生成器的使用注意.py | 1,822 | 3.90625 | 4 | """
#创建一个生成器
#目标:实现斐波那契数列
#1)定义变量保存第一列和第二列的值
#2)定义变量保存当前生成的位置
#3)循环生成数据 条件是当前列数《总列数
#4)保存a的值
#5)修改a \ b 的值
#6)返回a的值 使用yield
#2定义变量 保存生成器
#next(生成器)得到下一个元素值
"""
#创建一个生成器
def fibnacci(n):
#目标:实现斐波那契数列
#1)定义变量保存第一列和第二列的值
a = 1
b = 1
#2)定义变量保存当前生成的位置
weizhi = 0
... |
33a3b4ffaade3d62bed510314b6bdbafdaeec7fd | ash/amazing_python3 | /191-tuple-comma.py | 256 | 4.0625 | 4 | # How to create a tuple with
# only one element
x = ('value') # is it a tuple?
print(type(x)) # it is a string
y = ('value', ) # this comma makes it
# a tuple (because the compiler
# sees that you kind of want more
# elements here)
print(type(y)) # tuple |
08bfdad01dd4e9eeeda0a83f107bc19cf90430a6 | bsantos2/DataStructuresAlgos3 | /problem_6.py | 1,594 | 3.921875 | 4 | def get_min_max(ints):
result = merge_sort(ints)
minmax = (result[0], result[-1])
return minmax
def merge_sort(ints):
if len(ints) <= 1:
return ints
midpoint = len(ints) // 2
left = ints[:midpoint]
right = ints[(midpoint):]
left = merge_sort(left)
right = merge_sort(right)
... |
8fdc4f53f341efc3af7fd9d00aa96f1283ce32f1 | mohamed-elsayed/python-scratch | /list.py | 7,749 | 4.5625 | 5 | # =================================================
################ LISTS ###########################
# =================================================
# What is a list ?
# It is just a collection or grouping of items!
# Objective :
# Describe , create and access a list data structure
# Use built in methods to mo... |
6472cad359d0846baf1b88705b7554ccd1ae3b20 | wagner30023/fundamentos_python | /mundo1/alunoAleatorio.py | 267 | 3.765625 | 4 | from random import choice
n1 = str(input('>> primeiro nome: '))
n2 = str(input('>> segundo nome: '))
n3 = str(input('>> terceiro nome: '))
n4 = str(input('>> quarto nome: '))
list = [n1,n2,n3,n4]
choice = choice(list)
print('Aluno escolhido: {}'.format(choice))
|
41d240ddc519806a8da2088ccfae1202263755c3 | daniel-reich/ubiquitous-fiesta | /s45bQoPtMoZcj7rnR_21.py | 198 | 3.59375 | 4 |
def closest_palindrome(n):
for i in range(n*10):
if is_palindrome(n-i):
return n-i
if is_palindrome(n+i):
return n+i
def is_palindrome(n):
return str(n) == str(n)[::-1]
|
b511cf01c823d67ac41fc9473d8869dcd3edcca8 | SinghHarman286/Competitive-Programming | /DataStructures/binaryHeap.py | 2,699 | 3.796875 | 4 | '''
Max Heap -> Parent nodes are always larger than the child
-> Left nodes are filled first
For any index n of an array, its left child is at 2n + 1, right child is at 2n + 2,
parent is at (n - 1) / 2
NOTE: 1) For MinHeap, just reverse the signs in the below solutiom
2) For Priority Queue, ... |
2fdb9a705def1f5c68598bcafd4f05a4c5626a46 | LuuizAlves/FTC-Projeto_Pratico_002 | /projeto_pratico.py | 3,686 | 3.640625 | 4 | import ast
#---------------------------- FUNÇÃO DA MULTIPLICAÇÃO ----------------------#
def multiplicacao(x, y):
lin_x = len(x)
col_x = len(x[0])
lin_y = len(y)
col_y = len(y[0])
res = []
for linha in range(lin_x):
res.append([])
for coluna in range(col_y):
res[lin... |
5d24820407fc04f9f166293555e222f396bfb60c | jhovan/ContactBook | /contactBook.py | 4,875 | 4.0625 | 4 | #Gallardo Valdez Jose Jhovan
#06/09/2016
#Contact book
import re
class invalidEmail(Exception):
pass
class invalidNumber(Exception):
pass
#asks for a telephone number
def askNumber(message):
while True:
try:
number=raw_input(message)
if len(number)!= 10:
raise invalidNumber
number=int(number)... |
da58e2863ec05d6006db8849da0dd0eefc882237 | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/python-prac/mini-scripts/Python_Comparison_Operators_(not_equal).txt.py | 89 | 3.578125 | 4 | x = 5
y = 3
print(x != y)
# returns True because 5 is not equal to 3
# Author: Bryan G
|
48934276a924c07e73c1885f5d6cac9193ee3eff | mohanakrishnavh/Data-Structures-and-Algorithms-in-Python | /recursion/RecursiveStringReversal.py | 539 | 4.09375 | 4 |
def recursive_string_reversal(s, output=None):
# Base Case
if len(s) <= 1:
return s
# recursion
else:
if output is None:
output = ""
output += s[-1]
else:
output += s[-1]
return output + recursive_string_reversal(s[0:len(s)-1])
r... |
3c809666d40c73f25690761306857f106441d2b8 | JoyceYang2018/pythonDA | /Data_Structure/recursion.py | 1,968 | 3.5 | 4 | # coding: utf-8
from turtle import *
def to_str(n, base):
convert_str = '0123456789'
if n < base:
return convert_str[n]
return to_str(n // base, base) + convert_str[n % base]
def tree(branch_len, t):
if branch_len > 5:
t.forward(branch_len)
t.right(20)
tree(branch_len... |
398be4eac11899b464ef42d17e3895b2260296ae | lemon-l/Online-Judge | /算法训练/数组查找及替换.py | 775 | 3.5625 | 4 | '''
Description
给定某整数数组和某一整数b。要求删除数组中可以被b整除的所有元素,同时将该数组各元素按从小到大排序。如果数组元素数值在A到Z的ASCII之间,替换为对应字母。元素个数不超过100,b在1至100之间。
Input
输入描述:
第一行为数组元素个数和整数b
第二行为数组各个元素
输入样例:
Output
输出描述:
按照要求输出
输出样例:
'''
num, b = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = list... |
1508a1c13e6d6e425f91230ddc402e3979d15a26 | jasonkhs192/PythonPractice | /trynumpy.py | 1,941 | 3.53125 | 4 | # import numpy as np
#
# a = np.array([1,2,3])
# b = np.array([[4,5,6,7,8],[1,2,3,4,5]])
# num = [1,2,3,4,5]
# x = min(num)
#
#
# def centered_average(nums):
# x = int(len(nums)/2 + 0.5)
# if len(nums)%2 == 0:
# print((nums[x] + nums[x-1])/2)
# else:
# print((nums[x-1]))
#
#
# centered_average([5,3,4,6,2]... |
02c71c50aef4c6383d17a538ede7e9380b4a7eef | MVasanthiM/guvi | /programs/binary.py | 101 | 3.84375 | 4 | n=input()
b=set(n)
g={'0','1'}
if g==b or b=={'0'} or b=={'1'}:
print("yes")
else:
print("no")
|
7146fa5418cd5dd051b7c623135cb164fe12d578 | nischalshrestha/automatic_wat_discovery | /Notebooks/py/saimarapareddy/titanic-accuracy-80/titanic-accuracy-80.py | 6,616 | 3.59375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# List of libraries used
import pandas as pd
import numpy as np
from sklearn import preprocessing
from IPython.display import display # Allows the use of display() for DataFrames
from sklearn.preprocessing import LabelEncoder # Used for label encoding the data
# I... |
7e1b0c41bdc33414cf9398fb188b523716c758bf | jazznerd206/Snake | /list_ops/all_unique.py | 430 | 4.15625 | 4 | # all_unique
# Checks a flat list for all unique values. Returns True if list values are all unique and False if list values aren't all unique.
# This function compares the length of the list with length of the set() of the list. set() removes duplicate values from the list.
def all_unique(lst):
return len(lst) ... |
5ad4eb2ad15f4a95c0a0b88ff559fc566e88e9a5 | lebuingockhang123/L-p-tr-nh-python | /LeBuiNgocKhang_53157_CH03/Projects/page_99_exercise_11.py | 1,757 | 3.96875 | 4 | """
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Problem: In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7,the player wins $4;
otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are lots
of ways to win: (1, 6), (2, 5), and soon. A l... |
49fd88e75727fc6576d95ede3ab526f3adfbaf09 | ajustinpadilla/python_projects | /Python_and_Sql/exampleDB.py | 796 | 3.765625 | 4 |
import sqlite3
fileList = ('information.docx', 'Hello.txt', 'myImage.png', 'myMovie.mpg', 'World.txt', 'data.pdf', 'myPhoto.jpg')
conn = sqlite3.connect("files.db")
with conn:
cur = conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS tbl_files( \
ID INTEGER PRIMARY KEY AUTOINCREMENT, \
... |
476e6447b992240ce375cddf2042f29fec9d51f0 | larj3852/Curso_Python | /21 - Tkinter/09 - Ejercicio.py | 1,867 | 3.859375 | 4 | """
REALIZACION DE UNA CALCULADORA CON:
- Dos campos de texto
- 4 botones para las operaciones
- Mostar el resulltado en una alerta
"""
from tkinter import *
from tkinter import messagebox
ventana= Tk()
ventana.title("Ejercisio: Calculadora")
ventana.geometry("400x300")
num1 = StringVar()
num2 = StringVa... |
41994a1d041e34a5a9db45f320766d9e44c8292a | tboschi/advent-of-code-2020 | /day01/py/part1 | 499 | 3.640625 | 4 | #! /bin/python
import sys
if len(sys.argv) < 1:
print("Input file expected", file=sys.stderr)
sys.exit(1)
with open(sys.argv[1]) as infile:
costs = []
for line in infile:
x = int(line.strip()) # storing line
costs.append(x)
if 2020 - x in costs[:-1]: # looking for 2020 - ... |
d3ba96f994ca577efaa630ed6be12d67f679389d | GersonFeDutra/Python-exercises | /CursoemVideo/2020/world_2/ex038.py | 383 | 4.21875 | 4 | numbers: list = [
int(input('Enter an integer: ')),
int(input('Enter another integer: '))
]
if numbers[0] > numbers[1]:
print(f'The number {numbers[0]} is bigger than the number {numbers[1]}')
elif numbers[0] < numbers[1]:
print(f'The number {numbers[0]} is smaller than the number {numbers[1]... |
24818981a718608209881eb598a5a5308f370c9a | DonghwanKIM0101/CS454Project | /ExamplePrograms/trityp.py | 931 | 3.53125 | 4 | #https://www.cs.mtsu.edu/~untch/4900/public/trityp.c
def trityp(i,j,k):
TRIANG = 0
# TRIANG = 1 IF TRIANGLE IS SCALENE
# TRIANG = 2 IF TRIANGLE IS ISOSCELES
# TRIANG = 3 IF TRIANGLE IS EQUILATERAL
# TRIANG = 4 IF NOT A TRIANGLE
if (i<=0)or(j<=0)or(k<=0):
TRIANG = 4
return TRIANG
T... |
71a8f0661e23056125538ae39c9f2203ea46e99d | NikiDimov/SoftUni-Python-Basics | /conditional_statements/godzilla_vs_kong.py | 499 | 3.8125 | 4 | budget = float(input())
extras = int(input())
price_clothes = float(input())
decor = budget * 0.1
def movie_maker(budget, extras, price_clothes):
if extras > 150:
price_clothes -= price_clothes * 0.1
total = price_clothes * extras + decor
if total > budget:
return f"Not enough money!\nWin... |
20982a35fbba0fa0e026d755b3df0d399af8d41b | cil0834/Reflection_Summer | /Format_Dates.py | 4,048 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 27 12:31:50 2019
@author: KLAGG
"""
import numpy as np
def dates_in_myrors(
years, months, step=5):
"""Formats the dates so that they have the 'yyyy-dd-mm-hhmmss' format
:param years: the years that will formatted
:param months: the months that ... |
332cfc5d737a3efb14dc6fdbf92c6df37b4a3107 | GitCupper/lenPython | /day01/012-guessnumber01.py | 417 | 3.984375 | 4 | res = 45
input_num = 0
while True:
input_num = int(input("请输入一个数字(1-100):"))
if input_num < 0 or input_num > 100:
print("You have inputted a wrong number.")
break
elif input_num < res:
print("Your number is too small!")
elif input_num > res:
print("Your number is too bi... |
280150f5aaf49a9743ec49a1c5a953c61d5ba265 | AjayS1509/Hackerrank | /Python/power_mod.py | 197 | 3.8125 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
def main():
a = int(input())
b = int(input())
m = int(input())
print(pow(a,b))
print(pow(a,b,m))
main()
|
5309169e9969d013d6b7d9cfd94e669148dde0ab | BeemerCodes/Estudos-de-Python | /Guanabara/Aula if else.py | 750 | 4.15625 | 4 | #tempo = int(input('Quantos anos tem seu carro? '))
#print('UAU!, Seu carro é novo!' if tempo <= 3 else 'Poxa!, Seu carro é velho :(')
#print('-------FIM-------')
#Inicio Dos Estudos em if and else:
#nome = str(input('Qual é seu nome: '))
#if nome == 'Pedro':
# print('Que nome lindo!')
#else:
# prin... |
ce1225891fd6e66f38eb96bffe81290fea6efde4 | SuzyWu2014/Course-work-Algs | /tsp-final/tspFuns.py | 6,623 | 3.6875 | 4 | from math import sqrt
__author__ = 'suzy'
def readfile(path):
f = open(path)
n = 0
cities = []
while 1:
lines = f.readlines(100)
if not lines:
break
for line in lines:
cities = cities + [[int(i) for i in line.split()]]
n = n + 1
return cities, n
def merge(left, right, k): # k->index in array t... |
fd50bab9e17af9ade107196b06302da9f9233fd1 | AshuHK/Sorting_Visualization | /text_based_sorts/test.py | 4,086 | 4.21875 | 4 | # import the sorts here
from InsertionSort import insertion_sort
from SelectionSort import selection_sort
from BubbleSort import bubble_sort
from QuickSort import quick_sort
from MergeSort import merge_sort
# used to generate the rules
import random
import time
def generate_results(test_list, total_time, sort_type):... |
0ad4d3eee4cf6c52b56d891dbd46fa4d85d3d471 | sloria/TextBlob | /textblob/utils.py | 1,526 | 3.875 | 4 | # -*- coding: utf-8 -*-
import re
import string
PUNCTUATION_REGEX = re.compile('[{0}]'.format(re.escape(string.punctuation)))
def strip_punc(s, all=False):
"""Removes punctuation from a string.
:param s: The string.
:param all: Remove all punctuation. If False, only removes punctuation from
the ... |
2d554411e456c44b1afcda09ca4c159ee2a52527 | hmdshfq/Learn-Python-The-Hard-Way | /bin/ex08.py | 786 | 3.890625 | 4 | # Exercise 8 - Printing, printing
# a variable that saves string with four placeholders {} for future use
# variables can be put inside {}
formatter = "{} {} {} {}"
# .format function sends the values to the string
# here 1, 2, 3, and 4 are send to formatter string
print(formatter.format(1, 2, 3, 4))
print(formatter.f... |
2629e64289d57e494d64d37dc4da187ee61f676c | younkyounghwan/python_class | /201814099_11.py | 2,397 | 3.5 | 4 | """
201814099 윤경환
"""
def cul(a,b): #약분
if (a>=b):
while b!=0:
c=a%b
a=b
b=c
return a
else:
while a!=0:
c=b%a
b=a
a=c
return b
class Fraction:
def __init__(self,n,d):
"""
:param a:
... |
81e9aa77df7072d8cb6beeb809af318bf146ef3d | erx717/Basic-Projects | /Tic Tac Toe (OOP).py | 5,001 | 4.0625 | 4 | class TicTacToe():
def __init__(self):
self.board = [["[ ]", "[ ]", "[ ]"], ["[ ]", "[ ]", "[ ]"], ["[ ]", "[ ]", "[ ]"]]
self.status = True
self.move = 0
self.showBoard()
def play(self):
if self.move % 2 == 0:
self.move += 1
self.p1play... |
7b5e9eefce0371c01cd7c05ca47fd12fbb12b1f9 | lienne/PythonLearning | /12_Fibonacci_Recursion_Memoization.py | 1,711 | 4.25 | 4 | # Fib Sequence:
# 1, 1, 2, 3, 5, 8, 13, 21, . . .
# Write a function to return the nth term of the Fibonacci Sequence.
# Function should be fast, clearly written, and rock solid.
def fibonacci_recursive(n):
if n == 1:
return 1
if n == 2:
return 1
elif n > 2:
return fibonacci_recurs... |
382b4c98c3b978be8e6f3470a3296ea2981f4cc2 | bhavya152002/Patterns-using-turtle | /triangle spiral.py | 236 | 3.609375 | 4 | import turtle
t = turtle.Turtle()
s = turtle.Screen()
s,turtle.bgcolor('black')
t.width(3)
t.speed(10)
col = ('white', 'pink', 'cyan')
for i in range (300):
t.pencolor(col[i%3])
t.forward(i*4)
t.right(121)
turtle.done()
|
6a9f3747c63ab397088e61e718ceed4adfc6eb25 | elYaro/Codewars-Katas-Python | /7 kyu/Sort_Out_The_Men_From_Boys.py | 1,883 | 4.15625 | 4 | '''
Scenario
Now that the competition gets tough it will Sort out the men from the boys .
Men are the Even numbers and Boys are the odd !alt !alt
Task
Given an array/list [] of n integers , Separate The even numbers from the odds , or Separate the men from the boys !alt !alt
Notes
Return an array/list where Even nu... |
f3db7c324d7c8cfd650eec56bfbb14bfa3f6c049 | slieer/py | /Hands-On-Computational-Thinking-with-Python.-master/ch5_guess4.py | 499 | 3.96875 | 4 | import random as rand
compnumber = rand.randint(1, 100)
i = 5
for number in range(5):
usernumber = int(input("Choose a number between 1 and 100. You have " + str(i) + " guesses left. "))
if compnumber == usernumber:
print("You win!")
exit()
elif compnumber > usernumber:
print("Your n... |
52bf99c4723bba9523921b2e448ad62847496d2c | gusun0/curso--py | /operadores/1.py | 434 | 4 | 4 | #1: Pidele al usuario que ingrese dos numeros enteros por teclado
#y determine los siguientes aspectos.
#
#1: Si ambos numeros son iguales
#2: Si los numeros son diferentes
#3: Si el primero es mayor al segundo
#4: Si el segundo es mayor al primero
a = int(input('a: '))
b = int(input('b: '))
print('son iguales?', a ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.