blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
3edc7594094c64084caba96c3fec8299e5796f5f | pke11y/wpe | /b1/1-travel/solution.py | 1,262 | 4.03125 | 4 |
visits = {}
COMMA = ","
def collect_places():
"""
Collect city and country on the CLI from the user
"""
global visits
visits = {}
while True:
place = input('Tell me where you went: ')
if place == "":
return
elif not COMMA in place:
print("That's ... |
026d8d7fce772faafe68ba8898cf90b3989c79c6 | shenhuaze/jianzhi-offer | /python/print_numbers.py | 322 | 3.90625 | 4 | # @author Huaze Shen
# @date 2020-05-03
from typing import List
def print_numbers(n: int) -> List[int]:
result = []
max_num = 0
for i in range(n):
max_num += 9 * 10 ** i
for i in range(max_num):
result.append(i + 1)
return result
if __name__ == '__main__':
print(print_number... |
714b0edd520c2f28f5330ecdbf9609160debb387 | AbbyGeek/CodeWars | /8kyu/STRONGN Strong Number.py | 256 | 4.03125 | 4 | def strong_num(number):
from math import factorial
sum = 0
numlist = [int(x) for x in str(number)]
for x in numlist:
sum += factorial(x)
if sum == number:
return "STRONG!!!!"
else:
return "Not Strong !!" |
048a9bd61479fe626a0a7b4b508f2607003583ed | a973826287/dlLearning | /NumpyMatrixMultiplication.py | 1,183 | 3.8125 | 4 | import numpy as np
def generate_numpy_matrix(m, n):
a = np.random.randint(10, size = m * n, dtype = np.int32) + 10
a = a.reshape(m , n)
return a
matrix = generate_numpy_matrix(10, 5)
print (matrix)
print (matrix[0]) # first row
print (matrix[:, 0]) # first column
print (matrix[0::2]) # odd rows
matrix1 ... |
1ab9f3408d1437258a28b761c2d64cc57538a961 | robertvari/python_alapok_211106_1 | /phonebook_app.py | 529 | 3.59375 | 4 | import os, json, time
phonebook = {}
data_file = "phonebook.json"
# check data file
if os.path.exists(data_file):
with open(data_file) as f:
phonebook = json.load(f)
# get data from user
name = input("Your name?")
address = input("Your address?")
phone = input("Phone?")
email = input("Email?")
# add to... |
6e40b3efe00f9ce4a27b1a92df2983bed127dc35 | teyter/keppnis | /2021/vika03/checkmate/checkmate3.py | 2,694 | 3.671875 | 4 | board = []
for i in range(8):
board.append(list(input()))
def pl(lst):
for i in lst:
print(i)
def locate(board,piece):
for i in range(8):
for j in range(8):
if board[i][j] == piece:
return (i,j)
def count(board):
K = 0
R = 0
k = 0
for i in range... |
cb6f5647b6aac7851421b0280c95a4cf2654dc8c | Nitercrawler/hello-world | /Homework1/Birthday_Calculator.py | 1,005 | 4.28125 | 4 | # Michael Donald # 1896510 #
# College of Technology
# The University of Houston#
# CIS 2348 - January 27, 2021 #
# # # Homework #1 #####
# Birthday Calculator #
# Current date input
print('Birthday Calculator')
print('Current Day')
current_month = int(input('Month: '))
current_day = int(input('Day: '))... |
1472b75c6545e25178f368009b666a7cdbbffbef | jorgeacosta19/BrandTech_WebDev | /A6/6.12.py | 141 | 4.125 | 4 | #12 - Write a Python program to reverse the digits of an integer.
number=int(input("Please type a digit: "))
print(str(number)[::-1])
|
02c9f86810f63628d1c8462b19f1d5479c8b1396 | agrimsingh/50.007-Machine-Learning | /pset1/pset1_agrim_q4.py | 1,597 | 3.609375 | 4 | import numpy as np
import matplotlib.pyplot as plt
"""
Linear transforms in 2 variables
"""
#4A
def generate_gaussian_data(n):
x1 = np.random.normal(1,1,n)
x2 = np.random.normal(3,1,n)
return np.array([x1,x2])
def question4():
#Plot the 100 points
x = generate_gaussian_data(100)
plt.plot(x[0,:... |
9b6abd98bfd40085e7255b212801aaeb267219ac | YEWOONY/Python_CodingDojang | /Unit19/judge_star_mountain.py | 247 | 3.90625 | 4 | h = int(input())
for i in range(h):
for j in range(h-1, -1, -1):
if j <= i:
print('*', end='')
else:
print(' ', end='')
for j in range(h):
if j < i:
print('*', end='')
print() |
fe5bbf741882b831f5fc6523b5c4c55672c55a94 | SleepwalkerEJ/Firts | /Num.py | 166 | 3.796875 | 4 | def is_prime(x):
for i in range(2, x/2 + 1): #Por cada numero del 2 al 100
if x % i == 0:
return False
return True
print [is_prime (i) for i in range(2,100)] |
afecf856168e8a16f60ec912e072ab9c9a9fbbce | davidhousedev/Code-Wars-Solutions | /jan_18_2017.py | 2,324 | 4.25 | 4 | # Description:
# Write a program that will calculate the number of trailing zeros in a factorial of a given number.
# N! = 1 * 2 * 3 * 4 ... N
# zeros(12) = 2 # 1 * 2 * 3 .. 12 = 479001600
# that has 2 trailing zeros 4790016(00)
# Be careful 1000! has length of 2568 digital numbers.
def zeros(n):
sum = 0
co... |
14c1c4bdd5817b28b1b758d5b3d3fe51bb959f95 | LalithK90/LearningPython | /privious_learning_code/QuotationInPython.py | 448 | 4.40625 | 4 | print("Quotation in Python")
# Python accepts single ('), double (") and triple (''' or """) quotes to denote string literals,
# as long as the same type of quote starts and ends the string.
# The triple quotes are used to span the string across multiple lines.
word = 'word'
sentence = "This is a sentence."
paragraph... |
e9af950eb0753d93c1309df2aabb46d4c2a4679e | hemuke/python | /17_process_thread/26_0_multithread_synchronization_lock.py | 935 | 3.828125 | 4 | from threading import Thread
from threading import Lock
import time
start = time.time()
num = 0
#################################
#为了保证数据的一致性 #
#创建threading属性Lock的实例对象#
#################################
lock = Lock()
def do_sth():
global num
for i in range(1000000):
"""
# 上锁
... |
8a0500b0587418cd5f61d5ce50c9d4d1c283ef4b | menliang99/CodingPractice | /BASIC/Overriding.py | 232 | 3.703125 | 4 | class BaseClass(object):
def test(self):
print "hom"
class InClass(BaseClass):
def test(self): # function overriding
print "hammer time"
#print BaseClass.__subclasses__() # find the inheritance class
i = InClass()
i.test
|
8f7329745bd74286e1d3df0ea9914dfa18347a3b | anwittin/Python | /Final Project/final project.py | 3,384 | 4.0625 | 4 | from sys import exit
import time
def kitchen():
print "This is the kitchen, there is food to cook and a small door at the back too."
print "You're hungry. what do you do?"
print "cook | enter door"
choice = raw_input("> ").lower()
if choice == 'cook':
print "Nice, hopefully you know what you're doing!\n"
... |
b5268a5bb4e165bbfee3dfe4216dbe6c179616e1 | edu-athensoft/ceit4101python_student | /ceit_191116/py200111/review.py | 408 | 4.0625 | 4 | """
"""
# input("Enter your name:")
# input("Enter your password:")
# input("Enter your city:")
# input()
# mynum = input("Enter a number")
# print(mynum, type(mynum))
print(1,2,3)
print()
print(11,22,33, sep=",")
print(1,2,3, end="&")
print(1,2,3, end="\n") # print(1,2,3)
# print out a matrix 3x2
"""
11 12
21 2... |
2ae36f1d56a0f5f8453fb5b647a6c579ff1ead2c | Saraaltaweel/data-structures-and-algorithms | /python/challenges/array_binary_search/array_binary_search.py | 468 | 3.84375 | 4 | def BinarySearch(list,val):
indx_first=0
indx_last=len(list)-1
while indx_first <= indx_last:
middle_val=len(list-1)/2
middle_val_num=list[middle_val]
if middle_val_num==val:
return middle_val
elif middle_val_num>val:
indx_las... |
9aea7c9f41217b8053a3663457106211511f61ae | zcf1998/zcf1998 | /ex10.py | 280 | 3.703125 | 4 | import numpy as np
def Cir(r,name):
C=2*np.pi*r
print "The circumference of %s is %f."%(name,C)
def dif(a,b):
return a-b
a=raw_input("input float1\n")
a=float(a)
b=raw_input("input float2\n")
b=float(b)
c=dif(a,b)
print "%f"%c
Cir(6378,"Earth")
Cir(3396,"Mars")
|
dd186ed91a1f218b19c0afef835e36e406a4a7fd | Mat1005/esercizi_5-8 | /es5.py | 420 | 4.09375 | 4 | Numeri = []
Nndivi3 = []
n = int(input("quanti numeri scriverai?"))
for n in range(1,n +1):
numero = int(input("scrivi un numero compreso tra 1 e 30 inclusi"))
Numeri.append(numero)
divi = numero%3
if divi > 0 or divi < 0:
Nndivi3.append(divi)
else:
break
print("ecco i num... |
d3d6bcbcd4b2ba104acb9fee32f57ce11d961b4b | JoshuaRomanV/W3school-Python | /Python Strings/Ejercicio 28.py | 136 | 4.03125 | 4 | # Reemplace el carácter H con una J.
txt = "Hola Mundo!"
txt = txt.replace("H", "J")
print(txt)
# replace sirve para remplazar caracteres.
|
bc1e85598a1016be7b161f86a4b1456c630b1a41 | shiyanshirani/w3s-150-questions | /10_% character usage.py | 159 | 3.984375 | 4 | n = int(input("Input an integer : "))
n1 = int( "%i" %n )
n2 = int( "%i%i" %(n,n) )
n3 = int( "%i%i%i" %(n,n,n) )
print("Expected sum = {}".format(n1+n2+n3))
|
7c16687f89e299ca5f83137b4409831c37dcd1e5 | the-sankari/Python | /week 2/module 2/Problem2_7.py | 512 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Sep 12 20:01:11 2021
@author: Kajol Shutra Dhar
"""
#%%
def problem2_7():
""" computes area of triangle using Heron's formula. """
sideA = float(input("Enter length of side one: "))
sideB = float(input("Enter length of side two: "))
sideC = float(input("Ente... |
1c8fb9f324b65b01f5c48896388d79c4a3b0a434 | mikehung/leetcode | /189.Rotate_Array.py | 712 | 3.828125 | 4 | #!/usr/bin/env python
class Solution(object):
def rotate1(self, nums, k):
nums[:k], nums[k:] = nums[len(nums)-k:], nums[:len(nums)-k]
def rotate(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: void Do not return anything, modify nums in-place instead.
... |
2a93a1a65358768e00ff38173b72608b0dc23157 | wxzoro1/MyPractise | /python/liaoscode/迭代.py | 356 | 3.984375 | 4 | d = {'a': 1, 'b': 2, 'c': 3}
for x in d:
print(x)
#判断可迭代对象
'''from collections import Iterable
print(isinstance({11,112},Iterable))
isinstance(11,Iterable)
isinstance([11,112],Iterable)'''
# 如果需要下表排序字典需要先进行字典转化为列表嵌套元祖
b = list(d.items())
for i,items in enumerate(b):
print(i,items)
|
138b44ce9830ac058fe1f80d6ef0207b8c6bfee9 | Victor06022001/Maratona-Python-3 | /cedulas.py | 563 | 3.765625 | 4 | nota = int(input())
cedula = ['100', '50', '20', '10', '5', '2']
print("{} nota(s) de R$ 100".format(nota//int(cedula[0])))
valor = nota % 100
print("{} nota(s) de R$ 50".format(valor//int(cedula[1])))
valor %= 50
print("{} nota(s) de R$ 20".format(valor//int(cedula[2])))
valor %= 20
print("{} nota(s) de R$ 1... |
524155189b4dc38e3d3160a0b1685eafe2f8db29 | srehub/newfish | /cateleon/2017w32/2017w32d04-demo-stack-01.py | 930 | 3.78125 | 4 | #!/usr/bin/python
# encoding:utf-8
"""
@author: yuanxin
contact:
@file: 2017/8/11-demo-stack-01.py
@time: 2017/8/11
"""
list = [ ]
num = 6
for i in range(1,9):
# print(i)
if i < num:
list.append(i)
print( (list), ", I want" , (num), "balls, Now there is ", len(list), ", give me one more")
... |
e5ce3e834869eccb4070177cd0272c297ba34789 | MaxCosmeMalasquez/Ejercicios-Python- | /ejemplo2.11.py | 284 | 3.953125 | 4 | print("Write your note")
x = int(input())
print("Write your age ")
y = int(input())
print("Write yor gender")
z = input()
if x >= 5 and y >= 18 and z == "F":
print( "ACCEPTED")
elif x >= 5 and y >= 18 and z == "M" :
print( "POSSIBLE")
else :
print("NOT ACCEPTED")
|
bece58399c4352a6fa40e23b002b4fab4411386c | mariesstl/SWDV-610-3W-20SP2 | /Lesson 5/insertionsort.py | 780 | 4.375 | 4 | # Consider the following list of integers: [1,2,3,4,5,6,7,8,9,10].
# Show how this list is sorted by the following algorithms:
# insertion sort
def insertionSort(alist):
for index in range(1,len(alist)): #skip position 0. Move right and we assume a sorted sublist at 0
currentvalue = alist[index] #Get current v... |
045fd70f644c03213d7e49e28fee363a1734b728 | jhonnyelhelou91/ProjectEuler | /36 - Double Based Palindromes.py | 391 | 3.609375 | 4 | def isPalindrome(n):
count = len(n)
for i in range(0, count):
if (n[i] != n [count - i - 1]):
return False
return True
def isDoubleBasedPalindrome(n):
if (isPalindrome(str(n))):
return isPalindrome(bin(x)[2:])
return False
n = 1000000
result = 0
for x in range(1, n):
... |
4df6abda3257da5095fa1c2190df5787dc8990bb | armandouv/practicas-eda1 | /Práctica 10/ejercicio3.py | 1,238 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Editor de Spyder
Este es un archivo temporal.
"""
def promedio(lista):
return sum(lista) / len(lista)
def toStr(num):
return str(round(num, 2))
tareas = []
examenes = []
practicas = []
for i in range(5):
tareas.append( float(input("Introduzca la calificación de la tarea " + ... |
94ddf041fdda197370479b0a9cc13250b10cb760 | vsulabs/Cryptology | /El_Gamal/elgamal_check.py | 420 | 3.578125 | 4 | # -*- coding: utf-8 -*-
# Проверить подлинность сообщения
def check(p, g, y, q, r, s):
return (y ** r * r ** s) % p == pow(g, q, p)
if __name__ == '__main__':
p, g, y = 337, 15, 303
print(check(p, g, y, 309, 31, 232))
print(check(p, g, y, 19, 31, 74))
print(check(p, g, y, 106, 31, 324))
prin... |
e985a39e782309292de74d3e0dd8827b66b55f66 | yildirimyigit/phd_studies | /s3/python_ws/dme_irl_on_mc/owutils.py | 656 | 3.625 | 4 | """
@author: yigit.yildirim@boun.edu.tr
"""
class ObjectworldState(object):
def __init__(self, x=0, y=0):
self.x = x
self.y = y
# euler
def distance(self, s):
return ((s.x - self.x)**2 + (s.y - self.y)**2)**0.5
class ObjectworldAction(object):
def __init__(self, xch, ych):... |
4868df0f4793c3094f45f80f105f83e82cdfbd93 | Nan-Do/eulerproject | /Problem15.py | 330 | 3.625 | 4 | from operator import mul
def Lattice(start, end):
# Combinatorical solution
def binomial(n, k):
a = reduce(mul, xrange(n, k, -1))
b = reduce(mul, xrange(1, k + 1))
return a / b
n = end[0] - start[0]
k = end[1] - start[1]
return binomial(n + k, n)
print Lattice((0, 0), ... |
64d58894c647e198856a02a66d8aced941527aa2 | momentum-cohort-2018-10/w1d2-house-hunting-cat9563 | /dream_home.py | 613 | 4.21875 | 4 | annual_salary = float(input("What is your annual salaray"))
portion_saved = float(input("Enter the percent to be saved as a decimal"))
total_cost = float(input("What is the cost of your dream home"))
annual_saved = annual_salary*portion_saved
monthly_saved = annual_saved/12
portion_down_payment = .25 * total_cost
curre... |
98fd1990424619130d50a87750f8ddfadb87a5d7 | YuriiKhomych/ITEA-BC | /Andrii_Bakhmach/5_functions/HW/5_homework.py | 450 | 4.40625 | 4 | # The function `max()` and `max_of_three()` from previous exercises
# will only work for two and three numbers, respectively.
# But suppose we have a much larger number of numbers,
# or suppose we cannot tell in advance how many they are?
# Write a function max_in_list()
# that takes a list of numbers and returns the l... |
6d2588f5fd8f152659905403084d2e3515be2c46 | adwantgoutam/ToolDev | /test2.py | 1,053 | 3.546875 | 4 | __author__ = 'adwant'
import argparse
def Main():
parser = argparse.ArgumentParser(description="To the find the fibonacci number of the give number")
arg1 = parser.add_argument("-n", "--name", dest="name",action="store_true", help="Test2: Name of the person running this test")
arg2 = parser.add_argument("... |
7b5ba9ad6219b6e2e8cd258f53eb732c2b10659f | sajidqureshi19/Tic-Tac-Toe | /tic_tac_toe.py | 3,649 | 3.890625 | 4 | import random
the_board = [' ']*10
def displayBoard(board):
print('\n'*100)
print(''+board[7] + '|' + board[8] + '|' + board[9])
print('------')
print(''+board[4] + '|' + board[5] + '|' + board[6])
print('------')
print(''+board[1] + '|' + board[2] + '|' + board[3])
def playerInput():
... |
33cdf8b4c9e5660747e3e80a78121ede8e5f8a70 | harishramuk/python-handson-exercises | /154. Important Methods and Functions for List len count and index.py | 191 | 3.859375 | 4 | l = [1,2,1,2,3,4]
x = int(input('enter the element find to index:'))
if x in l:
print('{} present in index :{}'.format(x,l.index(x)))
else:
print(x,'is not avalable in list') |
c9ad504211d0532c9a053e19ed56f049acda7a10 | egalli64/pythonesque | /cip/w5/2.py | 438 | 3.921875 | 4 | """
Code in Place 2023 https://codeinplace.stanford.edu/cip3
My notes: https://github.com/egalli64/pythonesque/cip
Diagnostic 2
Print out each of the numbers 1 through 100 and whether that number is even or odd.
"""
# print numbers from 1 up until MAX_NUMBER, inclusive
MAX_NUMBER = 100
def main():
for i in rang... |
33c944dacbea84c4d9dda2de4df77280ce2eda10 | gmastorg/CSC121 | /CanjuraMenuExemptions.py | 1,259 | 4.03125 | 4 | # creates a shell that calls funtions and runs a loop
# 02/05/2018
# CSC-121 In Class
# Gabriela Canjura
import functions
def main():
keepGoing = "Y"
while keepGoing == "Y":
mainMenu()
keepGoing = input("Would you like to keep going? (Y/N) \n")
keepG... |
a0d4496361331ac498c9e58300b1ed7ec6419ffb | shaikhAbuzar/basicprograms | /Calc.py | 1,033 | 4.09375 | 4 | def addition(a,b):
print(a,"+",b,"=",a+b)
def multiple(a,b):
print(a,"X",b,"=",a*b)
def subtraction(a,b):
print(a,"-",b,"=",a-b)
def divide(a,b):
print(a,"/",b,"=",a/b)
def values():
a=int(input("Enter 1st No: "))
b=int(input("Enter 2nd No: "))
return a,b
def calc():
i="... |
bd244d4349c92c51965d7aca6b84a48d04d6fc3c | stevekutz/python_iter_sort | /REVERSE_a_String/reverse_string.py | 3,258 | 4.28125 | 4 | str_val = "Hello"
####################################################
# # Basic for loop to append ch to start of new string
# def reverse(x):
# sol = ''
# for ch in str_val:
# # sol += ch >> same as sol = sol + ch >> just copies string
# sol = ch + sol # appends like sol = e + H >>> sol... |
e80b4691b55a7b89778571cbaec6b99cc5f90173 | tumzera/Math-Related-Py-Files | /padovan.py | 192 | 3.53125 | 4 | def padovan(n):
if n < 4:
return "input should be more than 3"
else:
L = [1,1,1]
for i in range(3,n):
a = L[len(L)-3] + L [len(L)-2]
L.insert(len(L),a)
i = i + 1
return L |
11fdd68b882fa8454020e35f09ec3f5916030f25 | hulaba/geekInsideYou | /array/immediateSmaller.py | 942 | 4 | 4 | def immediateSmaller(arr, n, x):
"""
Given an array arr[] of size N containing positive integers
and an integer X. You need to find the value in the array
which is smaller than X and closest to it. You will be given a function
immediateSmaller() whose signature description given below:
"""
#... |
71f6c5c1162ba4e8a345d28b0b55034824ab7ce1 | jishnu-krishnan-au19/tree-dev-assignments-week01-day01 | /Untitled-1.py | 152 | 3.5 | 4 |
name=input()
print("Hello", name)
age=input()
print("you are",age)
address=input()
print("You are from ",address)
mob=input()
print("Mob ",mob) |
895948eacd6d6bf00dfefd27fe623ac6a650af01 | x6y4l2c1j1b1/rlpfmpj | /RL_brain_policy_gradient_lstm.py | 9,180 | 3.53125 | 4 | """
This part of code is the reinforcement learning brain, which is a brain of the agent.
All decisions are made in here.
Policy Gradient, Reinforcement Learning.
View more on my tutorial page: https://morvanzhou.github.io/tutorials/
Using:
Tensorflow: 1.0
gym: 0.8.0
"""
import numpy as np
import tensorflow as tf
... |
0ec69276dfef2745c20d83c9503f1af6c4b57e1f | denisqa2h/lesson1 | /simple.py | 933 | 3.828125 | 4 | # a = 2
# b = 0.5
# print(a+b)
# name = 'denis1 '
# print('Privet', name.replace('1','').strip().capitalize())
# v = int(input('Введите число от 1 до 10: '))
# if v<1:
# print('Ti chto, durak?')
# elif v>10:
# print('Ti real`no durak')
# else:
# print(f'{v+10}')
# name = input('Введите ваше имя: ')
# pri... |
69a785047c72f4a9b2baea89fce44494a90c5015 | sindura19/PythonPractice | /Add two hexadecimal values.py | 180 | 4.1875 | 4 | #program to add hexadecimal values
n1=input("Enter 1st hexadecimal value: ")
n2=input("Enter 2nd Hexadecimal value: ")
n3=int(n1,base=16)+int(n2,base=16)
print(n1,n2,hex(n3)) |
b6f7eb4d3662902fd79e8e62b7942b0183c8b3ec | se2313se/basics-of-programming-on-Python | /3/Linear equation system-1.py | 317 | 3.59375 | 4 | a = float(input())
b = float(input())
c = float(input())
d = float(input())
e = float(input())
f = float(input())
if d != 0:
x = (e-f*b/d)/(a-c*b/d)
y = (f-c*x)/d
print(x, y)
else:
if b != 0:
x = (f - e * d / b) / (c - a * d / b)
y = (e - a * x) / b
print(x, y)
|
acedd69b93bfe4c3aadecefaddb071cac3c881c1 | DavidEsau07/Ejercicios | /Ejercicio_13.py | 370 | 3.78125 | 4 | def carac():
x = str(input("\nIngrese una oración: "))
#Elimina el primer caracter de la cadena
print(x[1::])
a = int(input("\nSeleccione 1 para volver a intentar, cualquier otro número para cerrar: "))
if a == 1:
return carac()
else:
print("\nGracias!")
print(... |
b0d2d985158063ade466568c3a4bf87a26214b3f | thecomputerguy/full-speed-python | /asynchronous_programming/single_task/SquareNumber.py | 362 | 3.890625 | 4 | import asyncio
#sleep for a second and then generate a square
async def square_number(x):
print(f"going to sleep with input {x}")
await asyncio.sleep(1)
print(f"awake with number {x}")
return x**2
loop = asyncio.get_event_loop()
future = loop.create_task(square_number(5))
results = loop.run_until_comp... |
f5c0d6d360d75dd1cf8f52c13e5f770ea09e09e6 | luissalamanca/program-python | /inputoutput.py | 955 | 4.25 | 4 | # Coding utf-8
import os.path
def insertText(inputText):
text = input("Write your note: \n")
inputText.write(text)
inputText.close()
def files(fileName):
if os.path.exists(fileName + ".txt"):
while os.path.exists(fileName + ".txt"):
print("The file is already exists. Please, rename... |
f14956569a95eb338211d187830b2c7a7de18d77 | claesmk/wordcloud_sample | /txt2wc.py | 680 | 3.65625 | 4 | from wordcloud import WordCloud
import matplotlib.pyplot as plt
def word_map_from_file(file_name):
# initialize list of words we'll learn from the file
word_list = []
with open(file_name) as f:
for line in f:
# assume words are separated by a space
new_words = line.split(' ... |
bec40d2ac56970011bc7d09a94e7045ad87ae067 | TalhaYa/My_Python_Project | /siparis_otomasyonu.py | 1,622 | 3.5 | 4 | # Sipariş Otomasyonu
"""
3-herhangi bir restorana girdiklerinde hoşgeldiniz isminiz soyisminiz eğer ekleyebilirsem yaşa göre indirim.
"""
adisyon = []
class Adisyon:
def adisyonpideci(self):
pide = [pideci.tum_siparis]
adisyon.append(pide)
def adisyonaperatif(self):
ape = [Mehm... |
42ca1a6c0301b4b6c69863f3bb23e77bfff3f756 | qeedquan/challenges | /leetcode/difference-between-element-sum-and-digit-sum-of-an-array.py | 1,319 | 4.21875 | 4 | #!/usr/bin/env python
"""
You are given a positive integer array nums.
The element sum is the sum of all the elements in nums.
The digit sum is the sum of all the digits (not necessarily distinct) that appear in nums.
Return the absolute difference between the element sum and digit sum of nums.
Note that the absolu... |
8cef3fd7c3a14eb83f44552491696d9b3a566471 | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Advanced/File-Handling-Exercise/03_FileManipulation.py | 1,471 | 3.890625 | 4 | import os
def create_file(file_name):
if os.path.exists(file_name):
os.remove(file_name)
with open(file_name, 'x'):
pass
def append_line_to_file(fine_name, line):
with open(file_name, 'a') as file:
file.write(f"{line}\n")
def replace_string_in_file(file_name, old_string, new_s... |
47b3727bf70d52da8c211aea6ab33c21da2d6fa8 | t-a-y-l-o-r/Effective_Python | /3_CH/Generic.py | 5,267 | 3.765625 | 4 | '''
Author: Taylor Cochran
Book: Effective Python
Chapter 3
Goal: To utilize @classmethod polymorphism to construct classes generically
'''
import os
from threading import Thread
# a class representing input data
class InputData(object):
def read(self):
raise NotImplementedError
# this is an implementation of ... |
64a673ddfee56edb48576b11d132419999947eb6 | SabithaSubair/pythonpgms | /objectoriented/student.py | 476 | 3.65625 | 4 | class Student:
#attribute of person self.name,self.age,self.gender
def set_student(self,rol,name,course,total):
self.rol=rol
self.name=name
self.course=course
self.total=total
def print_student(self):
print("rol", self.rol)
print("name",self.name)
pri... |
c62a1cb38039096619e82c048a5c14c96abfb7db | y0m0/MIT.6.00.1x | /ProblemSet/ProblemSet4/compChooseWord.py | 1,460 | 4.03125 | 4 | def compChooseWord(hand, wordList, n):
"""
Given a hand and a wordList, find the word that gives
the maximum value score, and return it.
This word should be calculated by considering all the words
in the wordList.
If no words in the wordList can be made from the hand, return None.
hand: d... |
a74ad638ff979a27b657939cf793f06175a457e2 | catboost/catboost | /contrib/python/scikit-learn/py2/sklearn/neighbors/graph.py | 6,613 | 3.5625 | 4 | """Nearest Neighbors graph functions"""
# Author: Jake Vanderplas <vanderplas@astro.washington.edu>
#
# License: BSD 3 clause (C) INRIA, University of Amsterdam
from .base import KNeighborsMixin, RadiusNeighborsMixin
from .unsupervised import NearestNeighbors
def _check_params(X, metric, p, metric_params):
"""C... |
dcaa97328eeb6d537ab19f418e012ecf914f8d88 | aegirhall/console-menu | /examples/example3.py | 1,188 | 4.1875 | 4 |
from consolemenu import *
from consolemenu.items import *
#
# Example 3 shows the use of a multi-select menu. A multi-select menu will execute all of the
# selected actions with a single user input prompt.
#
def action(name):
print("\nHello from action {}!!!\n".format(name))
Screen().input('Press [Enter] to... |
573478d118e48df4856d25efe3d541e7fce57222 | metaodi/report-z | /pdf_to_db.py | 1,976 | 3.609375 | 4 | #!/usr/bin/env python3
# This script creates a new sqlite database based on the downloaded CSV
import sqlite3
import traceback
import os
import sys
import csv
from io import StringIO
import report_common as rc
__location__ = os.path.realpath(
os.path.join(
os.getcwd(),
os.path.dirname(__file__)
... |
fc77d7db1783a67611db38408a476b0c6c59f859 | iKilux/Python | /swordfish.py | 248 | 3.984375 | 4 | while True:
print('Type your name ')
name=input()
if name!='Joe':
continue
print('Welcome Joe! What is the password ? (Is it a fish)')
password=input()
if password=='swordfish':
break
print('Acces granted')
|
036c1251ab5ccf1eac1f74dbe045db36c218468c | danylo-boiko/HackerRank | /Problem Solving/Intermediate/weighted_uniform_strings.py | 712 | 3.75 | 4 | # !/bin/python3
# https://www.hackerrank.com/challenges/weighted-uniform-string/problem
def weightedUniformStrings(s, queries):
temp = set()
i = 0
while i < len(s):
j = i
cur = 0
while j < len(s) and s[j] == s[i]:
cur += ord(s[j]) - ord('a') + 1
temp.add(cur)... |
2f71615e3b915750f33907f0aaeacc6ae8f2c7ca | Vana-Vanch/py_algo | /undirectedgraph.py | 1,254 | 3.65625 | 4 | #Search in undirected graph
#create adjacency list
def makeGraph(edges):
graph = {}
for edge in edges:
a,b = edge
if a not in graph: graph[a] = []
if b not in graph: graph[b] = []
graph[a].append(b)
graph[b].append(a)
return graph
#traverse graph
def hasPath(gra... |
5c920c99c1e892d570a20c90d4b5d1376bf5e24b | yhnb3/Algorithm_lecture | /기본/Cage D5/stair.py | 454 | 3.53125 | 4 | N = int(input())
S = [0] + [int(input()) for i in range(N)]
max_num = [0]
s = [[-1] * 3 for i in range(N + 1)]
def stair(n, a):
if n > N:
return -10000001
if s[n][a] != -1:
return s[n][a]
if n == N:
return S[n]
if a == 2:
s[n][a] = stair(n + 2, 1) + S[n]
else:
... |
181e2e2068ecf4d8ade76e025eccb80677ead14e | d-anuhya/GeekWeek-Local | /Day-2_prob2.py | 424 | 3.84375 | 4 | # Geek Week: Local
# author: Devarakonda Anuhya
# Day- 2
def char(S3):
n = len(S3)
for i in range(1, n):
if S3[i] != S3[0]:
return False
return True
S1 = str(input("Enter a few alphabets: "))
S2 = str(input("Enter a few alphabets: "))
S3 = str(input("Enter a few alphabets: "))
if char(... |
0c9be8188dfdf850574800594805e3f2ea3c3937 | enrisan/AgendaTelefonos | /main.py | 2,705 | 3.984375 | 4 | # Ejercicio de manejo de elementos en funcion dict()
agenda_telefonica = dict()
def imprimir_operacion(nombre_operacion):
print()
print("-------- Agenda telefónica --------")
print(nombre_operacion)
print("-----------------------------------")
print()
def agregar_contacto():
contacto = inpu... |
995593e618f1995c70566ed79431d690fdb0192d | Ann-Mamaeva/second_lesson_2 | /zp.py | 190 | 4.09375 | 4 | print("Калькулятор")
name = input("Введите свое имя: ")
surname = input("Введите свою фамилию: ")
full_name = name.strip() + " " + surname.strip()
|
f485ded21b96b02f2689d6bf8a808f484ce3193b | Yuvv/LeetCode | /0901-1000/0941-valid-mountain-array.py | 1,069 | 3.671875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @File : 0941-valid-mountain-array.py
# @Date : 2021/04/12
# @Author : Yuvv <yuvv_th@outlook.com>
from typing import List
class Solution:
def validMountainArray(self, arr: List[int]) -> bool:
arr_len = len(arr)
if arr_len < 3:
retur... |
11d225acff80acd217f1adb2bdbfc75f63d71d72 | hiddenworlds225/School-code | /FOUNDPRO/segment 2/ASCII.py | 1,398 | 4.03125 | 4 | # 5.02 ASCII Code
# @Shawn Velsor
# 2/1/2021
# This is to encode and decode ASCII strings.
message = "Sometimes, I dream of cheese..."
#This quote is from Half-Life 2
# Need to first encode the message
def Main():
print("Encoded message: ")
print(Encode())
print()
Guess()
print("Decoded message: ... |
d837932504e830d41af899be40239a505198611c | seastarmanager/oj_solutions | /py/002-add_two_numbers.py | 966 | 3.765625 | 4 | #!/usr/bin/env python
# coding: utf-8
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: Lis... |
05bc30cb4b0520777cce22a6ece642a9bd271dea | jklypchak13/DailyCodingProblem-PY | /src/week2/day11.py | 3,163 | 3.75 | 4 | # Problem Description:
# Implement an autocomplete system. That is, given a query string s and a set of all possible query strings,
# return all strings in the set that have s as a prefix.
# For example, given the query string de and the set of strings [dog, deer, deal], return [deer, deal].
# Hint: Try preprocessin... |
91cfa44f46a16238aff4c38c0a5e5c49e88af514 | spinon187/practice | /insertintobst.py | 585 | 3.640625 | 4 | class Solution:
def insertIntoBST(self, root, val):
if not root:
root = TreeNode(val)
else:
self.traverseBST(root, val)
return root
def traverseBST(self, root, val):
if val > root.val:
if root.right:
... |
8c256e745dd57e27a15829c535c0aec3b489f5cc | Voron07137/PythonTutor | /ch3/l33.py | 581 | 3.96875 | 4 | def print_text(txt="Значение аргумента по умолчанию."):
print(txt)
def show_args(a, b="Второй аргумент не указан."):
print(a, b)
def my_func(x="1-й аргумент x.", y="2-й аргумент y.", ):
print(x, y)
print_text("Аргумент указан явно.")
print_text()
show_args("Первый аргумент.", "Второй аргумент.")
show... |
453cacd31a6f3013fdcfeb5ed33837cd73153987 | x1417641995/Leetcode | /leetcode/36. Valid Sudoku.py | 1,158 | 3.734375 | 4 | #36. Valid Sudoku 20190617
#finish
from typing import List
class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
for i in range(0, 9):
checkcol = []
checkrow = []
for j in range(0, 9):
#column check
if... |
a6457961ecd01e3b87b007401dabbd221cc0191a | deontaljaard/coding-problems | /codewars/py/dups.py | 765 | 4.21875 | 4 | """
Kata: Counting Duplicates
Details:
Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.
"""
def d... |
204a873852671fd094cd28d71e18fad2a0850754 | lawun330/Python_Basics | /Working in shell/command-line-args.py | 385 | 4.09375 | 4 | #!/usr/bin/env python3
#Test in linux
import sys
'''returns the arguments you have passed into the command line
Example - ./command-line-args.py arg1 arg2.
This is helpful than writing function(arg1,arg2) in command line.'''
arguments = sys.argv
def show_argument(args):
string = "The arguments you have passed are {... |
12d630a24af51c8acb8f824dddb0129ac8dd1e0d | frankshammer42/cs440_mp2 | /part2/GameNode.py | 2,184 | 3.5625 | 4 | import numpy as np
class Node:
def __init__(self, chess_board):
self.chess_board = chess_board
self.parent = None
self.children = []
self.value = 0
def set_parent(self, parent_node):
self.parent = parent_node
def add_child(self, child):
self.children.appe... |
c02e76aaf197d1f97c12e189838377516d8c2182 | Vinesh2004/Python-ICS3U | /Lesson 7 Review.py | 3,414 | 4.28125 | 4 | #-----------------------------------------------------------------------------
# Name: Review of Lessons (main.py)
# Purpose: To review the concepts previously learned
#
# Author: Vinesh Vivekanand
# Created: 04-Jan-2020
# Updated: 04-Jan-2020
#-------------------------------------------------... |
72c7d635f11096c6d267b54ea2cd4ac6a6a5c4fb | gstein/gjscalculator | /src/gjscalculator/app.py | 7,374 | 3.78125 | 4 | """
Simple calculator
"""
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW
### we're hard-coding for GTK/GDK right now
from gi.repository import Gdk
# Keycodes to show the "alternate" buttons
SHOW_ALT = {
Gdk.KEY_Control_L,
Gdk.KEY_Control_R,
}
# Special characters for disp... |
a1f9c92c7a9cf61c9ff425036fca257cc52c034a | jianhui-ben/leetcode_python | /605. Can Place Flowers.py | 1,722 | 4.0625 | 4 | #605. Can Place Flowers
#You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.
#Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, return if n new flowers can be plante... |
854fc6d49b390add25ca108fb1149ded157c4e49 | jaygattuso/Twitter_username_harvester | /lib/tweet_json_reader.py | 901 | 3.84375 | 4 | import json
from pprint import pprint
def process_tweet(tweet):
""" add your code here...."""
pprint(tweet)
print
print tweet.keys()
### set this to a path to some tweet json
f = r"..\stream_grabs_testing\BeeFaerie\json\01-06-2017_06-51-48_BeeFaerie.json"
### set this to limit the number of tweets you want ... |
77da36cbfcf94cb3b000b96da1f2344946b0ae0a | harshsaini697/CodingPractice | /RotateArray.py | 207 | 3.890625 | 4 | def rotate_array(arr,n,d):
if d>1:
temp=arr[:2:-1]
print(temp)
for i in temp:
arr.remove(i)
arr=arr+temp
return arr
print(rotate_array([1,2,3,4,5],5,2)) |
2c0ff76d1d829571ac7ab61f1355a3cc331b62ef | RohitYadav900/StudentGradingSoftware | /app.py | 2,451 | 3.90625 | 4 | import os
import time
os.system("color b")
# Input from user
std_name = str(input("Enter the name of the student: "))
# While for error
while std_name == "":
os.system("cls")
print("Plz type the name of the child !")
std_name = str(input("Enter the name of the student: "))
########################... |
6555400c4210b1f6177975b8681f84c0733033a2 | ravinaNG/python | /List/MaximumValue.py | 382 | 3.984375 | 4 | numbers = [50, 40, 23, 70, 56, 12, 5, 10, 7]
print "This is lenght :-", (len(numbers))
position_of_numbers = 0
biger_then_numbers = 0
while position_of_numbers < len(numbers):
if biger_then_numbers < numbers[position_of_numbers]:
biger_then_numbers = numbers[position_of_numbers]
position_of_numbers+=1
print "This... |
9c5504e1d9a77f4dd1e24e68fa6a3b89a5d24c59 | trapwalker/raytrace | /progressive_iter.py | 780 | 3.671875 | 4 | # -*- coding: UTF-8 -*-
from math import ceil
from itertools import groupby
def simplyfy(n):
n = abs(n)
i = 2
while i <= n:
while n % i == 0:
n /= i
yield i
i += 1
def nestedIterN(n):
return nestedIter(list(simplyfy(n)))
def nestedIterAB... |
d5067b51281765198e4d3021c7c4e0943a0c2b1b | KickItAndCode/Algorithms | /BinarySearch/CapacityToShipPackagesWithinDDays.py | 3,619 | 4.1875 | 4 | # 1011. Capacity To Ship Packages Within D Days
# A conveyor belt has packages that must be shipped from one port to another within D days.
# The i-th package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load... |
41c95b74768ebdcdcffaff8d092544f5d7a27384 | tyedge/holbertonschool-machine_learning | /supervised_learning/0x07-cnn/2-conv_backward.py | 1,648 | 3.75 | 4 | #!/usr/bin/env python3
"""This module contains a function that performs back propagation over a
convolutional layer of a neural network"""
import numpy as np
def conv_backward(dZ, A_prev, W, b, padding="same", stride=(1, 1)):
"""This function performs back propagation over a convolutional layer of a
neural netwo... |
87e0cfe7cbb1ed4421f1698bf3e4b2cd863a8dc4 | ferhatelmas/algo | /leetcode/algorithms/easy/merge_strings_alternately.py | 374 | 3.703125 | 4 | from itertools import zip_longest
class Solution:
def mergeAlternately(self, word1: str, word2: str) -> str:
# cooler but slower
# from itertools import chain
# return "".join(chain(*zip_longest(word1, word2, fillvalue="")))
s = ""
for a, b in zip_longest(word1, word2, fill... |
98130298daa0df03977a56f7e15395dd2b1d1c41 | MauricioSerranoG/MauricioSerranoG-Curso_Python_Ejercicios_02_Datos_Copuestos | /Datos_Compuestos-02.py | 362 | 4.375 | 4 | """
2.- Escribir un programa que almacene las asignaturas de un curso (por ejemplo
Matemáticas, Física, Química, Historia y Lengua) en una lista y la muestre por
pantalla.
"""
lista = []
contador = 1
while contador < 8:
m = input(f"Ingresa materia {contador}: ")
lista.append(m)
contador +=1
print("\n")
pri... |
6c38d7064c353e80c1757f60d837f0ca4ea8e233 | priyeshraj6/Rock-Paper-Scissors | /rock_paper_scissor.py | 1,530 | 3.96875 | 4 | from random import randint
a = input('Player A, Please enter your name:')
b = 'Computer'
c = ['rock', 'paper', 'scissor']
b_input = c[randint(0, 2)]
print(f'\nHello {a} ,welcome to the Rock-Paper-Scissor game.\ninputs allowed :Rock/rock,Paper/paper,Scissor/scissor \n')
def game():
while True:
s1 =... |
aa1dd9b05058e1faa5540ed2034ffd58a3743089 | dissident/andrew-improove-python-skills | /src/learn/arrays.py | 524 | 3.8125 | 4 | def add(array, item):
array.append(item)
return array
def reverse(array):
array.reverse()
return array
def five_index(array):
index = 0
for ind, x in enumerate(array):
print(ind, x)
if x == 5:
print(ind)
index = ind
break
return index
... |
79da9c551c87a05baa89478cc79afef994ab906e | Mudasirrr/Courses- | /Rice-Python-Data-Representations/week2/examples3_listidx.py | 945 | 4.40625 | 4 | """
List indexing and slicing.
"""
print("List Indexing")
print("=============")
groceries = ["butter", "milk", "bacon", "spaghetti", "asparagus"]
print(groceries)
# first item
print(groceries[0])
# third item
print(groceries[2])
# length of list
numitems = len(groceries)
print(numitems)
# last item
print(groceri... |
020b07070f5cec5371da2f55073dff6ac5dfe142 | aparnakn/myworkspace | /pythonII/monkey_patching.py | 2,091 | 3.984375 | 4 | ''' Monkey patching is making variable assignments into someone else's namespace.
Einstein would call it, "spooky action at a distance".
Legitimate use cases:
* Fixing erroneous constants
* Fixing bad, incorrect, or misleading error messages
* Improving the robustness of a function (expanding the d... |
e31dcd8b930f285b31eb6c3b4e719d3d615664bc | samahDD/ProjectX | /ProjectX_Translation_Application/User.py | 1,361 | 3.71875 | 4 | class User:
def __init__(self,words, file,answer,userAnswer,writeConfirmation,confirmation):
self.words = words
self.file = file
self.answer = answer
self.userAnswer = userAnswer
self.writeConfirmation = writeConfirmation
self.confirmation = confirmation
def... |
40315fe607442f555792897c03fbc0a157af03b3 | chapmtyl/AFS505_u1 | /assignment2/ex6.1.py | 783 | 3.921875 | 4 | types_of_people = 10 # gives value to this variable
x = f"There are {types_of_people} types of people." # defines x
binary = "binary" # defines the variable binary
do_not = "don't" # defines the varaible do_not
y = f"Those who know {binary} and those who {do_not}." # defines y
print(x) #prints the x variable
print(y)... |
d612347df689e91ca3ab83dd2b069c469949cbe1 | mythnc/codility-practice | /lesson4_Counting_Elements/PermCheck.py | 307 | 3.671875 | 4 | #!/usr/bin/env python
def solution(A):
n = len(A)
sum_ = sum(set(A))
if sum_ == (n * (n + 1) / 2):
return 1
else:
return 0
if __name__ == '__main__':
a = [4, 1, 3, 2]
print solution(a)
a = [4, 1, 3]
print solution(a)
a = [4, 1, 1]
print solution(a)
|
79287fa62c01489c4aa1e75ce5a247cc312bbf1f | rafaelperazzo/programacao-web | /moodledata/vpl_data/205/usersdata/264/87032/submittedfiles/questao2_av1.py | 391 | 3.8125 | 4 | # -*- coding: utf-8 -*-
#COMECE AQUI ABAIXO
n1= int(input('Digite o valor do número 1:'))
n2= int(input('Digite o valor do número 2:'))
n3= int(input('Digite o valor do número 3:'))
n4= int(input('Digite o valor do número 4:'))
n5= int(input('Digite o valor do número 5:'))
n6= int(input('Digite o valor do número 6:'))... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.