Skip to content

Instantly share code, notes, and snippets.

@salvianoo
Last active December 17, 2015 21:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salvianoo/5675391 to your computer and use it in GitHub Desktop.
Save salvianoo/5675391 to your computer and use it in GitHub Desktop.
# coding=UTF-8
"""
Desenvolva um programa que faça a tabuada de um número qualquer inteiro que será digitado pelo usuário, mas a tabuada não deve necessariamente iniciar em 1 e terminar em 10, o valor inicial e final devem ser informados também pelo usuário, conforme exemplo abaixo:
Montar a tabuada de: 5
Começar por: 4
Terminar em: 7
Vou montar a tabuada de 5 começando em 4 e terminando em 7:
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
"""
number = int(raw_input("Montar a tabuada de :"))
start = int(raw_input("Começar por :"))
end = int(raw_input("Terminar em: "))
def tabudada(inicial, final):
for x in range(inicial, final+1):
yield x, (x * number)
for index, result in tabudada(start, end):
print "%s X %s = %s" % (index, number, result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment