0% found this document useful (0 votes)
4 views2 pages

Python Lab Manual

The document outlines key features of Python, including its ease of learning and dynamic typing. It provides examples of executing a Python program, using different types of strings, string operations like concatenation and slicing, and checking if a number is even or odd. Each section includes code snippets and sample outputs to illustrate the concepts.

Uploaded by

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

Python Lab Manual

The document outlines key features of Python, including its ease of learning and dynamic typing. It provides examples of executing a Python program, using different types of strings, string operations like concatenation and slicing, and checking if a number is even or odd. Each section includes code snippets and sample outputs to illustrate the concepts.

Uploaded by

Ashwmee B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Features of Python
Code:
# Program to display Python features
print("Python is Easy to Learn, Interpreted, and Dynamically Typed.")
Sample Output:
Python is Easy to Learn, Interpreted, and Dynamically Typed.

2. Execution of a Python Program


Code:
# Save this file as [Link] and run it from the terminal
print("Hello, Python!")
Sample Output:
Hello, Python!

3. Single, Double, and Triple Quoted Strings


Code:
single_quoted = 'Hello'
double_quoted = "World"
triple_quoted = """This is a multi-line
string example."""

print(single_quoted)
print(double_quoted)
print(triple_quoted)
Sample Output:
Hello
World
This is a multi-line
string example.

4. String Concatenation, Repetition, and Slicing


Code:
str1 = "Hello"
str2 = "Python"
concat = str1 + " " + str2
repeat = str1 * 3
slice_str = str2[0:3]

print(concat)
print(repeat)
print(slice_str)
Sample Output:
Hello Python
HelloHelloHello
Pyt

5. Even or Odd Number Check


Code:
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")
Sample Output:
Enter a number: 4
Even

You might also like