Here is one way you can write a Python program to print the minimum and maximum value in a list without using any built-in functions:
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Initializing min and max values
min_value = numbers[0]
max_value = numbers[0]
# Iterating through the list
for num in numbers:
if num > max_value:
max_value = num
if num < min_value:
min_value = num
print("Minimum value:", min_value)
print("Maximum value:", max_value)
This program uses a for loop to iterate through the list of numbers, and compares each number to the current minimum and maximum values stored in the variables min_value
and max_value
. If the current number is greater than the maximum value, the maximum value is updated. If the current number is smaller than the minimum value, the minimum value is updated. At the end of the loop, the final values of min_value
and max_value
will be the minimum and maximum values in the list, respectively.