Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/feed-rss2.php on line 8
Gilberto Rogel García’s Articles at Courses by Ken https://kenscourses.com/tc101winter2015 Facilitator of Learning Experiences Thu, 07 May 2015 04:54:10 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ #mastery26 Creation and use of strings in Python https://kenscourses.com/tc101winter2015/2015/mastery26-creation-and-use-of-strings-in-python/ Thu, 07 May 2015 04:54:10 +0000 https://gilrg18.withknown.com/2015/mastery26-creation-and-use-of-strings-in-python

Python does not support a character type; these are treated as strings of length one, thos also considered a substring.

To access substrings, use the square brackets for slicing along with the index or indices to obtain your substring.

     Example:

var1= "Hello World"

print ("var1[0]:", var1[0])

     When the above code is executed, it produces:

var1[0]: H

Gilberto Rogel García

For more info visit:This link

26

1014

Continue reading ]]>

Python does not support a character type; these are treated as strings of length one, thos also considered a substring.

To access substrings, use the square brackets for slicing along with the index or indices to obtain your substring.

     Example:

var1= “Hello World”

print (“var1[0]:”, var1[0])

     When the above code is executed, it produces:

var1[0]: H

Gilberto Rogel García

For more info visit:This link

26

1014

]]>
https://creativecommons.org/licenses/by/4.0/
#mastery25 Creation and use of ranges in Python https://kenscourses.com/tc101winter2015/2015/mastery25-creation-and-use-of-ranges-in-python/ Thu, 07 May 2015 04:46:24 +0000 https://gilrg18.withknown.com/2015/mastery25-creation-and-use-of-ranges-in-python

The range() Function

If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates lists containing arithmetic progressions, e.g.:

 

>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

The given end point is never part of the generated list; range(10) generates a list of 10 values, exactly the legal indices for items of a sequence of length 10. It is possible to let the range start at another number, or to specify a different increment (even negative):

 

>>> range(5, 10)
[5, 6, 7, 8, 9]
>>> range(0, 10, 3)
[0, 3, 6, 9]
>>> range(-10, -100, -30)
[-10, -40, -70]

To iterate over the indices of a sequence, combine range() and len() as follows:

 

>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in range(len(a)):
...     print i, a[i]
... 
0 Mary
1 had
2 a
3 little
4 lamb

My example:

x=['mastery25','tc1014']

for i in range (len(x)):

     print ("#",x[i])

>>>25

>>>1014

25

1014

GILBERTO ROGEL GARCÍA

SOURCE: Here

Continue reading ]]>

The range() Function

If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates lists containing arithmetic progressions, e.g.:

 

>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

The given end point is never part of the generated list; range(10) generates a list of 10 values, exactly the legal indices for items of a sequence of length 10. It is possible to let the range start at another number, or to specify a different increment (even negative):

 

>>> range(5, 10)
[5, 6, 7, 8, 9]
>>> range(0, 10, 3)
[0, 3, 6, 9]
>>> range(-10, -100, -30)
[-10, -40, -70]

To iterate over the indices of a sequence, combine range() and len() as follows:

 

>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in range(len(a)):
...     print i, a[i]
... 
0 Mary
1 had
2 a
3 little
4 lamb

My example:

x=[‘mastery25′,’tc1014’]

for i in range (len(x)):

     print (“#”,x[i])

>>>25

>>>1014

25

1014

GILBERTO ROGEL GARCÍA

SOURCE: Here

]]>
https://creativecommons.org/licenses/by/4.0/
#WSQ16 Cars https://kenscourses.com/tc101winter2015/2015/wsq16-cars-11/ Thu, 07 May 2015 04:36:28 +0000 https://gilrg18.withknown.com/2015/wsq16-cars

 

I wrote a program that opens and reads the file 93cars.dat.txt which reads a series of data from certain cars and prints their CityMPG, HighwayMPG and their average mindrange price.

I got help from my classroom partners to make this

Link for the code: Here

16 Cars

1014 

Gilberto Rogel García

 

Continue reading ]]>

 

I wrote a program that opens and reads the file 93cars.dat.txt which reads a series of data from certain cars and prints their CityMPG, HighwayMPG and their average mindrange price.

I got help from my classroom partners to make this

Link for the code: Here

16 Cars

1014 

Gilberto Rogel García

 

]]>
https://creativecommons.org/licenses/by/4.0/
#mastery24 Creation and use of tuples in Python https://kenscourses.com/tc101winter2015/2015/mastery24-creation-and-use-of-tuples-in-python-2/ Thu, 07 May 2015 03:33:23 +0000 https://gilrg18.withknown.com/2015/mastery24-creation-and-use-of-tuples-in-python

A tuple is an unchangeable sequence of values.

x=("Gilberto",18,"ISC")   tuple is written with ()

When you do this you create a tuple with three elements. You can access these elements individually by typing the variable and the then inside brackets directly to the right of the variable type the number of the element to which you are referring.

print (x[o])

>>>Gilberto

Python starts numbering at 0 so Gilberto=0,18=1 and ISC = 2

Packing and Unpacking:

In tuple packing, the values on the left are ‘packed’ together in a tuple:

x=("Gilberto",18,"ISC")

In tuple unpacking, the values in a tuple on the right are ‘unpacked’ into the variables/names on the right:

x=("Gilberto",18,"ISC")

(Name,Age,Studies) = x

print(Name,Age,Studies)

>>>Gilberto 18 ISC

Sources for info. about tuples: Link

 

1014

24

Gilberto Rogel García

Continue reading ]]>

A tuple is an unchangeable sequence of values.

x=(“Gilberto”,18,”ISC”)   tuple is written with ()

When you do this you create a tuple with three elements. You can access these elements individually by typing the variable and the then inside brackets directly to the right of the variable type the number of the element to which you are referring.

print (x[o])

>>>Gilberto

Python starts numbering at 0 so Gilberto=0,18=1 and ISC = 2

Packing and Unpacking:

In tuple packing, the values on the left are ‘packed’ together in a tuple:

x=(“Gilberto”,18,”ISC”)

In tuple unpacking, the values in a tuple on the right are ‘unpacked’ into the variables/names on the right:

x=(“Gilberto”,18,”ISC”)

(Name,Age,Studies) = x

print(Name,Age,Studies)

>>>Gilberto 18 ISC

Sources for info. about tuples: Link

 

1014

24

Gilberto Rogel García

]]>
https://creativecommons.org/licenses/by/4.0/
#mastery09 Basic types and their use in Python https://kenscourses.com/tc101winter2015/2015/mastery09-basic-types-and-their-use-in-python-2/ Thu, 07 May 2015 03:10:13 +0000 https://gilrg18.withknown.com/2015/mastery09-basic-types-and-their-use-in-python

Types are a category for things within Python with which Python will work. Types are integers,float,strings,tuples,lists and dictionaries.

Integers 

Whole numbers from negative infinity to infinity, such as 1, 0, -5, etc.

Integers are numeric values and can be stored, manipulated, and expressed inside variables without quotes.

Example: 

x=5

print (x)

>>>5

Float

Short for "floating point number," any rational number, usually used with decimals such as 2.8 or 3.14159.

Strings 

A set of letters, numbers, or other characters.

Strings are a type. They are the basic unit of text in Python and all the other types except integers may contain strings.

Example:

x="Hello World"

print (x) 

>>>Hello World

Tuples 

A list with a fixed number of elements. ie x=(1,2,3) parentheses makes it a tuple.

A tuple is an unchangeable sequence of values.

Example:

x = ("element 1", "element 2", "element 3")

Lists

A list is a changeable sequence of data. A list is contained by square brackets i.e. [1,2,3]

Example:

x=[1,2,3]

print (x)

>>>[1,2,3]

Dictionaries 

A type with multiple elements i.e. x = {1: 'a','b': 2,3: 3} where you address the elements with, e.g., a text.

Example:

x={'Hello':'hola', 'Bye':'adios'}

 

print(x)

>>> {'Hello':'hola', 'Bye':'adios'}

Source with more info.: http://en.wikiversity.org/wiki/Python/Basic_data_types#quiz0

1014

09

Gilberto Rogel García

 

 

Continue reading ]]>

Types are a category for things within Python with which Python will work. Types are integers,float,strings,tuples,lists and dictionaries.

Integers 

Whole numbers from negative infinity to infinity, such as 1, 0, -5, etc.

Integers are numeric values and can be stored, manipulated, and expressed inside variables without quotes.

Example: 

x=5

print (x)

>>>5

Float

Short for “floating point number,” any rational number, usually used with decimals such as 2.8 or 3.14159.

Strings 

A set of letters, numbers, or other characters.

Strings are a type. They are the basic unit of text in Python and all the other types except integers may contain strings.

Example:

x=”Hello World”

print (x) 

>>>Hello World

Tuples 

A list with a fixed number of elements. ie x=(1,2,3) parentheses makes it a tuple.

A tuple is an unchangeable sequence of values.

Example:

x = (“element 1”, “element 2”, “element 3”)

Lists

A list is a changeable sequence of data. A list is contained by square brackets i.e. [1,2,3]

Example:

x=[1,2,3]

print (x)

>>>[1,2,3]

Dictionaries 

A type with multiple elements i.e. x = {1: ‘a’,’b’: 2,3: 3} where you address the elements with, e.g., a text.

Example:

x={‘Hello’:’hola’, ‘Bye’:’adios’}

 

print(x)

>>> {‘Hello’:’hola’, ‘Bye’:’adios’}

Source with more info.: http://en.wikiversity.org/wiki/Python/Basic_data_types#quiz0

1014

09

Gilberto Rogel García

 

 

]]>
https://creativecommons.org/licenses/by/4.0/
#mastery08 Python conventions (Zen of Python) https://kenscourses.com/tc101winter2015/2015/mastery08-python-conventions-zen-of-python/ Thu, 07 May 2015 00:21:46 +0000 https://gilrg18.withknown.com/2015/mastery08-python-conventions-zen-of-python

The zen of python is, according to long time Pythoneer Tim Peters, a set of rules you have to follow or at least to take into account while coding in python which are:

#f9f9f9; background-size: inherit; background-origin: inherit; background-clip: inherit; background-position: inherit; background-repeat: inherit;"> Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea -- let's do more of those!

Source: https://www.python.org/dev/peps/pep-0020/

08 

1014

Gilberto Rogel García

Continue reading ]]>

The zen of python is, according to long time Pythoneer Tim Peters, a set of rules you have to follow or at least to take into account while coding in python which are:

Source: https://www.python.org/dev/peps/pep-0020/

08 

1014

Gilberto Rogel García

]]>
https://creativecommons.org/licenses/by/4.0/
#quiz11 Gone bananas for files https://kenscourses.com/tc101winter2015/2015/quiz11-gone-bananas-for-files-2/ Wed, 29 Apr 2015 01:29:07 +0000 https://gilrg18.withknown.com/2015/quiz11-gone-bananas-for-files Continue reading ]]>

Codes here

-The first code uses a file named random_numbers.txt

-The second code uses a file named banana.txt and finds the word “banana” in that text and then shows you how many times did it find that word.

 

Gilberto Rogel García

a01630171

]]>
https://creativecommons.org/licenses/by/4.0/
#WSQ15 Final Dash https://kenscourses.com/tc101winter2015/2015/wsq15-final-dash-10/ Mon, 27 Apr 2015 15:17:00 +0000 https://gilrg18.withknown.com/2015/wsq15-final-dash Continue reading ]]>

I still have to do 9 masteries and 2 wsqs so my plan is to finish every WSQ and MASTERY before Sunday 3 so i can have plenty of time to study for the final exam on thursday 7th 

Gilberto Rogel García

]]>
https://creativecommons.org/licenses/by/4.0/
#ECOS #TC1014 https://kenscourses.com/tc101winter2015/2015/ecos-tc1014-2/ Thu, 23 Apr 2015 21:28:06 +0000 https://gilrg18.withknown.com/2015/ecos-tc1014 Continue reading ]]>

 

Every student must evaluate their teachers in order to know who are the best teachers so that the incoming students know who should they put their classes with, so they can learn more and better that will be useful for them in the future.

Gilberto Rogel García

]]>
https://creativecommons.org/licenses/by/4.0/
#QUIZ10 Wish Lists https://kenscourses.com/tc101winter2015/2015/quiz10-wish-lists/ Thu, 23 Apr 2015 16:19:37 +0000 https://gilrg18.withknown.com/2015/quiz10-wish-lists Continue reading ]]>

Useful link: HERE

Link for the codes: HERE

 

Gilberto Rogel García A01630171

]]>
https://creativecommons.org/licenses/by/4.0/