These are some basic problems. You have to take input from the user

Q1.) Write a program to find the largest number out of three numbers excepted from user.

Hint : use if-else

Q2.) Python Program for factorial of a number.

Hint: use loops

These are some basic problems. You have to take input from the user

Q1.) Write a program to find the largest number out of three numbers excepted from user.

Hint : use if-else

Q2.) Python Program for factorial of a number.

Hint: use loops

3 Likes

```
# uncomment following lines to take three numbers from user
#num1 = float(input("Enter first number: "))
#num2 = float(input("Enter second number: "))
#num3 = float(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
print("The largest number is", largest)
Q2.) Python Program for factorial of a number.
Hint: use loops
Ans) # factorial
# num = int(input('Enter number:'))
def fact(num):
print(f'factorial of {num} is:',end=' ')
res=1
for i in range(num,1,-1):
res = res*i
print(f'{i}*',end='')
print(f'1= {res}')
```

1 Like

@sms18680 for second code,

as factorial of num contains `1*2*3*4*....*num-1*num`

Your code is for the table of number not factorial

1 Like

```
# greatest number
# num1,num2,num3 = int(input('Enter three numbers:').split(','))
def greatest(num1,num2,num3):
if num1>=num2 and num1>=num3:
print(f'{num1} is greatest between {num1},{num2},{num3}')
elif num2>=num1 and num2>=num3:
print(f'{num2} is greatest between {num1},{num2},{num3}')
else:
print(f'{num3} is greatest between {num1},{num2},{num3}')
# factorial
# num = int(input('Enter number:'))
def fact(num):
print(f'factorial of {num} is:',end=' ')
res=1
for i in range(num,1,-1):
res = res*i
print(f'{i}*',end='')
print(f'1= {res}')
fact(12)
#fact(num)
greatest(34,67,23)
#greatest(num1,num2,num3)
```

```
factorial of 12 is: 12*11*10*9*8*7*6*5*4*3*2*1= 479001600
67 is greatest between 34,67,23
```

3 Likes

**PROGRAM FOR THE QUESTION NUMBER 1**

num1=int(input(‘enter the number’))

num2=int(input(‘enter the number’))

num3=int(input(‘enter the number’))

if num1>num2 and num1>num3:

largest=num1

elif num2>num1 and num2>num3:

largest=num2

else:

largest=num3

print(‘The Largest number is>>>>’,largest)

OUTPUT:-

Enter the number896

enter the number1025

enter the number63

The Largest number is>>>> 1025

2 Likes

** PROGRAM FOR QUESTION NO 2*****

number=int(input(‘enter the number’))

factorial=1

for i in range(1,number+1):

factorial=factorial*i

print(‘The factorial of the number is>>>>>>’,factorial)

OUTPUT:-

enter the number15

The factorial of the number is>>>>>> 156920924160000

2 Likes

Q-1)**Write a program to find the largest number out of three numbers excepted from user.**

a = int(input('Enter first number : '))

b = int(input('Enter second number : '))

c = int(input('Enter third number : '))

largest = 0

if a > b and a > c :

largest = a

elif b > c :

largest = b

else :

largest = c

print(largest, “is the largest of three numbers.”)

Q-2) **Python Program for factorial of a number.**

num = int(input(“Enter a number: “))

factorial = 1

if num < 0:

print(” Factorial does not exist for negative numbers”)

elif num == 0:

print(“The factorial of 0 is 1”)

else:

for i in range(1,num + 1):

factorial = factorial*i

print(“The factorial of”,num,“is”,factorial)

1 Like