0% found this document useful (0 votes)
5 views5 pages

Python_Starred_Practicals_Concise

The document outlines various practical exercises in Python programming, covering topics such as displaying messages, operators, conditional statements, looping, data structures (lists, tuples, sets, dictionaries), functions, modules, classes, and basic usage of libraries like Pandas and Tkinter. Each practical includes code snippets demonstrating the concepts. The exercises are designed to help learners understand fundamental programming principles in Python.

Uploaded by

Jay U. Mahankar
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)
5 views5 pages

Python_Starred_Practicals_Concise

The document outlines various practical exercises in Python programming, covering topics such as displaying messages, operators, conditional statements, looping, data structures (lists, tuples, sets, dictionaries), functions, modules, classes, and basic usage of libraries like Pandas and Tkinter. Each practical includes code snippets demonstrating the concepts. The exercises are designed to help learners understand fundamental programming principles in Python.

Uploaded by

Jay U. Mahankar
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
You are on page 1/ 5

Practical 1: Display Message and Read Data

print("Welcome to Python Programming!")

data = input("Enter something: ")

print("You entered:", data)

Practical 2: Operators in Python

a, b = 10, 3

print("Arithmetic:", a + b)

print("Relational:", a > b)

print("Logical:", a > 5 and b < 5)

print("Bitwise:", a & b)

print("Identity:", a is b)

Practical 3: Conditional Statements

x = int(input("Enter number: "))

if x > 0:

print("Positive")

elif x < 0:

print("Negative")

else:

print("Zero")

Practical 4: Looping Statements

for i in range(5):

print(i)

i = 0

while i < 5:

print(i)

i += 1

Practical 5: Loop Control Statements

for i in range(5):

if i == 3:

continue
print(i)

if i == 4:

break

Practical 6: List Operations

lst = [1, 2, 3]

lst.append(4)

print(lst)

lst.remove(2)

print(lst)

Practical 7: Tuple Operations

tpl = (1, 2, 3)

print(tpl)

print(tpl[1])

Practical 8: Set Operations

s = {1, 2, 3}

s.add(4)

s.remove(2)

print(s)

Practical 9: Dictionary Operations

d = {'a': 1, 'b': 2}

d['c'] = 3

d.pop('a')

print(d)

Practical 10: Function with Arguments

def add(a, b=0):

return a + b

print(add(2, 3))

print(add(4))

Practical 11: Lambda, Map, Reduce


from functools import reduce

nums = [1, 2, 3, 4]

square = list(map(lambda x: x**2, nums))

print(square)

sum_all = reduce(lambda x, y: x + y, nums)

print(sum_all)

Practical 12: User Defined Module

# module.py

def square(x):

return x * x

# main.py

import module

print(module.square(5))

Practical 13: Use of Modules

import math

import random

print(math.sqrt(16))

print(random.randint(1, 10))

Practical 14: User Defined Package

# package/module.py

def greet():

return "Hi"

# main.py

from package import module

print(module.greet())

Practical 15: Class and Objects

class Demo:

def show(self):

print("Hello")

d = Demo()
d.show()

Practical 16: Constructors

class Test:

def __init__(self, x=0):

self.x = x

def display(self):

print(self.x)

t1 = Test()

t2 = Test(10)

t1.display()

t2.display()

Practical 17: Method Overloading/Overriding

class A:

def show(self): print("A")

class B(A):

def show(self): print("B")

b = B()

b.show()

Practical 18: Inheritance

class A:

def msg(self): print("A")

class B(A): pass

b = B()

b.msg()

Practical 19: Pandas Basics

import pandas as pd

s = pd.Series([1,2,3])

print(s)

df = pd.DataFrame({'A':[1,2], 'B':[3,4]})

print(df)
Practical 20: Tkinter Basics

import tkinter as tk

win = tk.Tk()

win.title("My App")

win.mainloop()

You might also like