File tree
Expand file treeCollapse file tree7 files changed
+33
-15
lines changed 15-Digit_after_decimal_point
Expand file treeCollapse file tree7 files changed
+33
-15
lines changed Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | #Complete the function to return the first digit to the right of the decimal point.
|
2 | 2 | def first_digit(num):
|
3 |
| -return None |
| 3 | +return (((num%100)*100)%100)//10 |
4 | 4 |
|
5 | 5 |
|
6 | 6 |
|
7 | 7 | #Invoke the function with a positive real number. ex. 34.33
|
8 |
| -print(first_digit()) |
| 8 | +print(first_digit(1.79)) |
Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | #Complete the function to return the amount of days it will take to cover a route.
|
2 | 2 | #HINT: You may need to import the math module for this exercise.
|
| 3 | +import math |
3 | 4 |
|
4 | 5 | def car_route(n,m):
|
5 |
| -return None |
| 6 | +return math.ceil(m/n) |
6 | 7 |
|
7 | 8 |
|
8 | 9 | #Invoke the function with two intergers.
|
9 |
| -print(car_route()) |
| 10 | +print(car_route(700, 750)) |
Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | #Complete the function to return the respective number of the century
|
2 | 2 | #HINT: You may need to import the math module.
|
| 3 | +import math |
3 | 4 |
|
4 | 5 | def century(year):
|
5 |
| -return None |
| 6 | +return year//100 + 1 |
6 | 7 |
|
7 | 8 |
|
8 | 9 |
|
9 | 10 | #Invoke the function with any given year.
|
10 |
| -print(century()) |
| 11 | +print(century(1993)) |
Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | #Complete the function to return the total cost in dollars and cents of N cupcakes.
|
2 | 2 | #Remember you can return multiple parameters => return a, b
|
3 | 3 | def total_cost(d,c,n):
|
4 |
| -return None |
| 4 | +return d*n, c*n |
5 | 5 |
|
6 | 6 |
|
7 | 7 |
|
8 | 8 |
|
9 | 9 | #Invoke the function with three intergers: cost(dollars and cents) & number of cupcakes.
|
10 |
| -print(total_cost()) |
| 10 | +print(total_cost(20, 30, 5)) |
Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | #Complete the function to return the number of day of the week for k'th day of year.
|
2 | 2 | def day_of_week(k):
|
3 |
| - |
4 |
| -return None |
5 |
| - |
| 3 | +if (k == 1): |
| 4 | +return 4 |
| 5 | +if (k == 2): |
| 6 | +return 5 |
| 7 | +if (k == 3): |
| 8 | +return 6 |
| 9 | +if (k == 4): |
| 10 | +return 7 |
| 11 | +if (k == 5): |
| 12 | +return 1 |
| 13 | +if (k == 6): |
| 14 | +return 2 |
| 15 | +else: |
| 16 | +return 3 |
6 | 17 |
|
7 | 18 |
|
8 | 19 | #Invoke function day_of_week with an interger between 0 and 6 (number for days of week)
|
9 |
| -print(day_of_week()) |
| 20 | +print(day_of_week(1)) |
Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | #Complete the function to return how many hrs and min are displayed on the 24th digital clock.
|
2 | 2 | def digital_clock(n):
|
3 |
| -return None |
| 3 | +return n//60, n%60 |
4 | 4 |
|
5 | 5 | #Invoke the function with any interger (seconds after midnight)
|
6 |
| -print(digital_clock()) |
| 6 | +print(digital_clock(150)) |
Original file line number | Diff line number | Diff line change |
---|
|
1 |
| -# Your code here |
| 1 | +# Your code here |
| 2 | +x = int(input("coloca el numero para buscar su factorial")) |
| 3 | +fac = 1 |
| 4 | +for i in range(x, 0, -1): |
| 5 | +fac=fac*i |
| 6 | +print(fac) |
You can’t perform that action at this time.
0 commit comments