Practical-1: Aim: Write A Function To Find All Prime Numbers Occur Between 1 To 100
Practical-1: Aim: Write A Function To Find All Prime Numbers Occur Between 1 To 100
Practical-1
Aim: Write a function to find all prime numbers occur between 1 to 100.
Code:-
def is_prime(num):
if num < 2:
return False
if num % i == 0:
return False
return True
if is_prime(i):
Output:-
Practical-2
Aim: Write a python program to check whether the given string is a
palindrome or not.
Code:-
def isPalindrome(s):
return s == s[::-1]
if ans:
print(f"{s} is a palindrome.")
else:
print(f"{s} is NOT a palindrome.")
Output:-
Practical-3
Aim: Using concept of list comprehension, write a python program to
print the Fibonacci sequence form with a given n input by console.
Code:-
mylist=[0,1]
Output:-
Practical-4
Aim: Find out the list of subjects of a particular semester from the input
provided as a list of dictionaries using lambda map and filter together.
i/p:- [{'sem':6,'sub':'python'},{'sem':6,'sub':'cns'}, {'sem':5,'sub':'java'},
{'sem':5,'sub':'daa'}] o/p:- sem 6 subjects:['python','cns']
Code:-
subject = [{'sem':6,'sub':'python'},{'sem':6,'sub':'cns'},
{'sem':5,'sub':'java'}, {'sem':5,'sub':'daa'}]
print("sem:", list(b))
print("subject:", c)
Output:-
Practical-5
Aim: Write a program to count frequency of elements and storing in
dictionary using zip().
Code:-
def CountFrequency(my_list):
a = set(my_list)
b = []
for item in a:
b.append(my_list.count(item))
c = {a: b for a,
b in zip(a, b)}
print("Frequency count:", c)
if __name__ == "__main__":
my_list =[1, 1, 1, 5, 5, 3, 1, 3, 3, 1, 4, 4, 4, 2, 2, 2, 2]
CountFrequency(my_list)
Output:-
Practical-6
Aim: Write a program to check the validity of password input by users.
Following are the criteria for checking the password:
1. At least 1 letter between [a-z]
2. At least 1 number between [0-9]
3. At least 1 letter between [A-Z]
4. At least 1 special character
5. Min. length of transaction password: 6
6. Max. Length of transaction password: 12
Code:-
import re
flag = 1
while True:
flag = 1
break
flag = 1
break
flag = 1
break
flag = 1
break
flag = 1
break
else:
print("Valid Password")
flag = 0
break
if flag == 1:
print("Invalid Password")
Output:-
Practical-7
Aim: Write a program that can explore Scipy python library.
Code:-
# cube root of 64
print(cbrt(64))
# cube root of 78
print(cbrt(78))
print(cbrt(128))
Output:-