Computer Science, asked by saisanchit0, 10 months ago

Create a variable, b, and assign it the value of 15. Then, write code to see if the value b is greater than that of a. If it is, a’s value should be multiplied by 2. If the value of b is less than or equal to a, nothing should happen. Finally, create variable c and assign it the value of the sum of a and b. i want code in python plz

Answers

Answered by Equestriadash
10

a = int(input("Enter a value: "))

b = 15

if b > a:

   a = a*2

c = b + a

print(c)

An if conditional statement checks for the required condition given, and accordingly, proceeds with the required output to be generated.

The syntax of an if statement:

>>> if <test expression>:

            statement

What is does, is once data is entered, it checks and verifies with the test expression. If it results to "True", the required statement given will be generated as the output.

But if it results to  "False", nothing will happen as we haven't mentioned what should be done if it resuts to "False".

It mainly deals with Boolean values.

Boolean values are those that either result to "True" or "False." It is one among the many data types available in Python.

Similar questions