How to divide each element in a tuple by a number in Python

2 Answers

0 votes
tpl = (30, 40,50, 60, 7)

number = 2

tpl = tuple(item / number for item in tpl)

print(tpl)  





'''
run:

(15.0, 20.0, 25.0, 30.0, 3.5)

'''

 



answered Jul 18, 2022 by avibootz
0 votes
tpl = (30, 40,50, 60, 7)

number = 2

tpl = tuple(item // number for item in tpl)

print(tpl)  





'''
run:

(15, 20, 25, 30, 3)

'''

 



answered Jul 18, 2022 by avibootz
...