0% found this document useful (0 votes)
11 views

Python Pr02

The document is an assignment by Dhanashri Hemant Bahalkar that includes a Python program demonstrating string operations, conditional statements, and functions. It provides examples of if-else statements to determine if numbers are positive, negative, or even, and includes functions to find the greater number and calculate the sum. The output of the program is also displayed, showing results for various inputs.

Uploaded by

wafflerick69
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)
11 views

Python Pr02

The document is an assignment by Dhanashri Hemant Bahalkar that includes a Python program demonstrating string operations, conditional statements, and functions. It provides examples of if-else statements to determine if numbers are positive, negative, or even, and includes functions to find the greater number and calculate the sum. The output of the program is also displayed, showing results for various inputs.

Uploaded by

wafflerick69
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/ 3

ASSIGNMENT : 2

Name : Dhanashri Hemant Bahalkar


Roll Number : 01
Batch : S1
Date of Performance :

Title : Write a python program to understand string operations & string


methods, List, tuples and Arrays.
Input :

# if else conditional statements


num= 6
if num>0:
if num%2==0:
print("The num is positive and even")
else:
print("The num is positive and odd")
else:
print("The num is not positive")

# elif statemnets
num= -5
if num>0:
print("Positive number")
elif num<0:
print("Negative number")
else:
print("Zero")
# To find the greater no using if else
num1 =int(input("Enter the first num: "))
num2 =int(input("Enter the second num: "))
num3 =int(input("Enter the third num: "))

if num1>num2 and num1>num3:


print("Num 1 is greater:",num1)
elif num2>num1 and num2>num3:
print("Num 2 is greater:",num2)
else :
print("Num3 is greater:",num3)

# To find the greater no


num1 =int(input("\nEnter the first num: "))
num2 =int(input("Enter the second num: "))
num3 =int(input("Enter the third num: "))
print("The greater no is :",max (num1,num2,num3))

#function With 2 arguments


def add_number(num1,num2):
sum= num1+num2
print("The sum is",sum)

#Function call
add_number(67,90)
# Program to find prime number
num =int(input("\nEnter a number : "))
for i in range(2,num):
if num%i==0:
print("The num is Even")
break
else:
print("The num is Prime")
break
Output :

PS C:\Users\Admin\Desktop\phyton SY> &


C:/Users/Admin/AppData/Local/Programs/Python/Python312/python.exe
"c:/Users/Admin/Desktop/phyton SY/program2.py"
The num is positive and even
Negative number

Enter the first num: 225


Enter the second num: 144
Enter the third num: 121
Num 1 is greater: 225

Enter the first num: 25


Enter the second num: 37
Enter the third num: 67
The greater no is : 67
The sum is 157

Enter a number : 23
The num is Prime.

You might also like