Question: Convert the following C# code to phyton: CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DateExample { class Program { static
Convert the following C# code to phyton: CODE:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DateExample { class Program { static void Main(string[] args) { string date1, date2, str; Console.Write("Enter datetime1 :"); date1 = Console.ReadLine(); Console.Write("Enter datetime2 :"); date2 = Console.ReadLine(); Console.Write("Enter string :"); //string[] d1= date1.Split('/'); // string[] d2 = date2.Split('/'); str = Console.ReadLine(); System.DateTime firstDate;// = new System.DateTime(2000, 01, 01); System.DateTime secondDate;// = new System.DateTime(2000, 05, 31); if (DateTime.TryParse(date1, out firstDate) && DateTime.TryParse(date2, out secondDate)) { if (DateTime.Compare(firstDate, secondDate) < 0) { Console.WriteLine("D1 before D2"); } else if (DateTime.Compare(firstDate, secondDate) > 0) { Console.WriteLine("D2 before D1"); } else { Console.WriteLine("D1 is equal to D2"); } Console.WriteLine("Difference in minutes : " + Math.Abs((firstDate - secondDate).TotalMinutes)); Console.WriteLine("" + firstDate + "Is Leap Year?" + DateTime.IsLeapYear(firstDate.Year)); Console.WriteLine("" + secondDate + "Is Leap Year?" + DateTime.IsLeapYear(secondDate.Year)); } else { Console.WriteLine("Error in Datetime "); } str = str.ToUpper(); int s = str.IndexOf('['), e = str.IndexOf(']') ; string t = str.Substring(0, s) + str.Substring(e + 1); t = t.Replace("^", "LSU "); Console.WriteLine("String :"+t); Console.ReadKey(); } } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
