Python Coding Challenge -2
Question 1:
Scenario:
A company gives bonuses based on employee salary.
Task:
Write a Python program to calculate the bonus amount using given rules.
Example:
Input: 45000
Output: Bonus = 3150
Question 2:
Scenario:
An online platform categorizes users by age group.
Task:
Write a program to classify the user as Minor, Adult, or Senior.
Example:
Input: 65
Output: Senior
Question 3:
Scenario:
A payment system processes only numbers divisible by both 3 and 5.
Task:
Write a program to check if a number satisfies this condition.
Example:
Input: 15
Output: Yes
Question 4:
Scenario:
A system validates login credentials.
Task:
Write a program to verify username and password.
Example:
Input: admin, 1234
Output: Login Successful
Question 5:
Scenario:
A data analytics tool needs to identify the highest value.
Task:
Write a program to find the largest among three numbers.
Example:
Input: 10, 25, 15
Output: 25
Question 6:
Scenario:
A calendar application checks leap years.
Task:
Write a program to determine whether a year is a leap year.
Example:
Input: 2024
Output: Leap Year
Question 7:
Scenario:
A text processing tool identifies vowels.
Task:
Write a program to check if a character is a vowel.
Example:
Input: e
Output: Vowel
Question 8:
Scenario:
An exam system assigns grades.
Task:
Write a program to assign grade based on marks.
Example:
Input: 82
Output: B
Question 9:
Scenario:
A finance tool categorizes numbers.
Task:
Write a program to check if a number is positive, negative, or zero.
Example:
Input: -5
Output: Negative
Question 10:
Scenario:
A ticket booking system calculates ticket price based on day.
Task:
Write a program to determine ticket price.
Example:
Input: Sunday
Output: 200
Question 11:
Scenario:
A store tracks daily sales.
Task:
Write a program to calculate total weekly sales.
Example:
Input: [100,200,150,300,250,400,100]
Output: 1500
Question 12:
Scenario:
A system filters even numbers.
Task:
Write a program to print all even numbers from 1 to N.
Example:
Input: 10
Output: 2 4 6 8 10
Question 13:
Scenario:
A report counts high-value entries.
Task:
Write a program to count numbers greater than 50 in a list.
Example:
Input: [10,60,30,80]
Output: 2
Question 14:
Scenario:
A security system reverses numeric codes.
Task:
Write a program to reverse a number.
Example:
Input: 1234
Output: 4321
Question 15:
Scenario:
A system validates palindrome numbers.
Task:
Write a program to check if a number is palindrome.
Example:
Input: 121
Output: Palindrome
Question 16:
Scenario:
A math tool calculates factorial.
Task:
Write a program to compute factorial of a number.
Example:
Input: 5
Output: 120
Question 17:
Scenario:
A learning app generates multiplication tables.
Task:
Write a program to print multiplication table.
Example:
Input: 3
Output: 3 6 9 ... 30
Question 18:
Scenario:
A system analyzes numeric inputs.
Task:
Write a program to find sum of digits.
Example:
Input: 123
Output: 6
Question 19:
Scenario:
A validation tool counts digits.
Task:
Write a program to count number of digits.
Example:
Input: 45678
Output: 5
Question 20:
Scenario:
A data processor finds maximum value.
Task:
Write a program to find max without using built-in functions.
Example:
Input: [5,8,2]
Output: 8
Question 21:
Scenario:
A text analyzer counts vowels.
Task:
Write a program to count vowels in a string.
Example:
Input: "hello"
Output: 2
Question 22:
Scenario:
A validation tool checks palindrome strings.
Task:
Write a program to check if string is palindrome.
Example:
Input: "madam"
Output: Yes
Question 23:
Scenario:
A cleaning tool removes spaces.
Task:
Write a program to remove spaces from string.
Example:
Input: "hello world"
Output: "helloworld"
Question 24:
Scenario:
A system tracks character frequency.
Task:
Write a program to count occurrences of a character.
Example:
Input: "banana", 'a'
Output: 3
Question 25:
Scenario:
A formatter converts text.
Task:
Write a program to convert string to uppercase without built-in methods.
Example:
Input: "abc"
Output: "ABC"
Question 26:
Scenario:
A parser extracts longest word.
Task:
Write a program to find longest word.
Example:
Input: "I love programming"
Output: "programming"
Question 27:
Scenario:
A masking tool hides vowels.
Task:
Write a program to replace vowels with *.
Example:
Input: "hello"
Output: "h*ll*"
Question 28:
Scenario:
A system checks anagrams.
Task:
Write a program to verify two strings are anagrams.
Example:
Input: "listen", "silent"
Output: True
Question 29:
Scenario:
A tool counts words.
Task:
Write a program to count words in sentence.
Example:
Input: "Python is great"
Output: 3
Question 30:
Scenario:
A data cleaner identifies duplicates.
Task:
Write a program to find duplicate characters.
Example:
Input: "programming"
Output: "r g m"
Question 31:
Scenario:
A system removes duplicate entries.
Task:
Write a program to remove duplicates from list.
Example:
Input: [1,1,2,3]
Output: [1,2,3]
Question 32:
Scenario:
A tool finds common users.
Task:
Write a program to find common elements between lists.
Example:
Input: [1,2,3], [2,3,4]
Output: [2,3]
Question 33:
Scenario:
A ranking system finds second top score.
Task:
Write a program to find second largest element.
Example:
Input: [10,20,5,15]
Output: 15
Question 34:
Scenario:
A report counts unique items.
Task:
Write a program to count unique elements.
Example:
Input: [1,1,2,3,3]
Output: 3
Question 35:
Scenario:
A system sorts data manually.
Task:
Write a program to sort list without using sort().
Example:
Input: [3,1,2]
Output: [1,2,3]
Question 36:
Scenario:
A converter changes data structure.
Task:
Write a program to convert list to tuple.
Example:
Input: [1,2,3]
Output: (1,2,3)
Question 37:
Scenario:
A system merges sets.
Task:
Write a program to find union of two sets.
Example:
Input: {1,2}, {2,3}
Output: {1,2,3}
Question 38:
Scenario:
A tool finds common set elements.
Task:
Write a program to find intersection.
Example:
Input: {1,2}, {2,3}
Output: {2}
Question 39:
Scenario:
A sequence is missing a number.
Task:
Write a program to find missing number.
Example:
Input: [1,2,4,5]
Output: 3
Question 40:
Scenario:
A system rotates list data.
Task:
Write a program to rotate list by one position.
Example:
Input: [1,2,3]
Output: [3,1,2]
Question 41:
Scenario:
A system stores student marks.
Task:
Write a program to find student with highest marks from dictionary.
Example:
Input: {"A":80,"B":95,"C":78}
Output: B
Question 42:
Scenario:
A billing system calculates totals.
Task:
Write a function to calculate total bill amount.
Example:
Input: [100,200,300]
Output: 600
Question 43:
Scenario:
A system checks key existence.
Task:
Write a program to check if key exists in dictionary.
Example:
Input: {"a":1,"b":2}, "a"
Output: Yes
Question 44:
Scenario:
A function processes numbers.
Task:
Write a function to return square of a number.
Example:
Input: 5
Output: 25
Question 45:
Scenario:
A system groups data.
Task:
Write a program to count frequency of elements using dictionary.
Example:
Input: [1,2,2,3]
Output: {1:1,2:2,3:1}
Question 46:
Scenario:
A module performs calculations.
Task:
Create a module with a function to add two numbers and import it.
Example:
Input: 2,3
Output: 5
Question 47:
Scenario:
A report filters values.
Task:
Write a function to return all even numbers from list.
Example:
Input: [1,2,3,4]
Output: [2,4]
Question 48:
Scenario:
A dictionary needs sorting.
Task:
Write a program to sort dictionary by keys.
Example:
Input: {"b":2,"a":1}
Output: {"a":1,"b":2}
Question 49:
Scenario:
A system merges two dictionaries.
Task:
Write a program to merge dictionaries.
Example:
Input: {"a":1},{"b":2}
Output: {"a":1,"b":2}
Question 50:
Scenario:
A reusable function is required.
Task:
Write a function to check prime number.
Example:
Input: 7
Output: Prime