+ 1

I am just get into coding. I want to ask a question about what is % in python. I always get confused with this sign

25th Mar 2020, 12:08 PM
energon liew
energon liew - avatar
2 ответов
+ 4
The "%" symbol is also used in formatting output for print. It is used there as a placeholder, e.g. in conjunction with format specifiers. from datetime import datetime print('{:%Y-%m-%d %H:%M}'.format(datetime(2001, 2, 3, 4, 5))) # output: 2001-02-03 04:05 print('%d %f' % (1, 2)) # output: 1 2.000000
25th Mar 2020, 3:32 PM
Lothar
Lothar - avatar
+ 3
It is modulo operator which devides two numbers and returns it's remainder. For example:- 5%2 = 1 14%7 = 0
25th Mar 2020, 12:10 PM
Arsenic
Arsenic - avatar