Description
Q1) Write a Python program that accepts the radius of a circle from the user and computes the area.
The output should be formatted to two decimal points. Include error handling. Hint: the area of a circle
= π.r2
Q2) Write a Python program that accepts a sequence of comma-separated numbers from the user and
generates a list and a tuple with those numbers.
Q3) Write a Python program that accepts a number and calculates its factorial. No built-in function
should be used.
Q4) Write a Python program to calculate number of days between two dates. The dates should be
entered in the format: mm/dd/yyyy. Do not use any built-in function.
Q5) Write a Python program that finds if a given number is a multiple of 4.
Q6) Write a Python program to count how many times a given number occurred in the list [4, 6, 7, 2, 11,
6, 4, 2, 3, 9, 8, 5, 6, 3, 4, 7, 3]. If the number is not in the list your program prints 0. Do not use any builtin function or method.
Q7) Write a Python program to sum all elements in a given tuple. Your program should ignore all nonnumerical values. No built-in function is allowed.
Q8) Write a Python program to calculate the cardinality of the superset of a given set.
Q9) Write a Python program to compute the greatest common divisor (GCD) of two positive integers.
Q10) Write a Python program to compute the distance between two given points (x1, y1, z1) and (x2, y2,
z2).
Q11) Write a Python program that extracts all digit characters from a string into one string.
Q12) Write a python program to sum the first n positive integers in a given list.
Q13) Write a Python program that calculates the BMI (Body Mass Index) = weight (lb) / [height (in)]2 x
703 for a person and prints a message based on the following table:
Below 18.5 Underweight
18.5 – 24.9 Normal or Healthy Weight
25.0 – 29.9 Overweight
30.0 and Above Obese
Q14) Write a Python program to calculate the sum of the digits in an integer.
Q15) Write a Python program to sort a list of given strings alphabetically. Don’t use any built-in function
or method.
Q16) Write a Python program to check if a given number is integer or float. Do not use any built-in
function for numerical objects. For example: 4.0 is float, 3 is integer, 2.8 is float,…etc
Q17) Write a Python program that accepts a list of equal number of strings and numerical values. Create
a dictionary from the list where one number is a key for one string.
Q18) Write a Python program that finds the minimum numerical value in a tuple. The tuple may contain
non-numerical elements as well. Do not use any built-in function.
Q19) Write a Python program to calculate how many bits is required to represent a given positive
integer.
Q20) Write a Python program to check whether a given IP address is valid or not. The format of a valid IP
address is ddd.d[dd].d[dd].d[ddd] where d is a digit and [] means optional. For example, the following
are valid IP addresses: 321.22.434.56, 123.5.6.7890,…etc. examples of invalid IP addresses:
12.22.34.556, 9.222.34.1, 123.4567.23.1,…etc.
How to submit
Through blackboard. No hard copy is accepted. The system will close after 11:59PM and you will
not be able to turn it in. No late submission is accepted unless you receive instructor’s approval
no less than two days before the due date.