Question

but ime nd nt hour int min ナ eline -to-:- De tne the funchio on belre do convert the e suut ti12 harf our

kindly just answer part 1 and 2 i don't need whole code in c++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1-

def convert24(str1):

  

               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:8]

print("10:54 AM ")

Answer 2-

# Python program to convert time

def convert24(str1):


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:8]


print(convert24("12:54 AM "))

Add a comment
Know the answer?
Add Answer to:
kindly just answer part 1 and 2 i don't need whole code in c++ but ime...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is a c# assignment Please do not post just the code, I don't even know...

    This is a c# assignment Please do not post just the code, I don't even know how to start the project. Please explain step by step how I could complete this assignment. Thank you for your time! Create a database that stores baseball player information. You will have the following columns. You will need to have the ability to add rows and display the records. You may use LINQ or Given example using an access accdb file... Name string Batting...

  • Hi , I need your help please. I don't know how to do this . I...

    Hi , I need your help please. I don't know how to do this . I posted this question before and some sweet person did all this work below but I don't really understand ( i also don't know if it's right)and he also did the GRAPH on paper .I Need the GRAPH on EXCEL PLEASE. If you kindly maybe type it so I can fill this chart that would be really great ( I just gotta show some work...

  • What did I do wrong with this C++ code? Assume that we don't need to ask...

    What did I do wrong with this C++ code? Assume that we don't need to ask users for the number of students. #include <iostream> #include <iomanip> using namespace std; int main() { float *grades; // a pointer used to point to an array int size; int count = 0; // track the number of grade/student float grade; // the grade of a student float average, total; // average grade and total grades //**************start your code here************************ cout<<"How many student grades...

  • [C#] I need to convert this if/else statements into Switch I have the code for the...

    [C#] I need to convert this if/else statements into Switch I have the code for the if/else but now need to turn it into a switch. The Console.WriteLine and all that is fine. I just need to convert the if/else.      int x1, x2, y1, y2;                 Console.WriteLine("What is smallest value of x:");                 x1 = Convert.ToInt32(Console.ReadLine());                 Console.WriteLine("What is largest value of x:");                 x2 = Convert.ToInt32(Console.ReadLine());                 Console.WriteLine("What is smallest value of y:");                 y1 = Convert.ToInt32(Console.ReadLine());                 Console.WriteLine("What is largest value of y:");                 y2 =...

  • Java I just need the answer to the questions, not the whole implemented code please You have an object of the RandomAccessFile class named empRaf. It refers to a physical file that contains a company&...

    Java I just need the answer to the questions, not the whole implemented code please You have an object of the RandomAccessFile class named empRaf. It refers to a physical file that contains a company's employee records. Each employee record has: an int field named empID which points to its location in the file a 20 character last name a 15 character first_name a hire date stored as an int a 3 character job code The empID values begin at...

  • use for loop only, c++ i have most of it done, I just don't know how...

    use for loop only, c++ i have most of it done, I just don't know how to go by 10 on this line: for(int i = start;i<=end;i++) so you don't have to do the whole thing, just let me know how to go by 10 on the table. 4. Enter the table size (start, end): 10 100 10 XX.XX XX.XXXX.XX 20 xx.xxXX. 100 xX.xxxX.xxxx.xx € (Euro), £ (British Pound), ¥ (Yen)

  • I am given an input file, P1input.txt and I have to write code to find the...

    I am given an input file, P1input.txt and I have to write code to find the min and max, as well as prime and perfect numbers from the input file. P1input.txt contains a hundred integers. Why doesn't my code compile properly to show me all the numbers? It just stops and displays usage: C:\> java Project1 P1input.txt 1 30 import java.io.*; // BufferedReader import java.util.*; // Scanner to read from a text file public class Project1 {    public static...

  • Need some assistance of reorganizing this whole program. I have the right code for everything I...

    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...

  • Part 1: Python code; rewrite this code in C#, run the program and submit - include...

    Part 1: Python code; rewrite this code in C#, run the program and submit - include comments number= 4 guesscount=0 guess=int(input("Guess a number between 1 and 10: ")) while guess!=number: guesscount=guesscount+1 if guess<number: print("Your guess is too low") elif guess>number: print("Your guess is too high") else: print("You got it!!") guess=int(input("Guess again: ")) print("You figured it out in ",guesscount," guesses") Part 2: C++ code; rewrite the following code in C#. Run the program and submit. - include comments #include <iostream> using...

  • this is a c++ question. just need to do the part that says student code. Complete...

    this is a c++ question. just need to do the part that says student code. Complete the do-while loop to output 0 to countLimit. Assume the user will only input a positive number. Sample program: #include using namespace std; int main() { int countLimit = 0; int printVal = 0; // Get user input cin >> countLimit; printVal = 0; do { cout << printVal << " "; printVal = printVal + 1; } while ( ); cout << endl;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT