Basic - Level 1 Questions
Basic - Level 1 Questions
Input:
Input your First Name: Anushya
Page |2
Input:
Enter the Number: 100
Output:
Binary Equivalent of 100 is 0b1100100
Octal Equivalent of 100 is 0o144
Hexadecimal Equivalent of 100 is 0x64
-------------------------------------------------------------------------------------
P10: Write a Python program to print the ASCII value of a given character.
Input:
Enter a Single Character: A
Output:
ASCII equivalent of A is 65
Input:
Enter a Single Character: 5
Output:
ASCII equivalent of 5 is 53
Input:
Enter a Single Character: %
Output:
ASCII equivalent of % is 37
-------------------------------------------------------------------------------------
P11: Write a Python program to print the ASCII Character for the given
integer value.
Page |3
Input:
Enter a Number: 35
Output:
ASCII equivalent of 35 is #
Input:
Enter a Number: 125
Output:
ASCII equivalent of 125 is }
Input:
Enter a Number: 50
Output:
ASCII equivalent of 50 is 2
Input:
Enter a Number: 99
Output:
ASCII equivalent of 99 is c
-------------------------------------------------------------------------------------
P12: Write a Python program to read 5 numbers from the user and print
them in a single line as a comma separated values.
Input:
Enter the 1st Number: 10
Enter the 2nd Number: 20
Enter the 3rd Number: 30
Enter the 4th Number: 40
Enter the 5th Number: 50
Output:
10,20,30,40,50
-------------------------------------------------------------------------------------
P13: Write a Python program which accepts the radius of a circle from the
user and compute the area
Page |4
Input:
Enter the Radius: 1.1
Output:
Area = 3.8013271108436504
-------------------------------------------------------------------------------------
P14: Write a Python program to accept a filename from the user and print
the extension of that file.
Input:
myProgram.java
Output:
java
Input:
P1.py
Output:
py
-------------------------------------------------------------------------------------
P15: Write a Python program to get the volume of a sphere with radius 6.
The volume of the sphere is: V = 4/3 × π × r3 = π × d3/6
-------------------------------------------------------------------------------------
P16: Write a Python program to read two numbers from the user and swap
the values of both the numbers and display the values.
Input:
10
20
Output:
The value of x before swapping: 10
The value of y before swapping: 20
Input:
Page |5
Input:
Enter the Radius: 5.3
Output:
The area of the circle with radius 5.3 is: 88.244735
-------------------------------------------------------------------------------------
P19: Write a Python program to calculate the Simple Interest by taking the
values dynamically from the user. Formula: PNR/100
Input:
Enter the principal amount: Rs.25000
Enter the time(years): 2
Enter the rate: 5
Output:
The simple interest is: R 2500.0
-------------------------------------------------------------------------------------
P20: Write a Python program to dynamically read the height of a person in
centimetres and then converts the height to feet and inches and print them.
Note:
1 Feet = 12inches
1 Inch = 2.54cm
Input:
Enter your height in centimetres: 153
Page |6
Output:
Your height in inches is 60.28
Your height in feet is 5.02
-------------------------------------------------------------------------------------
P21: Write a Python program to read a number n from the user and
compute n+nn+nnn
Example: If the n = 5
5+55+555 = 615
Input:
Enter a number n: 5
Output:
The value is: 615
Input:
Enter a number n: 20
Output:
The value is: 204060
-------------------------------------------------------------------------------------
P22: Write a Python program read 2 Numbers and print their Quotient and
Remainder.
Input:
Enter the first number: 15
Enter the second number: 7
Output:
Quotient is: 2
Remainder is: 1
-------------------------------------------------------------------------------------
P23: Write a Python program to find the Square root of the given Number
Input: 8
Output: 2.828
Input: 15
Output: 3.873
Input: 25.83
Page |7
Output: 5.082
-------------------------------------------------------------------------------------
P24: Write a Python program to calculate the Area of a Triangle
Formula:
If a, b and c are three sides of a triangle. Then,
s = (a+b+c)/2
area = √(s(s-a)*(s-b)*(s-c))
-------------------------------------------------------------------------------------
P25: Write a Python program to solve the Quadratic Equation
Formula:
ax2 + bx + c = 0, where
a, b and c are real numbers and
a≠0
-------------------------------------------------------------------------------------
P26: Write a Python program to generate a Random Number between the
range of 1 to 10 and print it.
-------------------------------------------------------------------------------------
P27: Write a Python program to convert Kilometres to Miles
Input: 5
Output: 3.11
-------------------------------------------------------------------------------------
P28: Write a Python program –
• Convert Celsius to Fahrenheit → fahrenheit = (celsius * 1.8) + 32
• Convert Fahrenheit to Celsius → celsius = (fahrenheit - 32) / 1.8
-------------------------------------------------------------------------------------
P29: Write a Python program to calculate the Compound Interest
Formula:
P(1 + R / 100)T
where,
• P – Principle amount
• R – Rate of the interest, and
• T – Time in the years
Input:
1000
5
Page |8
2
Output:
Principle amount : 1000.0
Interest rate : 5.0
Time in years : 2.0
compound Interest : 1102.5
-------------------------------------------------------------------------------------
P30: Write a program to input a single digit (n) and print a 3 digit number
created as e.g., if you input 7, then it should print 789.
Note: Assume that the input digit is in range 1-7.
-------------------------------------------------------------------------------------
P31: Write code to obtain fee amount from the user and then calculate fee
hike as 10% of fees and print the newly revised amount.
Input: 28500
Output: 31350.0
-------------------------------------------------------------------------------------
P32: Write a program that accepts cost of goods sold (cgos) revenue
generated, operating costs (oc) and prints Gross profit, net profit and net
profit percentage.
Hint: Net profit = Revenue – cgos – oc
Input:
500
3000
300
Output:
Gross profit is 2500
Net profit is 2200
Net profit percentage is 73.33333333333333
-------------------------------------------------------------------------------------
P33: Write a Python program to read a Number n and print n^2, n^3 and
n^4
Input: 5
Output: 5 25 125 625
-------------------------------------------------------------------------------------
Page |9
P34: Write a Python program to print the documents (syntax, description etc.) of
Python built-in function(s).
-------------------------------------------------------------------------------------
P35: Write a Python program to print the calendar of a given month and
year.
-------------------------------------------------------------------------------------
P36: Write a Python program to calculate number of days between two
dates.
date(2014, 7, 2)
date(2014, 7, 11)
Output:
9
-------------------------------------------------------------------------------------