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

MJ Assignment

The document contains a series of Python code snippets demonstrating basic programming concepts such as printing, arithmetic operations, conditional statements, and triangle properties. It includes examples of user input, calculations, and checks for properties like Armstrong numbers and triangle types. Each code block is followed by sample input and output to illustrate the functionality.

Uploaded by

snehajana777
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 views5 pages

MJ Assignment

The document contains a series of Python code snippets demonstrating basic programming concepts such as printing, arithmetic operations, conditional statements, and triangle properties. It includes examples of user input, calculations, and checks for properties like Armstrong numbers and triangle types. Each code block is followed by sample input and output to illustrate the functionality.

Uploaded by

snehajana777
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

In [1]: 1 print("Hello World")

Hello World

In [2]: 1 a = 10
2 b = 20
3 Sum = a + b
4 print("Result:",Sum)

Result: 30

In [3]: 1 a = int(input ("Enter a Number:"))


2 b = int(input ("Enter another Number:"))
3 Sum = a + b
4 print("Result:",Sum)

Enter a Number:15
Enter another Number:25
Result: 40

In [4]: 1 a = int(input ("Enter a Number:"))


2 b = int(input ("Enter another Number:"))
3 Sub = a + b
4 print("Result:",Sub)

Enter a Number:35
Enter another Number:25
Result: 60

In [5]: 1 a = int(input ("Enter a Number:"))


2 b = int(input ("Enter another Number:"))
3 Mul = a * b
4 print("Result:",Mul)

Enter a Number:15
Enter another Number:7
Result: 105
In [6]: 1 a = int(input ("Enter a Number:"))
2 b = int(input ("Enter another Number:"))
3 Div = a / b
4 print("Result:",Div)

Enter a Number:25
Enter another Number:5
Result: 5.0

In [7]: 1 a = int(input ("Enter a Number:"))


2 b = int(input ("Enter another Number:"))
3 Power = a // b
4 print("Result:",Power)

Enter a Number:35
Enter another Number:7
Result: 5

In [8]: 1 a = int(input ("Enter First No.:"))


2 b = int(input ("Enter Second No.:"))
3 if(a>b):
4 print("a is big")
5 else:
6 print("b is big")

Enter First No.:9


Enter Second No.:12
b is big
In [12]: 1 a = int(input ("Enter First No.:"))
2 b = int(input ("Enter Second No.:"))
3 c = int(input ("Enter Third No.:"))
4 if(a>b and a>c):
5 print("a is Biggest")
6 elif(b>a and b>c):
7 print("b is Biggest")
8 else:
9 print("c is Biggest")

Enter First No.:35


Enter Second No.:67
Enter Third No.:25
b is Biggest

In [14]: 1 a = int(input ("Enter First No.:"))


2 b = int(input ("Enter Second No.:"))
3 c = int(input ("Enter Third No.:"))
4 if(a+b+c == 180):
5 print("Triangle is Possible.")
6 else:
7 print("Triangle is not Possible")
8 if(a==90 or b==90 or c==90):
9 print("It is an Right Angle Triangle.")
10 if(a>90 or b>90 or c>90):
11 print("It is an Obtuse Angle Triangle.")
12 else:
13 print("It is an Acute Angle Triangle.")

Enter First No.:60


Enter Second No.:60
Enter Third No.:60
Triangle is Possible.
It is an Acute Angle Triangle.
In [20]: 1 a = float(input ("Enter First Side:"))
2 b = float(input ("Enter Second Side:"))
3 c = float(input ("Enter Third Side:"))
4 if((a + b >= c) and (a + c >= b) and (b + c >= a)):
5 print("Triangle is Possible.")
6 else:
7 print("Triangle is Not Possible.")
8 if(a==b==c):
9 print("It is an Equilateral Triangle.")
10 elif(a == b or b == c or a == c):
11 print("It is an Isosceles Triangle.")
12 else:
13 print("It is an Scalene Triangle.")

Enter First Side:7


Enter Second Side:10
Enter Third Side:5
Triangle is Possible.
It is an Scalene Triangle.

In [21]: 1 num = int(input("Enter a No.:"))


2 sum = 0
3 temp = num
4 while temp > 0:
5 digit = temp % 10
6 sum += digit ** 3
7 temp //= 10
8 if num == sum:
9 print(num,"is an Armstrong number")
10 else:
11 print(num,"is not an Armstrong number")

Enter a No.:407
407 is an Armstrong number

In [ ]: 1 ​

You might also like