Skip to content

felipecostacouto/Python-Studies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Sure! Here are the problems listed in bullet points:

Prime Numbers in a Range

Description: Write a function that takes two integers, start and end, and returns a list of all prime numbers between start and end (inclusive). Function Signature: def primes_in_range(start, end): Example: print(primes_in_range(10, 30)) # Output: [11, 13, 17, 19, 23, 29] Sum of Digits

Description: Write a function that takes a positive integer and returns the sum of its digits. Function Signature: def sum_of_digits(n): Example: print(sum_of_digits(1234)) # Output: 10 Palindrome Number

Description: Write a function that checks if a given integer is a palindrome. A palindrome number is a number that remains the same when its digits are reversed. Function Signature: def is_palindrome(n): Example: print(is_palindrome(121)) # Output: True print(is_palindrome(123)) # Output: False Fibonacci Sequence

Description: Write a function that generates the first n numbers in the Fibonacci sequence. Function Signature: def fibonacci_sequence(n): Example: print(fibonacci_sequence(10)) # Output: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] Greatest Common Divisor (GCD)

Description: Write a function that takes two integers and returns their greatest common divisor using the Euclidean algorithm. Function Signature: def gcd(a, b): Example: print(gcd(48, 18)) # Output: 6 Least Common Multiple (LCM)

Description: Write a function that takes two integers and returns their least common multiple. Function Signature: def lcm(a, b): Example: print(lcm(4, 6)) # Output: 12 Armstrong Number

Description: Write a function to check if a given number is an Armstrong number. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits. Function Signature: def is_armstrong(n): Example: print(is_armstrong(153)) # Output: True (153 = 1^3 + 5^3 + 3^3) print(is_armstrong(123)) # Output: False Prime Factorization

Description: Write a function that returns the prime factorization of a given integer. Function Signature: def prime_factors(n): Example: print(prime_factors(56)) # Output: [2, 2, 2, 7] Binary to Decimal Conversion

Description: Write a function that converts a binary number (given as a string) to a decimal number. Function Signature: def binary_to_decimal(binary_str): Example: print(binary_to_decimal("1101")) # Output: 13 Decimal to Binary Conversion

Description: Write a function that converts a decimal number to a binary number (returned as a string). Function Signature: def decimal_to_binary(n): Example: print(decimal_to_binary(13)) # Output: "1101" These problems should provide a good variety of coding exercises to practice different concepts and improve your programming skills.

About

Some Python codes for study

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages