Posted at 15:42h
in
Uncategorized
by admin
Question:
write a program to ask user about the date(year, month and day), then calculate the day of the year.
Sample input:
Year: 2016
Month: 6
Day: 23
Sample output:
Day of the year: 175
Hint:
You need consider leap years and non leap years, in order to do easier calculation, you may...
Question:
Input a string. You must using a stack, reverse the string and print it.
Sample Input 1:
Enter String to reverse : Apple
Sample Output 1
elppA
Sample Input 2
Orange
Sample Output 2
eganrO...
Posted at 02:07h
in
Uncategorized
by admin
Question:
The factorial function (symbol: !) says to multiply all whole numbers from our chosen number down to 1.
Examples:
4! = 4 × 3 × 2 × 1 = 24
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040
1! = 1
Factorial is not defined for...
Posted at 02:03h
in
Uncategorized
by admin
Question:
Use the recursion we have learn in the class, please try to create a function to recursively calculate the total of 1 + 2 + …. (n-2) + (n-1) + n
def total(n):
# please write you program below
total(int(input('Please enter a number:')))
Class Notes:
All...
Posted at 05:56h
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...
Question 1:
You are playing paintball on a 1000 × 1000 square field. A number of your opponents are on the field hiding behind trees at various positions. Each opponent can fire a paintball a certain distance in any direction. Can you cross the field without...