0% found this document useful (0 votes)
2 views12 pages

Experiment 1 Python

The document outlines an experiment by Prarambh Nandusekar focused on implementing control flow statements in Python, including comments, data types, expressions, and input/output functions. It provides source code examples for various data types, arithmetic and logical expressions, and control flow structures like if-else statements, for loops, and while loops. Additionally, it includes examples of using break and continue statements within loops.

Uploaded by

fotamo7435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views12 pages

Experiment 1 Python

The document outlines an experiment by Prarambh Nandusekar focused on implementing control flow statements in Python, including comments, data types, expressions, and input/output functions. It provides source code examples for various data types, arithmetic and logical expressions, and control flow structures like if-else statements, for loops, and while loops. Additionally, it includes examples of using break and continue statements within loops.

Uploaded by

fotamo7435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Experiment 1

Prarambh Nandusekar
SY IT B 43
Aim:Write python programs to implement the Control Flow Statements including Comments,
Data Types, Expressions, Input and Output function.

Source Code:
Comments
# This is a single-line comment in Python

"""
This is a multi-line comment in Python.
It can span multiple lines.
"""

Data Types
# Numeric data types
a = 10 # Integer
b = 10.5 # Float
c = 10 + 5j # Complex number

print("Integer:", a)
print("Float:", b)
print("Complex number:", c)

# Sequence data types


fruits = ["apple", "banana", "cherry"] # List
colors = ("red", "green", "blue") # Tuple

print("List:", fruits)
print("Tuple:", colors)

# Mapping data type


person = {"name": "John", "age": 30} # Dictionary

print("Dictionary:", person)
Expressions
# Arithmetic expressions
a = 10
b=5
print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)

# Comparison expressions
print("Equal:", a == b)
print("Not equal:", a != b)
print("Greater than:", a > b)
print("Less than:", a < b)

# Logical expressions
print("And:", a > b and a == 10)
print("Or:", a > b or a == 5)
print("Not:", not a > b)

# Input function
name = input("Enter your name: ")
print("Hello,", name)

# Output function (print())


print("Hello, world!")

# Output function with multiple arguments


print("Hello,", "world!")

# Output function with separator


print("Hello", "world", sep="-")

# Output function with end


print("Hello", end=" ")
print("world")
Control Flow Statements

If-Else Statement

a = 10
if a > 5:
print("a is greater than 5")
else:
print("a is less than or equal to 5")

For Loop

fruits = ["apple", "banana", "cherry"]


for fruit in fruits:
print(fruit)

While Loop

i=0
while i < 5:
print(i)
i += 1

Break and Continue statements

for i in range(5):
if i == 3:
break
print(i)

for i in range(5):
if i == 3:
continue
print(i)
Output screenshots
Comments

Datatypes
Input Output functions
Iterative functions
Screenshots on next pages
Continuous and Break statements

Expressions

You might also like