DOC PREVIEW
TAMU CSCE 110 - Bases cont.
Type Lecture Note
Pages 2

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSCE 110 1nd EditionLecture 24Outline of Last Lecture:I. Returning to binaryA. Built-in number converterB. Adding in binaryII. Writing filesOutline of Current Lecture:I. BasesA. Higher basesB. UnitaryII. DictionariesA. Review of propertiesB. Nested dictionariesCurrent Lecture:I. BasesWe should already be familiar with base 2 and base 10 numbers. But can there be other higher bases? Can there be a base 1? The answer to both of those questions is yes. We can have bases as high as we'd like and there is such a thing as base 1.A. Higher basesIf we first consider base 2 and base 10, we notice that the only integers seen in base 2 numbers are 1 and 0, and the only integers seen in base 10 numbers are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. We can observe that the integers in each digit (representing the coefficient of the base to some exponential value) can be any value from 0 to one less than the base value we are working with.So, for example, if we are in base 6, we can use 0, 1, 2, 3, 4, and 5 to be multiplied by some 6n. What if we want a base higher than 10 (since we cannot have a base with two-digit integers within the number)? The next step would be to start using letters. That way, we could represent a number in base, say, 16, with 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. But what happens when we run out both numbers and letters? Well, the next thing to do would be to choose different symbols. Technically, one could keep creating numbers in higher symbols until they ran out of every possible symbol that they could use to represent some integer. B. UnitaryBase 1 is known as unitary, but you are probably already familiar with it, though you probably didn't realize until now. Unitary is, more or less, the tally-mark system that pretty much These notes represent a detailed interpretation of the professor’s lecture. GradeBuddy is best used as a supplement to your own notes, not as a substitute.everyone has used at some point in their life. So, if we wanted to represent the number 5 in unitary, we would have 00000. If we wanted to represent the number 17, we would have 00000000000000000. As you can see, unitary is not very efficient. it would be very tedious to represent large numbers in this base, which might explain why it is rarely used. II. DictionariesA. Additional propertiesWe can check membership of dictionaries, just as we can with strings, lists, and sets. It checks tosee whether or not a specified value is a key in the given dictionary, and returns a Boolean.>>> a = {'yes':'apple', 'no':6}>>> print 6 in aFalse>>> print 'no' in aTrueB. Nested dictionariesWe can also have nested dictionaries, just as we can have sets within sets, lists within lists, nested loops, etc. In this scenario, a dictionary would be a value of one of the keys within a [most likely] larger dictionary. For example:a = {'a': 'apple', 'b':'banana', 'm':{1:'mango', 2:'melon'}, 'p':papaya}Here, the key 'm' has a dictionary as its


View Full Document

TAMU CSCE 110 - Bases cont.

Type: Lecture Note
Pages: 2
Documents in this Course
06-IO

06-IO

29 pages

21-OOP

21-OOP

8 pages

key

key

6 pages

21-OOP

21-OOP

8 pages

Load more
Download Bases cont.
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Bases cont. and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Bases cont. 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?