Set A Python Lab Book

1. Write a Python Program to check whether given number is Prime or Not.

 a positive integer that is not divisible without remainder by any integer except itself and 1, 

n = int(input("Enter value: "))
count = 0
i =1
while(i<=n):
    if (n%i == 0):
        count = count + 1
    i=i+1
if(count == 2):
    print("prime no.")
else:
    print("non prime no.")
Enter value: 7
prime no.
2. Write a Python Program to display all the perfect numbers between 1 to n.

# Write a java Program to display all the perfect numbers between 1 to n.
n = int(input("Enter value of n: "))
count = 0
for i in range(1, n):
    if(n%i==0):
        count = count + i
        # print(i)
if count==n:
    print("perfect no.")
else:
    print("non perfect no")
Enter value of n: 6
perfect no.
3. Write a Python Program to accept employee name from a user and display it in reverse order.
temp = ''
n = input("enter employee name: ")
n = "".join(reversed(n))
print(n)
enter employee name: shreyash kolhe
ehlok hsayerhs
4. Write a Python program to display all the even numbers from an array. (Use Command Line arguments)
arr = [1,2,3,4,5,6,7,8,9,10]
for i in arr:
    if (i%2==0):
        print(i)
2
4
6
8
10
5. Write a java program to display the vowels from a given string.
str = "shreyash"
for i in str:
    if (i == "a" or i == "e" or i == "i" or i == "o" or i == "u" ):
        print(i, end=" ")
e a