Text Code File of Charging and Discharging
Text Code File of Charging and Discharging
def convert_to_24_hour(time_str):
"""converts 12-hour time format to 24-hour format."""
#for fetching the am or pm from user input for both lower and upper case
period = time_str[-2:].upper() or time_str[-2:].lower() # Get AM/PM or am/pm
#converting the input time to string and splitting through ":"
time_parts = time_str[:-2].strip().split(":")
hours, minutes, seconds = map(int, time_parts)
return f"{hours:02}:{minutes:02}:{seconds:02}"
def time_in_seconds(time_str):
"""converts time in 'HH:MM:SS' format to total seconds."""
hours, minutes, seconds = map(int, time_str.split(':'))
return hours * 3600 + minutes * 60 + seconds
for i in range(len(start_times)):
#convert times to 24-hour format if needed
start_time = get_time_input(start_times[i])
end_time = get_time_input(end_times[i])
return total_time_array
#display results
for i, total_seconds in enumerate(total_time_in_seconds):
print(f"Total time in seconds from start time {start_times[i].strip()} to
end time {end_times[i].strip()}: {total_seconds} seconds")
time=total_seconds
print(time)
###########timr code end
#code for find the battery %while charging and discharging and power delivered to
load and by load
#nominal capacity
un=int(input("enter (un) the nominal capacity in Ah = "))
#charging current
curf=int(input("enter the charging currentin amp = "))
#discharging current
curr=int(input("enter the discharging current = "))
if(curf!=0):
ut=((curf*time)/3600)##because time in sec and unit is coulamb so dividing by
3600 for Ah
print("charge stored in battery(ut) in Ah = ",int(ut),"Ah")
if(curr!=0):
ut=((curr*time)/3600)##curr is dischrge current at time , this diaplay
discharge of battry
print("charge discharged from battery(ut) in Ah = ",int(ut),"Ah")