0% found this document useful (0 votes)
2 views

Python Lab 1

The document outlines algorithms developed in Python for calculating the Logarithmic Mean Temperature Difference (LMTD) for both countercurrent and cocurrent heat exchangers, as well as for summing odd and even numbers between two given integers. It includes input prompts for temperature values and integer ranges, along with sample outputs demonstrating the calculations. The algorithms utilize mathematical operations and conditional statements to achieve the desired results.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Lab 1

The document outlines algorithms developed in Python for calculating the Logarithmic Mean Temperature Difference (LMTD) for both countercurrent and cocurrent heat exchangers, as well as for summing odd and even numbers between two given integers. It includes input prompts for temperature values and integer ranges, along with sample outputs demonstrating the calculations. The algorithms utilize mathematical operations and conditional statements to achieve the desired results.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PRACTICAL 6

AIM:TO DEVELOP ALGORITHM USING PYTHON PROGRAMMING


LANGUAGE
PROBLEM STATEMENT: Develop algorithm to calculate LMTD for Co-
current and counter current heat exchangers
INPUT:

#counter current flow operation

Ho=int(input('Enter the outlet temp for hot fluid'))


Hi=int(input('Enter the inlet temperature for hot fluid'))
Co=int(input('Enter the outlet temperature for cold fluid'))
Ci=int(input('Enter the inlet temperature for cold fluid'))
LMTD=((Hi-Co)-(Ho-Ci))/math.log((Hi-Co)/(Ho-Ci))
print('LMTD for counter current flow',LMTD)

#co current flow operation

Ho=int(input('Enter the outlet temp for hot fluid'))


Hi=int(input('Enter the inlet temperature for hot fluid'))
Co=int(input('Enter the outlet temperature for cold fluid'))
Ci=int(input('Enter the inlet temperature for cold fluid'))
LMTD=((Hi-Ci)-(Ho-Co))/math.log((Hi-Ci)/(Ho-Co))
print('LMTD for co current flow',LMTD)

PROBLEM STATEMENT:Develop algoritm to calculate summation of


odd number and even number between two given numbers

#Summation of odd numbers between two given integers


def sum_of_odds(start, end):
if start > end:
start, end = end, start
odd_sum = sum(num for num in range(start, end + 1) if num % 2 != 0)
return odd_sum
start = int(input("Enter the starting number: "))
end = int(input("Enter the ending number: "))
print(f"The sum of odd numbers between {start} and {end} is: {sum_of_odds(start, end)}")
#summation of even integers between two integers
def sum_of_evens(start, end):
if start > end:
start, end = end, start
even_sum = sum(num for num in range(start, end + 1) if num % 2 == 0)
return even_sum
start = int(input("Enter the starting number: "))
end = int(input("Enter the ending number: "))
print(f"The sum of even numbers between {start} and {end} is: {sum_of_evens(start, end)}")

OUTPUT
Output 1
Enter the outlet temp for hot fluid30

Enter the inlet temperature for hot fluid20

Enter the outlet temperature for cold fluid15

Enter the inlet temperature for cold fluid10

LMTD for counter current flow 10.820212806667225

Output 2
Enter the outlet temp for hot fluid80

Enter the inlet temperature for hot fluid20

Enter the outlet temperature for cold fluid30

Enter the inlet temperature for cold fluid10

LMTD for co current flow 24.853397382384475

Output 3
Enter the starting number: 351

Enter the ending number: 9984

The sum of odd numbers between 351 and 9984 is: 24889439

Output 4
Enter the starting number: 201

Enter the ending number: 8779

The sum of even numbers between 201 and 8779 is: 19257610

You might also like