Digilabs Task (1-7)
Digilabs Task (1-7)
def prime(num):
if num <= 1:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
def print_limit(limit):
for num in range(2, limit + 1):
if prime(num):
print(num)
* Create an array of lists. * Access and print specific elements from the nested lists.
array = [
[1, 2, 3],
['a', 'b', 'c'],
[True, False, True]
]
* Create a string and find its length. * Replace a specific substring in the string.
* Convert the string to uppercase and lowercase.
length_of_string = len(my_string)
print("Length of the string:", length_of_string)
ppercase_string = my_string.upper()
u
lowercase_string = my_string.lower()
mpty_Dictionary = {}
e
print("Empty Dictionaryionary:", empty_Dictionary)
mpty_Dictionary['grape'] = 4
e
empty_Dictionary['kiwi'] = 6
print("Dictionaryionary after adding key-value pairs:", empty_Dictionary)
* Create a list that includes elements of different data types (integers, strings, floats, Boolean).
* Print the type of each element in the list.
mptylist = []
e
emptylist.extend([6, 7, 8, 9, 10])
print("List 1 after adding elements:", emptylist)
mptylist2 = []
e
for i in range(1, 6):
emptylist2.append(i)
print("List 2 after adding elements dynamically:", emptylist2)
listlen = len(list1)
print("Length of list 1:", listlen)
rite a Python program that checks if a person is eligible to vote based on their age.
W
The voting age greater than 18 years
Example Output: Enter your age: 20 You are eligible to vote.
Note: your program should prompts the user to input their age