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 |
|---|---|---|---|---|---|---|
6a198cf572dbd140224232520c810b9dff3697c9 | bryantbyr/LeetCode-solutions | /606. Construct String from Binary Tree.py | 864 | 3.859375 | 4 | #606. Construct String from Binary Tree
#
#Created by bryantbyr on 20180714
#Space:O(1)
#Time:O(n)
#recursion
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def tree2str(self... |
609f83f8ae54f6e9cb99f13ac0dab14b4875d51d | bryantbyr/LeetCode-solutions | /623. Add One Row to Tree.py | 1,378 | 3.921875 | 4 | #623. Add One Row to Tree
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Tree(object):
def front_recursion(self, root):
"""利用递归实现树的先序遍历"""
if root is None:
... |
eecbed157b6b2660224a5a18a184bae662fc15d2 | bryantbyr/LeetCode-solutions | /508. Most Frequent Subtree Sum.py | 2,850 | 3.609375 | 4 | #508. Most Frequent Subtree Sum
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
#Created by bryantbyr on 20181103
#Time:O(N)
#Space:O(N)
#Tree + Post Order Traversal
class Solution:
def findFreque... |
e8a4ddb94789b95cc2879f6f19a4c2e11816da5b | bryantbyr/LeetCode-solutions | /404. Sum of Left Leaves.py | 1,471 | 3.875 | 4 | #404. Sum of Left Leaves
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
#Created by bryantbyr on 20180806
#Time:O(N)
#Space:O(1)
#recusion traverse
class Solution:
def __init__(self):
se... |
5c821550dcbe03d6969460f636b70fbe78bb21bd | bryantbyr/LeetCode-solutions | /77. Combinations.py | 652 | 3.53125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/2/15
# @Author : qirui
# @FileName: 77. Combinations.py
# Backtrack/DFS (general)
class Solution(object):
def combine(self, n, k):
"""
:type n: int
:type k: int
:rtype: List[List[int]]
"""
def backtrack(tmp,... |
3e1b7ff0e0abaaa52e1b92a76c5ad89ce72af9b9 | shayRusso320/CheckID | /main.py | 654 | 3.828125 | 4 | def check_ID(id_num):
sum_check = 0
weight = 1
if len(id_num) != 9:
print("length is not valid")
return
for ch in id_num[0:-1]:
digit = ord(ch) - ord('0')
if digit < 0 or digit > 9:
print("character '" + ch + "' is not a number")
return
... |
7c7a71d44e8e855999cf05b21baacf457159c60a | thedarthmike/E-Voting-on-Fenix | /VotingSite/ElectionServer/Crypto/numbTheory.py | 855 | 3.5 | 4 | def factor(n):
if n in [1,-1,0]: return []
if n<0: n=-n
F = []
while n!=1:
p = trial_division(n)
e = 1
n /= p
while n%p == 0:
e += 1; n/=p
F.append(int(p))
F.sort()
return F
def trial_division(n):
if n==1: return 1
for p in [2,3,5]:
... |
afd0cb636c4235318e66ea12e2fff67b2487c155 | muhanying/myFirstPython | /demo/demo.py | 355 | 3.640625 | 4 | int_a =1
float_b = 1.0
complex_c = 1.0
print(type(int_a))
print(type(float_b))
print(type(complex_c))
"""
段落注释
切片 [start:stop:step][开始:结束:步长]
"""
a = '1234567'
print(a[0:4])
list = [1,2,3]
print(list[0])
#切片
print(list[0:3])
if_a=0
if if_a==0:
print('ifle')
elif if_a==1:
print('else if')
else:
print('else... |
90463860233dc72c03b5ccc0e15c4975d3abb729 | muhanying/myFirstPython | /day1219/myExceptionDemo.py | 324 | 3.890625 | 4 | # class MyException(Exception):
# def __init__(self,v1,v2):
# self.v1=v1
# self.v2=v2
# raise MyException(1,2)
try:
num1 = int(input("please input a num "))
num2 = int(input("please input a num "))
print(num1 / num2)
except Exception as e:
print(str(e))
finally:
print("结束了")
|
a84672939ce92810a880d668ee4d63bcde87b160 | C-Laborde/RL_Udemy | /tic_tac_toe/play_game.py | 970 | 3.859375 | 4 | def play_game(p1, p2, env, draw=False):
# loop until the games is over
current_player = None
while not env.game_over():
# alternate between players
# p1 always starts first
if current_player == p1:
current_player = p2
else:
current_player = p1
... |
648a11b663475c9391fc62f3091ab0500cd79ee6 | C-Laborde/RL_Udemy | /Bandit.py | 1,441 | 3.671875 | 4 | import numpy as np
class Bandit:
def __init__(self, m, eps=None, upper_limit=None, method="eps"):
"""
m = true mean
mean = estimate of the bandit mean
N = nr of arm pulls
"""
self.m = m
if method == "eps":
try:
float(eps)
... |
951f684e020725c4f6daf5e556acb9b16027439e | Umid221/python-sariq-dev | /o'zgaruvchilar va ma'lumot turlari/#06 SONLAR.py | 465 | 3.609375 | 4 | son = int(input('istalgan sonni kiriting:\n>>>'))
print(f'{(son)} ning kvadrati {(son**2)} ga teng')
print(f'{son} ning kubi {son**3} ga teng')
yosh = int(input('yoshingiz nechada?\n>>>'))
tug_yil = 2021 - yosh
print(f'Siz', tug_yil, '-yilda tug\'ilgansiz')
a = float(input("birinchi sonni kiriting: "))
b = float(inp... |
41d8e3bf99f0cac068052febbcd1d243bd5a667f | Umid221/python-sariq-dev | /while/#18 WHILE, RO'YXATLAR VA LUG'ATLAR/3.py | 738 | 3.640625 | 4 | print('mahsulotlaringizni kiriting')
mahsulotlar1 = []
n = 1
while True:
mahsulot = input(f"{n}-mahsulotni kiriting: ")
mahsulotlar1.append(mahsulot)
a = input("yana mahsulot kiritasizmi?(ha/yo'q) ")
if a == 'ha':
n+=1
continue
else:
break
print("Mahsulot va uning narxini ki... |
1a1228c06b7772633a0e778b763a14508394014f | Umid221/python-sariq-dev | /while/#18 WHILE, RO'YXATLAR VA LUG'ATLAR/list to'ldirish.py | 281 | 3.71875 | 4 | print('mahsulotlaringizni kiriting')
mahsulotlar = []
n = 1
while True:
mahsulot = input(f"{n}-mahsulotni kiriting: ")
mahsulotlar.append(mahsulot)
a = input("yana mahsulot kiritasizmi?(ha/yo'q) ")
if a == 'ha':
n+=1
continue
else:
break |
de0cb83428357ad5fb96e04d238e959554cc42ed | adi-797/Python-Hackerrank | /Strings/Find a string.py | 350 | 3.875 | 4 | def count_substring(string, sub_string):
i=0
count = 0
while i<(len(string)-len(sub_string)+1):
temp = ""
before = i
for j in range(len(sub_string)):
temp = temp+string[i]
i = i+1;
if (temp == sub_string):
count +=1;
i = before
... |
040c6b25493ddc9af88004bafffc048d85d4258a | adi-797/Python-Hackerrank | /Strings/String Formatting.py | 496 | 3.640625 | 4 | def print_formatted(number):
b = str(bin(number))[2:]
sbuf = len(b)
buf = sbuf + 1
for x in range(1, number+1):
o = str(oct(x))[1:]
h = str(hex(x)).upper()[2:]
b = str(bin(x))[2:]
#p = str()
x = str(x)
while len(x) != sbuf:
x = " " + x
... |
aa2a9b4cb3496d7752f96a7a2164ef4d6b96a5c4 | adi-797/Python-Hackerrank | /Strings/sWAP cASE.py | 294 | 4.09375 | 4 | def swap_case(s):
ret = ""
for i in range(len(s)):
if s[i].isalpha() is True:
if s[i].isupper() is True:
ret+=s[i].lower()
elif s[i].islower() is True:
ret+=s[i].upper()
else:
ret+=s[i]
return ret
|
011b6da5f5731884fc1e268f3b07c30b996dfe80 | BBR2394/PerlinPython | /testPIL/extrapol.py | 739 | 3.671875 | 4 | # -*- coding: utf-8 -*-
# @Author: Baptiste Bertrand-Rapello
# @Date: 2020-01-23 17:14:51
# @Last Modified by: Baptiste Bertrand-Rapello
# @Last Modified time: 2020-02-13 13:48:16
# Cela fait un moment que je voulais refaire ce sous projet du RT ... (22/01/2020)
# ba voici au moins une nouvelle fonctione d'extrapo... |
380099c2dc41c651ace01f2b1e240a554b026441 | 0xomochi/Python | /Python100/02.py | 253 | 3.859375 | 4 | # 02.py
# "yume" + "tamu" の文字を先頭から交互に連結して文字列"ytuammeu"を得よ.
str1 = 'yume'
str2 = 'tamu'
sum = ''
for c1, c2 in zip(str1, str2):
sum += c1 + c2 # "a += b" means "a = a + b"
print(sum)
|
42572c73f0355a74c80997250ae8aebaad0c8d27 | bdavis160/ML | /perceptron.py | 6,787 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
author: Ben Davis
date: 2020-06-30
description: creates a network of perceptrons to identify hand written
numbers read in from a CSV file. These perceptrons are trained
for 50 epochs. At each epoch, an output file is generated containing
... |
24679fe79b0dac694844b5884f9818fe9ca5b605 | mustafaattiya/Udacity | /check profanity.py | 1,019 | 3.8125 | 4 | # Check profanity in a text file
import urllib
import urllib.request
import urllib.parse
# Python 3.6.4
# Read a text file
def read_text():
path = "/Users/mustafa/Documents/Office Corner/CV's/Forex Job Description.txt"
file = open(path, "r", encoding="utf-8")
file_contents = file.read()
#print(file_... |
bb4b61f5621077b1a8db9223d4b05430bca389a9 | sidcleyWilker/jogo-de-perguntas-e-respostas | /RespondaSePoder/src/interfacePy.py | 3,988 | 3.65625 | 4 | # -*- coding: UTF-8 -*-
from logicaPY import alternativas,pergunta,ranck,verificaResposta,ordenaRanking
from perguntas import procuraPergunta
import time
def imprimeRanking():
print ""
for i in range(len(ordenaRanking())-1,-1,-1):
print ordenaRanking()[i]
print ""
def cadastraUsuario():
... |
d27bfd91a438c03633c9d16f3748d209c79e9785 | jknapka/MyMacPyApp | /MyMacPyApp.app/Contents/app.py | 429 | 3.5625 | 4 | ''' Python 2.7 Tk example app. '''
import Tkinter as tk
import sys
def onQuit(): sys.exit(0)
win = tk.Frame(width=400,height=100)
win.master.title("Python 2.7 Example Application")
win.master.lift()
win.master.minsize(400,100)
win.master.attributes('-topmost',True)
win.master.after_idle(win.master.attributes,'-topmos... |
f4af753f2de6e46e5b416becd8ad181c7809fdf9 | code4love/dev | /Python/demos/python-course/python基础/格式化字符串.py | 2,159 | 4.03125 | 4 | # -*- coding: utf-8 -*-
#方式一:
a = 2
f = 3.14
print("a=%d, f=%.3f"%(a,f))
#只有一个参数可省略括号
print("a=%d"%a)
#方式二(新方式,推荐):
#语法
#它通过{}和:来代替%。
#1,通过位置:
print('{0},{1}'.format('kzc',18))
#output:'kzc,18'
print('{},{}'.format('kzc',18))
#Out: 'kzc,18'
print('{1},{0},{1}'.format('kzc',18))
#Out: '18,kzc,18'
#2,通过关键字参数
print('... |
370d394ee8d2a0b46a29799f1a24afb40db4bdc3 | code4love/dev | /Python/demos/python-course/面向对象编程/使用@property.py | 1,483 | 4.03125 | 4 | # -*- coding: utf-8 -*-
#Python内置的@property装饰器负责把一个方法变成属性调用
class Student(object):
@property
def score(self):
print("call score getter")
return self._score
@score.setter
def score(self, value):
print("call score setter")
if not isinstance(value, int):
raise... |
debfcc855154ac7dc1ef52eb6a24df322bd06f2d | code4love/dev | /Python/demos/practice/条件和循环语句.py | 358 | 3.890625 | 4 | #! /usr/bin/python
#条件和循环语句
x=int(input("Please enter an integer:"))
if x<0:
x=0
print ("Negative changed to zero")
elif x==0:
print ("Zero")
else:
print ("More")
# Loops List
a = ['cat', 'window', 'defenestrate']
for x in a:
print (x, len(x))
#知识点:
# * 条件和循环语句
# * 如何得到控制台输入
|
ae90c8d19c043fdf9ba27ca01682ff2da169c476 | code4love/dev | /Python/demos/python-course/高级特性/列表生成式.py | 750 | 3.671875 | 4 | # -*- coding: utf-8 -*-
#生成[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(list(range(1, 11)))
#生成[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
print([x*x for x in range(1, 11)])
#for循环后面还可以加上if判断
print([x*x for x in range(1, 11) if x%3==0])
#out: [9, 36, 81]
#还可以使用两层循环,可以生成全排列:
print([m + n for m in 'ABC' for n in 'XYZ'])
#out: ['A... |
099ea7d539a9e1f3e3671dfbab2b5f11e4bfaee0 | code4love/dev | /Python/demos/python-course/函数/函数参数.py | 4,160 | 4.3125 | 4 | # -*- coding: utf-8 -*-
#---默认参数---
#默认参数很有用,但使用不当,也会掉坑里。默认参数有个最大的坑,演示如下:
def add_end(L=[]):
L.append('END')
return L
# 当你正常调用时,结果似乎不错:
print(add_end([1, 2, 3]))
#Out: [1, 2, 3, 'END']
#当你使用默认参数调用时,一开始结果也是对的:
print(add_end())
#Out: ['END']
#再次调用add_end()时,结果就不对了:
print(add_end())
#Out: ['END', 'END']
#原因:Pyt... |
61b59a194213ca7d1c51f08d9585b61343d0498b | code4love/dev | /Python/demos/100Samples/18.py | 453 | 3.71875 | 4 | #题目:求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。
# 例如2+22+222+2222+22222(此时共有5个数相加),几个数相加有键盘控制。
def main():
a = int(input("input an integer:"))
count = int(input("input the count:"))
b = a
sum = 0
while count>0:
sum += a
a = a*10 + b
count -= 1
print(sum)
if __name__ == "__main_... |
b0177751d2322d24591dd0dac0760222e0a77b5e | code4love/dev | /Python/demos/100Samples/23.py | 376 | 3.9375 | 4 | """
2 【程序23】
3 题目:打印出如下图案(菱形)
4
5 *
6 ***
7 *****
8 *******
9 *****
10 ***
11 *
"""
def main():
for i in range(1, 8, 2):
#python中字符串可以做乘法和加法
print(' '*(4-(i+1)//2)+'*'*i)
for i in range(5, 0, -2):
print(' '*(4-(i+1)//2)+'*'*i)
if __name__=="__main__":
main()
|
99496768a485a2827075d00ef5331f1f97ecf69f | code4love/dev | /Python/demos/python-course/高级特性/生成器.py | 2,392 | 3.875 | 4 | # -*- cording: utf-8 -*-
#要创建一个generator,有很多种方法。第一种方法很简单,只要把一个列表生成式的[]改成():
g = (x * x for x in range(5))
print(g)
#如果要一个一个打印出来,可以通过next()函数获得generator的下一个返回值:
print(next(g))
#out: 0
print(next(g))
#out: 1
print(next(g))
#out: 4
print(next(g))
#out: 9
print(next(g))
#out: 16
#再调用next将raise StopIteration异常
#print(nex... |
799e14b86ce12ec280138c525258ffb8094bd399 | nickLuk/python_home | /16_1home2.py | 803 | 4.125 | 4 | # Програма пошуку святкових днів
day = int(input("Введіть день місяця: "))
mount = int(input("Введіть місяць: "))
def holy(day, mount):
if day == 1 and mount == 1:
print("<<<Новий рік>>")
elif day == 7 and mount == 1:
print("<<<Різдво>>>")
elif day == 8 and mount == 3:
print("<<<Мі... |
d516b1c2b45bf8145759ba5ae676f24c1c7384ce | ahmad-elkhawaldeh/ICS3U-Unit-4-03-python | /loop3.py | 779 | 4.5 | 4 | #!/usr/bin/env python3
# Created by: Ahmad El-khawaldeh
# Created on: Dec 2020
# a program that accepts a positive integer;
# then calculates the square (power of 2) of each integer from 0 to this number
def main():
# input
positive_integer = print(" Enter how many times to repeat ")
positive_string = ... |
a4914b21881b68d23fafd5e879ef237cffb3e647 | johnrobertlawson/evac | /evac/utils/timetool.py | 900 | 3.6875 | 4 | import os
import pdb
class TimeTool:
""" A custom time object.
Example:
To convert from a number of seconds to the largest units
possible, suitable for a WRF namelist for instance,
try the following::
secs = 10801
TT = TimeTool(seconds=secs)
... |
88e33f77320d763870cd15d893ca18866b8daa3d | carlosmgc2003/guia1paradigmas5 | /ejercicio4.py | 876 | 4.15625 | 4 | #Escribir un programa que reciba como parametro un string de elementtos separados por coma y retorne
#una lista conteniendo cada elemento.
def formatear_lista(lista : list) -> list:
return list(map(lista_from_string, lista))
#Modificar la funcion anterior pero obteniendo correctamente cada dato segun su tipo, da... |
81475a2eb3e949ac3449c63cf485f05f6c9c3c8d | bjemcnally/Udacity-DAND-Notes | /DAND_Lesson5.py | 12,582 | 4.375 | 4 | # Lesson 5: Scripting
"""
- Python Installation and Environment Setup
- Running and Editing Python Scripts
- Interacting with User Input
- Handling Exceptions
- Reading and Writing Files
- Importing Local, Standard, and Third-Party Modules
- Experimenting with an Interpreter
Python Installation
- to ope... |
a84296299e1569226fb934d66748a6881256a3ce | Gloom-er/training_pandas | /9.py | 324 | 3.890625 | 4 | import pandas as pd
import numpy as np
df = pd.DataFrame({
'country': ['Kazakhstan', 'Russia', 'Belarus', 'Ukraine', 'Kazakhstan'],
'population': [17.04, 143.5, 9.5, 45.5, 232.12],
'square': [2724902, 17125191, 207600, 603628, 123050]
}, index=['KZ', 'RU', 'BY', 'UA', 'KZ'])
print(df)
print(df... |
f340a6aa2513fa0c4c3259f0a510f0a5c889a409 | tush15/python-language- | /factorial_program.py | 201 | 3.6875 | 4 | no1 = 1
def fun(no):
for i in range(1,no+1):
global no1
no1 = no1 * i
def main():
no = int(input("Enter the number"))
no2 = fun(no);
print (no2)
if __name__ == "__main__":
main();
|
d0d253bb23b9f864e02b3243a2e36f26d19dec9f | Logesh-vasanth101/jeya | /char.py | 99 | 3.78125 | 4 | ch=raw_input("enter the character")
if(ch.isalpha()):
print("alphabet")
else:
print("not alpha")
|
d1bd8c93a30e153b1448fcc98cb468796afd0564 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/funções/desafio 100.py | 799 | 4.0625 | 4 | #Faça um programa que tenha uma lista chamada números e duas funções chamadas sorteia() e somaPar().
# A primeira função vai sortear 5 números e vai colocá-los dentro da lista
# e a segunda função vai mostrar a soma entre todos os valores pares sorteados pela função anterior.
from random import randint
from time import... |
93e6f42a043dccbdee8a819d44eb6e5367f7ff1d | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/funções/desafio 104.py | 600 | 4.15625 | 4 | # Crie um programa que tenha a função leiaInt(),
# que vai funcionar de forma semelhante ‘
# a função input() do Python, só que fazendo a
# validação para aceitar apenas um valor numérico. Ex: n = leiaInt(‘Digite um n: ‘)
def leiaint(msg):
ok = False
v = 0
while True:
n = str(input(msg))
if... |
295e226c54b2aa3e450125084075d6a081804625 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 10/desafio 030.py | 346 | 4.0625 | 4 | #crie um programa que leia um numero inteiro qualquer e mostre na tela se ele é par o ípar
n = int(input('Digite um núnmero:'))
r = n % 2
if r == 0:
print('Esse número é PAR')
else:
print('Esse numero é ÍMPAR')
#Esse modo da certo porque TODO numero PAR dividido por 2 tem o resto da divisao = 0 e todo numero I... |
8d4ece54c9eec19652392378331799d49966efe3 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 14/desafio 059.py | 1,245 | 4.125 | 4 | #Crie um programa que leia dois valores e mostre um menu na tela:
'''[ 1 ] somar
[ 2 ] multiplicar
[ 3 ] maior
[ 4 ] novos números
[ 5 ] sair do programa'''
#Seu programa deverá realizar a operação solicitada em cada caso.
from time import sleep
print('MENU')
v1 = float(input('Digite um valor:'))
v2 = float(input('Digi... |
9e496ea54fab02bf77b99c292ef7c633f0a2da03 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula18parte2lista/desafio 085.py | 569 | 4.09375 | 4 | #Crie um programa onde o usuário possa digitar sete valores numéricos
# e cadastre-os em uma lista única que mantenha separados os valores pares e ímpares.
# No final, mostre os valores pares e ímpares em ordem crescente.
lista = [[], []]
for c in range(0, 7):
valor = int(input(f'Digite o valor número {c}:'))
... |
352e9cb951a4b5a5a72649d16a16ff6b79cf47e1 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula16/desafio 076.py | 1,061 | 3.546875 | 4 | #Crie um programa que tenha uma tupla única com nomes de produtos e seus respectivos preços, na sequência.
# No final, mostre uma listagem de preços, organizando os dados em forma tabular.
'''print('{:-^42}'.format('Lista de compras'))
nomes = ('pao...............................R$ 2.50'), \
('presunto............ |
d7d91bf0f2a61b7b4d37af585dd60aa9bd6ffb70 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 13/main.py | 1,265 | 3.734375 | 4 | '''cont = 0
soma = 0
for contador in range(1, 501):
if contador % 2 == 1 and contador % 3 == 0:
cont += 1
soma = soma + contador
print(f'A somade todos os {cont} números foi: {soma} - ', end='')
print('Fim')'''
'''print('TABUADA')
contador = 0
valor = float(input('Voce uqer a tabuada de qual número... |
6b008409420ccaf183fa205979230f5d4a5a991c | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/funções/desafio 098.py | 879 | 4 | 4 | #Faça um programa que tenha uma função chamada contador(), que receba três parâmetros: início,
# fim e passo. Seu programa tem que realizar três contagens através da função criada:
from time import sleep
def contador(i, f, p):
if p < 0:
p *= -1
if p == 0:
p = 1
print('='*30)
print(f'Con... |
721113f0291864b1945065dc59b6ecba147ed476 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 7/2.py | 445 | 3.84375 | 4 | n1 = int(input('Me diga um valor'))
n2 = int(input('Me diga outro'))
a = n1 + n2
s = n1 - n2
d = n1 / n2
m = n1 * n2
di = n1 // n2
r = n1 % n2
e = n1 ** n2
print( 'a soma de {} e {} \né {} a subutração é {} a divisão é {} a multiplicação é {}'.format(n1, n2, a, s, d, m), end=' ')
print ('a divisão inteira é {} o resto ... |
c52ad49b831869a63f2940cc27e68098bd1d51d8 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/funções/main.py | 662 | 4.0625 | 4 | '''def soma(a, b):
s = a + b
print(s)
#progama principal
soma(5, 5)
soma(6, 2)
soma(7, 3)'''
'''def contador(* num):
tam = len(num)
print(f'Recebi {tam} valores e são eles {num}')
contador(5, 6, 9)
contador(6, 8, 4, 2, 0)
contador(2, 1)'''
#desse jeito ele vai guardar os valores em uma tupla
#da p... |
963adc2a7bd025e375d640dbe415ec440eefdb29 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 12/desafio 036.py | 1,201 | 4.03125 | 4 | #Escreva um programa par aprovar um emprestimo para comprar uma casa.
#O programa vai perguntar o valor da casa, o salario do comprador e em quantos anos ele vai pagar.
#calcule o valor dasprestações,sabendo que ela não pode execer 30% do salario, ou então o emprestimovai ser negado.
casa = float(input('Qual o valor da... |
17aa08a317e99c320417562a583b857fdc26b78b | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 14/desafio 058.py | 1,694 | 4.0625 | 4 | #Melhore o jogo do DESAFIO 28 onde o computador vai “pensar” em um número entre 0 e 10.
# Só que agora o jogador vai tentar adivinhar até acertar,
# mostrando no final quantos palpites foram necessários para vencer.
from random import randint
computador = randint(0,10)
print('\033[35m***'*13)
print('\033[34mOlá sou seu... |
0450351f3e67647c92d4ce38820cb61ec98d3376 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 13/desafio 055.py | 468 | 3.875 | 4 | #Faça um programa que leia o peso de cinco pessoas. No final, mostre qual foi o maior e o menor peso lidos.
maior = 0
menor = 0
for c in range(1,6):
peso = float(input('Peso da pessoa n° {} :'.format(c)))
if c == 1:
maior = peso
menor = peso
else:
if peso > maior:
maior =... |
baf5351dc7f66539d19f62e1fa9069fa5faca834 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 9/desafio 022.py | 966 | 4.28125 | 4 | #crie um programa que leia o nome completo de uma pessoa e mostre na tela:
#o nome com todas as letras maiusculas
#o nome com todas as letras minusculas
#quantas letras tem ao todo sem comsiderar os espaços
#quantas letras tem o primeiro nome
nome = str(input('Digite seu nome completo:')).strip()
print('Seu nome em mai... |
c5a31966f85d8c2dae8a33befcdfbfe2eaece1ec | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 14/main.py | 87 | 3.84375 | 4 | n = int(input('DIGITE UM NUMERO'))
n2 = int(input('Digite outro'))
r = n + n2
print(r)
|
beb1c1a8624e6f434571c831c831b82f247921b6 | MarcelaSamili/Desafios-do-curso-de-Python | /Python/PycharmProjects/aula 12/desafio 041.py | 905 | 4.28125 | 4 | #A Confederação Nacional de Natação precisa de um programa que leia o ano de nascimento de um atleta
#E mostre sua categoria, de acordo com a idade:
'''Até 9 anos: MIRIM ;Até 14 anos: INFANTIL; Até 19 anos: JÚNIOR; Até 25 anos: SÊNIOR; Acima de 25 anos: MASTER'''
from datetime import date
ano = int(input('Qual ano voce... |
e88b158ac68c381b0b1214d6d5a5fe7bb0485ede | nishikantdhuri/DSA | /queue_link_list.py | 1,109 | 3.921875 | 4 | class Node:
def __init__(self,val):
self.next = None
self.data = val
class LinkList:
def __init__(self):
self.head = None
self.node = None
def Display(self):
tmp = self.head
while self.head != None:
print(self.head.data)
... |
7c5367bf84daec3735a5139fd91aa7d6940a68d8 | HarderThenHarder/SimCity | /PencilForSimCity.py | 3,456 | 3.515625 | 4 | from Pencil import Pencil
import math
import pygame
class PencilForSimCity:
@staticmethod
def draw_area(screen, building_color, building_pos, building_name, width=0, name_size=20, name_color=(0, 0, 0)):
Pencil.draw_rect(screen, building_pos, building_color, width=width)
name_length = len(buil... |
c189f18447e2b1cd0f39432d995dd1de407ec683 | thebrianvargas/AMS209 | /HW5/lengthConvert.py | 2,153 | 3.9375 | 4 | """
Brian Vargas (bvargas6@ucsc.edu)
AMS209 Foundations of Scientific Computing
Homework #5 - Problem #2
lengthConvert.py
"""
def lengthConvert(measurement,unit):
"""
Converts a length in a given unit system into other systems
Inputs:
* measurement numerical measurement to be converted
* unit... |
20e9b8f959c2a16d8550b582f11e9d4a9a130431 | igoreshik001/pset6 | /crack.py | 765 | 3.53125 | 4 | import sys
import crypt
if len(sys.argv) != 2:
print ("python crack.py hashValue")
sys.exit()
hash=sys.argv[1]
psw=""
alph=['']
flag=True
for i in range(26):
alph.append(chr(i+ord('A')))
for i in range(26):
alph.append(chr(i+ord('a')))
for i1 in range(53):
if not flag:
break
... |
9ea1b3d72e3ea116a849c352f23f7c42420f23de | hahahayatoo/exercism | /python/simple-cipher/cipher.py | 1,003 | 3.5625 | 4 | # -*- coding: utf-8 -*-
import math
import re
class Caesar(object):
def __init__(self):
self.salt = "d"
def prepare(self, text):
r = re.compile("[a-z]")
return r.findall(text.lower())
def key_gen(self, plain):
salt = self.salt
plain_len = len(plain)
salt_le... |
5c2c7eadd693d7e557e5baa63176c24bfdee59bf | hahahayatoo/exercism | /python/prime-factors/prime_factors.py | 799 | 3.828125 | 4 | # -*- coding: utf-8 -*-
import math
def prime_factors(given_number):
table = sieve(given_number)
return prime_search(given_number, table)
def sieve(given_number):
limit = int(math.sqrt(given_number))
ans = [2, 3]
if limit < 5:
return ans
search_list = [x for x in range(5, limit + 1) if... |
6584106b4f394a022d58fc4568e58ecc760b49d2 | bikash-das/pythonprograms | /tkinter/ch-3/messageBoxes.py | 1,014 | 3.546875 | 4 | import tkinter as tk
from tkinter import ttk
from tkinter import scrolledtext
from tkinter import Menu
from tkinter import messagebox as msg
win = tk.Tk()
win.title('demo messagebox')
def _msgBox():
# msg.showinfo('title', 'description')
# msg.showinfo('Inserted', 'New Record Inserted Successfully')
# msg... |
35a923c33a657d4532d7e2ef2e7386d992caeb4d | bikash-das/pythonprograms | /openCV/loadImage.py | 376 | 3.84375 | 4 | import cv2
print("OpenCV version:")
print(cv2.__version__)
img = cv2.imread("testimage.jpg") #reading image
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #converting to gray scale
cv2.imshow("Over the clouds", img) #showing image
cv2.imshow("Over the clouds - gray", gray)
cv2.imwrite('output.jpg', gray) #writing a ne... |
cdaf89b335282a91211d510d537bb184c96bf2f6 | bikash-das/pythonprograms | /checkNum.py | 202 | 4.09375 | 4 | import re
def checkPhoneNumber(n):
x = re.findall("\d{3}-\d{3}-\d{4}", n)
if(len(x) != 0):
print("Valid")
else:
print("Invalid")
n = input("Enter a number (xxx-xxx-xxxx): ")
checkPhoneNumber(n)
|
c0c7507d3d351d1cdd4dff4624acef7f54b4b52f | bikash-das/pythonprograms | /practice/check_list.py | 1,293 | 4.21875 | 4 | def is_part_of_series(lst):
'''
:param: lst - input is the set of integers (list)
:output: returns true if the list is a part of the series defined by the following.
f(0) = 0 f(1) = 1 f(n) = 2*f(n-1) - 2*f(n-2) for all n > 1.
'''
assert(len(lst) > 0)
if(lst[0] != 0):... |
42cc20d8e977fd01acec24007509d1ab54d7a8f2 | bikash-das/pythonprograms | /tkinter/ch-2/tabbedWidgets.py | 1,843 | 3.578125 | 4 | import tkinter as tk
from tkinter import ttk
from tkinter import Spinbox
from tkinter import scrolledtext
win = tk.Tk()
win.title("Tabbed Widgets")
tabControl = ttk.Notebook(win) # creates tabl
tab1 = ttk.Frame(tabControl)
tabControl.add(tab1, text = "Tab 1")
tab2 = ttk.Frame(tabControl)
tabControl.add(tab2, text = "... |
77cd1c50f8387075f3685b03c8f53ccd781bfae3 | bikash-das/pythonprograms | /openCV/loadAndDisplayDimension.py | 401 | 3.578125 | 4 | #load image and display it's dimension
import cv2
image = cv2.imread("openCV/output.jpg")
print(image.shape) #displays dimension
cv2.imshow("Image", image)
(b,g,r) = image[10,20]
print(b,g,r)
corner = image[0:100, 0:100] #slicing an area from image 100 X 100
cv2.imshow("corner: ", corner)
image[0:100, 0:100] = (128,0,... |
e88ebc2c6874684891d9cb6424f8a52c94eab052 | bikash-das/pythonprograms | /tkinter/ch-1/exercise.py | 773 | 4 | 4 | from tkinter import *
def convert():
kg = 3.34
grams = kg * 1000
pounds = kg * 2.20462
ounces = kg * 35.274
output = str(round(grams,2)) + " g " + str(round(pounds,2)) + " p " + str(round(ounces,2)) + " o"
label2 = Label(window, text = output)
label2.grid(row=1, column = 1)
window = Tk() #... |
3ad3950e0d0b1cef1791b7563714f3ffec93d4ac | bikash-das/pythonprograms | /tkinter/ch-1/clickEvent2.py | 761 | 4.3125 | 4 | import tkinter as tk
from tkinter import ttk
# create an instance of window (tk)
win = tk.Tk() # creates an empty window
# action for button click
def click():
btn.configure(text = "Hello " + name.get()) # get() to retrive the name from the text field
# create a Label
ttk.Label(win, text = "Enter a name: ").... |
5e9c092473f6f2e780979df5f11b74d30db9d346 | bikash-das/pythonprograms | /ds/linkedlist.py | 1,233 | 4.15625 | 4 | class node:
def __init__(self,data):
self.value = data
self.next=None;
class LinkedList:
def __init__(self):
self.start = None;
def insert_last(self,value):
newNode = node(value)
if(self.start == None):
self.start = newNode;
else:
... |
22822d1ab0841c8a907dc5562ec3e0211e1750c6 | bikash-das/pythonprograms | /practice/sockMerchant_hr.py | 533 | 3.65625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the sockMerchant function below.
def sockMerchant(n, ar):
d = dict()
for val in ar:
if val not in d:
d[val] = 1
else:
d[val] = d[val]+1
count = 0
for val in d.items(): #val is t... |
3ffbb426d64e35a96746eeadf36913eb96d7b2d3 | FDWraith/leetCodePractice | /leetCode/medium/3sum/code.py | 6,416 | 3.78125 | 4 | """
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
The solution set must not contain duplicate triplets.
Example:
Given array nums = [-1, 0, 1, 2, -1, -4],
A solution set is:
[
[-1, 0, 1],
[... |
5caaddd1fae1933ef7ae4563be98d1327e82be6f | ToxicMushroom/bvp-python | /oefenzitting 3/exercise1.py | 345 | 4.09375 | 4 | n = int(input("Enter the number of terms: "))
forCounter = 0
for i in range(1, n+1):
forCounter += i
print("The sum of the first 10 natural numbers is", forCounter)
whileCounter = 0
whileItter = 0
while whileItter <= n:
whileCounter += whileItter
whileItter += 1
print("The sum of the first 10 natural nu... |
b1578b627b3cd2f2f6675c4cab839c7665211440 | ToxicMushroom/bvp-python | /oefensessie 1/oefening4.py | 366 | 4.28125 | 4 | # first vector
x1 = float(input("Enter x-coordinate of the first vector: "))
y1 = float(input("Enter y-coordinate of the first vector: "))
# second vector
x2 = float(input("Enter x-coordinate of the second vector: "))
y2 = float(input("Enter y-coordinate of the second vector: "))
inwendig_product = x1 * x2 + y1 * y2
... |
8496f9b9b7d38f0690e62e4a327ecd4c20cc1069 | ToxicMushroom/bvp-python | /oefenzitting 2/oefening5.py | 202 | 3.8125 | 4 | a = int(input("First number? "))
b = int(input("Second number? "))
c = int(input("Third number? "))
ls = [a, b, c]
list.sort(ls)
print(f"The inputs in sorted order are: {ls[0]}, {ls[1]} and {ls[2]}")
|
398b2c5fc86987fa9332c3b2d4ac23a8d1ff7a1d | ToxicMushroom/bvp-python | /oefenzitting 3/exercise3.py | 264 | 4.15625 | 4 | number = int(input("Enter a number: "))
total = 0
flipper = True
while number != 0:
if flipper:
total += number
flipper = False
else:
total -= number
flipper = True
number = int(input("Enter a number: "))
print(total)
|
03cdcc617ccc37c01acd4814c3ef066ea6041eb0 | ToxicMushroom/bvp-python | /oefenzitting 2/oefening7.py | 316 | 4 | 4 | first = float(input("Enter a floating-point number: "))
second = float(input("Enter a floating-point number: "))
diff = 0.0
if first > second:
diff = first - second
else:
diff = second - first
if diff >= 0.01:
print("They are different.")
else:
print("They are the same up to two decimal places.")
|
612039c651d89dcb2a3cc291ea78f2eb7e114dff | devanshshukla99/Chromos | /Chromos/_Chromos.py | 9,355 | 3.75 | 4 | #!/usr/bin/python3
from sys import stdout
__all__ = ["Chromos"]
"""Package for getting colored text output in Python terminal
"""
class Chromos():
"""Chromos provides colored-text terminal output.
Colors:
Black -- black
Red -- red
Green -- green
Yellow ... |
89062387a2773c1692bd80da6cd612f52cdc09f0 | LouiseVuitton/100-Heroes-Villains | /venv/Lib/site-packages/sqlite4dummy/row.py | 10,636 | 4.3125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
.. _row-en:
English Doc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
By default the cursor returns record tuple. Row object is a package of record
data, which provides two more way of visiting values by it's column name:
1. ``Row.c... |
ff983f0996b4abffdfa420f9449f95aa47097011 | xXPinguLordXx/py4e | /exer11.py | 234 | 4.125 | 4 | def count (word, char):
char_count = 0
for c in word:
if c == char:
char_count += 1
return char_count # occurences
inp_word = input ("Enter word: ")
inp_char = input ("Enter char: ")
print (count)
|
2b2260baa8a63839a1d3feeabfc645cf52ef7761 | xXPinguLordXx/py4e | /exer8.py | 768 | 4.28125 | 4 | #declare this shit outside the loop because if you put it inside it will just get looped forever
#declare this outside so that it is accessible by the entire program outside and not just within the loop
sum = 0
count = 0
while True:
number = input ("Enter a number: ")
if number == 'done':
break
tr... |
b2dbc0198ea3ffa88efc3c95d2a50a696384add8 | xXPinguLordXx/py4e | /exer13.py | 340 | 3.515625 | 4 | filename = input("Enter filename: ")
sum = 0
count = 0
try:
fhandle = open(filename)
except:
print("File not found")
exit()
for line in fhandle:
if line.startswith("X-DSPAM-Confidence:"):
dspam = float(line[line.find(':')+1:])
count += 1
sum += dspam
print("Average spam confid... |
e3d5c813c35e2ba8683d5404fa936e862a7e35f3 | mileuc/breakout | /paddle.py | 725 | 4.1875 | 4 | # step 2: create paddle class
from turtle import Turtle
class Paddle(Turtle): # paddle class is now effectively the same as a Turtle class
def __init__(self, paddle_position):
super().__init__() # enable Turtle methods to be used in Ball class
self.shape("square")
self.color("white")
... |
b5b34dd6187ea0358c49522a15939bfa5a2367a7 | karuneshgupta/python-prog | /patterns.py | 1,569 | 4.1875 | 4 | #squares
for row in range (1,5):
for column in range (1,5):
print("*",end=" ")
print()
#triangle pyramid
for row in range (1,5):
for column in range(1,row+1):
print("*",end=" ")
print()
# reverse triangle pyramid
for row in range(1,5):
for column in range(row,5):
print("*",en... |
36e5ea1cf8cad032002ade255a2aed3ec6a8f05d | karuneshgupta/python-prog | /argssss.py | 237 | 3.640625 | 4 | def studentinfo(*args,**kwargs,):
print(args)
print(kwargs)
courses=["maths","arts"]
marks={"maths":"30","arts":"40"}
studentinfo(*courses,**marks)
# one * is used for list and ** are used for dictionary args and kwargs concept
|
d28416ab8188cbd45b74d43f7ad162749e51c189 | karuneshgupta/python-prog | /increment.py | 627 | 3.96875 | 4 | ''''for i in range(5,0,-2):
print(i)
a=int(input("enter a number"))
if (a%2!=0):
print("the no. is odd")
else:
print("no. is even")
n=int(input("enter the year"))
if (n%4==0):
print("year is leap")'''
c = int(input("enter marks"))
if (100>c>90):
print("a1")
elif(c<0):
print("not possible")
e... |
f3a4029a782a8129318f0fbefc57eeb038730d10 | wyattsmcall1/funcobspy | /functionobservers/optimizers/linalg_o.py | 1,258 | 3.609375 | 4 | """
"""
import numpy as np
def solve_chol(L, B):
"""
Solve linear system given a Cholesky factorization.
X = L\(L'\B);
We solve X = A\B: here, A must be a positive-definite
N x N matrix, and B must be a 2D array that is N x M.
The user must pass in L such that X = np.dot(L, L.T).
:param ... |
7e2fbff3f44ec1707cf435db0506e963101e9fd2 | framboises/mac_gyver_game | /main.py | 6,504 | 3.6875 | 4 | #!/usr/bin/env python3
#-*- coding: utf-8 -*-
import os
from tkinter import *
import class_tool as tool
import class_character as char
from import_maze import maze
""" The core of the game. This file create a graphic canvas with Tkinter.
and define conditions to win or lose the game.
"""
#Condition to continue the ga... |
e8e1e72c351c7a12885e4c82ba27b127169bb15b | Shubhrmcf07/guvi_tech | /anagram.py | 267 | 3.53125 | 4 | s=input()
strlist=list(s)
analis=list("dhoni")
count=0
if(len(strlist)!=5):
count=10
else:
for i in range(5):
for j in range(5):
if(strlist[i]==analis[j]):
count=count+1
if(count==5):
print("yes")
else:
print("no")
|
61ad337b4f1cee62148907d74bb6f9debb2a0260 | issacamara/Data_Science | /Coursera/4_Applied_Text_Mining_in_Python/Assignment+1.py | 5,797 | 4.09375 | 4 |
# coding: utf-8
# ---
#
# _You are currently looking at **version 1.1** of this notebook. To download notebooks and datafiles, as well as get help on Jupyter notebooks in the Coursera platform, visit the [Jupyter Notebook FAQ](https://www.coursera.org/learn/python-text-mining/resources/d9pwm) course resource._
#
# ... |
621c95b35fe0596b675ba8473551897cea111c6e | Dimama/NutritionBot | /calculator.py | 1,560 | 3.609375 | 4 | class Calculator(object):
""" Класс для математических расчетов основного обмена"""
def __init__(self, sex, age, height, weight):
self.sex = sex
self.age = age
self.height = height
self.weight = weight
@staticmethod
def calc_product_energy(mass, protein100, fat100, carbs... |
6ff3d2c4c52c4ed4c0543b81eb97a4e59e6babeb | vishalkmr/Algorithm-And-Data-Structure | /Searching/Binary Search(Ascending Order).py | 1,134 | 4.15625 | 4 | '''
Binary Search on Ascending order Lists
Assume that list is in Ascending order
Note : Binary search is aplicable only when list is sorted
'''
def binary_search(list,item):
'''
funtion for binary search of element in list
synatx: binary_search( list,item)
retrun index of element where the item is... |
edd37b42b381dfc85b5f443b79e151f7225b9201 | vishalkmr/Algorithm-And-Data-Structure | /Arrays & Strings/Array Pair Sum.py | 2,761 | 4.40625 | 4 | '''
Given an integer array, output all the unique pairs that sum up to a specific value k.
Example
pair_sum([1,2,3,4,5,6,7],7)
Returns: (3, 4), (2, 5), (1, 6)
'''
#using Sorting
def pair_sum(list,k):
'''
Funtion return all the unique pairs of list elements that sum up to k
Syntax: insert(list,k)
Time Complexity... |
aba4633ded621a38d9a0dd4a6373a4b70ee335d9 | vishalkmr/Algorithm-And-Data-Structure | /Linked Lists/Rotate Right.py | 1,755 | 4.40625 | 4 | '''
Rotates the linked-list by k in right side
Example:
link-list : 1,2,3,4,5,6
after 2 rotation to right it becomes 5,6,1,2,3,4
'''
from LinkedList import LinkedList
def rotate_right(linked_list,k):
"""
Rotates the linked-list by k in right side
Syntax: rotate_right(linked_list,k)
Time Complex... |
bac0d9c2b34bf891722e468c11ff0f615faef1fc | vishalkmr/Algorithm-And-Data-Structure | /Arrays & Strings/Missing element.py | 1,576 | 4.28125 | 4 | '''
Consider an array of non-negative integers. A second array is formed by shuffling the elements of the first array
and deleting a random element. Given these two arrays, find which element is missing in the second array.
Example :
The first array is shuffled and the number 5 is removed to construct the second ... |
23ad168cebd9f937871f8ef52f0822387308dbc5 | vishalkmr/Algorithm-And-Data-Structure | /Trees/Mirror Image.py | 1,639 | 4.34375 | 4 | '''
Find the Mirror Image of a given Binary tree
Exapmle :
1
/ \
2 3
/ \ / \
4 5 6 7
Mirror Image :
1
/ \
3 2
/ \ / \
7 6 5 4
'''
from TreeNod... |
8f8ba9c1a6e13d1527f0c3ac5c2a72dc330a0321 | vishalkmr/Algorithm-And-Data-Structure | /Sorting/Bubble Sort.py | 2,203 | 4.5625 | 5 | '''
SORT the given array using Bubble Sort
Example: Let us take the array of numbers "5 1 4 2 8", and sort the array in ascending order using bubble sort.
First Pass
( 5 1 4 2 8 ) -> ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 > 1.
( 1 5 4 2 8 ) -> ( 1 4 5 2 8 ), Swap sin... |
30a98b2f034a60422a2faafbd044628cd1011e43 | vishalkmr/Algorithm-And-Data-Structure | /Arrays & Strings/Max and Min(Recursion).py | 1,108 | 4.40625 | 4 | '''
Find the maximum and minimum element in the given list using Recursion
Example
max_min([11,-2,3,6,14,8,16,10])
Returns: (-2, 16)
'''
def max_min(list,index,minimum,maximum):
'''
Funtion to return maximum and minimum element in the given list
Syntax: max_min(list,index,minimum,maximum)
Time Complexity: O... |
ff0564ad823133a4f27e14e900c892ff5c8457cb | vishalkmr/Algorithm-And-Data-Structure | /Dynamic Programming/Longest Common Subsequence.py | 1,384 | 3.71875 | 4 | '''
'''
#Conventional Recursive Method
def longet_common_subseqeuence(x,y,n,m):
'''
Funtion return the length of longest subseqeuence between string x and y
Syntax:longet_common_subseqeuence(x,y,n,m)
Time Complexity: O(2^(n+m))
'''
if n<0 or m<0:
return 0
else:
if x[n]==y[m]:
return 1+longet_co... |
4106cc2dccfacb7322a9e00a440321b30d224e30 | vishalkmr/Algorithm-And-Data-Structure | /Searching/Ternary Search.py | 1,860 | 4.46875 | 4 | '''
Ternary Search on lists
Assume that list is already in Ascending order.
The number of Recursive Calls and Recisrion Stack Depth is lesser for Ternary Search as compared to Binary Search
'''
def ternary_search(list,lower,upper,item):
'''
Funtion for binary search of element in list
Synatx: ternary_search... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.