Computer Programming for Teens phần 3

Mẹo Toán tử logic và đã có tất cả các biểu thức quan hệ xung quanh nó là đúng cho nó để tạo ra một câu trả lời tổng thể thực sự. Toán tử logic hoặc chỉ cần một trong các toán hạng của nó là đúng để tạo ra một câu trả lời tổng thể thực sự. Lưu ý nhà điều hành và thường được các từ và ampersands đôi: &. | A Special Logic Operator The Not Operator 51 5 although 65 is 20 but the entire statement is false because we have a false on one side of the and. In the last example 28 is 12 but 28 is not 20 so true and false produces false. Tip The logic operator and has to have all relational expressions around it to be true for it to generate an overall true answer. The logic operator or needs only one of its operands to be true to generate an overall true answer. Note The and operator is usually the word and or double ampersands . The or operator is the word or or it is represented symbolically as two vertical bars . Examples x 3 and x 10 y 100 or y 0 is the same as is the same as x 3 x 10 y 100 y 0 A Special Logic Operator The Not Operator Our last logic operator is the word not. What does a not operator do In order to understand the not operator let s look at an example from the real world. Imagine that you have a very contrary friend lucky you . Everything you say she changes. Let s look at some of your conversations. You That movie was great Her No it was horrible You I liked the opening scene. Her No you didn t. You said it was lame. You I didn t like the ending however. Her Yes you did. You were laughing all during it. After a series of conversations like these you might want to avoid your friend for a while. Your friend behaves like the not operator. Everything that you have said gets changed logically. If you said you liked something the not operator your friend will say you didn t like it. If you say you didn t like something the not operator your friend will say you liked it by altering what you said to its logical opposite. Let s take a few sentences and apply the not operator to them and then 52 Chapter 3 Everything You Ever Wanted to Know About Operators see what that does to the meaning of those statements. Notice that the not operator precedes the statement that will be altered. Operator Statement Resulting Statement not It s raining outside. It s not raining .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
12    26    1    02-12-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.