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

A392 Niharika Exp2

The document contains various Python code snippets that demonstrate how to classify triangles, calculate polynomial functions, determine BMI categories, convert distances, and check for palindromes. Each code segment includes user input prompts and corresponding outputs for different scenarios. The examples illustrate basic programming concepts and conditional statements.

Uploaded by

Niharika Mahnot
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)
8 views2 pages

A392 Niharika Exp2

The document contains various Python code snippets that demonstrate how to classify triangles, calculate polynomial functions, determine BMI categories, convert distances, and check for palindromes. Each code segment includes user input prompts and corresponding outputs for different scenarios. The examples illustrate basic programming concepts and conditional statements.

Uploaded by

Niharika Mahnot
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/ 2

2/17/2025 Untitled

In [2]: a,b,c=map(int,input("Enter the sides of the triangle:").split())


if (a==b) and (b==c) and (c==a):
print("Equilateral Triangle")
elif (a==b) or (b==c) or (c==a):
print("Isoceles Triangle")
else:
print("Scalene Triangle")

Equilateral Triangle

In [4]: a,b,c,d=map(int,input("Enter the values a,b,c,d:").split())


x=int(input("Enter the value of x:"))
k=int(input("Enter the value of k:"))
if x > k:
f = a*(x**3) -b*(x**2) + c*x -d
elif x==k:
f=0
elif x < k:
f = -a*(x**3) +b*(x**2) - c*x +d
print(f)

-343

In [9]: w=float(input("Enter the weight in kg:"))


h=float(input("Enter the height in cm:"))
h=h/100
bmi=w/(h**2)
if bmi<=18.4:
print("Underweight")
elif bmi>=18.5 and bmi<24.9 :
print("Normal")
elif bmi>=25.0 and bmi<39.9:
print("Overweight")
elif bmi>=40:
print("Obese")

Underweight

In [19]: choice=str(input("Enter whether distance is in ''in or 'cm'"))


d=float(input("enter distance"))
if(choice=="in"):
d=d/12
print("Distance in feet:",d)
else:
d=d/100
print("Distance in meters:",d)

Distance in feet: 30.0

In [18]: a=str(input("Enter a string"))


print(a)

hello world

In [23]: a=str(input("Enter a string:"))


print(a[1::2])

iaia

file:///C:/Users/Niharika Mahnot/Desktop/jupyter projects/A392_Niharika_Exp2.html 1/2


2/17/2025 Untitled

In [30]: a=str(input("Enter a string:"))


if(a==a[-1::-1]):
print("Palindrome")
else:
print("Not a palindrome")

Palindrome

In [ ]:

file:///C:/Users/Niharika Mahnot/Desktop/jupyter projects/A392_Niharika_Exp2.html 2/2

You might also like