Tôi đang cố gắng làm như sau:
Viết một chương trình đọc ba số và in tất cả các cùng một cách khác nếu tất cả đều giống nhau, tất cả đều khác nhau nếu tất cả đều khác nhau, và không phải là một cách khác.
Chương trình của bạn nên yêu cầu 3 số nguyên thông qua 3 câu lệnh đầu vào. Sử dụng kết hợp IF, ELIF và nếu không để thực hiện thuật toán cần thiết cho vấn đề này.
Tuy nhiên, bất cứ khi nào tôi nhập tất cả các số nguyên giống nhau, tôi sẽ nhận được cả 'tất cả giống nhau' và 'cũng không'. Làm cách nào để làm cho nó để phần "không" của tôi là chính xác?
x=input['enter an integer:']
y=input['enter an integer:']
z=input['enter an integer:']
if x==y and y==z: print['all the same']
if not x==y and not y==z: print['all different']
if x==y or y==z or z==x: print['neither']
Thegrinner
10,9k5 Huy hiệu vàng42 Huy hiệu bạc64 Huy hiệu đồng5 gold badges42 silver badges64 bronze badges
Hỏi ngày 19 tháng 9 năm 2013 lúc 15:53Sep 19, 2013 at 15:53
7
Vấn đề ở đây là bạn sử dụng if
cho mỗi trường hợp. Điều này có nghĩa là tất cả các trường hợp được đánh giá bất kể điều gì, và nhiều trường hợp có thể đúng.
Ví dụ: nếu cả ba biến là 1, các trường hợp đánh giá như thế này:
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
Bạn muốn sử dụng elif
[nếu không] và else
[xem tài liệu điều khiển dòng chảy] để các điều kiện của bạn trở nên loại trừ lẫn nhau:
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
Đã trả lời ngày 19 tháng 9 năm 2013 lúc 20:04Sep 19, 2013 at 20:04
Thegrinnerthegrinnerthegrinner
10,9k5 Huy hiệu vàng42 Huy hiệu bạc64 Huy hiệu đồng5 gold badges42 silver badges64 bronze badges
Hỏi ngày 19 tháng 9 năm 2013 lúc 15:53
Vấn đề ở đây là bạn sử dụng if
cho mỗi trường hợp. Điều này có nghĩa là tất cả các trường hợp được đánh giá bất kể điều gì, và nhiều trường hợp có thể đúng.
x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
Ví dụ: nếu cả ba biến là 1, các trường hợp đánh giá như thế này:Feb 13, 2014 at 12:28
Làm thế nào để bạn so sánh 4 biến trong Python? Sử dụng hoặc hoặc và để so sánh nhiều biến với vị trí giá trị hoặc giữa nhiều biến boolean để kiểm tra xem có bất kỳ biến nào có đúng không. Đặt và giữa nhiều biến Boolean để kiểm tra xem tất cả các biến có đúng không.
Làm thế nào để bạn so sánh các số trong Python?
Làm thế nào để bạn so sánh 4 biến trong Python? Sử dụng hoặc hoặc và để so sánh nhiều biến với vị trí giá trị hoặc giữa nhiều biến boolean để kiểm tra xem có bất kỳ biến nào có đúng không. Đặt và giữa nhiều biến Boolean để kiểm tra xem tất cả các biến có đúng không.
Làm thế nào để bạn so sánh các số trong Python?
So sánh bình đẳng với python == và! = Sử dụng các toán tử bình đẳng == và! = Nếu bạn muốn kiểm tra xem hai đối tượng có cùng giá trị hay không, bất kể chúng được lưu trữ trong bộ nhớ.
Examples:
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes
Cải thiện bài viết{IDE} first, before moving on to the solution.
Lưu bài viết
Đọc
Implementation:
Python
def
check[list1, val]:
Bàn luận
Cho một danh sách, in tất cả các giá trị trong một danh sách lớn hơn giá trị đã cho & nbsp;
Đượ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: Danh sách truyền tải
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
6>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
8>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
9x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
1x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
3x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
5x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
7x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
9Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes0
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes1
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8 Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes3
if
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes5
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
0Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes7
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes8
else
if
0
Bằng cách đi qua trong danh sách, chúng ta có thể so sánh mọi yếu tố và kiểm tra xem tất cả các phần tử trong danh sách đã cho có lớn hơn giá trị đã cho hay không. & NBSP;
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes1
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8 x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
1if
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes5
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
0Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes7
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes8
else
if
0
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
0Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes7
if
3if
Input : list = [10, 20, 30, 40, 50]
given value = 20
Output : No
Input : list = [10, 20, 30, 40, 50]
given value = 5
Output : Yes
5
Phương pháp 3: Sử dụng phương thức Min []
Implementation:
Python
def
check[list1, val]:
Các
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
6>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
8>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
9x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
1x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
3x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
5x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
7x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
9Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes0
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes1
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8 Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes3
if
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes5
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
0Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes7
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes8
else
if
0
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
0Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes7
if
3Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes1
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8 x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
1if
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes5
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
0Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes7
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes8
else
if
0
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
0Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes7
if
3Phương pháp 3: Sử dụng phương thức Min []
Python3
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
6>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
8>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
elif not x == y and not y == z: print["all different"]
else: print["neither"]
all the same
>>>
9x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
1x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
3x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
5x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
7x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
0x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
9Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes0
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes1
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8 Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes3
if
else
1
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
39>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
40>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
42Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes1
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
8 x = input["Enter the 1st integer"]
y = input["Enter the 2nd integer"]
z = input["Enter the 3rd integer"]
if x == y and y == z:
print["All the numbers are the same"]
elif x!= y and y != z: # or use elif not and replace all != with ==
print["None of the numbers are the same"]
else:
print["Neither"]
1else
if
0
>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
0Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes7
else
1if
3>>> x = 1
>>> y = 1
>>> z = 1
>>> if x == y and y == z: print["all the same"]
all the same
>>> if not x == y and not y == z: print["all different"]
>>> if x == y or y == z or z == x: print['neither']
neither
>>>
47