Python 3.4 Human readable time intervals problem
![Write the function readable-interval that takes a string consisting of a human-readable time interval Homework #3 CSE 101 Spring 2017 Page 3 and converts it into a list of six integers, given in this order: of years, of months, t of days, #of hours, of minutes, of seconds] The input values stored within the string can be quite scrambled and consist of multiple, repeated time components (days, months, etc.), as shown in the examples below. If a time component appears more than once, the values are be added. The time units might be given in singular or plural form (e.g., month and months are both valid). There will always be at least (but not necessarily exactly) one space between the tokens (i.e., components) of the string. Examples: Function Call: readable-interval 1 year 2 months 3 seconds) Return Value: 1, 2, 0, 0, 0, 31 Function Call: readable-interval 1 second 2 years 3 seconds 7 months 6 days Return Value: [2, 7, 6, 0, 0, 4 Function Call 4 hours 17 minutes) readable interval 1 days 4 days 3 years Return Value: 13, 0, 5, 4, 17, 01 Function Call readable interval 6 hours 20 minutes 421 seconds Return Value: [0, 0, 0, 6, 20 421] Function Call readable interval 0 days 0 months 7 months 18 years) Return Value: 18 7, 0, 0, 0, 01](http://img.homeworklib.com/questions/cccb4410-12ab-11ec-bebd-c13fd6cd62f3.png?x-oss-process=image/resize,w_560)
I really need help with this problem. I don't know how to start and what method will be most helpful and easy.
![Program: def readable interval(intervalstring): value = interval-string Split( ) interval= [0, 0, 0, 0, 0, 0] I for i in ra](http://img.homeworklib.com/questions/cd94b660-12ab-11ec-b59e-bf0febd3c8ce.png?x-oss-process=image/resize,w_560)

![Sample output: [GCC 4.8.2] on linux [2, 7, 6, e, e, 4] [3, θ, 5, 4, 17, θ] [a, θ, θ, 6, 28, 421] [18, 7, θ, θ, θ, θ]](http://img.homeworklib.com/questions/ce590e30-12ab-11ec-aa28-e544e09d28d9.png?x-oss-process=image/resize,w_560)
Editable code:
def readable_interval(interval_string):
value = interval_string.split(" ")
interval = [0, 0, 0, 0, 0, 0]
for i in range(len(value)):
if i % 2 != 0:
if value[i] == "years" or value[i] == "year":
interval[0] += int(value[i - 1])
elif value[i] == "month" or value[i] == "months":
interval[1] += int(value[i - 1])
elif value[i] == "day" or value[i] == "days":
interval[2] += int(value[i - 1])
elif value[i] == "hour" or value[i] == "hours":
interval[3] += int(value[i - 1])
elif value[i] == "minute" or value[i] == "minutes":
interval[4] += int(value[i - 1])
elif value[i] == "second" or value[i] == "seconds":
interval[5] += int(value[i - 1])
return interval
print(readable_interval('1 year 2 months 3 seconds'))
print(readable_interval('1 second 2 years 3 seconds 7 months 6
days'))
print(readable_interval('1 days 4 days 3 years 4 hours 17 minutes
'))
print(readable_interval('6 hours 20 minutes 421 seconds'))
print(readable_interval('0 days 0 months 7 months 18 years'))
Python 3.4 Human readable time intervals problem I really need help with this problem. I don't...
i need #6 but i believe #6 function needs to call #5 function. I
would like this in C language, and have no pointers, arrays or
strings (on function calling and parameters). Thanks! I have
attached the other functions that you might need to call for
function 6
1. Write and test a function called is_multiple_of that takes a
integer n1, integer n2 and determines whether the second argument
(n2) is a multiple of the first argument (n1). The function...
need help with balancing brackets in python. I don't really
understand it much.
an unbalanced one will look like this: (<x)>(())()
For this exercise, you must write a function called balanced brackets brackets in the string, that is: '(' , ') and >', are correctly balanced. This function will be passed a string as an input, and you must check that any parentheses or angled Here are a few examples of strings where brackets are correctly balanced: a (<bcd>ef)g abcde...
I need help implementing 3 function prototypes with using operator overloading in a class. I have bolded the section I need help with since the cpp file is bigger than I expected. Any comments throughout would be extremely helpful. Time.cpp file #include "Time.h" #include #include #include // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for...
In (11): def convert time time in seconds) <Fill in the docstring for this function 0 # <Add your code below. Note that the return value is currently arbitrary # Note that number format in the format string below> + hours = 5 minutes - 38 seconds = 12 designation - "PM" return "{:62d}: {:02d):{:02dH)".format( hours, minutes, seconds, designation # Tests print( convert time 7)) print convert time 2 • 60 60 + 7)) print( convert time( 12 * 60...
I need help implementing class string functions, any help would be appreciated, also any comments throughout would also be extremely helpful. Time.cpp file - #include "Time.h" #include <new> #include <string> #include <iostream> // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for the hours, // an integer variable for the minutes, and a char variable for...
PYTHON 3!!!!! Write a function: class Solution { public String solution(String T); } that, given a string T, returns the latest valid time that can be obtained from T, as a string in the format "HH:MM", where HH denotes a two-digit value for hours and MM denotes a two-digit value for minutes. Examples: 1. Given T = "2?:?8", the function should return "23:58". 2. Given T = "?8:4?", the function should return "18:49". 3. Given T = "??:??", the function...
Need some assistance of
reorganizing this whole program. I have the right code for
everything I just need help on putting all the codes in the right
spot so it can come out to the correct output.
output is supposed to look like this:
1 \\ user inputs choice to convert 12 to 24
8 \\ user inputs 8 for hours
30 \\ user inputs 30 for minutes
20 \\ user inputs 20 for seconds
AM \\ user inputs AM...
use matlab to solve it
1. Write a function called MyTimeConversion with the following function declaration line. begin code function [Hours, Minutes, Message] = MyTimeConversion (TotalMinutes) end code The input argument TotalMinutes should be a nonnegative scalar integer representing the total number of minutes in a specified time interval. The output arguments Hours and Minutes should be nonnegative scalars such that Hours*60 + Minutes = TotalMinutes and the value of Minutes must be less than 60. The output argument Message...
I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n): lst = [] for i in range(1,n+1): val = float(input('Enter float '+str(i)+': ')) lst.append(val) return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...
In this exam, you will design and implement a Python class called 'Date according to the following API specifications. • Do NOT use any existing classes in your answer such as datetime. . You will design your class so that it operates correctly on another planet, where the total days in a year, total days in a month, and months per year may be different. For our planet Earth, you will assume that a year has 360 days and all...