blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
f21040812b1241328df75d665a7a1ecdf0b14834 | sananand007/LeetCodeProblems | /MajorityElement.py | 374 | 3.90625 | 4 | def MajorityElement(nums):
"""
:type nums: List[int]
:rtype: int
"""
if nums==None: return None
nums.sort()
count=0
n = len(nums)
candidate = nums[n//2]
for num in nums:
if num==candidate:
count+=1
if count>=(n+1)//2:
return candidate
retur... |
71c104628ae9f8830348e45736e33e8066156509 | shubham-beri/Point-Of-Sales-Software | /Customer1.py | 501 | 3.578125 | 4 | class Customer:
def __init__(self,cid,name,phoneNo,address,order):
self.cid = cid
self.name = name
self.phoneNo = phoneNo
self.address = address
self.order = order
def showCustomer(self):
return ("Customer ID: {}\nName: {}\nContact No: {}\nAddress: {}".for... |
43b6bcd65e382592e4e0b07d2e1a739b864594f6 | ahsan-rahim/Jumping-frog- | /FrogJump.py | 3,427 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 5 19:25:09 2020
@author: Ahsan Rahim
"""
#Graph to be AutoGenerated
graph={}
def validStates(node):
valid=[];
s=list(node);
for i in range(len(s)):
s=list(node);
if(i+1<len(s) and s[i]<='B' and s[i+1]=='-'):
... |
2961ec0fe3ae39a62d0822418b91674fcbc301db | lucasmbrute2/Blue_mod1 | /Aula13/Exercicio04_func.py | 623 | 4.03125 | 4 | # Faça um programa que calcule o salário de um colaborador na empresa XYZ.
# O salário é pago conforme a quantidade de horas trabalhadas.
# Quando um funcionário trabalha mais de 40 horas ele recebe um adicional de 1.5 nas horas extras trabalhadas.
def salario(n1,n2):
salario = n1 *n2
if n2 >= 40:
ext... |
698d2b093fd758c8b9f55e70a930ea09e6821717 | IamOmaR22/HackerRank-Problems-Solve-and-Programs-Practice-with-Python | /30 Days of Code/Day 25 - Running Time and Complexity.py | 878 | 4.125 | 4 | # Solution - 1
# Enter your code here. Read input from STDIN. Print output to STDOUT
import math
def isPrime(n):
if n <= 1:
return False
sqrt_n = math.sqrt(n)
if sqrt_n.is_integer():
return False
for i in range(2, int(sqrt_n)+1):
if n%i == 0:
return False
return... |
aecfed69bdeb9cfb937f3927fdf9232b18df33dd | qa-trainee/qa-trainee-learning-python | /python-practice/ATBS_S1_L7.py | 829 | 4.03125 | 4 | # ATBS_S1_L7.py is a proram that wrote to test my understanding of
# Automate the boring stuff Section 1, Lecture 7
# for loop
# for i in range(5)
# range (5) stops at 4
# you can give multiple arguement to range like range(5, 10)
# this will continue from 5 till 9
import datetime
print('This program prints a sum o... |
560f133094635d60fca4517fc8a68bc5a1ea3287 | mxl1994/Program_Python | /算法联系/插入排序.py | 309 | 3.609375 | 4 | A = [16,4,6,3,77,22,10,6]
def insert_sort(A):
for i in range(1, len(A)):
key = A[i]
j = i - 1
while j >= 0 and key < A[j]:
A[j + 1] = A[j]
j -= 1
A[j + 1] = key
return A
if __name__ == "__main__":
result = insert_sort(A)
print result
|
cacc60727d813b745399312d09ead10d4a63625d | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/luhn/25aae77f9280459cac2b3e7d34ad599d.py | 1,057 | 3.515625 | 4 | class Luhn(object):
def __init__(self, number):
self.number = number
def addends(self, offset=1):
number_string = str(self.number)
number_list = [int(digit) for digit in number_string]
reversed_list = number_list[::-1]
# Double every second number
reversed_list... |
d8828809e4d7ee616b28b386c53efc1238248ba9 | jmetzz/ml-laboratory | /basic_ml/src/neural_networks/base/costs.py | 1,752 | 3.5625 | 4 | import numpy as np
from numpy import log, nan_to_num
class CrossEntropyCost:
@staticmethod
def evaluate(activation, true_label):
"""Return the cost associated with an output activation and desired output
``y``.
The cross-entropy is positive number.
Note that np.nan_to_num is u... |
d3e25805b601aff974c730abd85b4368724d09d4 | grimmi/learnpython | /reversebytes.py | 810 | 4.125 | 4 | '''
A stream of data is received and needs to be reversed.
Each segment is 8 bits meaning the order of these segments need to be reversed:
11111111 00000000 00001111 10101010
(byte1) (byte2) (byte3) (byte4)
10101010 00001111 00000000 11111111
(byte4) (byte3) (byte2) (byte1)
Total number of bits will always be a mu... |
8767900d987e0fed3a5e6eff1afe2b6a80e12ab0 | mbgaspar/Cursos | /Descubra o Python/Cap. 04/leituraArquivo_start.py | 335 | 3.859375 | 4 | #
# Lendo arquivos com funções do Python
#
def leituraArquivo():
arquivo = open ("Novo Arquivo.txt", "r")
if (arquivo.mode == "r"):
conteudo = arquivo.read() #caso tenha um arquivo grande todo o arquivo irá para essa variavel, pode não ser boa ideia.
print (conteudo)
arquivo.close()
leitu... |
afbf05366c33bc9d395e7def0f88e1753ee69187 | takushi-m/atcoder-work | /work/abc121_d.py | 201 | 3.515625 | 4 | # -*- coding: utf-8 -*-
a,b = map(int, input().split())
def g(x):
if x%2==1:
return ((x+1)//2)%2
else:
return ((x//2)%2)^x
def f(a,b):
return g(b) ^ g(a-1)
print(f(a,b))
|
c6734f9980b6902a5230a0c61cbb2a0d99f520b7 | BohaoLiGithub/Leetcode | /Search a 2D Matrix/Search a 2D Matrix(Accepted).py | 535 | 3.53125 | 4 | class Solution(object):
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
m = len(matrix)
if m > 0:
n = len(matrix[0])
if n > 0 :
for i in range(m):
... |
f2c2668a934e8c7ee8f3737e4489d6bc5ef5d489 | swjtuer326/shiny-enigma | /基本数据处理.py | 658 | 3.625 | 4 | def getNum():
nums = []
iNumStr = input('请输入数字(回车退出):')
while iNumStr != '':
nums.append(eval(iNumStr))
iNumStr = input('请输入数字(回车退出):')
return nums
def mean(numbers):
s = 0.0
for i in numbers:
s += i
return s/len(numbers)
def dev(numbers, mean):
sdev = 0.0
for i in numbers:
sdev += (i-mean)**2
return... |
39ef37e43c5fca55ea2daf9022e19ab74be75945 | happyjun190/machine-learning-py | /function.py | 134 | 3.609375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
def area_of_circle(r):
return math.pi * r * r
print(area_of_circle(5)) |
5ab1cf1e2e1ab4618a0f5db70a49d1dc851574a6 | AshkenSC/Programming-Practice | /LeetCode/0136. Single Number.py | 515 | 3.53125 | 4 | # 0136. Single Number
'''
遍历数组,用字典存储元素出现过的次数。
'''
from typing import List
class Solution:
def singleNumber(self, nums: List[int]) -> int:
occurs = dict()
for num in nums:
if num not in occurs.keys():
occurs[num] = 1
else:
occurs[num] += 1
... |
33136278a794ebfecc9ca852a525aea70e365014 | viktor-taraba/Dataquest | /Python Programming: Intermediate/Introduction to Functions-4.py | 2,092 | 3.953125 | 4 | ## 1. Overview ##
f = open("movie_metadata.csv", 'r')
file = f.read()
rows = file.split('\n')
movie_data = []
for row in rows:
split = row.split(',')
movie_data.append(split)
print(movie_data[0:2])
print(rows[0:2])
## 3. Writing Our Own Functions ##
def movie(movie_data):
alist = []
for item in movie... |
374b34df61c51aa98285edb3f57ab8a0c8a8cb91 | zkz917/program-practice | /Remove Duplicates from Sorted Array.py | 606 | 3.5 | 4 | class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
p1, p2 = 0,1
# use two pointers to solve the problem
while p2 < len(nums):
if p2 < len(nums) and nums[p1]... |
6c914d0f3842230fe60198185e699f7060811ccd | vlcgreen/DigitalCrafts | /Python/Homework/W1D2/Day2HW_ExtraChallenge.py | 663 | 3.84375 | 4 | #Day 2 Homework Extra Challenge
# PROBLEM 1 - TRIANGLE NUMBERS
## Print the first 100 triangle numbers. formula
# num = 0
# for numbers in range(1,100):
# num += numbers
# print (num)
#I worked it this way first but it wasn't as pretty:
for stuff in range(1,100):
f = stuff * (stuff + 1) / 2
print(i... |
d8c7df818b20a08de6a1fc50435d841db5f33c4e | AshFrankland/Conway-s-Game-of-Life | /life.py | 5,469 | 3.578125 | 4 | import pygame
WIDTH = 800
FPS = 10
WIN = pygame.display.set_mode((WIDTH, WIDTH))
pygame.display.set_caption("Conway's Game of Life")
GREY = (128, 128, 128)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
class Cell:
def __init__(self, row, col, width, total_rows):
... |
13d6125e2dfdcf63be5ad2bd9e4703af1b325399 | amj18/test-driven-development | /Checkout.py | 1,779 | 3.546875 | 4 | from typing import Dict
class Checkout:
class Discount:
def __init__(self, nbrItems, price):
self.nbrItems = nbrItems
self.price = price
def __init__(self):
self.prices = {}
self.discounts = {}
self.items = {}
def addDiscount(self, item... |
5672d4a5b80291362a9e31d7aa5647d762b438d3 | FelipeMirandaM/Albion_bot | /Conexion/conection_lite.py | 2,424 | 3.59375 | 4 | import sqlite3
class conection:
def __init__(self):
self.con = None
def open_con(self):
self.con = sqlite3.connect("member_list.db")
def close_con(self):
self.con.close()
def load_data(self, members):
self.delete_data()
self.open_con()
query = "INSERT ... |
c39aecac652ba3860500c5ff37d7fa3f05d8e3bd | psideleau/shu-book-rental-owners | /book_rental_class.py | 1,833 | 3.859375 | 4 | class BookRental:
# Creating Book Rental class
def __init__(self, isbn, book_title, author, rental_id, owner_id, rental_value, start_date, end_date,):
self.isbn = isbn
self.book_title = book_title
self.author = author
self.rental_id = rental_id
self.owner_id = ow... |
d6fc0b18c210d5c6883c48fbe7c716805edd58df | thecodesanctuary/python-study-group | /assessment/assessment_1/DimejII/assignment5.py | 186 | 4.09375 | 4 | #this prog asks for your weight in kg
kilo_grams = float(input('Enter weight in Kg to Convert into pounds:'))
pounds = kilo_grams * 2.2
print(kilo_grams,' Kilograms =', pounds,' Pounds') |
bfb87251e8500338aa182edcdf96940323f10770 | DevinTyler26/learningPython | /mvaIntroToPython/if-else.py | 315 | 4.125 | 4 | g = 9
h = 8
if g < h:
print('g < h')
else:
if g == h:
print('g == h')
else:
print('g > h')
name = 'Devin'
height = 2
weight = 110
bmi = weight / (height ** 2)
print('bmi: ')
print(bmi)
if bmi < 25:
print(name)
print('is not overweight')
else:
print(name)
print('is overweight') |
666d881694b2d704cee38dabd05cc9c651b43136 | kelvin-jose/computer_vision_opencv | /erosion.py | 430 | 3.578125 | 4 | import cv2
import numpy as np
image = cv2.imread('image.jpg', 0)
"""
a kernel slides over the binary image like convolution and
changes the current pixel value to 0 if all the pixels under
the kernel are not 1s i.e erode the pixels. So the pixels of
the edges of white region might change from 1 to 0.
"""
kernel = n... |
fdbe94b9f0a67e74945563e17d56aa0e05236365 | Pysche666/coffee_machine_coding | /coffee_machine/core/beverage.py | 1,527 | 3.515625 | 4 | from coffee_machine.core.ingredient import Ingredient
class Beverage:
"""
A class for Beverage.
It has the information about ingredients, time required to prepare a beverage and dispense it.
"""
_preparation_time: int
def __init__(self, name, ingredients, preparation_time=10, dispensing_time=... |
97b88634e78f4ac8c0bfd3919da75ed9976c82dc | websvey1/TIL | /algorithm/home/every's_algorithm/하노이탑.py | 250 | 3.9375 | 4 | def hanoi(n, S, E, M):
if n == 1:
print(S, "->", E)
return
hanoi(n-1, S, M, E)
# print(S, "->", E)
hanoi(n-1, M, E, S)
# print("n=1")
hanoi(1, 1, 3, 2)
# print("n=2")
hanoi(2,1,3,2)
# print("n=3")
hanoi(3,1,3,2)
|
7dade6f6a5a3ec14cb6d745dad2b797ccf91c4c0 | pradeepkumar1017/guvitask | /hangman.py | 386 | 3.78125 | 4 |
import random
strs = ['A','B','C','D','E','F']
count = 0
string = random.choice(strs)
for i in range(5):
c = input('Enter a character: ')
if c in string and c!='':
print('Good')
counts = count + 1
if count == 3:
break
else:
print('You entered a wrong character')... |
53852d5166b4763891674d06b05ffe12376f67d3 | dicao425/algorithmExercise | /LeetCode/countingBits.py | 402 | 3.546875 | 4 | #!/usr/bin/python
import sys
class Solution(object):
def countBits(self, num):
"""
:type num: int
:rtype: List[int]
"""
result = [0]*(num+1)
for i in range(num+1):
result[i] = result[i>>1] + i&1
return result
def main():
aa = Solution()
p... |
43048d3b0847066a2e0ed27b1a65722ba5213c0f | psbarros/Variaveis3 | /2019-1/230/users/4023/codes/1877_1653.py | 196 | 3.515625 | 4 | from numpy import *
##############Entrada#################:
vet = input("Digite as iniciais do pais: ")
v1 = vet.split(',')
###############For####################:
for i in range(:
cont = cont |
f4f1b9f384bf64b302ce03d0be3a255a237f8498 | Satar07/whatpython | /code/pass7.py | 186 | 3.8125 | 4 | a = 0
while a < 100:
a += 1
if a % 7 == 0:
continue
elif (a + 3) % 10 == 0:
continue
elif (a + 30) % 100 <10:
continue
else:
print (a) |
e7f9b17221058f912c7eec6a21af0f325a79cd45 | tusvhar01/practice-set | /Practice set 38.py | 362 | 4.1875 | 4 | def fibonacci(n):
if n < 1:
return None
if n < 3:
return 1
elem1 = elem2 = 1
sum = 0 ## Fabonacci no.(it is addition of last two no.)
for i in range(3,n+1):
sum = elem1 + elem2
elem1, elem2 = elem2, sum
return sum
for n in range(1,51):
... |
3add99ca8bf8ed1aad0cf30d66f190f5eaeb3f76 | Yuvv/LeetCode | /2001-2100/2042-check-if-numbers-are-ascending-in-a-sentence.py | 802 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @File : 2042-check-if-numbers-are-ascending-in-a-sentence.py
# @Author : Yuvv (yuvv_th@outlook.com)
# @Date : 2021-10-25
class Solution:
def areNumbersAscending(self, s: str) -> bool:
v = -1
for e in map(int, filter(lambda s : s and s.isdigit()... |
8bf2136907255571402b7e11afc440f4c98f0282 | DianaBonilla/deber_Harry | /harry_potter.py | 1,421 | 3.703125 | 4 | ##ESCUELA POLITECNICA NACIONAL
##ESCUELA DE FORMACION DE TECNOLOGOS
##PROGRAMACION AVANZADA
##AUTOR:DIANA BONILLA-VALERIA OCHOA
##TITULO: OCURRENCIAS DE UNA PALABRA
print("\t\t\t Escuela Politécnica Nacional")
print("\t\t\t Escuela de Formación de Tecnólogos")
print("\t\t\t\t Programación Avanzada")
print("\t\t\t... |
bb63cb4638dc346fd9dcb37d374302756d9d29d5 | miguelabreuss/scripts_python | /CursoEmVideoPython/desafio89.py | 944 | 3.71875 | 4 | grade = []
aluno = []
notas = []
medias = float()
while True:
aluno.append(str(input('Nome: ')))
notas.append(float(input('Digite primeira nota: ')))
notas.append(float(input('Digite segunda nota: ')))
aluno.append(notas[:])
medias = (notas[0] + notas[1]) / 2
aluno.append(medias)
grade.appen... |
e29744b1b7710351d415e16ef198aacf9d1cf78a | LourdesOshiroIgarashi/algorithms-and-programming-1-ufms | /matrizes/thiagoD/13.py | 644 | 3.53125 | 4 | matriz1 = []
for i in range(4):
matriz1.append(list(map(int, input(
f"Digite os 5 elementos da linha {i + 1} divididos por espaço: ").split())))
matriz2 = []
for i in range(5):
matriz2.append(list(map(int, input(
f"Digite os 2 elementos da linha {i + 1} divididos por espaço: ").split())... |
6e4ab2110958b633deec1f6550cd28f5ca2293cb | ShourjaMukherjee/Dummy | /11thcodes/Lists/ASSIGN 111 - LIST - Rotate List (1).py | 646 | 3.734375 | 4 | def RollUp(L):
l=len(L)
t=L[0]
for i in range(l-1):
L[i]=L[i+1]
L[-1]=t
#print "Rolled Up List:-", L
return L
def RollDown(L):
l=len(L)
t=L[-1]
for i in range(l-2,-1,-1):
L[i+1]=L[i]
L[0]=t
#print "Rolled Down List:-", L
return L
L=[1... |
a44998ee0751e39ddc092b944f68f3615e30c37f | RuachKim/Algorithm_Practice | /CodeWithPython/codetest/etc/codetest04.py | 2,054 | 3.703125 | 4 | """
Greedy method: find all the ways to achieve goal.
count the number of condition, includes '3' in time
"""
# n = int(input())
# cnt = 0
# for i in range(n+1):
# for j in range(60):
# for k in range(60):
# num = str(i)+str(j)+str(k)
# if '3' in num:
# c... |
a0884cc494db0dff69a64054bdcc3f381202ebd7 | dhhyey-desai/python-crash-course-code | /for-loops.py | 115 | 3.859375 | 4 | fruits = ["apple", "banana", "orange"]
for x in fruits:
print(x)
else:
print("I'm done!")
|
a807c48bd3a26182853c9dc91b821104c4dcf676 | BrunoVittor/pythonexercicios | /pythonexercicios/pythonexercicios/ex015.py | 893 | 3.9375 | 4 | # km percorridos e dias pelos quais foi alugado, preço a pagar , carro custa 60 reais o dia , e 0,15 o km rodado
'''dia = int(input('Por quantos dias foi alugado: '))
km = float(input('Quando km foram rodados: '))
res = (dia * 60) + (km * 0.15)
print('Se passaram {} dias \n foram percorridos {} km \n O valor tota... |
e53a3021a6d9f9f779bb1e24fe4d105792c2d298 | LegendaryKim/Hackerrank_30_Days_of_Code | /8-DictionariesAndMaps/Solution.py | 407 | 3.796875 | 4 | num = int(input())
phone_book = {}
for i in range(num):
entry = str(input()).split(" ")
name = entry[0]
phone = int(entry[1])
phone_book[name] = phone
while True:
try:
name = input()
if name in phone_book:
phone = phone_book[name]
print(name + "=" + str(ph... |
f077be2430de2207d9301b5469f473337e671d77 | XiaoqingWang/python_code | /python语法基础/02.if、while、for/08-判断星期几.py | 381 | 3.796875 | 4 | #1.获取用户的输入
num = int(input("请输入一个数字(1~7):"))
#2.判断用户的数据,并且显示对应的信息
if num == 1:
print("星期一")
elif num == 2:
print("星期二")
elif num == 3:
print("星期三")
elif num == 4:
print("星期四")
elif num == 5:
print("星期五")
elif num == 6:
print("星级六")
else:
print("你输入的数据有误...") |
a1551921c6f4b23662ff71fbbaa8359235fbd987 | VitaliiStorozh/Python_marathon_git | /2_sprint/Tasks/s2.1.py | 423 | 4.09375 | 4 | # As input data, you have a list of strings.
#
# Write a method double_string() for counting the number of strings from the list,
# represented in the form of the concatenation of two strings from this list
def double_string(s):
return len([i for i in s if i + i in s])
data = ['aa', 'aaaa', 'abc', 'abcabc', 'qwe... |
3363948902d8d0c138b0593c345243bcb8c6f45a | DCC-Lab/RayTracing | /raytracing/ray.py | 8,026 | 3.59375 | 4 | import warnings
from .utils import deprecated
class Ray:
"""A vector and a light ray as transformed by ABCD matrices.
The Ray() has a height (y) and an angle with the optical axis (theta).
It also has a position (z) initially at z=0, the diameter of the aperture at that point
when it propagated throu... |
beff77c181bf91a2d1b6fbb37660257e34afcf4d | slavkoBV/solved-tasks-SoftGroup-course | /Sockets/Chat/model.py | 3,281 | 3.609375 | 4 | import sqlite3
import hmac
# Secret key for hash generate password
SECRET_KEY = 'secret'
def hash_generate(user_pass):
"""Generate hash of user password
:param user_pass: string
:return: hash.digest()
"""
user_hash = hmac.new(SECRET_KEY.encode(), user_pass.encode())
return user_hash.digest()... |
7a6f1ea8e0d8b3000e224ebe322015bd973ac702 | Junewang0614/pypypy | /chap07/p7-3.py | 119 | 3.53125 | 4 | n = input()
if int(n) % 10 == 0:
print(n + '是10的整数倍。')
else:
print(n + '不是10的整数倍。')
|
33922a0e31894e848897eef47323449828e5c90c | Jiaweihu08/EPI | /6 - Strings/6.12 - substring_matching.py | 1,055 | 3.96875 | 4 | """
Given two strings s and t, find the starting position of s in t if
s is a substring of t, otherwise return -1.
The naive approach is to go through t and at each position i compare
the substring starting at i to s. This leads to a O(n^2) algorithm.
A simple and more efficient algorithm for string matching is the
R... |
371791950f055bef08336f12740275146d3e1bcf | tkj5008/Luminar_Python_Programs | /Object_Oriented_Programming/polymorphism/demo2.py | 367 | 4.03125 | 4 | #overriding
# same method name and same num of parameters
# Child class method overide parent class method
class Person:
def printval(self,name):
self.name=name
print("Inside Parent",self.name)
class Child(Person):
def printval(self,class1):
self.class1=class1
print("Inside Chi... |
0708e51e1db878e97be5fab7fd0f87df2b21b872 | sibodiamond/kaggle-lshtc-1 | /tf-idf.py | 3,190 | 3.53125 | 4 | # Extract the most important terms from each document
# This script generates tf-idf.csv,
# where each document from {INPUT_FILE}
# is represented with {TERMS_NEEDED} most important terms.
# Structure of tf-idf.csv:
# - each line is a document,
# for example "335416,416827 57:3.5 70:3.0 71:2.5 72:1.5 81:1.5... |
ca541d793567078594fba910524598004e920ba8 | Chener-Zhang/HighSchoolProject | /python/hw3pr1/csgrid.py | 2,135 | 3.9375 | 4 | from turtle import *
#TheScreen = Screen()
#TheScreen.onclick( mouseHandler )
currentL = None
COL = -1
ROW = -1
currentXs = []
currentYs = []
def getCol(mouse_x, mouse_y):
global currentXs;
global currentYs;
global COL
global ROW
COL = 0
ROW = 0
for i in range(len(currentXs)-1):
... |
f4326995781d824ab481c03159b45581e7a328c6 | gautambatra100/Health-Management-System-in-Python | /Gym(Trainer-Client) Management System.py | 4,006 | 3.71875 | 4 | import datetime
def gettime():
return datetime.datetime.now()
try:
client_list={1:"Harry",2:"Gautam",3:"Sara"}
log_list={1:"add",2:"retreive"}
work_list={1:"diet",2:"exercise"}
while True:
for key,value in client_list.items():
print("press",key,"for",value,"\n",end="")
client_number=int... |
6f58ffc4fe45e530e846f7442fa3ede493bb68b2 | Niroshan-Selvaraj/100daysofpython | /day-19/main.py | 1,311 | 4.28125 | 4 | from turtle import Turtle, Screen
import random
tim = Turtle()
screen = Screen()
screen.setup(width=500, height=400)
all_turtles = []
user_bet = screen.textinput(title="Make your bet", prompt="Which turtle will win the race? Enter a color: ")
colors = ["red","green","yellow","blue","orange","purple"]
is_game_on = Fals... |
832bc6064a6e56e501dbe950822d714d0fc237cf | Android4567/Python | /integer.py | 126 | 4.09375 | 4 | a = int(input("Enter any Integer "))
if (a > 0):
print("Integer is positive")
else:
print("Integer is Negative")
|
77ec36dece8eb5e225eec561d2c904b45c5ac3e1 | jrcox/dsp | /python/q8_parsing.py | 734 | 4.25 | 4 | # The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’
# contain the total number of
# goals scored for and against each team in that season
# (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against them).
# Write a ... |
3c2f528708277c04773a910e90b372b6dea7374f | syurskyi/Python_Topics | /115_testing/_exercises/_templates/temp/Github/_Level_1/Python_Unittest_Suite-master/Python_Test_Mock_Check_Multiple_Calls.py | 2,151 | 3.671875 | 4 | # Python Test Mock
# unittest.mock � mock object library
# unittest.mock is a library for testing in Python.
# It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used.
# unittest.mock provides a core Mock class removing the need to create a host of st... |
f3b468bfae4c95364df663edf7431d671c987899 | Cheryl-Tsui/D002-2019 | /L1/Q2.py | 225 | 3.921875 | 4 | from math import*
print(8*3.57)
print(5+30*20)
print((5+30)*20)
print(1+(2+20*3)/(4*2))
print(1+2**10)
print(ceil(29/4))
radius=input("What is the radius?")
int(radius)
radius=sqrt(100/pi)
print((2*radius+1)**2)
|
68cb62e5d516e60f3fe43db4066fb9bf5eaacf52 | gitter-badger/python_me | /hackrankoj/itertool/permutations.py | 551 | 3.578125 | 4 | #!/usr/bin/env python
# coding=utf-8
from itertools import permutations
print '\n'.join([''.join(_) for _ in sorted(list(permutations(*map(lambda s:int(s) if s.isdigit() else s,raw_input().split()))))])
#上面语句的list可以不用写,单纯返回一个迭代器,反正前面有for
'''
permutations(iterable[,k])函数会根据中的iterable的顺序排列,'213'就会先2开头,然后1开头,再3开头,
'''
... |
17186a0b0140bf6713855347e1c33f1b64d2b837 | peterneyens/pygame-tetris | /tetris.py | 9,909 | 4 | 4 | #!/usr/bin/python
# Filename: tetris.py
#
# A game of Tetris
#
# Author; Peter Neyens
# Version: 31-01-2012
import random
class Position:
'''A postition'''
def __init__(self, x=0, y=0):
self.x = int(x)
self.y = int(y)
def rotate90(self):
'''Return the positions when this position... |
2f171ba7822aa3b5e3de7b13b3574bb94fc37612 | manelmmh/Arrays-practice | /pos_neg_index.py | 608 | 3.515625 | 4 | #another approach to solving the negative, positive numbers sorting
# is by using 2 index pointers, one is incremented and the other is decremented
def partition(lo,hi):
up_ptr=lo
dwn_ptr=hi
while(up_ptr<dwn_ptr):
while(A[up_ptr]<0):
up_ptr+=1
while(A[dwn_ptr]>... |
ba22c0a53a402f2ae7174548e3e240f099e6bc83 | DanzTheDeadly/algorithms_and_data_structures | /python/algorithms/sort.py | 1,941 | 3.59375 | 4 | from math import floor, ceil, inf
def insertion_sort (m, inplace=False):
if not inplace:
m = m[:]
for j in range(1, len(m)): # m
k = m[j] # m-1
i = j-1 # m-1
while i >= 0 and m[i] > k: # m(m+1)/2
m[i+1] = m[i] # m(m+1)/2-1
i -= 1 # m(m+1)/2-1
m[i+... |
3840b515569ee1b25ebd663822b20d9e33b75ad4 | violenttestpen/DataStructureAlgorithms | /Sort/SelectionSort.py | 352 | 3.734375 | 4 | # selection sort [O(n**2)]
def ssort(array):
a = array[:]
# start from the second element
for i in range(len(a) - 1):
min_index = i
for j in range(i + 1, len(a)):
if a[min_index] > a[j]:
min_index = j
if min_index != i:
a[min_index], a[i] = a... |
d25b39f60a7cd0b3123655a705bf046610e81db3 | marionseignovert/tp-proba | /dossier_code/monty_hall.py | 2,735 | 3.734375 | 4 | from random import *
class Game:
def __init__(self):
porte_win = randint(0, 2)
self.porte_gagnante = porte_win
self.porte_ouverte = -1
self.porte_designe = -1
#print("Porte gagnante :", self.porte_gagnante)
def init_game(self):
pass
def choix_porte(self):... |
32f22d35eccf4f3d90785c49d20f669bb1ecd408 | El-fish/Sirius_python | /4 Условия/ThirdStar.py | 552 | 3.8125 | 4 | x1 = int(input())
y1 = int(input())
x2 = int(input())
y2 = int(input())
# 1
if x1 + 1 == x2 and y1 + 2 == y2:
print("YES")
# 2
elif x1 + 2 == x2 and y1 + 1 == y2:
print("YES")
# 3
elif x1 + 2 == x2 and y1 - 1 == y2:
print ("YES")
# 4
elif x1 + 1 == x2 and y1 - 2 == y2:
print ("YES")
# 5
elif x1 - 1 == x... |
b9c5b548e99abdbe246b9e97b0777a0969c80776 | fiona-tina/Duke-ECE-568 | /Scalability&Performance/erss-hwk4-kx30-wz125/analysis/main.py | 756 | 3.75 | 4 | import matplotlib.pyplot as plt
import sys
# Read a file line by line and return list of lines.
def read_file(filename):
f = open(filename, "r")
lines = f.readlines()
f.close()
return lines
# Parse the log file line by line.(strictly follow our print format)
def parse_log(filename):
lines = read... |
c2298f59deb8d79100c23150513d8bbc292148fd | Pizzabakerz/codingsuperstar | /python-codes/codes/file_operations/file_writting.py | 505 | 3.765625 | 4 | # if you are writting a file it dont mean the file should exist
st = """
Java
A suite of computer software products and specifications from Sun Microsystems
for developing apps that can run on many different types of computers.
"""
# write
f = open('/Users/jacksonjegatheesan/PycharmProjects/meena/file_operat... |
68da4f7f9003cc013a229ad141839bfcb801a75f | sendurr/spring-grading | /submission - lab5/set2/KAITLYN CALLAHAN SHEREYK_9399_assignsubmission_file_Lab5/lab5/Q2.py | 289 | 3.703125 | 4 | def printstar(n):
print '*'*n
def printstarx(n, row=1):
default=1
for i in range(row):
printstar(n) # call printstar function row number of times
printstarx(10)# print star of lenth n and in 4 row
printstarx(10,5)# print stars of length 18 and in one row (default value of row = 1) |
ebe83d3d4e9e3ffb5ba6110cb4878e2eab888abf | suhas456/suvvi | /vtweetp.py | 656 | 3.703125 | 4 | #tweeting using python
import tweepy
def get_api(cfg):
auth = tweepy.OAuthHandler(cfg['consumer_key'], cfg['consumer_secret'])
auth.set_access_token(cfg['access_token'], cfg['access_token_secret'])
return tweepy.API(auth)
def main():
# Fill in the values from ur tweeter a/c
cfg = {
"consumer_key" ... |
daf0db3d3c8ff11e5a76ad7bc2528a281a73fccb | localsnet/Python-Learn | /PCC/ch9/95login_attempts.py | 1,340 | 4.09375 | 4 | #!/usr/bin/python3
class User():
def __init__(self, first_name, last_name):
"""Initialize name and age attributes."""
self.first_name = first_name
self.last_name = last_name
self.age = 0
self.gender = ""
self.login_attempts = 0
##Increment method
def increment_login(self):
""" Method increments the val... |
8fcbf12038249929fc173fccc73b1a31b51e900d | Rokoshan/CP3-Komkrit-Visetkhumphai | /Assignment/Exercise8_Komkrit_V.py | 1,598 | 3.9375 | 4 | usernameInput = input("Username :")
passwordInput = input("Password :")
username = "Komkrit"
password = "12345"
if usernameInput == username and passwordInput == password:
print(" ยินดีต้อนรับเข้าสู่ร้านของเรา ")
print("------- Bank Shop -------")
print("กรุณาเลือกรายการสินค้าที่ท่านต้องการ")... |
d512af493cb803cdf1258b184db67468d232faca | dkowsikpai/s1python | /Python/list_fibo.py | 131 | 3.578125 | 4 | listf=[0,1]
n=int(input("Enter the limit: "))
for i in range(2,n+1):
listf.append(listf[i-2]+listf[i-1])
print(listf)
input() |
49f4b36a143cbbfdb52cd59ebce569f984b985bc | ChrisMiller83/python-101 | /hello2.py | 201 | 4.15625 | 4 |
name = input('What is your name? '.upper())
print("HELLO, " + name.upper(),'!')
countLetters = len(name)
greeting = (f"Your name has {countLetters} letters in it! Awesome!")
print(greeting.upper()) |
03fc1dd1a2b0510ce6d206a45ce5ab487ee7a1ad | Crucialjun/HelloWorldPython | /practice+part+1.py | 674 | 4.25 | 4 | price_product_1=input("What is the price of product 1:")
quantity_product_1=input("What will be the quantity of product 1:")
price_product_2=input("What is the price of product 2:")
quantity_product_2=input("What will be the quantity of product 2:")
price_product_3=input("What is the price of product 3:")
quantity_prod... |
3b98e20d5e25a6df2b95ebd259e55910a03dbcbb | pedantic79/Exercism | /python/darts/darts.py | 207 | 3.609375 | 4 | def score(x, y):
dist_squared = x*x + y*y
if dist_squared > 100:
return 0
elif dist_squared > 25:
return 1
elif dist_squared > 1:
return 5
else:
return 10
|
ec10fd43b4f7ac7da6b49222d25b57c19eaeb3a7 | sheepolata/GraphEngine | /main.py | 3,306 | 3.546875 | 4 | # import the pygame module, so you can use it
import pygame
from pygame.locals import *
import random
import numpy as np
import drawer
import ggraph
import graphdisplay as gd
import console
GlobalLog = console.Console(head="Head, ", tail=", tail")
InfoConsole = console.Console()
# define a main function
def main():
... |
a6f73728a83ea22a17f3d36102977bfaea74138a | irfan-ansari-au28/Python-Pre | /Doubt/kanhu_ll_palindrome.py | 1,061 | 3.8125 | 4 | #Q-2 ) Palindrome Linked List
#Answer:-
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def isPalindrome(self, head):
if not head or not head.next:
return True
... |
364c0b9226188515f66ef63c77eee0aaf3026ffe | varlack1021/HarvardX-Data-Science | /Discrete Probaility/monty_hall_problem.py | 1,215 | 4.25 | 4 | '''
Say there are three doors and one door is the correct door.
Once a person chooses a door, one wrong door is then revealed.
The person then has two remaining doors to choose from and can either switch their choice
and choose the other door or stay with their original door.
Question---
Is the probablity higher is ... |
b6381838ea6c9d0915aaa451e9c46fd32858f2a2 | kvharini/Harni | /FindFileCount.py | 1,089 | 3.671875 | 4 | import os
import math
def findDirectories(root_dir, keyword):
outputArray={}
for root, Dirs, files in os.walk(root_dir):
for Directory in Dirs:
if(Directory is not None):
fileCount =FindFilecount(Directory)
if(fileCount is not None):
... |
924c3db6848f1d81c4195d6bf6f2f8def4812fe2 | projeto-de-algoritmos/Divide_Hanoi_tower | /hanoi.py | 368 | 3.921875 | 4 | def TowerOfHanoi(n , fromT, toT, aux):
if n == 1:
print("Move disk 1 from tower",fromT,"to tower",toT )
return
TowerOfHanoi(n-1, fromT, aux, toT)
print("Move disk",n,"from tower",fromT,"to tower",toT)
TowerOfHanoi(n-1, aux, toT, fromT)
n = input("Number of disks in your hanoi t... |
bb5c403f43b460b3398149f6e334a6e01198a40f | phanithi/PythonSamples | /PythonSamples/src/com/python/samples/strings/RepeatedCharacterFinder.py | 365 | 3.640625 | 4 | '''
Created on Apr 13, 2017
@author: Phanithi
'''
# Find 1st repeated character. duplicate comment
def findRepeatedChar(s):
print('Inside function : findRepeatedChar()')
if(len(s) == 1) : return s
st = set()
for ch in s:
if (ch in st):
return ch
else:
s... |
8aa61193db7a6dc88fa247fd76fc144c071934df | spirit0908/pyTimer | /timer.py | 2,276 | 3.578125 | 4 | #!/usr/bin/python
#import Tkinter
from tkinter import *
from tkinter import ttk
from tkinter import font
import time
import datetime
#import wiringPi2 as wiringpi
import RPi.GPIO as GPIO
global endTime
global timer_M
global timer_S
global Timer_val
def quit(*args):
root.destroy()
def show_time():
# Get the... |
750d5d783685fac09cdae6991017d5febecddb44 | renanaquinno/python3 | /#ATIVIDADES_URI/#AtividadeURI_3_Iterações/AtividadeURI_3_Intereacoes_1143_quadrado_ao_cubo.py | 247 | 3.9375 | 4 | #entrada
n = int(input())
contador = 1
# processamento
def quadrado_cubo (n, contador):
while contador <= n:
print(contador, contador*contador, contador**3)
contador += 1
#saida
quadrado_cubo(n, contador) |
ad03024b2e54ca4368dd0eb01d01db89e75eafea | capslockd/test | /test_code_python/randomizer.py | 233 | 3.71875 | 4 | import random
print(random.randrange(10, 20))
x = ['a', 'b', 'c', 'd', 'e']
# Get random choice
print(random.choice(x))
# Shuffle x
random.shuffle(x)
# Print the shuffled x
print(x)
# Print random element
print(random.random()) |
6ae70a82e4e9534eb5ecbeb11f977d5a4a7bde80 | njoki2017/Age-calculator | /age calculator.py | 426 | 4.15625 | 4 | from datetime import date
import calendar
AGE = int(input('enter your age: '))
YEAR = int(input('enter the current year: '))
DOB= int(input('date of birth(1-31): '))
month = int(input('month(1-12): '))
current_date = 18,5
if DOB >18 and month > 5:
b = YEAR - AGE - 1
else:
b = YEAR - AGE
birthday = ... |
c807d115d66bd83c1628c9312c24fac282af5259 | guilhermeagostinho22/exercicios-e-exemplos | /Pyton/exercicio8.py | 113 | 3.90625 | 4 | kelvin = float(input("Digite a temperatura em kelvin: "))
print("temperatura em celcius é: ", (kelvin - 273.15)) |
a06e68bb473d20d26fdf2f25fc01678e2d9933c8 | DziadoszWiktor/pp1 | /02-ControlStructures/Mandat.py | 265 | 3.546875 | 4 | a = int(input("Podaj limit predkosci (km/h): "))
b = int(input("Podaj predkosc pojazdu (km/h): "))
if b<=60:
m=(b-a)*5
print("Mandat (zl): ",m)
if b<=50:
print("Mandat (zl): 0 ")
if b>60:
n=(b-a)*5*1.5
print("Mandat (zl): ",n)
|
215967a30e5f451c6ca35442f42756175bbc4e74 | bgoonz/UsefulResourceRepo2.0 | /GIT-USERS/TOM-Lambda/CSEU4_Intro_Python_GP/rps.py | 2,459 | 4.15625 | 4 | import random
# Create a rock/paper/scissors REPL loop
# Have a computer AI to play against us
# Keep track of the score
# Rules: r beats s, s beats p, p beats r
wins = 0
losses = 0
ties = 0
<<<<<<< HEAD
choices = ['r', 'p', 's']
=======
choices = ["r", "p", "s"]
>>>>>>> 23fb4d348bb9c7b7b370cb2afcd785793e3816ea
whil... |
953b340846d1a0f6d21e42bea8bd5340f454bbbe | RodolfoDelgadoDev/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/12-roman_to_int.py | 797 | 3.65625 | 4 | #!/usr/bin/python3
def roman_to_int(roman_string):
if type(roman_string) is not str or roman_string is None:
return 0
ro = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
con = 0
rev = False
lon = len(roman_string)
for n in range(lon):
if rev is True:
... |
0438667447eb04ee2e25877290625d86adf4946b | 7Aishwarya/HakerRank-Solutions | /Data_Structures/queues/truck_tour.py | 1,985 | 4.28125 | 4 | '''Suppose there is a circle. There are N petrol pumps on that circle. Petrol pumps are numbered 0 to N-1 (both inclusive).
You have two pieces of information corresponding to each of the petrol pump: (1) the amount of petrol that particular
petrol pump will give, and (2) the distance from that petrol pump to the nex... |
1d0c573ffb1053bd49ee3a8e6b58e9abd9a3fe3d | srungarapugopikrishna/problems | /bit_wise_and.py | 951 | 3.578125 | 4 |
# def bit_wise():
# n = int(raw_input())
# for _ in range(n):
# ip = raw_input()
# A = int(ip.split(' ')[0])
# B = int(ip.split(' ')[1])
# sol = A
# for i in range(A, B+1):
# sol = sol & i
# if sol == 0:
# break
# print sol
# print bit_wise()
def significant_bit_p... |
573a596f0811fd5063018db6dd11204d053572c5 | Cooleyy/AdventCode2020 | /day2/day2solution.py | 782 | 3.625 | 4 | #!/usr/bin/env python3
import sys
passwordsFile = open (sys.argv[1], 'r')
passwordAndRules = passwordsFile.read().splitlines()
counter = 0
for item in passwordAndRules:
passAndRule = item.split()
passAndRule[0] = list(map(int, passAndRule[0].split("-")))
passAndRule[1] = passAndRule[1][0]
passwordAnd... |
abeee882a38315b1e33d00bc2e98f88ec1358034 | yorch-el-profe/TECP0006FSPYOL2101 | /sesion06/inventario_tienda.py | 1,412 | 3.96875 | 4 | class Producto:
def __init__(self, nombre, precio):
self.nombre = nombre
self.precio = precio
def __str__(self):
return "{} - ${}".format(self.nombre, self.precio)
inventario = []
def agregar_producto():
print("Ingresa el nombre:")
nombre = input()
print("Ingresa el precio:")
precio = inpu... |
585daa66a34fccafbb8efeee1a31177b3306d967 | ShivLakhanpal/CS-UY-1114 | /Lab Work/Lab 8.py | 2,048 | 3.953125 | 4 | #1a
print("Problem 1a: ")
n = 10
def fib(n):
if n == 1:
return 1
elif n == 0:
return 0
else:
return fib(n-1) + fib(n-2)
print(fib(n-10),fib(n-9),fib(n-8),fib(n-7),fib(n-6),fib(n-5),fib(n-4),fib(n-3),fib(n-2),fib(n-1))
#1b
print(... |
8eae022df50cf8cf7670664fbc030f4240a055a3 | becca6223/Tech_Prep | /recursion/pairParens.py | 935 | 4.125 | 4 | def getAllPairParens(n):
"""
n: n pairs of parentheses
"""
if n == 0:
return None
result = []
getAllPairParensVisit(n, 0, result, "")
return result
def getAllPairParensVisit(n, openLeft, result, string):
"""
n: remaining pairs
openLeft: number of left parentheses
result (list): contains all the possi... |
ef3c1af06dad30e5a132fc26169ab89ba61f963c | J0e-Kozsuch/Monte-Carlo-Poker-Probabilities | /Poker Simulations.py | 19,916 | 3.65625 | 4 | import numpy as np
import pandas as pd
import math as m
import os
import random as r
def reformat_numbers(x):
'''
Allign one and two digit numbers to consistently have two as a string
'''
x=str(x).strip()
if len(x)<2:
return '0'+x
return x
class best_poker_hand:
... |
adf1bda5febdb6e0a967d53fcd48660eca99e671 | BPBO/Project1 | /build/lib/Calculadora_pkg/__main__.py | 5,907 | 3.75 | 4 | '''--------------------------------------------------------------------
Tittle: Interfaz grafica de la calculadora
Developed by: Alex Montano Rojas
Date: January of 2021
-----------------------------------------------------------------------
'''
import tkinter # Libreria que maneja el entorno grafico en p... |
15d91d49699e305ed7e35be6f3cab36df170469b | louisuss/Algorithms-Code-Upload | /Python/AlgorithmsBookStudy/Nonlinear/Tree/tree_travelsals.py | 379 | 3.5 | 4 | def preorder(node):
if node is None:
return
print(node.val)
preorder(node.left)
preorder(node.right)
def inorder(node):
if node is None:
return
inorder(node.left)
print(node.val)
inorder(node.right)
def postorder(node):
if node is None:
return
postorde... |
b77d412b49a07e6bde4c21d8e6af61c25fe84a6b | rafaelvictor88/python3exercises | /ex034.py | 257 | 3.71875 | 4 | salário = float(input('Qual o valor do salário do funcionário? R$'))
if salário > 1250:
novo = salário + (salário * 10 / 100)
else:
novo = salário + (salário * 15 / 100)
print('O seu salário passará a ser de R${:.2f}.'.format(novo))
|
bdeec68890498468a2bdb9f2add8bfc7a203082c | RobertG247/classDAY | /tomorrow/tempo.py | 303 | 4.15625 | 4 | def Temperature():
entry="yes"
while (entry=="yes" or entry=="Yes" ):
x = float(input("what temperature is it outside in grades fahrenheit??"))
y=(x-32)/ 1.8
print ("the temperature in celsius is", y)
entry=input("continue yes or no?")
Temperature()
|
2daaea5c2e96d8f0385f2a9ccd1be1dc887bf7d0 | wjasonhuang/python_utils | /standard_library/concurrent_execution/lib_queue.py | 1,499 | 4.28125 | 4 | '''
https://docs.python.org/3/library/queue.html
class queue.Queue(maxsize=0) constructor for a FIFO queue
class queue.LifoQueue(maxsize=0) constructor for a LIFO queue
class queue.PriorityQueue(maxsize=0) data format: (priority_number, data)
Queue.qsize()
Queue.empty()
Queue.full()
Queue.put(ite... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.