Repository navigation
Expand file tree
/
Copy path038-If-Statement.py
More file actions
46 lines (37 loc) · 1.54 KB
/
Copy path038-If-Statement.py
File metadata and controls
46 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
===============================================================================
If Statement
===============================================================================
Program Description:
--------------------
This program demonstrates the use of the if statement in Python.
The if statement is used to execute a block of code only when a given
condition is True.
Syntax:
if condition:
statements
Author : Shaik Mahaboob Basha
Repository : 13-Python
File Name : 38-If-Statement.py
===============================================================================
"""
# -----------------------------------------------------------------------------
# Accepting a number from the user.
# -----------------------------------------------------------------------------
number = int(input("Enter a Number: "))
# The entered value is converted into an integer.
# -----------------------------------------------------------------------------
# Checking whether the number is greater than zero.
# -----------------------------------------------------------------------------
if number > 0:
# This block executes only if the condition is True.
print("The Number is Positive.")
# Output (Example):
# Enter a Number: 15
# The Number is Positive.
# -----------------------------------------------------------------------------
# Displaying a message after the if statement.
# -----------------------------------------------------------------------------
print("Program Completed.")
# Output:
# Program Completed.