Python Tutorial - Get Multiplication Table on console using PYTHON

Publicado em: 27 Setembro 2017
no canal de: Appanna Damu
79
5

#Hi everyone,in this video am going to explain how to do simple multiplication table in python
#lets begin
#lets consider that below is the our requirement
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
like this we need to print on console
here 2 is constant it means not repeating
and repeated values are from 1 to 5
lets start the code,
here i want to take the values from key board
for that i will use input() method to read data from keyboard
#to get repeated values in result i will use for loop
here i used range function in for loop
it means that from 1 to 10(excluding 11) assigning to variable i,
so for every iteration variable 'i' will have from 1 to 10
use print statement
in print function we can give format of our requirement , means how you want to see out put on console
lets run the code,
ohh NO, the output what we see is not correct , our requirement is differ what discussed earlier like this
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8

if you want to solve this issue , we have to look at input method,
in python or other programming languages , when you read data from keyboard ,by default it will consider as string data , but in our case we need interger data
so now we can change the code
this is called explicit conversion
now run the code,
wow , we got result what we expected on console
Thank you for watching this video


CODE:

num= int (input('enter number'))
for i in range(1,11):
print (num,'x',i,'=',num*i)


Nesta página do site você pode assistir ao vídeo on-line Python Tutorial - Get Multiplication Table on console using PYTHON duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Appanna Damu 27 Setembro 2017, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 79 vezes e gostou 5 espectadores. Boa visualização!