0% found this document useful (0 votes)
5 views8 pages

ARTIFICIAL INTELLIGENCE ASSIGNMENENT

The document contains a series of programming assignments focused on basic Python tasks. These tasks include calculating simple interest, character classification, finding the maximum of three numbers, calculating electricity charges based on consumption, summing natural numbers, generating multiplication tables, and working with lists to compute sums of even and odd elements. Each assignment is presented with a code snippet to demonstrate the solution.

Uploaded by

LEGEND GAMING
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)
5 views8 pages

ARTIFICIAL INTELLIGENCE ASSIGNMENENT

The document contains a series of programming assignments focused on basic Python tasks. These tasks include calculating simple interest, character classification, finding the maximum of three numbers, calculating electricity charges based on consumption, summing natural numbers, generating multiplication tables, and working with lists to compute sums of even and odd elements. Each assignment is presented with a code snippet to demonstrate the solution.

Uploaded by

LEGEND GAMING
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/ 8

ARTIFICIAL INTELLIGENCE

ASSIGNMENENT
Q1. Write a program to compute simple interest.
p=int(input("Enter the principal amount"))
r=int(input("Enter the rate of interest"))
t=int(input("Enter the time"))
si=p*r*t/100
print("The si is :",si)

Q2.Write a program to check whether the given character is an


uppercase letter or lowercase letter or a digit or a special
character
char = input("Enter a character: ")
if char.isupper():
print("The character is an uppercase letter.")
elif char.islower():
print("The character is a lowercase letter.")
elif char.isdigit():
print("The character is a digit.")
else:
print("The character is a special character.")
Q3.Write a program to find the maximum number out of the
given three numbers.
a=int(input("Enter a first number"))
b=int(input("Enter a second number"))
c=int(input("Enter a third number"))
if(a>b and a>c):
print(a, " is the maximum")
elif(b>a and b>c):
print(b, " is the maximum")
elif(c>a and c>b):
print(c, " is the maximum")
else:
print("Invalid input")
Q4. An electric power distribution company charges its domestic
consumers as follows:
Consumption Units:
0-100
Rate of charge:
Rs 1 per unit
Consumption units:
101-300
Rate of charge:
Rs 100 plus Rs 1.25 per unit on excess of 100
Consumption Units:
301-500
Rate of charge:
Rs 350 plus rs 1.50 per unit in excess of 300
Consumption Units:
500 and above
Rate of charge:
Rs 650 plus Rs1.75 per unit in excess of 500

u=int(input("The unit is :"))


if(u>0 and u<100):
amt=u*1
print("The amount is: ",amt)
elif(u>101 and u<300):
amt=100+(1.25*(u-100))
print("The amount is: ",amt)
elif(u>301 and u<500):
amt=350+(1.50*(u-300))
print("The amount is: ",amt)
elif(u>=500):
amt=650+(1.75*(u-500))
print("The amount is: ",amt)
else:
print("No amount to be paid")
Q5.Write a program to display summation of first N natural
numbers.
a=int(input("The number of natural numbers "))
n=1
sum=0
while(n<=a):
sum=sum+n
n=n+1
print("The sum is :",sum)

Q6. Write a program to print a multiplication table of any


positive integer N.
a=int(input("The number of natural numbers "))
n=1
m=0
while(n<=10):
m=a*n
n=n+1
print(m)
Q7.Write a program to create a list of students’ marks with user-
defined values and find the total and maximum of the marks.
sum=0
largest=0
for a in range(0,5):
x=int(input("Enter marks :"))
if a==0:
largest =x
if x>largest:
largest=x
sum=sum+x
print ("total marks ",sum ,"highest marks is :",largest)
Q8. Write a program to create a list of numbers and find the sum
of the even elements and the sum of the odd elements present
in it.
n=int(input("How many numbers you want to enter :"))
sum1=0
sum2=0
while(n>0):
x=int(input("Enter a number :"))
if(x%2==0):
sum1=sum1+x
else:
sum2=sum2+x
n=n-1
print("Sum of even numbers is :",sum1)
print("Sum of odd numbers is :",sum2)

Q9. Write a program to create a list of numbers and find the sum
of the even location elements and the sum of the odd location
elements present in it.
n=int(input("How many numbers you want to enter :"))
m=1
sum1=0
sum2=0
while(m<=n):
x=int(input("Enter a number :"))
if(m%2==0):
sum1=sum1+x
else:
sum2=sum2+x
m=m+1
print("Sum of even numbers is :",sum1)
print("Sum of odd numbers is :",sum2)

Q10. Write a program


to find the factorial value of N. Accept the value of N from the
user.
n=int(input("Enter the number :"))
f=1
while(n>0):
f=f*n
n=n-1
print("The factorial is :",f)

You might also like