2
I created two 'if and Else' structures to make the program write to the user using the plural correctly and as you can see below, I created two variables within the structures to assign the plural that the program decides. Is there any way to assign values to two variables within a single structure? Do something like:
if m > 1: b = metros, c = centimetros?
As I don’t know what value the user will provide, I decided to declare the variable as float
, but as float
are the real numbers, if the user type an integer number, the result will be . 0 at the end. For that not to happen, I would need to create another structure if
and else
?
I am using Python 3.7 and IDE Pycharm.
Make a Program that converts meters to centimeters.
m = float(input('Insira a medida em metros: '))
b = 'd'
if m > 1:
b = 'metros'
else:
b = 'metro'
if m > 1:
d = 'equivalem'
else:
d = 'equivale'
c = m * 100
print(f'{m} {b} {d} a {c} centimetros')
See https://answall.com/q/101691/101
– Maniero
Related: Numbers and plural
– Woss
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the site.
– Maniero