This is my code, it outputs a multiplication table but it's not what I wanted! Show
I am basically creating a multiplication table from the user's input from 1-9. Ex. If the user inputs "3", I should get this output:
Tomerikoo 16.6k15 gold badges37 silver badges54 bronze badges asked Jul 5, 2018 at 9:04
3 The reason why you have an infinite loop on your hands is because you are comparing
answered Jul 5, 2018 at 9:32
0 Even if the code you posted is not pythonic at all (it is very close to what could be written in C language), it nearly works: with minimum modifications, it can be fixed as follows to give your expected ouput:
In a more pythonic way, you can also do the following:
answered Jul 5, 2018 at 9:22
Laurent H.Laurent H. 5,9761 gold badge17 silver badges37 bronze badges For this problem it's easier to use for loops.
To understand this problem, look at the two multiplicands: left and right. Left multiplicand goes from (1-->num), hence the first for loop. Then, for each value of the left multiplicand, the right multiplicand goes from (1-->num), hence the 2nd loop is nested inside the first loop. answered Jul 5, 2018 at 9:30
bda01bda01 211 bronze badge You've lots of logical error. Please have a look at this updated code:
Output (for input 3):
answered Jul 5, 2018 at 9:12
Taohidul IslamTaohidul Islam 5,1003 gold badges23 silver badges38 bronze badges In Python 3.6+, you can use f-strings with a nested
answered Jul 5, 2018 at 9:36
jppjpp 151k31 gold badges256 silver badges317 bronze badges multiplication table using while loop in python
output
funie200 3,4325 gold badges20 silver badges32 bronze badges answered Dec 2, 2020 at 7:54
1
answered Aug 29, 2021 at 1:31
0 Multiplication table 1 to 10
Eric Aya 69.1k34 gold badges176 silver badges245 bronze badges answered Jan 24, 2019 at 16:48
1 input any number to get your normal multiple table(Nomenclature) in 10 iterate times.
answered Apr 10, 2019 at 19:19
answered Jul 4, 2019 at 11:36
SumitSumit 11 bronze badge Creating a multiplication table using
Shmn 6511 gold badge4 silver badges20 bronze badges answered Oct 24, 2020 at 6:28
0 To create a multiplication table in python:
answered Jul 13, 2021 at 15:05
How do you code a multiplication table in Python?Code using a for loop. ourNum = int(input("Enter the number you want to generate a multiplication table for, then hit the `enter` key: ")). ourRange = range(1,6). for x in ourRange:. result = ourNum * x.. print(ourNum," * ",x," = ",result). How do you multiply a number in a while loop?write a c program to print multiplication table of any number using for loop. #include <stdio.h>. int n, i;. printf("Enter a Number ");. scanf("%d",&n);. while(i<=10){. printf("%d * %d = %d \n", n, i, n*i);. How do you print a multiplication table?To print multiplication table we need to iterate from 1 to 10. Run a loop from 1 to 10 , increment 1 on each iteration. The loop structure should look like for(i=1; i<=10; i++) . Inside loop generate multiplication table using num * i and print in specified format.
|