filmov
tv
50+ Python Practice Exercises || Master Python 2024

Показать описание
ALL Problems :
Hello World: Write a program to print "Hello, World!".
Variables and Types: Write a program that assigns and prints different types of variables: integer, float, string, and boolean.
Basic Arithmetic: Write a program that takes two numbers as input and prints their sum, difference, product, and quotient.
Exponentiation: Write a program that calculates and prints the result of raising one number to the power of another.
Control Flow
Even or Odd: Write a program that checks if a number is even or odd.
Leap Year: Write a program to check if a given year is a leap year.
Largest of Three: Write a program to find the largest of three numbers.
FizzBuzz: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Data Structures
Lists
List Sum: Write a program that takes a list of numbers and prints their sum.
List Average: Write a program that calculates the average of a list of numbers.
Find Max in List: Write a program to find the largest number in a list.
List Comprehension: Write a program that uses list comprehension to create a list of the squares of the numbers from 1 to 10.
Count Occurrences: Write a program that counts the number of occurrences of a specific element in a list.
Tuples
Swap Variables: Write a program that swaps the values of two variables using a tuple.
Tuple Unpacking: Write a program that demonstrates tuple unpacking with multiple variables.
Dictionaries
Phonebook: Write a program that creates a phonebook dictionary with names as keys and phone numbers as values. Allow the user to look up a number by name.
Count Words: Write a program that counts the occurrences of each word in a given string and stores the results in a dictionary.
Merge Dictionaries: Write a program to merge two dictionaries into one.
Strings
Palindrome: Write a program to check if a given string is a palindrome.
Anagram: Write a program to check if two strings are anagrams of each other.
Reverse String: Write a program to reverse a string.
String Length: Write a program that returns the length of a string without using the built-in len() function.
Count Vowels: Write a program that counts the number of vowels in a given string.
Functions
Factorial: Write a function to calculate the factorial of a number.
Fibonacci: Write a function that returns the nth Fibonacci number.
Prime Check: Write a function to check if a number is prime.
GCD: Write a function to compute the greatest common divisor of two numbers.
LCM: Write a function to compute the least common multiple of two numbers.
File I/O
Read File: Write a program that reads a text file and prints its contents.
Write File: Write a program that writes a list of strings to a file, each string on a new line.
Hello World: Write a program to print "Hello, World!".
Variables and Types: Write a program that assigns and prints different types of variables: integer, float, string, and boolean.
Basic Arithmetic: Write a program that takes two numbers as input and prints their sum, difference, product, and quotient.
Exponentiation: Write a program that calculates and prints the result of raising one number to the power of another.
Control Flow
Even or Odd: Write a program that checks if a number is even or odd.
Leap Year: Write a program to check if a given year is a leap year.
Largest of Three: Write a program to find the largest of three numbers.
FizzBuzz: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Data Structures
Lists
List Sum: Write a program that takes a list of numbers and prints their sum.
List Average: Write a program that calculates the average of a list of numbers.
Find Max in List: Write a program to find the largest number in a list.
List Comprehension: Write a program that uses list comprehension to create a list of the squares of the numbers from 1 to 10.
Count Occurrences: Write a program that counts the number of occurrences of a specific element in a list.
Tuples
Swap Variables: Write a program that swaps the values of two variables using a tuple.
Tuple Unpacking: Write a program that demonstrates tuple unpacking with multiple variables.
Dictionaries
Phonebook: Write a program that creates a phonebook dictionary with names as keys and phone numbers as values. Allow the user to look up a number by name.
Count Words: Write a program that counts the occurrences of each word in a given string and stores the results in a dictionary.
Merge Dictionaries: Write a program to merge two dictionaries into one.
Strings
Palindrome: Write a program to check if a given string is a palindrome.
Anagram: Write a program to check if two strings are anagrams of each other.
Reverse String: Write a program to reverse a string.
String Length: Write a program that returns the length of a string without using the built-in len() function.
Count Vowels: Write a program that counts the number of vowels in a given string.
Functions
Factorial: Write a function to calculate the factorial of a number.
Fibonacci: Write a function that returns the nth Fibonacci number.
Prime Check: Write a function to check if a number is prime.
GCD: Write a function to compute the greatest common divisor of two numbers.
LCM: Write a function to compute the least common multiple of two numbers.
File I/O
Read File: Write a program that reads a text file and prints its contents.
Write File: Write a program that writes a list of strings to a file, each string on a new line.
Комментарии