hello
Programs to practise
Sure! Here are 50 basic but logically challenging Python programs to practice for entry-level learners:
-
Hello World: Write a program to print "Hello, World!". done
-
Odd or Even: Write a program that asks the user for a number and prints whether it is odd or even. done
-
Leap Year: Write a program to check if a year is a leap year or not. done
-
Prime Number: Write a program to check if a number is prime or not. done
-
Factorial: Write a program to compute the factorial of a number. done
-
Fibonacci Sequence: Write a program to print the first n numbers of the Fibonacci sequence. done
-
Sum of Digits: Write a program to find the sum of the digits of a number. done
-
Reverse a String: Write a program to reverse a string.
-
Palindrome: Write a program to check if a string is a palindrome.
-
Count Vowels: Write a program to count the number of vowels in a string.
-
String Length: Write a program to find the length of a string without using the
len()function. -
Largest Element in a List: Write a program to find the largest element in a list.
-
Sum of List: Write a program to find the sum of all elements in a list.
-
List Average: Write a program to find the average of all elements in a list.
-
Count Elements in List: Write a program to count the occurrences of each element in a list.
-
Remove Duplicates from List: Write a program to remove duplicates from a list.
-
Check Sorted List: Write a program to check if a list is sorted in ascending order.
-
Second Largest Element in List: Write a program to find the second largest element in a list.
-
Merge Two Lists: Write a program to merge two lists into one.
-
Find Common Elements in Lists: Write a program to find common elements in two lists.
-
Matrix Addition: Write a program to add two matrices.
-
Transpose Matrix: Write a program to find the transpose of a matrix.
-
Matrix Multiplication: Write a program to multiply two matrices.
-
Find GCD: Write a program to find the greatest common divisor (GCD) of two numbers.
-
Find LCM: Write a program to find the least common multiple (LCM) of two numbers.
-
Binary to Decimal: Write a program to convert a binary number to a decimal number.
-
Decimal to Binary: Write a program to convert a decimal number to a binary number.
-
Calculate Simple Interest: Write a program to calculate simple interest.
-
Calculate Compound Interest: Write a program to calculate compound interest.
-
Quadratic Equation: Write a program to solve a quadratic equation.
-
Armstrong Number: Write a program to check if a number is an Armstrong number.
-
Perfect Number: Write a program to check if a number is a perfect number.
-
Sum of Series: Write a program to compute the sum of the series 1 + 1/2 + 1/3 + ... + 1/n.
-
Exponentiation: Write a program to compute the power of a number using a loop.
-
Check Substring: Write a program to check if one string is a substring of another.
-
Sort List: Write a program to sort a list of numbers in ascending order.
-
Find Intersection of Lists: Write a program to find the intersection of two lists.
-
Check Anagram: Write a program to check if two strings are anagrams of each other.
-
Binary Search: Write a program to implement binary search.
-
Linear Search: Write a program to implement linear search.
-
Caesar Cipher: Write a program to implement a Caesar cipher.
-
Word Frequency: Write a program to count the frequency of each word in a string.
-
Find Duplicates in List: Write a program to find all duplicate elements in a list.
-
Flatten List: Write a program to flatten a nested list.
-
Check Armstrong Numbers in Range: Write a program to find all Armstrong numbers in a given range.
-
Check Prime Numbers in Range: Write a program to find all prime numbers in a given range.
-
Generate Pascal's Triangle: Write a program to generate Pascal's triangle up to n rows.
-
Longest Common Subsequence: Write a program to find the longest common subsequence of two strings.
-
Implement Queue using List: Write a program to implement a queue using a list.
-
Implement Stack using List: Write a program to implement a stack using a list.
These programs will help you understand fundamental programming concepts and improve your problem-solving skills. Happy coding!
Sure! Here are 10 practice programs for you to work on:
-
User Information
- Ask the user for their name, age, and favorite color. Display a message that includes all this information.
-
Full Name Separator
- Take the user's full name and separate it into first and last name. If the user enters more than two names, consider only the first and last names.
-
Reverse Name
- Take the user's full name and print it in reverse order (last name first).
-
Sentence Capitalizer
- Take a sentence from the user and return it with each word capitalized.
-
Personalized Greeting
- Ask the user for their first name, last name, and hometown, and print a personalized greeting.
-
Email Formatter
- Ask the user for their first name and last name, and then generate an email address in the format
firstname.lastname@example.com.
- Ask the user for their first name and last name, and then generate an email address in the format
-
Initials Extractor
- Take the user's full name and extract the initials.
-
Name Length Checker
- Ask the user for their full name and display the number of characters in the full name (excluding spaces).
-
Username Generator
- Generate a username for the user by asking for their first name, last name, and a random number, and then combining these elements.
-
Phone Number Formatter
- Ask the user for a 10-digit phone number and format it as (XXX) XXX-XXXX.