Tuesday, February 10, 2026

Python

Passing arguments through function using args and kwargs

args take non keyworded arguments, while kwargs take keyworded arguments.

def act1(*args, **kwargs):
print(args)
print(kwargs)


act1(5,10,15,vehicle="Car",job="Doctor",country="India")

Output
(5, 10, 15)
{'vehicle': 'Car', 'job': 'Doctor', 'country': 'India'}


Monday, February 9, 2026

 Python

Built-in functions

msg = "hello world"
print(msg.capitalize())
print(msg.islower())
print(msg.isupper())
IP=("192","168","1","1")
print(".".join(IP))
countries = ["India","Pakistan","UAE","Germany","UK","Australia"]
print(countries)
#append to add item
countries.append("US")
print(countries)
#pop to delete item
countries.pop()
print(countries)
countries.pop(3)
print(countries)

Output
Hello world
True
False
192.168.1.1
['India', 'Pakistan', 'UAE', 'Germany', 'UK', 'Australia']
['India', 'Pakistan', 'UAE', 'Germany', 'UK', 'Australia', 'US']
['India', 'Pakistan', 'UAE', 'Germany', 'UK', 'Australia']
['India', 'Pakistan', 'UAE', 'UK', 'Australia']


 Python

Conditions

IT = ["Tech Support", "Development", "QA"]
Healthcare = ("Doctor", "Nurse", "Attender")

profession = input("Enter your profession:")

if profession in IT:
print(f" {profession} in IT")
elif (profession in Healthcare):
print(f" {profession} in healthcare")
else:
print("Profession not found")

Output
Enter your profession:Doctor
 Doctor in healthcare

Sunday, February 8, 2026

 Python

Dictionary 

Dictionaries are used to store data values in key:value pairs.

#Dictionary
Countries = {"Asia":("India","China", "Pakistan", "Thailand"), "Europe":["Germany","Italy"]}
print(Countries)
print(Countries["Asia"])
print(Countries["Europe"])

Output
{'Asia': ('India', 'China', 'Pakistan', 'Thailand'), 'Europe': ['Germany', 'Italy']}
('India', 'China', 'Pakistan', 'Thailand')
['Germany', 'Italy']

Friday, February 6, 2026

 Python

String indexing        

state = "Kerala is a state located in the southwestern region of India"
print(state[0])
print(state[1])
print(state[2])

print(state[-1])
print(state[-2])

Output
K
e
r
a
i

 Python

Dictionary

Elements in the variable are always in pairs(key: value), curly brackets.

#Dictionary
Dictionary1 = {"Name": "Hafeed", "Age": 36, "Hobbies":["Reading", "Cycling"] }
print(Dictionary1)

Output
{'Name': 'Hafeed', 'Age': 36, 'Hobbies': ['Reading', 'Cycling']}

 Python

Tuple                        

It is a collection data types enclosed in round bracket. 

#Tuple
str1 = "Hello"
num1 = 15
tuple1 = (str1, "India", 10, num1, 3.5)
print(tuple1)  

output
('Hello', 'India', 10, 15, 3.5)          

 Python

List

It is a collection of multi data types enclosed in square brackets.

#List
str1 = "Hello"
num1 = 15
list1 = [str1, "India", 10, num1, 3.5]
print(list1)

output

['Hello', 'India', 10, 15, 3.5]

 Python - Variables

# printing variables
a = 10
b= 20
c = 30
print(a)
print(b)
print(c)            

Output

10
20
30

Python Passing arguments through function using args and kwargs args take non keyworded arguments, while kwargs take keyworded arguments. de...