blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
502640ad479b3762cc044e6be86d7a3c742b1f44 | AndreySkryl/Codewars | /Python/5 kyu/Double Cola/main.py | 973 | 3.9375 | 4 | # TODO : пересмотреть
# def who_is_next(names, r):
# calculation = True
# start, end, i = 1, 0, 0.5
# while calculation:
# i *= 2
# end += i * len(names)
# if r <= end:
# step_back = (i * len(names)) // len(names)
# for index in range(len(names)):
# ... |
a85f3c7c11a0f530337788c1277b703df4c285d9 | AndreySkryl/Codewars | /Python/7 kyu/Password should not contain any part of your username/main.py | 691 | 3.84375 | 4 | def validate(username, password):
if len(username) == 0 or len(password) == 0:
return False
for start in range(len(password)):
for end in range(len(password) + 1):
if start < end and end - start >= min(len(username), len(password)) // 2:
substring = password[start:end... |
c991771512832fd1a2eccc44f068c8c75df54bed | amulyadhupad/My-Python-practice | /emp.py | 618 | 3.671875 | 4 | """ Code to enter name, numbwe and salary of an employee """
class Employee(object):
"""docstring for Customer"""
def __init__(self,num,name,salary):
self.__empNo = num
self.__empName = name
self.__empBasic = salary
def display(self):
with open('emp.txt','r') as f1:
contents=f1.read()
pri... |
232a1fe10287b50ad250d045a8c3936427c63359 | amulyadhupad/My-Python-practice | /ap9.py | 318 | 4.03125 | 4 | """ This code is to get user input with specified number of attempts """
for i in range(1,4):
un=input("Enter number between 1 to 10")
if int(un)>1 and int(un)<10:
print(un)
break
else:
if 3-i != 0:
print("Left with"+ " "+str(3-i)+" "+"chance")
else:
print("Sorry! you ran out of chances") |
f9f3819c0cacfd8d0aba22d64628ab343e94b5b7 | amulyadhupad/My-Python-practice | /square.py | 202 | 4.15625 | 4 | """ Code to print square of the given number"""
def square(num):
res =int(num) * int(num)
return res
num=input("Enter a number")
ans=square(num)
print("square of "+str(num)+" "+"is:"+str(ans)) |
7d25c0bb7cf42f2ff9b7ccb853ec634b0324a189 | bradforddavis/Workshop_4 | /Lecture.py | 531 | 3.890625 | 4 | def main():
valid_input = False
while not valid_input:
try:
age = int(input('Age: '))
if age < 0:
print('Invald (must be above 0')
else:
valid_input = True
except ValueError:
print('Invalid (not an integer)')
pri... |
36fb454d1b2e63a8c94a4c7b00bb9dc8716b5e56 | promolife539/lesson1 | /if2.py | 148 | 3.828125 | 4 | x=input()
y=input()
if len(x)==len(y):
print(1)
elif x != y and len(x)>len(y):
print (2)
elif x != y and y == ('learn'):
print(3) |
b75bff54b8db08985af2be72712a9b29ce0ac44a | YuriiShp/Elementary-tasks-python | /demo_tasks_framework/validators/validators.py | 1,217 | 3.625 | 4 | """Module contains validators"""
from abstract.classes import Validator
class PositiveIntValidator(Validator):
"""Validate positive integer"""
def validate(self, value):
if isinstance(value, list):
if len(value) > 1:
return False, value, f'Value should be <int> type,' \
... |
08b7ec6c673db8a1ee5af9c19d27938f7ff523b0 | yuedibit2/Python003-003 | /week08/homework_2.py | 280 | 4.09375 | 4 | #自定义一个 python 函数,实现 map() 函数的功能
from typing import Callable, Sequence, Iterator
def diy_map(func:Callable , seq:Sequence) -> Iterator :
return (func(item) for item in seq)
l=[2,4,6,7]
def two(x):
return 2*x
m=diy_map(two,l)
next(m)
list(m) |
4eb2a728c130e787459c6ddda73481b13cb8aa2d | nomii15/COMP1531-server | /server/email_check.py | 339 | 3.765625 | 4 | #definition for check email function comes from
#https://www.geeksforgeeks.org/check-if-email-address-valid-or-not-in-python/
import re
def email_check(email):
regex = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$'
if (re.search(regex, email)):
return "Valid Email"
else:
retur... |
3cd18383ae51da4f1055ebe3e8cc5165f305d454 | nelson-liu/nlp-phd-vis | /when-did-you-start-with-lor-writers.py | 1,124 | 3.671875 | 4 | '''
Makes the graphs for the "when did you start your PhD" graph
Author : John Hewitt
'''
from functools import reduce
from collections import Counter
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(font_scale=2)
responses = {
"Sebastian": (4,),
"Roma": (3,), # Late August, early September.
... |
5194c736e5a0db5200dc8d90929d3585decd36ef | ssub-e/Programmers-algorithms | /Level 2/다리를 지나는 트럭/solution.py | 570 | 3.625 | 4 | def solution(bridge_length, weight, truck_weights):
answer = 0
bridge=[]
s=0
while True:
answer+=1
if len(bridge)!=0 and bridge[0][1]==bridge_length:
s-=bridge[0][0]
bridge.pop(0)
if len(bridge)|len(truck_weights)==0:
return a... |
84296a9ab16c077451782ed4e43a4e804a16f819 | CHATTU-RUPA/CHATTU-RUPA | /algebraic operations.py | 677 | 3.734375 | 4 | import numpy as np
A=np.array(input("enter the first array:"))
B=np.array(input("enter the second array:"))
C=A+B
print"addition of matrix:",C;
D=A-B
print"subtraction of matrix:",D;
E=A.dot(B)
print"multiplication of matrix:",E;
Y=A/B
print"division of matrix:",Y;
F=(A.transpose())
print"transpose of matrix:",F;
Y=np.... |
1ff5b60dd84e60277a9b5e1c53d0534354d35344 | robertyoung1993/Tester_home | /Basing/list_comprehensions.py | 381 | 3.78125 | 4 | """
列表生成式
"""
import os
# 1
print(list(range(1, 11)))
# 2
l = [x for x in range(1, 11)]
print(l)
# 3
l1 = [x ** 2 for x in range(1, 11) if x % 2 == 0]
print(l1)
# 4
l2 = [m + n for m in 'ABC' for n in 'XYZ']
print(l2)
# 5
l3 = [d for d in os.listdir('.')]
print(l3)
# 6
d = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
l4 =... |
e35bf120762ef57b77799846b2150a86de16c3de | robertyoung1993/Tester_home | /Basing/record_error.py | 766 | 4.21875 | 4 | """
记录错误
内置logging模块可以非常容易的记录错误信息
"""
import logging
# def foo(s):
# return 10 / int(s)
#
# def bar(s):
# return foo(s) * 2
#
# def main():
# try:
# bar('0')
# except Exception as e:
# logging.exception(e)
#
# main()
# print('END')
"""
抛出错误
"""
class FooError(ValueError):
pass
d... |
428e4e0e776d7f5953c22c2318bb3cf045760e30 | robertyoung1993/Tester_home | /Basing/map_reduce.py | 1,392 | 4 | 4 | """
高阶函数:既然变量可以指向函数,函数的参数能接收变量,那么一个函数就可以接收另一个函数作为参数,这种函数就称之为高阶函数
map/reduce/filter/sorted
"""
# map()接收两个参数,一个是函数,一个Iterable, map将传入的函数一次作用序列的每个元素,并把结果作为新的Iterator返回
# def f(x):
# return x ** 2
#
# r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9])
# print(list(r))
#
# print(list(map(str, [1, 2, 3, 4 ,5, 6, 7, 8, 9])))
#
# #... |
3ccf441078cd84a87c82117e10313f0835713d6b | wahyudibo/project-euler-solution | /solution-3.py | 644 | 4.09375 | 4 | import math
def is_prime(n):
if n <= 1:
return False
if n != 2 and n % 2 == 0:
return False
for i in range(3, int(math.sqrt(n)) + 1, 2):
if n % i == 0:
return False
return True
# generate sequence of prime number with generator function
def generate_prime_number(... |
98f863f10d16533e9c980045562262483d7ed7ce | DANUSHRAJ/LANGUAGE-TRANSLATOR | /python-language-translator.py | 4,533 | 3.65625 | 4 |
from tkinter import *
from tkinter import ttk
from googletrans import Translator , LANGUAGES
from tkinter import messagebox
import speech_recognition as sr
import pyttsx3
root = Tk()
root.geometry('1080x800')
root.title("Language Translator -- DANUSHRAJ M")
root.config(bg = 'light yellow')
#heading
L... |
d43432a89b81fb8c5d591a362f043d5c224aee7c | suoiviet/bulkRenameFiles | /bulkRenameFiles.py | 2,200 | 3.671875 | 4 | import os
import re
import sys
#RenameFile.py
#Coder: suoiviet
#Description: This script serves to rename all files within a directory ("source").
#The new filenames are generated dynamically by a template & a number sequence specified by the user.
#USER NEED TO CHANGE THESE****************************************... |
92d0d484ed90e2f57e86811178aadb1d35ff3eb0 | Ewelina0/js_zad7 | /main.py | 661 | 3.96875 | 4 | def foo(*integers, **words):
result = 1
for x in integers:
result *= x
print("Wynik mnozenia:", result)
result = ""
for arg in words.values():
result += arg
print("Wynik konkatenacji:", result)
# tej funkcji nie można wywołać ponieważ argument 'age' powinien wystąpić przed arg... |
88fccb26d861fba2b5600b65c965ab5edb6189f6 | emmanuelkant/Learn_Python | /Module1/zombieExtras/zombie15.py | 188 | 3.921875 | 4 | total = 0
count = 0
while count < 10:
num = int(input("Enter the %dº number to average: " %(count + 1)))
total += num
count += 1
print("The average is %.2f" %(total / count))
|
afb41d76e1c6a3f948ec9e7fb73388d3f7424091 | emmanuelkant/Learn_Python | /Module1/zombieExtras/zombie17.py | 172 | 4.15625 | 4 | fat = 1
count = int(input("Enter the number which you need make factorial: "))
i = 1
while i < count:
fat *= i
i += 1
print("Factorial the %i is %i" %(count, fat))
|
7fc968e0bb0a051957467637d4ea8d4f47a08f52 | emmanuelkant/Learn_Python | /Module1/bancoTatu/bank.py | 1,047 | 3.640625 | 4 | class Client:
def __init__(self, name, phone):
self.name = name
self.phone = phone
class ContaCorrente:
def __init__(self, client, number, balance = 0):
self.balance = 0
self.number = number
self.client = client
self.extract = []
self.deposit(balance)
... |
044550c3c6d9484ba80e6abf3ee3c4c6bdc8c033 | emmanuelkant/Learn_Python | /Module1/zombieExtras/zombie24.py | 91 | 3.5 | 4 | text = 'aeiou'
k = 0
while k < len(text):
word = text[k]
print(word)
k = k + 1
|
fe300faf290c3cce2a231f718d5249ece95becb3 | ridwanray/Telusko-oop-concept | /poly_operator_overloading.py | 731 | 3.703125 | 4 | # a = 'an'
# b = 'kd'
# print(a+b)
# print(str.__add__(a,b))
class Student:
def __init__(self, m1,m2):
self.m1=m1
self.m2 = m2
def __add__(self, other):
m1 = self.m1 + other.m1
m2 = self.m2 + other.m2
s3 = Student(m1,m2)
return s3
def __gt__(self, ot... |
b59487256f7060a15d2f4c2a0ddef108ea17a10b | leburney/calc | /calc.py | 483 | 4 | 4 |
op = input("Which operation do you wish to do? [add,minus,mult,div]")
first = int(input("what is the first number of this operation? "))
second = int(input("what is the second number of this operation? "))
if op == "add":
re = (first + second)
print(re)
elif op == "minus":
re = (first - second)
print(r... |
c24f75d0d5082ef5c1dc469305309f552b1971ec | palfi-andras/NBAPredictor | /NBAPredictor/analyze/automated_selection.py | 8,727 | 3.625 | 4 | import hashlib
import random
from typing import List
from read_game import DEFAULT_FEATURES, POSSIBLE_FEATURES, PREDICTION_FEATURES
from read_stats import ReadStats
class AutomatedSelection:
"""
NBAPredictor has the ability to run in a fairly automated fashion, executing "batch" runs of itself,
each with... |
c93c2c8f1a4a7a0a2d8a69ad312ea8c06dc54446 | tuanvp10/eng88_python_oop | /animal.py | 555 | 4.25 | 4 | # Create animal class via animal file
class Animal:
def __init__(self): # self refers to this class
self.alive = True
self.spine = True
self.eyes = True
self.lungs = True
def breath(self):
return "Keep breathing to stay alive"
def eat(self):
return "Nom no... |
566d1c2cb8f74586408656cd04e5c01cf62906a5 | moisesmagno/aulas | /python/curso-video/testes/aula06A.py | 200 | 3.984375 | 4 | # type(...) Este método mostrar o tipo primitivo do conteúdo.
n1 = int(input('Número 1: '))
n2 = int(input('Número 2: '))
soma = n1 + n2
print('A soma entre {0} e {1} é: {2}'.format(n1,n2,soma)) |
e6e7ae853aac4dfafb3635b0ee0cdbb8daf42b26 | moisesmagno/aulas | /python/curso-video/testes/ex_aula07.py | 251 | 3.828125 | 4 | nome = input('Qual é seu nome? ')
# print('Seu nome é {:20}'.format(nome))
# print('Seu nome é {:>20}'.format(nome))
# print('Seu nome é {:<20}!'.format(nome))
# print('Seu nome é {:^20}!'.format(nome))
print('Seu nome é {:=^20}!'.format(nome)) |
ade466a9d3f69fdc2a4c9dc7cfcbdf48893e3544 | ANzaharenkov/Infa2021ChDV | /Project_2.py | 4,787 | 3.5 | 4 | import pygame
from pygame.draw import *
pygame.init()
FPS = 30
# colors
BLACK = (0, 0, 0)
CLOUD_WHITE = (190, 200, 255)
HOUSE_ORANGE = (200, 70, 0)
YELLOW = (254, 243, 5)
LIGHT_YELLOW = (205, 255, 100)
GREEN = (0, 70, 0)
PURPLE = (123, 5, 111)
BLUE = (0, 100, 255)
GREEN_GRASS = (0, 255, 0)
PINK = (200, 70, 150)
BROW... |
e2b7b646bc50fc5bd7ec7befed85e1d4453ae993 | sapanp007/Py-Notes | /property decorator.py | 1,738 | 4.03125 | 4 | """
Gives ability to define a function and use it/ call it just like an attribute
Advantages - if anyone using our class using any method and we want to add additional
functionality to it the we can convert that attribute to a method and add @property
so that we can continue to use that as an attribute
Gives a new w... |
36ebb911a6ed22babbba25576f55427e1bba2e59 | DarthDark/Deberes | /Divisibles.py | 597 | 4.03125 | 4 | for x in range(1):
numero = int(input("Selecciona un número entre 0 y 100: "))
if numero < 0:
print("El número debe ser entre 0 y 100")
numero = int(input("Selecciona un número entre 0 y 100: "))
elif numero > 100:
print("El número debe ser entre 0 y 100")
numero = int(input... |
089c7cfa99da10383401b35796e3eab6c1446a99 | tdavchev/algorithms | /sorting/quicksort.py | 308 | 3.8125 | 4 | def quick_sort(arr):
if len(arr) < 2:
return arr
pivot = arr[0]
less = [i for i in arr[1:] if i <= pivot]
greater = [i for i in arr[1:] if i > pivot]
return quick_sort(less) + [pivot] + quick_sort(greater)
a = [55, 23, 26, 2, 18, 78, 23, 8, 2, 3]
ans = quick_sort(a)
print(ans) |
e24805c9c1d370b50a557375b1678f46ab68a0a9 | tdavchev/algorithms | /Trees/print_perimeter.py | 1,480 | 3.859375 | 4 | class TreeNode():
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def set_left(self, data):
self.left = data
def set_right(self, data):
self.right = data
def left_side(root):
while root.left != None:
print(root.data)
... |
0ac6163cd3ab9790e8b1a24d7f79d80b76c52210 | tdavchev/algorithms | /math and stats/kth_permut.py | 338 | 3.5 | 4 | def factorial(n):
if n == 0 or n == 1:
return 1
return n * factorial(n-1)
def kth(arr, k, result):
if len(arr) == 0:
return
n = len(arr)
count = factorial(n-1)
selected = (k-1)/count
result += str(arr[selected])
arr.pop(selected)
k = k - (count * selected)
k... |
225531615d6a16ef72d30337ed57920491b6b0f8 | tdavchev/algorithms | /Trees/find_diameter.py | 2,461 | 3.671875 | 4 | class TreeNode():
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def set_right(self, data):
self.right = data
def set_left(self, data):
self.left = data
def height(root):
if root == None:
return 0
stack = []
while... |
341c538e530cccde34ca12567cb72625af3d214f | tdavchev/algorithms | /strings/regx_3.py | 538 | 3.53125 | 4 | def regx(pattern, text, i, j):
if len(pattern) == i and len(text) == j:
return True
if i < len(pattern) - 1 and pattern[i+1] == "*":
for k in range(i, len(text) + 1):
if regx(pattern, text, i+2, k):
return True
if k >= len(text):
return F... |
8ee162a86f5b40d3b7da411d6dc836c86f12785e | tdavchev/algorithms | /miscellaneous/find_all_palindrome_substr.py | 471 | 3.90625 | 4 | # Given a string find all substrings that are palindromes.
def is_palindrome(input, i, j):
while i<j:
if input[i] != input[j]:
return False
i += 1
j -= 1
return True
def find_all_palindrome_substrings(input):
count = 0
for i in range(0, len(input)):
for j i... |
dbf79c9aa3972921dd908ad0d9d29cdca1f09d39 | tdavchev/algorithms | /Trees/isBST.py | 1,579 | 3.5625 | 4 | class TreeNode():
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def set_right(self, data):
self.right = data
def set_left(self, data):
self.left = data
def checkBST(root):
collection = set()
bst = True
node = root
q =... |
23b56af4cf34b7f5c25444fe8a054ca2fdbeee6f | tdavchev/algorithms | /arrays/find_low_high.py | 818 | 3.6875 | 4 | def find_low(arr, key):
start = 0
end = len(arr) - 1
low = -1
while start <= end:
mid = start + (end - start)//2
if mid - 1 < 0:
return mid
if arr[mid] == key and arr[mid - 1] < key:
return mid
if arr[mid] < key:
start = mid
el... |
0497c2f4b574dd6a6a2d9400b47bb36170300234 | tdavchev/algorithms | /recursion/parentheses.py | 151 | 3.8125 | 4 | def parenthesis(count):
if count > 0:
print("(", end='')
parenthesis(count-1)
print(")", end='')
parenthesis(3)
print("") |
68f6c3ff73296d02dbce5c313fa3027cf432de5a | tdavchev/algorithms | /Trees/mirror.py | 2,673 | 3.640625 | 4 | class TreeNode():
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def set_right(self, data):
self.right = data
def set_left(self, data):
self.left = data
def mirror_tree(root):
if root == None:
return
if root.left != ... |
4184a58765ec5d61cad8d9aefe5884eddb2a7a5f | tdavchev/algorithms | /Graphs/recursive_dfs.py | 1,074 | 4.03125 | 4 | def recursive_dfs(graph, start, path=[]):
''' recursive depth first search from start '''
path = path + [start]
for node in graph[start]:
if not node in path:
path = recursive_dfs(graph, node, path)
return path
def iterative_dfs(graph, start, path=[]):
''' iterative depth first... |
6d094d2ba5b6082ce897d5a86cf879083b8c500e | tdavchev/algorithms | /stacks and queues/stack_from_queues.py | 2,552 | 3.9375 | 4 | from collections import deque
class stack_using_queue:
def __init__(self):
self.queue1 = deque()
self.queue2 = deque()
def push(self, data):
self.queue1.append(data)
def isEmpty(self):
return len(self.queue1) + len(self.queue2) == 0;
def pop(self):
if self.isEmpty():
raise Exceptio... |
9754a7d5af1e76a61c643f027b6b8c6450b79cee | tdavchev/algorithms | /Trees/mirror_tree.py | 1,070 | 3.59375 | 4 | class TreeNode():
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def set_right(self, data):
self.right = data
def set_left(self, data):
self.left = data
def mirror_tree(root):
if root == None:
return
if root.left != N... |
6ed88decfe1aff784b893ece7535d8e56b24b3bb | Nice2haveSomeInformation/mpi-parallel-processing | /src/sieve-of-eratosthenes/sieve_sequencial.py | 624 | 3.96875 | 4 | import primesieve
def is_prime(num):
return num % 2 == 0 and num > 1
def sieve_of_eratosthenes(start, end):
return primesieve.primes(start, end)
def sieve_of_eratosthenes_python(end):
"""Return a list of the primes below n."""
prime = [True] * end
result = [2]
append = result.append
sq... |
dbd58746291cf2ac5d6d51266bf01d112058ebed | CandiceD17/Leetcode-Everyday | /new_pracetice_prob/105. Construct Binary Tree from Preorder and Inorder Traversal.py | 670 | 3.875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode:
if len(preorder) == 0 or l... |
bcedde1bf74bc38c1b9f3a72c16191546ae17d22 | erikpsw/practice | /gensubset.py | 1,008 | 4.09375 | 4 | def PowerSetsRecursive(items):
"""Use recursive call to return all subsets of items, include empty set"""
if len(items) == 0:
# if the lsit is empty, return the empty list
return [[]]
subsets = []
first_elt = items[0] # first element
rest_list = items[1:]
# Strateg... |
1332a67400a98ec47c6bec60a8782cb1f3a37735 | BenioffOceanInitiative/ws-scraping-scripts | /JSON 2 CSV_API Script.py | 5,131 | 3.921875 | 4 | # Title: JSON 2 CSV_API Script
# Author: Ben Gaiarin (bgaiarin@ucsb.edu)
# Purpose:
# This is a short Python script that extracts data from
# a .php URL as a JSON string and converts those data into
# a CSV file for visualization and manipulation.
# The user of this script must input the URL and parameters
# of t... |
4a38774b4dae220dc29e577731fadf091428cd7e | artlawson/Twilio-Practice | /practice07.py | 892 | 3.859375 | 4 | import os
import sys
#
# Complete the timeConversion function below.
#convert given regular time to military time
#format "HH:MM:SSAM"
#
def timeConversion(s):
#check to see if it is am or pm
#if pm, add 12 and return
#if am return without the am
x = 12
if s[-2] == "P":
if s[0:2] == "12"... |
84bf9e1dad4f21d981d02ac30d12f120bab24a70 | srikloud/PyProjects | /List/ReverseList.py | 120 | 3.578125 | 4 | l = [1,2,3,4,5]
l2 = list()
for i in range(0,len(l)):
ll = (-1*(i+1))
l2.append(l[ll])
print(l2)
l = l2
print(l) |
7ea0e0946f599d03e719341955107722d69916c7 | srikloud/PyProjects | /List/eleminate_strings_fromList.py | 228 | 3.8125 | 4 | l = ['sri',1,3,'kanth',4,6,'chaw']
l2 = list()
l3 = list()
for i in range(0,len(l)):
if str(l[i]).isnumeric():
l2.append(l[i])
else:
l3.append(l[i])
print(l2)
print(l3)
#print(str(l[0]).isnumeric())
|
0b149e4be5487c872da038357a1db6db63753a2c | srikloud/PyProjects | /General/recur_multpl.py | 242 | 4 | 4 | def recur_multi(n=1):
print(3*n)
if n<=10:
recur_multi(n+1)
'''
# Iterative Multiplication
for i in range(1, 10):
str(
print(str(eval("n"))+"*"+str(eval("i"))+"="+str(n*i)))
'''
recur_multi()
|
d79a24305b8031eb7c25005f0d307121287c0100 | srikloud/PyProjects | /List/node.py | 3,247 | 3.953125 | 4 | class Node():
def __init__(self, data = None, next_node_pntr=None):
print("in Node init")
self.data = data
print('1')
print(self.data)
self.next_node_pntr = next_node_pntr
print('2')
print(self.next_node_pntr)
def set_data(self,data):
self.data=da... |
9c9a6ac4453551b0eca0e4974c119ddf1597f62a | srikloud/PyProjects | /List/mergeSrtedLists.py | 617 | 3.875 | 4 | def mergelists(a,b):
c=[]
while a and b:
if a[0] < b[0]:
c.append(a.pop(0))
else:
c.append(b.pop(0))
print(a)
print(b)
print(c+a+b)
#mergelists([1,2,3,10,15],[5,20,30,40,50])
def mergeUnsortedLists(a,b):
a=a+b
for j in range(0,len(a)-1):
pri... |
be117321acffe93080bdce2a340f61b274cafd90 | srikloud/PyProjects | /search/bs_iterative.py | 657 | 3.828125 | 4 | def bs_iter(l,lft,rt,ele):
while lft <=rt:
print("print left " + str(lft))
print("print right " + str(rt))
print("Search element " + str(ele))
mid = (lft + rt) // 2
print("middle position " + str(mid))
if l[mid] == ele:
print("element found at position "+... |
27414315c6d0b520aec8bb8d767ddaa04351d624 | srikloud/PyProjects | /List/Surprising_List.py | 188 | 3.96875 | 4 | def sup_list(a=[]):
#a=[]
a.append(1)
return a
x = sup_list()
print(x)
x = sup_list()
print(x)
x = sup_list()
print(x)
m = ['a','b','c','d','e','f']
print(m)
print(m[1:-1])
|
ce862c1f6c2feccca1daeab841270e802bd8bc6c | srikloud/PyProjects | /List/asc_list.py | 255 | 3.609375 | 4 | l = [2,5,3,1,12,9,4,7,10]
ll = 0
l2 = 0
l3 = list()
la = 0
lo = 0
for j in range(0,len(l)):
for i in range(0,len(l)):
if l[i] not in l3:
if l[i] > la:
la = l[i]
lo = la
l3.append(lo)
la = 0
print(l3) |
8a4e0c49270009a4ef435fb268e800eb66ec73d6 | srikloud/PyProjects | /linkedlist_pkg/join_two_lists.py | 1,803 | 3.984375 | 4 | class node():
def __init__(self,value=None,nextnode=None):
print("node__init()___")
self.value = value
print("self.value"+str(self.value))
self.nextnode = nextnode
print("self.nextnode"+str(self.nextnode))
class ll():
def __init__(self):
print("ll__init()___")
... |
fad77f9512cbe2ea9f381d523101edb3db67d39d | anayatzirojas/lesson2python- | /Lesson2/problem2.py | 91 | 3.53125 | 4 | numbers = [3, 5, 9, 17, 123, 666, 1000, 4321]
for number in numbers:
print(number * 2) |
617b0b81f3c5ca52ec255b528b15d6862aa34f52 | maria-gabriely/Maria-Gabriely-POO-IFCE-INFO-P7 | /Presença/Atividade 02/Lista_Encadeada.py | 227 | 4.25 | 4 | # 3) Lista Encadeada (A retirada e a inserção de elementos se faz em qualquer posição da Lista).
Lista3 = [1,2,3,4,'a','c','d']
print(Lista3)
x = 'b'
Lista3.insert(5,x)
print(Lista3)
Lista3.pop(2)
print(Lista3)
|
2c7dc38d445ef570992c989b842918cb1be05511 | TripleChoco/ubb | /sem1/cl/Computational Logic Homework/ui/ui.py | 5,809 | 3.8125 | 4 | from number.number import *
import os
class ui:
def __init__(self):
pass
def printMenu(self):
s = 'Please choose an operation:\n'
s += ' 1. Addition\n'
s += ' 2. Subtraction\n'
s += ' 3. Multiplication by one digit\n'
s += ' 4. Division by one digit\n'
... |
c69e6a90a8906f203d8be7e65b8fe5944df88f87 | TripleChoco/ubb | /sem1/fop/Christmas Present/driver/driver.py | 538 | 3.578125 | 4 | class driver:
def __init__(self, id, distance):
self.__id = id
self.__distance = distance
def getId(self):
'''
This method the id attribute
'''
return self.__id
def getDistance(self):
'''
This method returns the distance attribute
... |
8cd1dba79b9a4a65ed1e35db29ca91087af5acbb | TripleChoco/ubb | /sem2/Algoritmica Grafelor/practical work no. 1/digraph/digraph.py | 6,345 | 3.71875 | 4 | #!/usr/bin/python3
import os
class DiGraph:
def __init__(self, vertices = {}, outEdges = {}, inEdges = {}):
'''
:param vertices: the key is a vertex v, the value is a list of tuples
(u, c) with the meaning that there is an edge from
v to u of cost c
... |
2980ce18ba08bc9b8db0cf9d96867dccf0b7f7b7 | TripleChoco/ubb | /sem1/fop/Lab2-4/Family Expenses/files.py | 3,903 | 3.8125 | 4 | import cmd
import os.path
#FILES#####################################################################################################
def checkIntegrityOfTheFiles(categoryList):
'''
This function checks whether or not the files containing the data do in fact exist.
If not, they are created and ini... |
8cf38bf4b949101cf4b0324ec04aedb40283d8bc | TripleChoco/ubb | /sem1/fop/Lab5-7/Book Rental/rental/rental.py | 611 | 3.6875 | 4 | class rental:
def __init__(self, customerId, book, date, days):
self.__customer = customerId
self.__book = book # bookId
self.__date = date # The date it was rented
self.__days = days # the number of days it has been rented for
def returnCustomerId(self):
return self.__customer
def returnBookId(self):
... |
ce57776b7e8363b53a3eeb9d65320ce89f099120 | Niksscoder/Python-Tasks-Stepik | /task_4.py | 769 | 3.875 | 4 | '''
Learning that DNA is not a random string, computer science students who had just entered
the Institute of Bioinformatics suggested using a compression algorithm that compresses
repeated characters in a string.
Coding is done as follows:
s = 'aaaabbсaa' converted to a4b2с1a2 that is, groups of identical characters... |
f446063fd73cac63a7c39bd8375c2defb79a9a9c | ilyaderkatch/python-review1 | /cows.py | 6,008 | 3.75 | 4 | import random
import os.path
import os
import pickle
number_list = list(range(10)) #комментарий
def num_correct_sequences(n):
return 10**n
def checker(ans, real_ans):
bulls = 0
cows = 0
for i in range(0, len(ans)):
if ans[i] == real_ans[i]:
bulls += 1
elif ans[i] in real_... |
8a62b3472dc8c1042d3fd320964cfa262f9a7430 | deluxjun/CrackingTheCodeInterview6E | /interview-py/P1-8.py | 637 | 3.6875 | 4 | def makeCol(m, row, colLen):
for j in range(colLen):
m[row][j] = 0
def makeRow(m, col, rowLen):
for j in range(rowLen):
m[j][col] = 0
def makeZero(m):
rowLen = len(m)
colLen = len(m[0])
rows = []
cols = []
for i in range(rowLen):
for j in range(colLen):
... |
78e5a6117525081ab62929960d7e43a5143ad237 | Skybluewater/QuestGeneratorWebsite | /generate/solve.py | 2,607 | 3.609375 | 4 | from fractions import Fraction
class solvable:
prior = {'+': 0, '-': 0, '*': 1, '/': 1, '^': 2, '(': -1}
def solve(self, num1: Fraction, num2: Fraction, operator):
if operator == '+':
return num1 + num2
elif operator == '-':
return num2 - num1
elif operator == ... |
222a5256a01145f08d272ec0fd53ed50508439db | mohits23/django-API-references | /api_crud_practical/myApp.py | 3,633 | 3.765625 | 4 | import requests
import json
# This will be treated as a Python Application that will
# use this 'crud_api' that we have created to a extract or post
# some data into the database (via API)
# This app can be present anywhere in the system but we have made it
# inside the project just for our convinience.
# This "my... |
5a7fa47d18c7d1a74c719863450f9596ead61595 | joshuamainsmith/Exercises-for-Programmers | /Problem 3/Python/Problem3.py | 110 | 3.703125 | 4 | quote = input("What is the quote? ")
name = input("Who said it? ")
print (name, " says \"", quote, "\"") |
b1621ef5be76651e75a70c4ac59bea2c55b49d7a | peter6204/Computational-Physics-step-A-with- | /포물선.py | 625 | 3.625 | 4 | import numpy as np #"*"는 모든 이란 뜻
import pylab as pl
x = pl.linspace(0,10,51) #linspace(a,b,c) a이상 b이하 c개의 등차수열 생성 라인의 공간 0이상 10 이하 51개로 쪼개기
#print(x)
y=2*x*x -x -1
z=x*x
pl.title('My Second graph') #그래프 이름
pl.xlabel('Time (fortnights)') #x축 label
pl.ylabel('Distance(furlongs)') #y축 label
pl.x... |
6732ef16de0393dcbb264758d9ce2f8fc5e58295 | LeeDongGeon1996/co-te | /book/[구현-q2] 문자열 재정렬.py | 364 | 3.546875 | 4 | # solution: 알파벳와 순자를 분리하고 각각을 처리.
# time-complexity: O(N) - 선형시간
# start_input
N = input()
# end_input
alpha_list = []
sum = 0
for i in N:
if i.isalpha():
alpha_list.append(i.upper())
else:
sum += int(i)
alpha_list.sort()
# start_print
for i in alpha_list: print(i, end='')
print(sum)
# end_pr... |
f02705df831fd72efc3f9611f9582392519b8f33 | jonDuke/cs-module-project-iterative-sorting | /src/iterative_sorting/iterative_sorting.py | 3,168 | 4.21875 | 4 | """ insertion sort written by Matt during lecture """
def insertion_sort(input_list):
# think of the first element as sorted
# for all unsorted items
for i in range(1, len(input_list)):
# mark the current item we are considering
current = input_list[i]
# look left until we find the... |
1aa7e11de6c87dc651272fd1a9a6577e33497143 | raulexposito/kakebo-api | /flaskr/modelo/movimientos.py | 1,923 | 3.828125 | 4 | from utilidades.formateador import formateador
from utilidades.fecha import fecha
import itertools
class movimientos:
"""Un conjunto de movimientos"""
def __init__(self, movimientos):
self.movimientos = movimientos
self._gastos = self._calcular_gastos(self.movimientos)
self._ingresos... |
e5e01b416c7956dca9630cf46e3949f090303199 | sandeep4216/Python | /methods.py | 346 | 4.0625 | 4 | # def move(time,speed):
# print("I am moving on " + str(speed) + " Kmph" + "at" + str(time))
# x = time + 1
# y = speed - 1
# print("I am moving on " + str(x) + " Kmph" + "at" + str(y))
# move(10,5)
# print("______________")
# move(2,10)
# print("______________")
# move(3,11)
def stars(n):
print(n * "*")
sta... |
d518cd15132012a1f28e184485785247a22dc6de | maxild/algorithms | /graphs/min_cut.py | 11,938 | 3.84375 | 4 | import time
from itertools import repeat
from re import sub
from random import randint
from copy import deepcopy
# List representation of adjacency list
# * the vertices of a graph with n nodes will be numbered from 0 to n-1
# * vertex labels can be stored in separate list
# * edge weights must be stored in 'dict ... |
d3f709fd589f5c4e8cba8bd80dcc80b65e2ca5d1 | djstrayk/praktikum | /mnojestva.py | 610 | 3.578125 | 4 | # напишите код функции print_valid_cities, которая
# принимает аргументы all_cities и used_cities
def print_valid_cities(allCities, useCities):
notUsedCities = allCities.difference(useCities)
print(','.join(notUsedCities))
all_cities = set([
'Абакан',
'Астрахань',
'Бобруйск',
'Калуга',
'Кар... |
3b83a072866fda61926ad460451abd3a621a01ed | djstrayk/praktikum | /10-2.py | 371 | 3.953125 | 4 | friends = {'Серёга': 'Омск', 'Соня': 'Москва', 'Дима': 'Челябинск', 'Женя': 'Ставрополь', 'Артем': 'Калининград'}
print("Вот в каких городах живут мои друзья: " + ", ".join(friends.values()))
for name in friends:
print(name + ' живёт в городе ' + friends[name]) |
65492a228dd46eed5bafc725dae2bdb07fb2baaf | nuno-21902803/pw-python | /pw-python-03/exercicio_3/main.py | 667 | 3.6875 | 4 | import os
def pede_pasta():
while True:
try:
nome = input("Introduza o caminho para pasta: ")
if os.path.isdir(nome):
return os.path.realpath(nome)
except IOError:
print("Pasta não existente")
def calcula_tamanho_pasta(pasta):
if os.path.i... |
0adb2ce98d7be603ba00c82e95326eb0ba25e395 | pyaria/ProjectEuler | /12.py | 1,335 | 3.8125 | 4 | #Problem 12
'''The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.
The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
1: 1
3: 1,3
6: 1,2,3,6... |
82eebf25bf6788a402c1a1679235eba87b51091a | pyaria/ProjectEuler | /23.py | 3,252 | 4.09375 | 4 | #Problem 23
'''
A perfect number is a number for which the sum of its proper divisors
is exactly equal to the number.
For example, the sum of the proper divisors of 28 would be
1 + 2 + 4 + 7 + 14 = 28,
which means that 28 is a perfect number.
A number n is called deficient if
the sum of its proper divisors is less tha... |
a69c7e7f6b6ff4d5ea8378758a726d39dfbb1221 | vlad101vlad/universityAssignments | /ContestApp_modularProgramming/UI_functions.py | 10,307 | 3.53125 | 4 | import time
import Modular_programming.domain as domain
import Modular_programming.contest_functions as functions
import Modular_programming.undo as UNDO
from Modular_programming.tests import *
def print_console_based_menu():
print("Welcome to the menu! Chose an action :\n"
"add <P1 score> <P2 score> <P... |
356ab6ccdfc9a7c1dfbca7466182acc565a310e0 | 2gisprojectT/komissarov-habrahabr | /2_lion/State.py | 512 | 3.5625 | 4 | __author__ = 'jk'
# -*- coding: utf-8 -*-
# Базовый класс сотояния
class State(object):
def __init__(self, name):
self.name = name
def message(self):
print 'State: ' + self.name
# Голодный
class HungryS(State):
def __init__(self):
super(HungryS, self).__init__('Hungry')
# Сыты... |
edd97b485bfb1659f7745e4d0ddfa916d85c13c2 | taswani/Number-Guessing-Game-Tanuj-Aswani | /number_guessing_game.py | 2,343 | 4.03125 | 4 | import random
global high_score
def start_game():
# write your code inside this function.
print("\n\033[1mWelcome to the Number Guessing Game!\033[0m\n")
random_number = random.randint(1, 10)
num_guesses = 1
high_score = 0
game_done = False
while not game_done:
print("Try to guess ... |
c9ac07fd9409119b75fa29f3017e1dd450e736fb | JamesTang2001/super-duper-adventure | /01-machine-learning-fundamentals-with-python/02-unsupervised-learning-in-python/03-decorrelating-your-data-and-dimension-reduction.py | 11,628 | 4.59375 | 5 | # 03 Decorrelating your data and dimension reduction
'''
Dimension reduction summarizes a dataset using its common occuring patterns. In this chapter, you'll learn about the most fundamental of dimension reduction techniques, "Principal Component Analysis" ("PCA"). PCA is often used before supervised learning to improv... |
baf5643e85d2807b34118425a78d93cb636c761d | JamesTang2001/super-duper-adventure | /03-finance-fundamentals-in-python/01-introduction-to-python-for-finance/05-s&p-100-case-study.py | 5,985 | 4.4375 | 4 | # 05 S&P 100 Case Study
'''
In this chapter, you will get a chance to apply all the techniques you learned in the course on the S&P 100 data.
'''
# Introducing the dataset
'''
Video
'''
# Lists
'''
Stocks in the S&P 100 are selected to represent sector balance and market capitalization. To begin, let's take a loo... |
16e9ff7b1c409224a53cc8ef5083fd473c820539 | JamesTang2001/super-duper-adventure | /03-finance-fundamentals-in-python/02-intermediate-python-for-finance/01-datetimes-and-dictionaries.py | 9,599 | 4.8125 | 5 | # 01 Datetimes and Dictionaries
'''
In this chapter, you’ll learn how to create and manipulate Python datetime objects to help you identify key financial events, such as Black Friday. You’ll also learn how to store and efficiently look up items using Python dictionaries.
'''
# Representing time with datetimes
'''
Vi... |
84942b18989f513760f03df006e01bdb79e08d46 | zymrytekabashi/python_fundamentals | /Store & products/Products.py | 1,289 | 3.75 | 4 | class Products:
def __init__(self, name, price, category):
self.name=name
self.price=price
self.category=category
def update_price(self, percent_change, is_increased):
if is_increased == True:
self.price += self.price*percent_change
else:
... |
bcf7438807a1c884d2caffc28eee8afb70098107 | jiangfeng-Myself/my-test | /python100days/day12/str1.py | 1,008 | 4.0625 | 4 | """
字符串常用操作
"""
import pyperclip
# 转义字符
print(' My brother\'s name is \'007\'')
# 原始字符串
print(r'My brother\'s name is \'007\'')
str = 'hello123world'
print('he' in str)
print('her' in str)
# 字符串是否只包含字母
print(str.isalpha())
# 字符串是否只包含字母和数字
print(str.isalnum())
# 字符串是否只包含数字
print(str.isdecimal())
... |
e66bf9bfe521f9e989250c34224d74260cb16d19 | jiangfeng-Myself/my-test | /python100days/day16-20/python语言进阶/高级函数的用法(map,filter).py | 246 | 3.546875 | 4 | def main():
items = [23,34,32,43,432,23,4,5,34,34]
items1 = list(map(lambda x:x ** 2, filter(lambda x:x%2, items)))
print(items1)
items2 = [x ** 2 for x in items if x % 2 ]
print(items2)
if __name__ == '__main__':
main() |
a85b210d1df4455d8fbad8113c076b28ae258387 | jiangfeng-Myself/my-test | /python100days/day6/fun1.py | 191 | 4.125 | 4 |
# 求阶乘的功能 函数
def factorial(n):
result = 1
for num in range(1,n + 1):
result *= num
return result
print(factorial(7)//factorial(3)//factorial(4)) |
3dbe016fc684b063276a25e7bbfa8a09354c6861 | jiangfeng-Myself/my-test | /python100days/day10/game.py | 3,325 | 3.875 | 4 | from enum import Enum, unique # 枚举类型
from math import sqrt
from random import randint
import pygame
@unique # 检测枚举类型中是否有重复
class Color(Enum):
"""颜色"""
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GRAY = (242, 242, 242)
... |
a6bd084d668d7a348290b9298e5cfebae48c8e67 | borgwang/tinynn | /examples/binary_classification/run.py | 2,985 | 3.625 | 4 | """Example code for binary classification."""
import argparse
import os
import time
import numpy as np
import tinynn as tn
def main():
if args.seed >= 0:
tn.seeder.random_seed(args.seed)
mnist = tn.dataset.MNIST(args.data_dir, one_hot=True)
train_x, train_y = mnist.train_set
test_x, test_y ... |
fed2927e1966010ae13f613e321c1682ce0e04d8 | leskovsky1/FRI | /Ing/1.semester/Teoria_Oznamovania/cvicenia/python/objekt.py | 395 | 3.609375 | 4 | class Polynom:
def __init__(self, koef):
self.koef = koef
self.stupen = len(koef) - 1
def printPolynom(self):
vypis = ""
x = self.stupen
#for x in range(self.stupen, -1, -1):
# vypis += "+" + str(self.koef[x])+"x^"+str(self.stupen)
while(x>=0)
vypis += "+" + str(self.koef[x])+"x^"+int(x)
x=x-1... |
a7a4cf36749aec07dc5a11bd4d9783671057f319 | diegocolombo1989/Trabalho-Python | /23-Aula23/exercicios/resolucao/exercicio1.py | 1,616 | 3.515625 | 4 | # Aula 22 - 10-12-2019
# Como Tratar e Trabalhar Erros!!!
# Com base no seguinte dado bruto:
dadobruto = '1;Arnaldo;23;m;alexcabeludo2@hotmail.com;014908648117'
# 1) Faça uma classe cliente que receba como parametro o dado bruto. ok
# 2) A classe deve iniciar (__init__) guardando o dado bruto nume variável chamada s... |
a6a9ca58f31c8161792d2c6ce7a73f1318bc8589 | diegocolombo1989/Trabalho-Python | /Aula20/exercicios/Resolução/exercicio1.py | 2,183 | 4.28125 | 4 | # Aula 20 - 05-12-2019
# Lista com for e metodos
# Com esta lista:
lista = [
['codigo','produto','valor','quantidade'],
[1,'Cevada',15.00,10],
[2,'Lupulo',150.50,200],
[3,'Malte',57.80,5000],
[4,'Levedura 1',10.65,500],
[5,'Extrato de Levedura',15.00,60],
... |
d93212f1f43802b19d913aa1b4f2c8f8fed56850 | diegocolombo1989/Trabalho-Python | /Aula29/revisao.py | 309 | 3.84375 | 4 | #----- Listas
pessoasL = ['Gustavo', 'Maykao','Josue Rei das Listas']
#----- Tuplas
pessoasT = ('Gustavo', 'Maykao','Josue Rei das Listas')
#----- Dicionários
pessoasD = {'aluno':'Gustavo', 'prof':'Maykao', 'rei':'Josue Rei das Listas'}
print(pessoasD)
print(pessoasT[1])
print(pessoasL[2])
print(pessoasD['aluno'])
fo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.