0% found this document useful (0 votes)
29 views2 pages

Easy Python Coding Challenges 2025

The document outlines a list of 30 easy-level programming challenges for a Code Sprint 2025 event. Each challenge focuses on fundamental programming concepts such as arithmetic operations, string manipulation, and data structures. Participants are tasked with writing code to solve these problems using Python.

Uploaded by

sujaamoni916
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Easy Python Coding Challenges 2025

The document outlines a list of 30 easy-level programming challenges for a Code Sprint 2025 event. Each challenge focuses on fundamental programming concepts such as arithmetic operations, string manipulation, and data structures. Participants are tasked with writing code to solve these problems using Python.

Uploaded by

sujaamoni916
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CODE SPRINT 2025

Easy Level (30 Questions)


1. Sum of Two Numbers
Write a program to take two numbers as input and print their sum.
2. Find the Largest of Three Numbers
Given three numbers, find the largest among them.
3. Check for Even or Odd Number
Write a function that checks whether a given number is even or odd.
4. Swap Two Variables Without Using a Third Variable
Swap two numbers using Python’s tuple unpacking method.
5. Reverse a String
Input a string and print its reverse.
6. Count Vowels in a String
Given a string, count and print the number of vowels present.
7. Check for Palindrome Number
A number is a palindrome if it reads the same forward and backward. Write a program to
check if a given number is a palindrome.
8. Factorial of a Number
Write a function to calculate the factorial of a given number.
9. Find the ASCII Value of a Character
Input a character and print its ASCII value.
10. Print First N Fibonacci Numbers
Print the first N Fibonacci numbers.
11. Find the Sum of Digits of a Number
Given an integer, find the sum of its digits.
12. Count the Number of Words in a String
Input a sentence and count the number of words in it.
13. Check if a String is a Palindrome
A string is a palindrome if it reads the same forward and backward. Write a program to check
this.
14. Convert Celsius to Fahrenheit
Given a temperature in Celsius, convert it to Fahrenheit.
15. Find the Smallest Element in a List
Input a list of numbers and print the smallest element.
16. Calculate Simple Interest
Write a program to calculate the simple interest given principal, rate, and time.
17. Find the Maximum of a List Without Using max()
Given a list, find the maximum element manually.
18. Check for Leap Year
Input a year and determine if it is a leap year.
19. Count the Occurrences of an Element in a List
Input a list and a number, count how many times the number appears.
20. Find the First Non-Repeating Character in a String
Given a string, find the first character that does not repeat.
21. Check if a Number is Prime
Input a number and determine if it is a prime number.
22. Reverse a List Without Using Reverse Function
Given a list, reverse it manually.
23. Print the Multiplication Table of a Number
Input a number and print its multiplication table up to 10.
24. Remove Duplicates from a List
Given a list with duplicate elements, return a new list without duplicates.
25. Find the GCD of Two Numbers
Calculate the greatest common divisor (GCD) of two numbers.
26. Find the Sum of a List Without Using sum()
Input a list and calculate its sum manually.
27. Check if a Given String Contains Only Digits
Input a string and check if it consists only of digits.
28. Convert a Decimal Number to Binary
Convert a given decimal number to its binary equivalent.
29. Find the Second Largest Number in a List
Input a list and find the second largest number.
30. HackerRank: Time Conversion
Convert 12-hour format time (AM/PM) to 24-hour format. HackerRank Link

Common questions

Powered by AI

Calculating the GCD of two numbers helps in simplifying fractions, optimizing algorithms for computational mathematics, and is pivotal in number theory’s study of divisors. The Euclidean algorithm used for this computation exemplifies efficient problem-solving techniques and serves as a gateway to understanding concepts like coprime numbers, modular arithmetic, and their applications in cryptography .

Symmetry is essential in defining palindromes because it requires the sequence of digits to mirror itself from both ends towards the center. To verify programmatically, convert the number to a string and compare it with its reverse using slicing (e.g., str_num == str_num[::-1]). This straightforward method effectively checks for reflective symmetry, capturing both the beginning and end of the number .

The conversion from decimal to binary involves successive division by 2, recording the remainder for each division. The binary number is formed by reading the remainder from the last division to the first. Understanding this conversion process illuminates the positional value system of binary numbers, vital in computer architecture where binary serves as the foundational language. It also connects arithmetic with computer science concepts such as bit manipulation and data encoding .

To determine if a year is a leap year, check if it is divisible by 4 but not by 100, unless it is divisible by 400. This logic accounts for the calendar's need to synchronize with Earth’s orbit, adding a day in February every four years, except for years divisible by 100, which are leap years only if divisible by 400. This rule ensures the calendar's long-term seasonal alignment .

Swapping two variables without using a third can be achieved using Python's tuple unpacking. For example, given variables a and b, you can swap their values using 'a, b = b, a'. This method leverages Python’s ability to handle tuples efficiently, making it concise and reducing the risk of errors associated with using an extra variable. Additionally, it improves readability and can enhance performance by minimizing memory usage .

To manually find the maximum element in a list, iterate through the list, compare each element with a current maximum, and update the maximum when a larger element is found. Initialize the maximum with the first element and loop through the remainder of the list. This algorithm is efficient for its simplicity and direct approach, adhering to the comparison model of O(n) complexity where n is the number of elements in the list .

Reversing a list manually involves iterating through the list while swapping elements symmetrically from both ends towards the center. This method deepens understanding of data structures by highlighting index manipulation, encouraging a closer examination of the list’s organization in memory. It emphasizes logical structuring of operations and reinforces the knowledge of time complexity, important in optimizing list operations in algorithm design .

A common method for counting vowels involves iterating over each character of the string and incrementing a counter whenever a character matches any vowel ('a', 'e', 'i', 'o', 'u'). It is crucial to consider case sensitivity, thus converting the string to lowercase at the start ensures that both uppercase and lowercase vowels are counted. Non-alphabet characters should be ignored, emphasizing the need for character type validation to maintain accuracy and efficiency in the count .

Finding the first non-repeating character requires handling data efficiently to minimize time complexity. This involves using data structures like hash tables for counting occurrences, allowing for quick lookups, and keeping track of insertion order or a secondary pass. It tests one's ability to balance optimal space usage with speed of access, as well as to organize and traverse string data effectively, a skill crucial for real-time data processing applications .

To find the smallest element in a list, iterate through each element and maintain a variable holding the smallest value found. Update the variable whenever a smaller element is encountered. This understanding is essential in computer science because it provides foundational knowledge in search algorithms and efficiencies associated with various data structures. It aids in optimizing other computational tasks requiring minimal resources .

You might also like