Programming challenge description:
Write a program that, given two clock times, prints out the absolute number of minutes between them.
Input:
Your program should read lines from standard input. Each line contains two wall clock times separated by a hyphen. Wall clock time is defined as hh:mm followed by AM' or 'PM', e.g. '09:05 AM'
Output:
Print to standard output the number of minutes between the two times from standard input. Print out each result on a new line.
Test 1
Test Input
10:00 AM - 11:00 AM
Expected Output
60
Test 2
Test Input
1:00 PM - 11:00 AM
Expected Output
1320
i have created 2 function
1. to change 12 hour format to 24 hour format
2. to calculate minutes
1. python code
def convert24(str1):
''' this function converts 12 hour clock time to 24 hour clock time
'''
if str1[-2:] == "AM" and str1[:2] == "12":
return "00" + str1[2:-2]
elif str1[-2:] == "AM":
return str1[:-2]
elif str1[-2:] == "PM" and str1[:2] == "12":
return str1[:-2]
else:
return str(int(str1[:2]) + 12) +
str1[2:-2]
def minute(x):
''' this function finds difference between 2 clock'''
#changing time to 24 hour format
first_clock=convert24(x[:7])
Second_clock=convert24(x[-7:])
#changing hour to minute
first_clock_minutes=int(first_clock[:2])*60+int(first_clock[-2:])
Second_clock_minutes=int(Second_clock[:2])*60+int(Second_clock[-2:])
#calculating minute differences
if first_clock_minutes > Second_clock_minutes:
return (24*60-first_clock_minutes+Second_clock_minutes)
return Second_clock_minutes-first_clock_minutes
print('enter the input in following form example')
print('10:00AM-11:00AM')
x=input('enter time whose difference u need to find\n')
print(minute(x))
sample screenshot
Programming challenge description: Write a program that, given two clock times, prints out the absolute number...
C++
Write a program that asks for a number and then prints as many
lines as the user inputs. Each line contains as many pairs of
characters ("*#") as the number of this line. It should look like
the right half of a pyramid. Your version of the program must print
the same result as the expected output. To to this lab, you must
use two do-while loops.
Two exceptions:
When the user inputs a number less than 1, then...
using C programming
Date Write a program that reads a month and a day in that month and prints the date in format "month day". The input is two integers, one between 1 and 12 (inclusive) and one between 1 and 31 (inclusive) and the output is a single line in format "month day". For example, for input 2 10 the program will print "February 10th". The day will always have the ordinal indicator, e.g. 1st, 2nd, 3rd, 4th. Example...
[loops] Write a java program that accepts a number, as command line argument and prints out “Hello, World!” that many times using a for loop. E.g. if the input number is 3, the program outputs: Hello, World! Hello, World! Hello, World! Keep it simple, please use the argument, not interact with the console. Thanks
HI C PROGRAMMING COULD YOU,, Rewrite the program to have it display the time on the second line of the display, using the HH:MM:SS format. Use the 24-hour format for the hours, in other words, have the time go from 00:00:00 to 23:59:59. #include<LiquidCrystal.h> LiquidCrystal LcdDriver(11, 9, 5, 6, 7, 8); int minutes = 27; //These global integers keep the value of the clock int sec = 10; int hr = 10; const long interval = 1000; //This interval is...
Write a program (python) that multiplies two hard-coded numbers, then prints the individual numbers out and prints their product out, all on separate lines. You can choose the two numbers that are multiplied together. Make a copy of previous exercise then modify it to print output exactly like this, rather than just the numbers on separate lines: 10 x 7 = 70 Do this using the string.format() function discussed in the lecture.
write the program with the language NODEJS need help Programming challenge, screenshot your work and output. Description A positive integer is a palindrome if its decimal representation (without leading zeros, is a palindromic string (a string that reads the same forwards and backwards). For example, the number 5, 77, 363, 4884, 11111, 12121 and 349943 are palindromes A range of integers is interesting if it contains an even number of palindromes. The range [L, R], with L <= R, is...
Parallelogram Program
Write a program that prints the following parallelogram pattern
given the the following two inputs.
Here are the rules:
Your program must work with any length greater than 1.
Your program must use the character the user inputs to draw the
parallelogram.
Your program must not use global variables or global code other
than a call to main().
Your program output must match my out
exactly. I have provided you with the
strings you need for the output...
it's in C programming language
3. Write a program to find out if the first two bits of an input hex number is 11and will print "the first two bits are ones" 4- Write a program that will perform the following: Check the first two numbers of an input data if they are 11 and will print "open door 1" if so, otherwise Check the last two bits of that number if they are 11 and print" Open door 2...
POD 3: Tick Tock Instructions There are 24 hours in a day, but we all think about them differently. Some people and places in the world work with a 24-hour clock that goes from 0:00 to 23:59, while others work with a 12-hour clock that goes from 12.00AM to 11:59PM 24-hour clock 0.00 (midnight) 1200 (noon) 23:59 (one minute before midnight), A COLLAPSE 12-hour clock: *12.00 AM" (midnight) *12:00 PM" (noon) "11:59 PM" (one minute before midnight), You are going...
IN C#.Develop a program that prints out the location of the largest value in a two-dimensional array. The largest values may appear more than once in the array, so you must only print out the first instance. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints...