Cải thiện bài viết
Lưu bài viết
Cải thiện bài viết
Lưu bài viết
Đọc
Examples:
Input : a = 2, b = 4, c = 3 Output : 4 Input : a = 4, b = 2, c = 6 Output : 6
Bàn luận{IDE} first, before moving on to the solution.
Đưa ra ba số A B và C, nhiệm vụ là chúng ta phải tìm ra yếu tố lớn nhất trong số trong các mẫu đã được cho là:
Được đề xuất: Vui lòng thử cách tiếp cận của bạn trên {IDE} trước, trước khi chuyển sang giải pháp.
Phương pháp 1 [đơn giản]
def
140
141
142
143
144
145
146
143
144
149
140
141
144
143
141
148
149
141
145
146
144
148
146
146
144
149
140
141
144
146
140
141
144
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
3141
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
5 # Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
6# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
7144
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
9The largest number is 14.06
The largest number is 14.07
Output:
14
The largest number is 14.0
014
4 The largest number is 14.0
2
. Initialize three number by n1, n2 and n3
. Add three numbers into list lst = [n1, n2, n3].
. Using max[] function to find the greatest
number max[lst].
. And finally we will print maximum number
Được đề xuất: Vui lòng thử cách tiếp cận của bạn trên {IDE} trước, trước khi chuyển sang giải pháp.
Phương pháp 1 [đơn giản]
def
140
140
141
144
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
3141
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
5 # Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
6# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
7144
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
9The largest number is 14.06
The largest number is 14.07
Output:
14
The largest number is 14.0
014
4 The largest number is 14.0
2
140
141
144
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
3141
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
5 # Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
6# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
7144
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
9The largest number is 14.06
# Python program to find the largest number among the three input numbers # take three numbers from user 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]7
# Python program to find the largest number among the three input numbers # take three numbers from user 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]6
def
3Output:
14
Trong chương trình dưới đây, ba số được lưu trữ trong def
4, def
5 và def
6 tương ứng. Chúng tôi đã sử dụng thang def
7 để tìm cái lớn nhất trong số ba và hiển thị nó.
Mã nguồn
# Python program to find the largest number among the three input numbers
# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12
# uncomment following lines to take three numbers from user
#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]
Đầu ra
The largest number is 14.0
Lưu ý: Để kiểm tra chương trình, thay đổi các giá trị của def
4, def
5 và def
6. To test the program, change the values of def
4, def
5 and def
6.
Mức độ khó: Hoạt động trung bình / thực hiện: Trong chương trình này, chúng tôi yêu cầu người dùng nhập ba số. Chúng tôi sử dụng các thang If Elif Elif khác để tìm thấy lớn nhất trong số ba người và hiển thị nó.Mã nguồn:
# Python program to find the largest number among the three input numbers
# take three numbers from user
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]
Đầu ra 1:
Enter first number: 10
Enter second number: 12
Enter third number: 14
The largest number is 14.0
Đầu ra 2:
Enter first number: -1
Enter second number: 0
Enter third number: -3
The largest number is 0.0
Giải trình
Các chương trình liên quan khác trong 14
01
- Chương trình Python để tạo một máy tính đơn giản
- Chương trình Python để kiểm tra xem một chuỗi có phải là palindrom hay không
- Chương trình Python để nhân hai ma trận
- Chương trình Python để thêm hai ma trận
- Chương trình Python để chuyển đổi thập phân thành nhị phân bằng cách sử dụng đệ quy
- Chương trình Python để tìm giai thừa số lượng bằng cách sử dụng đệ quy
- Chương trình Python để chuyển đổi thập phân thành nhị phân, bát phân và thập lục phân
- Chương trình Python để hiển thị sức mạnh của 2 bằng cách sử dụng hàm ẩn danh
- Chương trình Python để in chuỗi Fibonacci
- Chương trình Python để hiển thị bảng nhân