Posted at 00:42h
in
Uncategorized
by admin
Question:
The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult’s health. The doctor measures the patient’s height (in meters) and weight (in kilograms), then calculates the BMI using the formula
BMI = weight / (height * height)
Write a program which...
Posted at 00:40h
in
Uncategorized
by admin
Question:
Write a method that reads in three angles (in degrees). State the type of the triangle based on the conditions below:
If all three angles are 60, output Equilateral.
If the three angles add up to 180 and exactly two of the angles are the...
Posted at 00:34h
in
Uncategorized
by admin
Question:
You have come up with the following compression technique: for each symbol, write down the number of times it appears consecutively, followed by the symbol itself. This compression technique is called run-length encoding.
Given a sequence of characters, write a program to encode them in this...
Posted at 00:29h
in
Uncategorized
by admin
Question:
Create the following * pattern image base on your input
Hint:
Remember when we multiply a string by a number, the string is repeated the number times.
>>> '*' * 10
'**********'
Also you would need 2 for loops to solve the question
Sample Input 1:
3
Sample Output 1:
***
**
*
*
**
***
Sample Input 2:
5
Sample Output...
Question:
Write a code that prints the multiplication table of a number. Use recursion, the code shouldn’t have any for loop or while loop
Sample Input:
3
Sample Output:
3X1=3
3X2=6
3X3=9
3X4=12
3X5=15
3X6=18
3X7=21
3X8=24
3X9=27
3X10=30...
Posted at 00:19h
in
Uncategorized
by admin
Question:
Write a program to ask the user for five names. The program should store the names in a list, and print them all out at the end. It should look something like this:
Sample input:
Enter 5 names:
Tony
Paul
Nick
Michel
Kevin
Sample output:
The names are Tony, Paul, Nick, Michel, Kevin
Hint:
You can...