About Lesson
Create a Program to Find the Largest of Three Numbers
- Objective: Write a Python program that takes three numbers as input and determines the largest.
- Steps:
- Prompt the user to enter three numbers.
- Use
if
,elif
, andelse
statements to compare the numbers. - Print the largest number.
python
num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) num3 = float(input("Enter third number: ")) if num1 >= num2 and num1 >= num3: largest = num1 elif num2 >= num1 and num2 >= num3: largest = num2 else: largest = num3 print("The largest number is", largest)
Write a Program to Print the Fibonacci Series Up to a Given Number
- Objective: Write a Python program that prints the Fibonacci series up to a specified number.
- Steps:
- Prompt the user to enter the maximum number for the series.
- Initialize the first two numbers of the series.
- Use a
while
loop to generate and print the series.
python
max_num = int(input("Enter the maximum number: ")) a, b = 0, 1 while a <= max_num: print(a, end=" ") a, b = b, a + b