0

How to print a table upto 10 of any number given by user

4th Sep 2018, 6:38 PM
Hrishi Gothe
Hrishi Gothe - avatar
3 ответов
+ 10
# Python 3 def mult_table(n): for i in range(1,11): print(f'{n} x {i} = {n*i}') mult_table(int(input('Enter a number to get its multiplication table: ')))
4th Sep 2018, 10:55 PM
Eduardo Petry
Eduardo Petry - avatar
+ 9
Hrishi Gothe It's a new functionality of Python3. It's called "f-string" (stands for "format string"). To learn more about this way of formatting, check out this wonderful blog post: https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-f-strings/
5th Sep 2018, 5:22 PM
Eduardo Petry
Eduardo Petry - avatar
+ 1
but why you used print(f'{n}..... why f is used here
5th Sep 2018, 4:09 PM
Hrishi Gothe
Hrishi Gothe - avatar