Premium Essay

Boolean

In:

Submitted By marcusbenson83
Words 2530
Pages 11
Lab 7: Functions
This lab accompanies Chapter 6 of Starting Out with Programming Logic & Design.

Name: ___________________________

Lab 7.1 – Functions and Pseudocode

Critical Review

You have been coding with modules in pseudocode and functions when using Python.

You modules in pseudocode can be made into functions by returning a value.

A function is a special type of module that returns a value back to the part of the program that called it.

Most programming languages provide a library of prewritten functions that perform commonly needed tasks.

Library functions are built into the programming language and you can call them as needed. They are commonly performed tasks.

Help Video: View the tutorial video titled, "lab7-1.wmv" to assist you in completing this lab assignment.

Writing Your Own Function that Returns an Integer
Step 1: A function contains three parts: a header, a body, and a return statement. The first is a function header which specifies the data type of the value that is to be returned, the name of the function, and any parameter variables used by the function to accept arguments. The body is comprised of one or more statements that are executed when the function is called. In the following space, complete the following: (Reference: Writing Your Own Functions, page 225).

a. Write a function with the header named addTen.
b. The function will accept an Integer variable named number.
c. The function body will ask the user to enter a number and the add 10 to the number. The answer will be stored in the variable number.
d. The return statement will return the value of number.

Function a.Integer a.addTen (b.integer number) Display “Enter a number:” Input c.number
Set c.number = number + 10
Return d.15 Step 2: In the following space, write a function call to your function from Step 1.

Similar Documents

Free Essay

Boolean Logic

...UNDERSTANDING BOOLEAN LOGIC AND ITS APPLICATIONS In the 1800’s (1815-1864), George Boole, a English mathematician who did extensive work in the subject of logic, invented a system of mathematics in which the abstract concepts of true and false can be used in computations. In an attempt to create a new form of mathematics, Mr. Boole identified certain patterns of logic that were later found to be easily translated into an electronic language—essentially, a "switchon/switchoff" pattern. Today, using tiny electronic switching mechanisms inside the computer, "decisions" are made with lightning speed within the central processing unit (CPU). These decisions are based on whether a tiny switch is on or off at any given time. Computer programmers follow prescribed sets of instructions to "teach" computers how to make decisions to carry out instructions. Programming is made possible by sets of instructions called languages. Many of these languages are made up of the logic building blocks identified by Mr. Boole more than 100 years ago, long before computers. The building blocks that Mr. Boole identified are AND logic, OR logic, NOT logic, NAND logic, and NOR logic. Computer decisions are made from these patterns of logic. All programming languages allow you to create expressions that can be evaluated as either true or false, which are called Boolean expressions. A Boolean condition is a conditional statement containing a Boolean expression, and another name for a conditional...

Words: 703 - Pages: 3

Free Essay

Boolean Assignment

...TR PT1420 5/13/14 Unit Assignment 4 l. What is the general fom1at of the statement used to code decisions in an application? A power full asset of the computer is its ability to make decisions and to take alternate course of action based on the outcome. 2. What is a Boolean expression? a logical statement that is either TRUE or FALSE. 3 . Explain the purpose of comparison operators and logical operators. The purpose of a comparison operator is to test some kind of relationship between two entities examples are >, <, ==, !=, etc 4. How does a comparison performed on numeric data differ from a comparison performed on string data? There are commonly used interchangeably, and the distinction between them is a small one. Comparison to" should be used when comparison is made between specific people, things, or other instances. 5. How does Visual Basic compare the Text property of a text box? When you compare the Text property of a text box with another value the Text property behaves like a variant. Visual Basic compares one text box to another as strings and compares a text box to a numeric variable or constant with a numeric compare. You can force a numeric comparison on a Text property by using the Val function. 6 . Why would it be useful to include the ToUpper method in a comparison? When comparing strings, the case of the characters is important. An uppercase “Y” does not compare equal to a lowercase “y”. Since the user may type a name or word in either...

Words: 902 - Pages: 4

Free Essay

Boolean Operator

...In logic, a logical connective (also called a logical operator) is a symbol or word used to connect two or more sentences (of either a formal or a natural language) in a grammatically valid way, such that the sense of the compound sentence produced depends only on the original sentences. The most common logical connectives are binary connectives (also called dyadic connectives) which join two sentences which can be thought of as the function's operands. Also commonly, negation is considered to be a unary connective. Logical connectives along with quantifiers are the two main types of logical constants used in formal systems such as propositional logic and predicate logic. Semantics of a logical connective is often, but not always, presented as a truth function. A logical connective is similar to but not equivalent to a conditional operator. [1] Contents [hide] 1 In language 1.1 Natural language 1.2 Formal languages 2 Common logical connectives 2.1 List of common logical connectives 2.2 History of notations 2.3 Redundancy 3 Properties 4 Order of precedence 5 Computer science 6 See also 7 Notes 8 References 9 Further reading 10 External links In language[edit] Natural language[edit] In the grammar of natural languages two sentences may be joined by a grammatical conjunction to form a grammatically compound sentence. Some but not all such grammatical conjunctions are truth functions. For example, consider the following sentences: A: Jack went up...

Words: 2282 - Pages: 10

Premium Essay

Boolean Identities

...Boolean Algebraic Identities Boolean Addition and Subtraction Complementary Gates (NOT) Boolean complementation finds equivalency in the form of the NOT gate, or a normallyclosed switch or relay contact: Topic Notes: • Boolean addition is equivalent to the OR logic function, as well as parallel switch contacts. • Boolean multiplication is equivalent to the AND logic function, as well as series switch contacts. • Boolean complementation is equivalent to the NOT logic function, as well as normallyclosed relay contacts. 1 Boolean algebraic identities The algebraic identity of x + 0 = x tells us that anything (x) added to zero equals the original ”anything,” no matter what value that ”anything” (x) may be. Like ordinary algebra, Boolean algebra has its own unique identities based on the bivalent states of Boolean variables. The first Boolean identity is that the sum of anything and zero is the same as the original ”anything.” This identity is no different from its real-number algebraic equivalent: No matter what the value of A, the output will always be the same: when A=1, the output will also be 1; when A=0, the output will also be 0. The next identity is most definitely different from any seen in normal algebra. Here we discover that the sum of anything and one is one: Next, we examine the effect of adding A and A together, which is the same as connecting both inputs of an OR gate to each other and activating them with the same signal: Introducing the uniquely...

Words: 1385 - Pages: 6

Free Essay

Finite Math

...n ≥ 2. If xi is a Boolean variable for all 1 ≤ i ≤ n, prove that a) (x1 + x2 + ・ ・ ・ + xn) _ x1x2 ・ ・ ・ xn Assume the result for n _ k (≥ 2) and consider the case of n _ k + 1. b) (x1x2 ・ ・ ・ xn) _ x1 + x2 + ・ ・ ・ + xn Follows from part (a) by duality. 5. Let_be a Boolean algebra that is partially ordered by≤. If x, y, z ∈ _, prove that x + y ≤ z if and only if x ≤ z and y ≤ z. If x ≤ z and y ≤ z, then from Exercise 6(b) of Section 15.4 we have x + y ≤ z + z. z + z _ z. Conversely, suppose that x + y ≤ z.We find that x ≤ x + y, because x(x + y) _ x + xy _ x. Since x ≤ x + y and x + y ≤ z, we have x ≤ z, because a partial order is transitive. 6. State and prove the dual of the result in Exercise 5. Exercise 15.1, problems 1, 2, 11, 12, 14, & 15 1. Find the value of each of the following Boolean expressions if the values of the Boolean variables w, x, y, and z are 1, 1, 0, and 0, respectively. a) xy + x y = 1 b) w + xy = 1 c) wx + y + yz = 1 d) (wx + yz) + wy + (w + y)(x + y) = 1 2. Let w, x, and y be Boolean variables where the value of x is 1. For each of the following Boolean expressions, determine, if possible, the value of the expression. If you cannot determine the value of the expression, then find the number of assignments of values for w and y that will result in the value 1 for the expression. a) x + xy + w b) xy + w c) xy + xw d) xy + w 11. Simplify the following Boolean expressions. ...

Words: 1076 - Pages: 5

Free Essay

Computer Science

...Chapter 4: More on Logical, Information, and Text Functions Introduction Logical functions are those that involve Boolean values. The Boolean values are TRUE and FALSE. Some logical functions return a Boolean value as their result, others use the Boolean result of a comparison to choose between alternative calculations. There are six functions listed in the logical group in Excel 2003 – the functions AND, FALSE, IF, NOT, OR, TRUE – and a seventh in Excel 2007 – the function IFERROR. You’ll see the use of most of these in this lab. First, however, it’s worthwhile to become familiar with the logical operators. Logical Operators TRUE and FALSE are common concepts. They are values which pertain to statements. For example, the statement “It is morning.” is either TRUE or FALSE. We recognize that its truth value may change, but at any particular time the statement is either TRUE or FALSE. What may be hidden here is the existence of an implied comparison. To determine the truth value of any statement we compare our understanding of the meaning of the claim with the facts. Strictly speaking the statement “It is morning.” means the time of day is after midnight and before noon. To decide if it’s TRUE we need to know the actual time of day and compare it to our criteria. It’s in these comparisons that we use Logical Operators: |Comparison |Symbol | |less than |< | |less...

Words: 2638 - Pages: 11

Free Essay

Kjeoc

...so if the vice president, and the secretary voted yes, but the president and treasurer voted no, since the president's vote is a no, the majority vote would end with a no vote. we had to create a truth table of every different outcome to make sure everything would check out. then after that we would get all of the ones with a positive outcome, and then write them all out as if it were a math problem. then using this stuff called boolean algebra, we had to make the bigger math problem much simpler so it would fit into the circuit system that we use to simulate how it would look in real life. the simplification was very long and quite difficult. it is very confusing and very difficult to explain. so to simplify it, the example i'm going to give you is very simple compared to what we had to do. so say that the president said no, so in the simplification, it would be not P, or not president. and continuing this same process down the line until you would get them all. say that two terms would be PT and the others would be P and not T, according to boolean you could just write it as P(T+not T) and it would be the same while eliminating a gate, which is what we would use to wire these up. when you would wire them up a + sign is an or gate. which takes two inputs and says if one of these are on and the other is off, it will go through as on. and a X would be an and gate, those will only pass the signal if both inputs are the same....

Words: 534 - Pages: 3

Premium Essay

Help Me

...15.1, problems 1a Find the value of each of the following Boolean expressions if the values of the Boolean variables w, x, y, and z are 1, 1, 0, and 0, respectively. xy + x y x y xy (xy) ̅ x ̅ y ̅ x ̅y ̅ (xy) ̅+x ̅y ̅ 1 0 0 1 0 1 0 1 Solution: 1 2a Let w, x, and y be Boolean variables where the value of x is 1. For each of the following Boolean expressions, determine, if possible, the value of the expression. If you cannot determine the value of the expression, then find the number of assignments of values for w and y that will result in the value 1 for the expression. a) x + xy + w x = 1 then x+xy+w = 1+1y+w = 1+(1y+w) 1+z = 1 for every Boolean value z then: if we take z = 1y+w 1+(1y+w) = 1 Solution: Yes is possible, x+xy+w = 1 4a a) Find the fundamental conjunction made up from the variables w, x, y, z, or their complements, where the value of the conjunction is 1 precisely when i) w _ x _ 0, y _ z _ 1. ii) w _ 0, x _ 1, y _ 1, z _ 0. iii) w _ 0, x _ y _ z _ 1. iv) w _ x _ y _ z _ 0. 9 Let Bn →B. If the d.n.f. of f has m fundamental conjunctions and its c.n.f. has k fundamental disjunctions, how are m, n, and k related? 12 Find the values of the Boolean variables w, x, y, z that satisfy the following system of simultaneous (Boolean) equations. x + xy _ 0 xy _ xz xy + x z + zw _ zw x+x ̅y=0→(x+x ̅ )(x+y)=0 Distributive Law of + over  1(x+y)=0...

Words: 404 - Pages: 2

Free Essay

Programming Final

...Programming Final 1. The case structure lets the value of a variable or an expression determine which path of execution the program will take. It’s a multiple alternative decision structure that allows you to test the value of a variable or an expression and then use that value to determin which statement to execute. 2. The AND operator takes two Boolean expressions as operands and creates a compound Boolean expression that is true only when both expressions are true. True AND True = True 3. The OR operator takes two Boolean expressions as operands and creates a compound Boolean expression that is true when either of the sub expressions is true. True OR False = True 4. The NOT operator is a unary operator that takes a Boolean expression as its operand an reverses its logical value. The Not operator reverses the truth of its operand. If it is applied to an expression that is true the operator returns false. If it is applied to an expression that is false it returns True. Not true = False, Not false = True 5. Flow chart 6. And, Or , Not 7. And, Or, Not 8. And, OR, Not 9. > greater than, < less than, >= greater than or equal to, <= less than or equal to, == equal to, != not equal to 10. Case structure has a diamond at the top and branches down into different parallelograms. 11. A repetition structure causes a statement or set of statements to execute repeatedly. 12. A condition-controlled loop uses a true/false condition to control the number of times that...

Words: 991 - Pages: 4

Premium Essay

Library and Information Science

...Use of Information Search Techniques and Tools on Web By Prof. A. B. Bhosle* A university, a college or an institution of higher learning is rightly described as community where teachers and scholars are the head, students are the body and the library is it’s heart. If the body is to perform its function properly and efficiently its hearth must be well maintained and strong in its functioning. Thomas Carlyle was not exaggerating when he described a ‘true university as a collection of books’.[1] The library is obviously the source of power of knowledge. In higher education and research, the use of library is a matter of concerns to students, teachers, and researchers. The exponential growth of literature often creates problems for them to access appropriate literature and their use. The problem has, however, considerably been resolved with the help of information and communication technology (ICT). The use of information technology for management and handling of information and data has grown significantly even in many least-developed countries, despite their economic constraints. The use of information technology in libraries has been profoundly affecting all aspects of information acquisition, storage, and transfer. Its magnificent development has dramatically changed the mode of library operations and information services; we have now started to speak of a new type of information source, ‘knowledge base’.[2] Computer-based communications have not only widened...

Words: 2293 - Pages: 10

Premium Essay

Paper

...* Ch. 15 Supplementary Exercises, problems 1, 5, & 6 * 1. Let n ≥ 2. If xi is a Boolean variable for all 1 ≤ i ≤ n, prove that a) (x1 + x2 + ・ ・ ・ + xn) = x1x2 ・ ・ ・ xn * b) (x1x2 ・ ・ ・ xn) = x1 + x2 + ・ ・ ・ + xn * 5. Let B be a Boolean algebra that is partially ordered by ≤. If x, y, z ∈ B, prove that x + y ≤ z if and only if x ≤ z and y ≤ z. * * 6. State and prove the dual of the result in Exercise 5. * * Ch. 15 Exercise 15.1, problems 1, 2, 4, 5, 9, 12, & 15, * 1. Find the value of each of the following Boolean expressions if the values of the Boolean variables w, x, y, and z are 1, 1, 0, and 0, respectively. a) xy + x y b) w + xy c) wx + y + yz * d) (wx + yz) + wy + (w + y)(x + y) * 2. Let w, x, and y be Boolean variables where the value of x is 1. For each of the following Boolean expressions, determine, if possible, the value of the expression. If you cannot determine the value of the expression, then find the number of assignments of values for w and y that will result in the value 1 for the expression. a) x + xy + w b) xy + w * c) xy + xw d) xy + w * 4. a) Find the fundamental conjunction made up from the variables w, x, y, z, or their complements, where the value of the conjunction is 1 precisely when i) w = x = 0, y=_ z = 1. ii) w = 0, x = 1, y = 1, z = 0. iii) w = 0, x = y = z = 1. iv) w = x = y = z = 0. b) Answer part (a) this time for fundamental disjunctions, instead of fundamental conjunctions...

Words: 523 - Pages: 3

Free Essay

Dialog Styles

...DIALOG The Dialog service is the world's most comprehensive online information Retrieval service and has been serving users since 1972. With over 600 databases from a broad range of disciplines, Dialog provides international access to information in a broad scope of subject areas. The volume of data available combined with the system's searching capabilities make Dialog the largest and most powerful online service of its type. The Dialog content collection contains hundreds of databases comprised of millions of documents drawn from a multitude of sources. Dialog brings you scientific and technical literature; full-text trade journals, newspapers and newswires; details on millions of chemical substances; information on patents and trademarks issued worldwide; demographic data; and company financial statistics. Accessing Dialog. All Dialog Command Language interfaces are accessible via the Internet using TCP/IP protocols, most commonly using: A Web browser. Internet Explorer 5.X or higher or Netscape Navigator 4.7 or higher are recommended. Internet access is available at the desktop in most businesses and academic institutions. Internet Service Providers (ISP) also provides Internet access for a fee by means of a telephone dial-up connection, DSL broadband cable, or wireless service. In addition to Internet access, you will also need a valid user account for Dialog. Each account is assigned User ID and password that are required in order to log on to the service. Institutions...

Words: 2834 - Pages: 12

Free Essay

Back Log of Data

...digital logic level output which is dependent on the type of logic gate and the inputs applied to the gate. For the TTL logic family, any gate input that is not connected will be treated as if a logic 1 is present on that input. The number of different possible combinations of inputs is 2n where n is the number of inputs. Therefore, four unique combinations of inputs are possible for a two input gate. A B Q 0 0 1 1 FIGURE 2 0 1 0 1 0 0 0 1 The AND function is similar to the multiplication in mathematics, and provides a logic 1 output only when all the inputs of the gate are at logic 1, and logic 0 output for all other input combinations. Figure 2 contains the logic symbols and truth table for the AND function. The Boolean Equation for a 2 input AND gate, the Boolean Equation is: Q = AB <1> Page 1 ENGI 241 Experiment 5 Basic Logic Gates A B 0 0 1 1 FIGURE 3 Q 1 1 1 0 0 1 0 1 The NAND...

Words: 1423 - Pages: 6

Free Essay

George Boole Research Paper

...best within the mathematics community for his success in defining logic by using algebra, or Boolean algebra as it is known today. Boole was born on November 2, 1815, in Lincoln, England, known predominantly as an industrial town. Gasser (2006) states “He was the first of four children born to John Boole, a cobbler, and Mart Ann Boole, nee Joyce, a lady’s maid” (p. 377-78). According to Britannica Online (2015), “He was given his first lessons in mathematics by his father, a tradesman, who also taught him to make optical instrument. Aside from his father’s help and a few years at local schools, however, Boole was self-taught in mathematics.” During the timeframe of Boole’s life, there were many political and social events that took place all around the world. Within England, Victoria took the throne in 1837 and would ultimately rule longer than any other British monarch. In 1838, slavery was abolished in the British empire. Additionally, in Ireland in 1845 the great potato famine began that lasted approximately four years killed about a million people, creating a large emigration to England and North America. In North America, in 1846 the Mexican-American War was fought, as well as the Civil War, although Boole died on December 8, 1864, in Ballintemple, Ireland, before the Civil War ended. Boole is most well-known for his discovery of algebra of logic, known today as Boolean algebra. He stated, “Boole was interested in symbolic analysis years before he wrote his Laws...

Words: 813 - Pages: 4

Free Essay

Pico

...to MEDLINE at http://www.pubmed.gov and conduct a search on your clinical question. Please type your search history in the table below: Search Number | P | I | C | O | T | # of Results | Notes | 1 | Congestive Heart Failure | | | | | 33058 | I typed “congestive heart failure” in the search field and clicked ‘Search’. | 2 | | Home Monitoring | | | | 1077 | I cleared the search field and typed in “home monitoring” and clicked ‘Search’. | 3 | | | | Decreased Readmission | | 11954 | I cleared the search and typed in readmission instead of decreased readmission to widen my search results and clicked ‘Search’. | 4 | #1 | #2 | | #3 | | 40 | I then clicked ‘Advanced Search’ and combined Searches #1, #2, and #3 using the Boolean operator “AND”. I then clicked ‘Search’. | 5 | #1 | #2 | | #3 | 5 years | 22 | I chose to further the search by retrieving only current articles, so I used the same ‘Advanced Search’ from 4 but then clicked on ‘Limits’ and requested only articles from the last 5 years. I then clicked ‘Search’. Although 10-20 articles is preferred I felt 22 returned articles was still close. | | | | | | | | | | | | | | | | | 4. Search: EBSCO/CINAHL Go to the Chamberlain Library at http://www.chamberlain.edu/library and enter EBSCO. Conduct a search on your clinical question. Please type your search history...

Words: 580 - Pages: 3