· last year · May 05, 2024, 12:50 PM
1#Reverse
2num = int(input("Enter a number: "))
3reversed_num = 0
4while num > 0:
5 digit = num % 10
6 reversed_num = (reversed_num * 10) + digit
7 num = num // 10
8print(f"The reversed number: {reversed_num}")
9
10#fibonacchi
11num_terms = int(input("Enter the number of terms for the Fibonacci series: "))
12if num_terms <= 0:
13 print("Invalid input. Please enter a positive integer.")
14else:
15 fib_series = [0, 1]
16 while len(fib_series) < num_terms:
17 fib_series.append(fib_series[-1] + fib_series[-2])
18 sum_fib_series = sum(fib_series)
19 print(f"The sum of the first {num_terms} terms in the Fibonacci series is: {sum_fib_series}")
20
21#armstrong
22num = int(input("Enter a number: "))
23original_num = num
24num_digits = len(str(num))
25sum_of_digits = 0
26while num > 0:
27 digit = num % 10
28 sum_of_digits += digit ** num_digits
29 num = num // 10
30if original_num == sum_of_digits:
31 print(f"{original_num} is an Armstrong number.")
32else:
33 print(f"{original_num} is not an Armstrong number.")
34
35
36#positive negative sum
37sum_positive = 0
38sum_negative = 0
39for i in range(10):
40 num = float(input(f"Enter number {i + 1}: "))
41
42 if num > 0:
43 sum_positive += num
44 elif num < 0:
45 sum_negative += num
46
47print(f"Sum of positive numbers: {sum_positive}")
48print(f"Sum of negative numbers: {sum_negative}")
49
50
51#palindrome
52
53num = int(input("Enter a number: "))
54original_num = num
55reversed_num = 0
56while num > 0:
57 digit = num % 10
58 reversed_num = (reversed_num * 10) + digit
59 num = num // 10
60if original_num == reversed_num:
61 print(f"{original_num} is a palindrome.")
62else:
63 print(f"{original_num} is not a palindrome.")
64
65
66*
67* *
68* * *
69* * * *
70* * * * *
71
72rows = 5
73for i in range(0, rows):
74 for j in range(0, i + 1):
75 print("*", end=' ')
76 print()
77
781
792 2
803 3 3
814 4 4 4
825 5 5 5 5
83
84rows = 6
85for i in range(rows):
86 for j in range(i):
87 print(i, end=' ')
88 print('')
89
901
911 2
921 2 3
931 2 3 4
941 2 3 4 5
95
96rows = 5
97for i in range(1, rows + 1):
98 for j in range(1, i + 1):
99 print(j, end=' ')
100 print('')
101
1021
1032 3
1044 5 6
1057 8 9 10
10611 12 13 14 15
107
108rows = 5
109counter = 1
110for i in range(1, rows + 1):
111 for j in range(1, i + 1):
112 print(counter, end=' ')
113 counter += 1
114 print('')
115
116 *
117 * *
118 * * *
119 * * * *
120 * * * * *
121
122size = 5
123m = (2 * size) - 2
124for i in range(0, size):
125 for j in range(0, m):
126 print(end=" ")
127 m = m - 1
128 for j in range(0, i + 1):
129 print("* ", end=' ')
130 print(" ")
131
132''' OR
133n = 5
134for i in range(n):
135 print(' '*(n-i-1) + '* ' * (i))
136print()
137'''
138
139* * * * *
140 * * * *
141 * * *
142 * *
143 *
144
145size = 5
146m = 0
147for i in range(size, 0, -1):
148 for j in range(0, m):
149 print(end=" ")
150 m = m + 1
151 for j in range(0, i):
152 print("* ", end=' ')
153 print(" ")
154
155''' OR
156n = 5
157for i in range(n-1,-1,-1):
158 print(' ' * (n - i - 1) + '* ' * (i))
159'''
160
161 *
162 * *
163 * * *
164 * * * *
165 * * *
166 * *
167 *
168
169rows = 3
170k = 2 * rows - 2
171for i in range(0, rows):
172 for j in range(0, k):
173 print(end=" ")
174 k = k - 1
175 for j in range(0, i + 1):
176 print("* ", end="")
177 print("")
178
179k = rows - 2
180
181for i in range(rows, -1, -1):
182 for j in range(k, 0, -1):
183 print(end=" ")
184 k = k + 1
185 for j in range(0, i + 1):
186 print("* ", end="")
187 print("")
188
189
190'''OR
191
192n = 3
193for i in range(n):
194 print(' '*(n-i-1) + '*' * (2*i+1))
195for i in range(n-2,-1,-1):
196 print(' ' * (n - i - 1) + '*' * (2 * i + 1))'''
197
198
199#calculator
200
201def addition(num1, num2):
202 num1 += num2
203 return num1
204
205def subtraction(num1, num2):
206 num1 -= num2
207 return num1
208
209def mul(num1, num2):
210 num1 *= num2
211 return num1
212
213def division(num1, num2):
214 if num2 != 0:
215 num1 /= num2
216 return num1
217 else:
218 return "Cannot divide by zero"
219
220def module(num1, num2):
221 if num2 != 0:
222 num1 %= num2
223 return num1
224 else:
225 return "Cannot perform modulus with zero"
226
227def default(num1, num2):
228 return "Incorrect day"
229
230switcher = {
231 1: addition,
232 2: subtraction,
233 3: mul,
234 4: division,
235 5: module
236}
237
238def switch(operation):
239 num1 = float(input("Enter the first number: "))
240 num2 = float(input("Enter the second number: "))
241 return switcher.get(operation, default)(num1, num2)
242
243print('''You can perform the following operations:
244
2451. **Addition**
2462. **Subtraction**
2473. **Multiplication**
2484. **Division**
2495. **Modulus (Remainder)''')
250
251# Take input from the user
252choice = int(input("Select an operation from 1 to 5: "))
253print(switch(choice))
254
255
256
257
258#Fibonacchi using recursion
259def fibonacci(n):
260 if n <= 0:
261 return "Please enter a positive integer"
262 elif n == 1:
263 return [0]
264 elif n == 2:
265 return [0, 1]
266 else:
267 fib_series = fibonacci(n - 1)
268 fib_series.append(fib_series[-1] + fib_series[-2])
269 return fib_series
270
271n = int(input("Enter the value of 'n' to print Fibonacci series up to n: "))
272
273result = fibonacci(n)
274print(f"Fibonacci series up to {n}: {result}")
275
276
277
278#GCD using recurtion
279def gcd_recursive(a, b):
280 if b == 0:
281 return a
282 else:
283 return gcd_recursive(b, a % b)
284
285# Take input from the user
286num1 = int(input("Enter the first number: "))
287num2 = int(input("Enter the second number: "))
288
289result = gcd_recursive(num1, num2)
290print(f"The GCD of {num1} and {num2} is: {result}")
291
292
293
294# Wap to print sum of list
295l1 = [12+13+14+15+56]
296sum = 0
297
298for i in l1:
299 sum += i
300
301print(sum
302
303#output
304110
305
306#Wap to print mal element
307ls=[]
308print("Enter Elements in array")
309for i in range(5):
310 el=int(input())
311 ls.append(el)
312
313maxel=ls[0]
314
315mi=0
316for i in range(1,len(ls)):
317 if ls[i]>maxel:
318 maxel=ls[i]
319 mi = i
320
321print("Max element is: ",maxel)
322
323#output
324Enter Elements in array
32513
32667
32734
32899
32912
330Max element is: 99
331
332#wap to print common elements
333def compare_lists(list1, list2):
334 common_elements = set(list1) & set(list2)
335 return list(common_elements)
336
337
338list1_input = input("Enter elements of the first list separated by spaces: ")
339list1 = list(map(str, list1_input.split()))
340
341
342list2_input = input("Enter elements of the second list separated by spaces: ")
343list2 = list(map(str, list2_input.split()))
344
345common_elements = compare_lists(list1, list2)
346
347if common_elements:
348 print("Common elements: ", common_elements)
349else:
350 print("No common elements found.")
351
352#output
353Enter elements of the first list separated by spaces: 12 13 45 67 89
354Enter elements of the second list separated by spaces: 12 45 67 89
355Common elements: ['12', '45', '67', '89']
356
357#Wap to remove even numbers
358def remove_even_numbers(input_list):
359 return [num for num in input_list if int(num) % 2 != 0]
360
361user_input = input("Enter a list of numbers separated by spaces: ")
362numbers_list = user_input.split()
363
364filtered_list = remove_even_numbers(numbers_list)
365
366print("List after removing even numbers:", filtered_list)
367
368
369#output
370Enter a list of numbers separated by spaces: 12 34 56 77 43 31
371List after removing even numbers: ['77', '43', '31']
372
373#Wap to print number of occurance
374def count_occurrences(array, target_element):
375 return array.count(target_element)
376
377user_input = input("Enter a list of numbers separated by spaces: ")
378numbers_list = user_input.split()
379
380
381target_element = input("Enter the element to count: ")
382
383occurrences = count_occurrences(numbers_list, target_element)
384
385print(f"The number of occurrences of {target_element} in the list is: {occurrences}")
386
387#output
388Enter a list of numbers separated by spaces: 12 33 33 45 67 54
389Enter the element to count: 33
390The number of occurrences of 33 in the list is: 2
391
392
393#accept and print matrix
394matrix = []
395
396for i in range(3):
397 row = []
398 for j in range(3):
399 row.append(int(input(f"Enter element at position ({i+1}, {j+1}): ")))
400 matrix.append(row)
401
402print("Entered 3x3 matrix:")
403for row in matrix:
404 print(row)
405
406output:
407Enter element at position (1, 1): 1
408Enter element at position (1, 2): 2
409Enter element at position (1, 3): 3
410Enter element at position (2, 1): 4
411Enter element at position (2, 2): 5
412Enter element at position (2, 3): 6
413Enter element at position (3, 1): 7
414Enter element at position (3, 2): 8
415Enter element at position (3, 3): 9
416Entered 3x3 matrix:
417[1, 2, 3]
418[4, 5, 6]
419[7, 8, 9]
420
421
422#accept matrix and element sum
423matrix = []
424a=0
425sum=0
426
427for i in range(3):
428 row = []
429 for j in range(3):
430 a=int(input(f"Enter element at position ({i+1}, {j+1}): "))
431 row.append(a)
432 sum+=a
433 matrix.append(row)
434
435print("Entered 3x3 matrix:")
436for row in matrix:
437 print(row)
438
439print("Sum = ",sum)
440
441Output:
442Enter element at position (1, 1): 1
443Enter element at position (1, 2): 2
444Enter element at position (1, 3): 3
445Enter element at position (2, 1): 4
446Enter element at position (2, 2): 5
447Enter element at position (2, 3): 6
448Enter element at position (3, 1): 7
449Enter element at position (3, 2): 8
450Enter element at position (3, 3): 9
451Entered 3x3 matrix:
452[1, 2, 3]
453[4, 5, 6]
454[7, 8, 9]
455Sum = 45
456
457
458
459#Accept matrix and trace
460matrix = []
461
462for i in range(3):
463 row = []
464 for j in range(3):
465 element = int(input(f"Enter element at position ({i+1}, {j+1}): "))
466 row.append(element)
467 matrix.append(row)
468
469print("Entered 3x3 matrix:")
470for row in matrix:
471 print(row)
472
473trace = 0
474for i in range(3):
475 trace += matrix[i][i]
476
477print(f"Trace of the matrix: {trace}")
478
479Output:
480Enter element at position (1, 1): 1
481Enter element at position (1, 2): 2
482Enter element at position (1, 3): 3
483Enter element at position (2, 1): 4
484Enter element at position (2, 2): 5
485Enter element at position (2, 3): 6
486Enter element at position (3, 1): 7
487Enter element at position (3, 2): 8
488Enter element at position (3, 3): 9
489Entered 3x3 matrix:
490[1, 2, 3]
491[4, 5, 6]
492[7, 8, 9]
493Trace of the matrix: 15
494
495
496
497#Matrix multiplication
498import numpy as np
499
500matrix1 = []
501for i in range(3):
502 row = []
503 for j in range(3):
504 element = int(input(f"Enter element for matrix1 at position ({i+1}, {j+1}): "))
505 row.append(element)
506 matrix1.append(row)
507
508matrix2 = []
509for i in range(3):
510 row = []
511 for j in range(3):
512 element = int(input(f"Enter element for matrix2 at position ({i+1}, {j+1}): "))
513 row.append(element)
514 matrix2.append(row)
515
516print("Entered 3x3 matrix 1:")
517for row in matrix1:
518 print(row)
519
520print("\nEntered 3x3 matrix 2:")
521for row in matrix2:
522 print(row)
523
524array1 = np.array(matrix1)
525array2 = np.array(matrix2)
526
527
528result_array = np.dot(array1, array2)
529
530print("\nResult of matrix multiplication:")
531print(result_array)
532
533Output:
534Enter element for matrix1 at position (1, 1): 1
535Enter element for matrix1 at position (1, 2): 2
536Enter element for matrix1 at position (1, 3): 3
537Enter element for matrix1 at position (2, 1): 4
538Enter element for matrix1 at position (2, 2): 5
539Enter element for matrix1 at position (2, 3): 6
540Enter element for matrix1 at position (3, 1): 7
541Enter element for matrix1 at position (3, 2): 8
542Enter element for matrix1 at position (3, 3): 9
543Enter element for matrix2 at position (1, 1): 1
544Enter element for matrix2 at position (1, 2): 10
545Enter element for matrix2 at position (1, 3): 11
546Enter element for matrix2 at position (2, 1): 12
547Enter element for matrix2 at position (2, 2): 13
548Enter element for matrix2 at position (2, 3): 14
549Enter element for matrix2 at position (3, 1): 15
550Enter element for matrix2 at position (3, 2): 16
551Enter element for matrix2 at position (3, 3): 17
552Entered 3x3 matrix 1:
553[1, 2, 3]
554[4, 5, 6]
555[7, 8, 9]
556
557Entered 3x3 matrix 2:
558[1, 10, 11]
559[12, 13, 14]
560[15, 16, 17]
561
562Result of matrix multiplication:
563[[ 70 84 90]
564 [154 201 216]
565 [238 318 342]]
566
567
568
569#Count vowels, consonants and blanks
570def count_vowels_consonants_blanks(string):
571 vowels = 'aeiouAEIOU'
572 consonants = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'
573 blanks = ' '
574
575 vowel_count = 0
576 consonant_count = 0
577 blank_count = 0
578
579 for char in string:
580 if char in vowels:
581 vowel_count += 1
582 elif char not in consonants:
583 consonant_count += 1
584 elif char in blanks:
585 blank_count += 1
586
587 return vowel_count, consonant_count, blank_count
588
589input_string = input("Enter a string: ")
590vowels, consonants, blanks = count_vowels_consonants_blanks(input_string)
591print("Vowels:", vowels)
592print("Consonants:", consonants)
593print("Blanks:", blanks)
594
595#Output:
596Enter a string: Arijit is my name
597Vowels: 6
598Consonants: 8
599Blanks: 3
600
601#find substring in a string
602def find_substring(string, substring):
603 index = string.find(substring)
604 if index != -1:
605 print(f"'{substring}' found at index {index} using find() method.")
606 else:
607 print(f"'{substring}' not found using find() method.")
608
609
610input_string = input("Enter the main string: ")
611input_substring = input("Enter the substring to find: ")
612
613find_substring(input_string, input_substring)
614
615
616#Output:
617Enter the main string: i live in India
618Enter the substring to find: India
619'India' found at index 10 using find() method.
620
621
622#print reverse and check palindrome
623def is_palindrome(string):
624 reversed_string = string[::-1]
625 if string == reversed_string:
626 return True, reversed_string
627 else:
628 return False, reversed_string
629
630input_string = input("Enter a string: ")
631check, reversed_string = is_palindrome(input_string)
632
633print("Original string:", input_string)
634print("Reversed string:", reversed_string)
635
636if check:
637 print("The string is a palindrome.")
638else:
639 print("The string is not a palindrome.")
640
641
642#Output:
643Enter a string: malayalam
644Original string: malayalam
645Reversed string: malayalam
646The string is a palindrome.
647
648#Print pattern
649word = "INDIA"
650for i in range(len(word), 0, -1):
651 print(word[:i])
652
653#Ouput:
654INDIA
655INDI
656IND
657IN
658I
659
660
661
662
663def tuple_length(tup):
664 return len(tup)
665my_tuple = (1, 2, 3, 4, 5)
666print("Length of the tuple:", tuple_length(my_tuple))
667
668Output:
669Length of the tuple: 5
670
671def tuple_to_string(tup):
672 return ''.join(tup)
673
674my_tuple = ('Hello', ' ', 'world', '!')
675result = tuple_to_string(my_tuple)
676print("Converted string:", result)
677
678Output:
679Converted string: Hello world!
680
681def common_elements(tup1, tup2):
682 common = tuple(x for x in tup1 if x in tup2)
683 return common
684
685tuple1 = (1, 2, 3, 4, 5)
686tuple2 = (4, 5, 6, 7, 8)
687result = common_elements(tuple1, tuple2)
688print("Common elements:", result)
689
690Output:
691Common elements: (4, 5)
692
693def merge_tuples(tup1, tup2):
694 merged_list = list(tup1)
695 for item in tup2:
696 if item not in merged_list:
697 merged_list.append(item)
698 merged_tuple = tuple(merged_list)
699 return merged_tuple
700
701tuple1 = (1, 2, 3, 4, 5)
702tuple2 = (4, 5, 6, 7, 8)
703result = merge_tuples(tuple1, tuple2)
704print("Merged tuple without duplicates:", result)
705
706Output:
707Merged tuple without duplicates: (1, 2, 3, 4, 5, 6, 7, 8)
708
709def even_odd_numbers(tup):
710 even_numbers = tuple(num for num in tup if num % 2 == 0)
711 odd_numbers = tuple(num for num in tup if num % 2 != 0)
712 return even_numbers, odd_numbers
713
714my_tuple = (1, 2, 3, 4, 5, 6, 7, 8, 9)
715even, odd = even_odd_numbers(my_tuple)
716print("Even numbers:", even)
717print("Odd numbers:", odd)
718
719Output:
720Even numbers: (2, 4, 6, 8)
721Odd numbers: (1, 3, 5, 7, 9)
722
723def tuple_product(tup):
724 product = 1
725 for num in tup:
726 product *= num
727 return product
728
729my_tuple = (1, 2, 3, 4, 5)
730result = tuple_product(my_tuple)
731print("Product of all elements in the tuple:", result)
732
733Output:
734Product of all elements in the tuple: 120
735
736
737emails = tuple()
738username = tuple()
739domainname = tuple()
740n = int(input("How many email ids you want to enter?: "))
741for i in range(0, n):
742 emid = input("> ")
743 emails = emails + (emid,)
744 spl = emid.split("@")
745 username = username + (spl[0],)
746 domainname = domainname + (spl[1],)
747
748print("\nThe email ids in the tuple are:")
749print(emails)
750
751print("\nThe username in the email ids are:")
752print(username)
753
754print("\nThe domain name in the email ids are:")
755print(domainname)
756
757
758Output:
759How many email ids you want to enter?: 2
760> arijit@gmail.com
761> abir@outlook.com
762
763The email ids in the tuple are:
764('arijit@gmail.com', 'abir@outlook.com')
765
766The username in the email ids are:
767('arijit', 'abir')
768
769The domain name in the email ids are:
770('gmail.com', 'outlook.com')
771
772
773
774#Q1. python program to check if a string starts with the and end with spain use regex
775
776
777import re
778
779def check_string(input_string):
780 pattern = r'^the.*spain$'
781 if re.match(pattern, input_string, re.IGNORECASE):
782 return True
783 else:
784 return False
785
786test_string1 = input("Enter string: ")
787
788print(check_string(test_string1))
789
790#output:
791Enter string: the spain
792True
793Enter string: the spain not
794False
795
796
797#Q. program to find all lowercase charcters aplhabetically between a and m, use regex
798import re
799
800def find_lower_chars(input_string):
801 pattern = r'[a-m]'
802 result = re.findall(pattern, input_string)
803 return result
804
805user_input = input("Enter a string: ")
806lowercase_chars = find_lower_chars(user_input)
807print("Lowercase characters between 'a' and 'm':", lowercase_chars)
808
809#output:
810Enter a string: The quick brown fox jumps over the lazy dog
811Lowercase characters between 'a' and 'm': ['h', 'e', 'i', 'c', 'k', 'b', 'f', 'j', 'm', 'e', 'h', 'e', 'l', 'a', 'd', 'g']
812
813#Q. program to search for the first white space character in the string
814
815
816import re
817
818txt = "The rain in Spain"
819x = re.search("\s", txt)
820
821print("The first white-space character is located in position:", x.start())
822
823#Output:
824The first white-space character is located in position: 3
825
826#Q. program to split at each whitespace character using regex
827
828import re
829
830def split_at_whitespace(input_string):
831 return re.split(r'\s+', input_string)
832
833user_input = input("Enter a string: ")
834result = split_at_whitespace(user_input)
835print("Split at each whitespace character:", result)
836
837
838#Output:
839Enter a string: This is a demo input.
840Split at each whitespace character: ['This', 'is', 'a', 'demo', 'input.']
841
842
843#Q. replace every white space character with the number nine
844
845import re
846
847def replace_whitespace_with_nine(input_string):
848 return re.sub(r'\s', '9', input_string)
849
850user_input = input("Enter a string: ")
851result = replace_whitespace_with_nine(user_input)
852print("String with every whitespace character replaced with '9':", result)
853
854
855#Output:
856Enter a string: This is a demo input
857String with every whitespace character replaced with '9': This9is9a9demo9inputp
858
859
860#Q: check if email valid or not:
861import re
862
863def validate_email(email):
864 pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
865 regex = re.compile(pattern)
866 return bool(regex.match(email))
867
868user_email = input("Enter your email address: ")
869
870if validate_email(user_email):
871 print("Valid email address!")
872else:
873 print("Invalid email address. Please enter a valid email.")
874
875
876#Output:
877Enter your email address: arijit@gmail.com
878Valid email address!
879
880Enter your email address: arijit@gmail
881Invalid email address. Please enter a valid email.
882
883
884
885#Q1. python program to check if a string starts with the and end with spain use regex
886
887
888import re
889
890def check_string(input_string):
891 pattern = r'^the.*spain$'
892 if re.match(pattern, input_string, re.IGNORECASE):
893 return True
894 else:
895 return False
896
897test_string1 = input("Enter string: ")
898
899print(check_string(test_string1))
900
901#output:
902Enter string: the spain
903True
904Enter string: the spain not
905False
906
907
908#Q. program to find all lowercase charcters aplhabetically between a and m, use regex
909import re
910
911def find_lower_chars(input_string):
912 pattern = r'[a-m]'
913 result = re.findall(pattern, input_string)
914 return result
915
916user_input = input("Enter a string: ")
917lowercase_chars = find_lower_chars(user_input)
918print("Lowercase characters between 'a' and 'm':", lowercase_chars)
919
920#output:
921Enter a string: The quick brown fox jumps over the lazy dog
922Lowercase characters between 'a' and 'm': ['h', 'e', 'i', 'c', 'k', 'b', 'f', 'j', 'm', 'e', 'h', 'e', 'l', 'a', 'd', 'g']
923
924#Q. program to search for the first white space character in the string
925
926
927import re
928
929txt = "The rain in Spain"
930x = re.search("\s", txt)
931
932print("The first white-space character is located in position:", x.start())
933
934#Output:
935The first white-space character is located in position: 3
936
937#Q. program to split at each whitespace character using regex
938
939import re
940
941def split_at_whitespace(input_string):
942 return re.split(r'\s+', input_string)
943
944user_input = input("Enter a string: ")
945result = split_at_whitespace(user_input)
946print("Split at each whitespace character:", result)
947
948
949#Output:
950Enter a string: This is a demo input.
951Split at each whitespace character: ['This', 'is', 'a', 'demo', 'input.']
952
953
954#Q. replace every white space character with the number nine
955
956import re
957
958def replace_whitespace_with_nine(input_string):
959 return re.sub(r'\s', '9', input_string)
960
961user_input = input("Enter a string: ")
962result = replace_whitespace_with_nine(user_input)
963print("String with every whitespace character replaced with '9':", result)
964
965
966#Output:
967Enter a string: This is a demo input
968String with every whitespace character replaced with '9': This9is9a9demo9inputp
969
970
971#Q: check if email valid or not:
972import re
973
974def validate_email(email):
975 pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
976 regex = re.compile(pattern)
977 return bool(regex.match(email))
978
979user_email = input("Enter your email address: ")
980
981if validate_email(user_email):
982 print("Valid email address!")
983else:
984 print("Invalid email address. Please enter a valid email.")
985
986
987#Output:
988Enter your email address: arijit@gmail.com
989Valid email address!
990
991Enter your email address: arijit@gmail
992Invalid email address. Please enter a valid email.
993
994
995