Basic Programming questions:
1. Write a program to calculate the cube of a number
2. Write a program to calculate the area of a triangle.
Formula: ½ * b * h
3. Write a program to calculate the square of a number
4. Write a program to calculate the discounted price of a product. The
cost of the product is 75. The discount applied to the product is
25%.
5. Write a program to calculate your age using the birth year and the
current year. Also calculate your age in months.
6. Write a program to get the remainder when a number is divided by
another.
7. Write a program to get the integer part when a number is divided
by another
8. Write a program to get your first name, second name and surname
in three variables and then join them.
9. Write a program to get the power of any number.
10. Write a program to calculate the area of a square.
11. Write a program to calculate the area of a circle.
12. (use import math and [Link] when using Python code)
13. Write a program to swap between two numbers
14. Write a program calculate speed = distance * time
15. Write a program to calculate the total cost of products by using
weight of the products and the number of products purchased.
16. Write a program to convert hours to minutes and minutes to
seconds
Conditional Statements(IF, multiple IFs, Boolean
operators)
17. Write a program to check if the student is eligible for scholarship.
If the student has achieved marks above 75, then display the
student is eligible for 25% scholarship, else display the student
gets a scholarship of 10%.
18. Write a program to check if a number is divisible by 5
19. Write a program to check if a number is even or odd
20. Write a program to check if the entered number is greater than,
lesser than or equal to each other.
21. Write a program to display the grades of a student. If the student
scores above 80, then the student gets an A grade, else a B grade
22. Write a program to check if the age of a person is older than 18.
If older, then display “Old enough to drive” else, display, “Not old
enough to drive”
23. Write a program to check if the month entered by the user is
“December”, then display “Yay! Its Christmas time!” else, display
“Oh! Its some other month”
24. Write a program to check if the age of the child is older than 10,
then display “Ticket cost is 2500” else, display, “the ticket cost is
1250”
25. Write a program to to display the cost of the fuel type selected. If
the fuel type is Petrol, then display “Pay 104 Rs” and if the fuel
type is Diesel, then display “Pay 90 Rs”. If the fuel type is CNG,
then display “Pay 50 Rs” otherwise display “Its an electric car,
charge the car”
26. Write a program to perform the addition and subtraction of two
numbers. Get the user to enter a choice and input two numbers. If
the choice entered by the person is 1, then addition should be
performed and the result should be displayed. Else, subtraction
should be performed.
27. Write a program to display “Left”, “Right”, “Straight” depending on
the letter input given by the user. If the user inputs “L”, then display
“Left”, else if the user inputs “R”, then display “Right”, else if the
user inputs “S”, then display “Straight”. If the user inputs any other
letter, then display “I do not understand the letter input by the
user”. (You may change this question to accommodate the usage
of L or l, R or r etc…)
28. Write a program to perform mathematical operations based on
the number selected. Take input of two numbers a and b. Make
the user enter a choice. If the choice entered by the user is 1, then
perform an addition and display the result. If the choice entered by
the user is 2, then perform subtraction. If the choice is 3, then
multiplication and if the choice is 4, then division. If the user’s
choice is none of these, then display “wrong option chosen.
29. Write a program to display the direction that you are facing. Make
the user enter a value from 0 to 360. If the value entered by the
user is greater than 315, then display “North”, else if the value is
greater than 225, then display “West”, else if the value is greater
than 45, then display “South”, else “East”.
30. Create a program to check if the person can be given entry into a
park. Take age and the possession of an id card as inputs from the
user. If the age of the person is greater than 16 and the person
has an id card, then display, entry permitted. Otherwise, display
“entry denied”
31. Create a program to take inputs from the user, the number of
subjects and the final grade. If the number of subjects is greater
than 6 and the final grade is Merit, then display the result “You will
be awarded the ICE award” otherwise, display “Not eligible for the
award”
32. Write a program to display if the person is eligible to take the Nitro
ride. If the height of the person is more than 100 and age of the
person is more than 10, then display “You are permitted to take the
ride” else if the person’s height is more than 100 and age is less
than 10, display “you have to be accompanied by a parent”. Else if
the person’s height is less than 100 and age is more than 10,
display “You have to be accompanied by a parent” else display
“Sorry you cant take the ride”.
33. Write a program to display “Allowed to drive” if the person’s age is
more than 18 and has a valid driving licence. Take the input for
age and “Y” for having a valid driving licence. Otherwise, display
“Allowed to drive”.
34. Write a program to take the input for a color and name of a fruit. If
the color is “Red” and fruit is “Apple”, display “Oh it’s a Red Apple”.
Otherwise, display the fruit and the color whatever was entered.
35. Write a program to check the validity of the data entered. In the
webpage, the person is supposed to enter an age other than 20. If
he does not enter 20, then it should display “Valid entry of data”.
Else display “” Not allowed to enter 20.
36. Write a program to display the text “Allowed to take the ride” if the
child’s height is over 4 feet and the age is over 8. If these are not
satisfied, then display “Not allowed to take the ride”.
37. Write a program to check if he child has not entered the number
67, the display “you dint follow the trend”. Otherwise, display “SIX
SEVEN”
38. Write a program to check if the character entered is N or n. Then
display, “Go to the North corner of the classroom” else display “you
may wander around”
39. Create a pseudocode to check if the car’s fuel is Petrol or Diesel.
If the fuel used is Petrol, then display “We are running short of
Petrol! Please find another filling station”. If the fuel used is Diesel,
then display “Yay!, we are filling diesel for free today….”
40. Create a pseudocode to display the generation name. If the birth
year is after 2000, then display, “Yo!, Gen Z” , otherwise display
“Oldies!!!....”
Functions with or without parameters
1. Write a program to add two number using functions. Write programs
for these operations also. (Subtract, multiply, divide, power of)
2. Write a program to find the area of a square using functions.
3. Write a program to find the area of a rectangle using functions.
4. Write a program to accept your first name and last name in a
function and then display your full name in the main program.
5. Write a program to accept your first name and favourite colour in a
function and then display “My name is ____________” and my
favourite color is _______ in the main program.
6. Write a program to create a function for area and perimeter of a
rectangle. If the user enters, “A”, then the function area() should
execute. Otherwise, the function perimeter() should execute.
7. Write a program to create a calculator. Let the user enter a choice of
1, 2,3 or 4. If the user enters 1, then the function for add() should
work. If the user enters 2, then subtract(), 3 for multiply() and 4 for
division(). If the user enters, any other option, the display “wrong
choice”
8. Write a program to display the area of a square and rectangle. If the
user enters his choice as S, then display the area of square
otherwise display the area of a rectangle. Both the area of the
shapes should be a function.
9. Write a program to calculate the area of a rectangle using functions.
The values length and breadth must be passed as parameters in the
function.
10. Write a program to calculate the perimeter of rectangle using
functions. The values length and breadth must be passed as a
parameter in the function.
11. Write a program to calculate the area of a square using functions.
The value side must be passed as parameter to the function.
12. Write a program to calculate the perimeter of square using functions.
The value of the side must be passed as a parameter in the function.
13. Write a program to check if the number is even or odd using
functions. Define a function in which a number is passed as a
parameter. In the function, use the mathematical operation to get the
remainder. Return the remainder to the main program to then check
if the number passed was even or odd.
14. Write a program to create a simple calculator. If the user selects 1,
then the function of addition should work; if the user selects 2, then
the function for subtraction should work; if the user selects 3, then the
function for multiplication should work ; if the user selects 4, then the
function for division should work. If any other value is entered, then it
should display “Wrong choice selected”. The values used for the
calculator should be passed as parameters in the functions.
15. Write a function definition for area which takes only one parameter.
This function should return the area of a circle. Remember to include
the program library for using the value of pi.
16. Write a procedure definition multiply which does not pass
parameters.
17. Write a procedure definition calculate with two parameters.
18. Write a function definition calc with no parameters.
19. Write how a function will be called in the program. The function
name is calc with no parameters.
20. Write how a function with parameters will be called with two
parameters.
21. Write a function definition divide with two parameters passed and
returns the result of the values divided.
22. Write a program that adds two random numbers. The random
numbers generated should be between 10 and 20.
23. Write a program that acts according to the input given by the
user. If the option entered by the user is 1, then the area of the
square is calculated. If the option entered by the user is 2, then a
random number between 5 and 15 is generated. If the option is 3,
then a procedure star is executed. This procedure has no
parameters. This should print 5 stars; else you should select any
value between 1,2 and 3.