>> Here's a list of some basic Python programs covering different concepts: 1. Hello, World! Program: print("Hello World!") Output : Hello world! 2. Sum of Two Numbers: num1 = int(input("Enter value of num1: ")) num2 = int(input("Enter value of num2: ")) sum_result = num1 + num2 print("Sum:", sum_result) Output : Enter value of num1: 34 Enter value of num2: 56 Sum: 90 3. Finding the Largest Number in a List: numbers = [12, 45, 89, 23, 67] max_number = max(numbers) print("Largest Number:", max_number) Output : Largest Number: 89 4. Factorial of a Number: def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) #user input any number num = int(input("Enter number of factorial found: ")) print("Factorial of", num, "is", factorial(num)) Output : Enter number of factorial found: 5 Factorial of 5 is 120 5. Checking if a Number is Prime: def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True num =int(input("Enter the number: ")) if is_prime(num): print(num, "is a prime number.") else: print(num, "is not a prime number.") Output: Enter the number: 6 6 is not a prime number. Enter the number: 27 27 is not a prime number. 6. Reversing a String: #user input the string string = input("Enter the string: ") reversed_string = string[::-1] print("Reversed String:", reversed_string) Output : Enter the string: Hello Python Reversed String: nohtyP olleH 7. Counting the Occurrences of Each Character in a String: #user enter any string from a to z string = input("Enter any string from a to z: ") char_counts = {} for char in string: char_counts[char] = char_counts.get(char, 0) + 1 print("Character Counts:", char_counts) Output : Enter any string from a to z: jaishreeram Character Counts: {'j': 1, 'a': 2, 'i': 1, 's': 1, 'h': 1, 'r': 2, 'e': 2, 'm': 1} 8. Checking if a String is a Palindrome: def is_palindrome(s): return s == s[::-1] string = input("Enter any string : ") if is_palindrome(string): print(string, "is a palindrome.") else: print(string, "is not a palindrome.") Output : Enter any string : aabbaa aabbaa is a palindrome. 9. Fibonacci Series: def fibonacci(n): if n <= 0: return [] elif n == 1: return [0] elif n == 2: return [0, 1] else: series = [0, 1] for i in range(2, n): next_num = series[-1] + series[-2] series.append(next_num) return series n_terms = int(input("Enter the number: ")) fib_series = fibonacci(n_terms) print("Fibonacci Series:", fib_series) Output : Enter the number: 10 Fibonacci Series: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] These programs cover various concepts like printing, basic arithmetic,lists, functions, loops, conditionals, and string manipulation in Python. They should give you a good starting point to explore different aspects of Python programming.
Here A list of some basic Python programs covering different concepts:
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated