Saturday, February 24, 2018

Artificial Intelligence Python

Tags

2.
Write a program to find the sum of all numbers stored in a list.
Code:
 
list=map(int,input("Enter List : ").strip().split());
s=0;
for j in list:
    s=s+j;
print("Sum is : ",s);

Output: 
 


 3.
Write a program to find factorial
of a number.
Code:
fact=1;
n=int(input("Enter Number : "));
for j in range(2,n+1):
    fact=fact*j;
print("Factorial is : ",fact);
 
Output:
 
 
 4.
Write a program to display formatted text calendar and entire calendar for a year
 
Code :
import calendar;
year=int(input("Enter Year"));
for month in range(1,13):
    print(calendar.month(year,month));
 
Output:
 
 
7.
Code:
celsius=int(input("Enter Temperatue in Celsius "))
f=celsius*1.8+32;
print('Temperatue in Farenheit is : ',f);
 
Output: