Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152
‘#mastery08’ Articles at TC101 Fall 2015
Introduction to Programming Python and C++

Tag Archives: #mastery08

Mastery08

The Zen of Python The Zen of Python is an Interesting easter egg in Python. Originally written by Tim Peters in 2004, it as an informational entry number 20 in Python Enhancement Proposals You can find it by entering the statement “import this” I shall comment on a few of them because I think they […]

Mastery08: The Zen of Python

The zen of python is a set of 19 principles that rule the design of the programming language python 1.- Beautiful is better than ugly This basically means the fact that python is, unlike others, a language restricted by identations and arrangements; in python, identation … Continúa leyendo Mastery08: The Zen of Python

Mastery 8

On this mastery I’ll talk about coding conventions on C++. 

Coding conventions are just a set of “guidelines” that talk about the style to format a code. For example, how to correctly use braces, commas, comments, capitalization, etc. You can read a lot more of these “rules” in these webpages:

https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Style_Conventions

https://gcc.gnu.org/wiki/CppConventions

Since masteries 1 and 7 we’ve been using the correct style and format. If we weren’t, we could’ve just written all our codes in one line instead of multiple lines, for example, tell me how do you prefer to read a code, like this? ->

Or like this? ->

Which one is easier to read?

And know you now why there are coding conventions: to make everything look nice and easy to read.

Mastery 08 & 09

Mastery 08 – The Zen of Python Here’s the Zen of Python running inside my shell. Mastery 09 – Basic type and their use in Python Python has 6 different basic types of data. They are: Integers These are numbers that belong to all the real numbers. Floating point numbers These are all the real […]

MASTERY#8

TUTORIAL: https://youtu.be/YHx0e0-QfPk The Zen of Python, by Tim Peters 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 […]

Mastery 8 – Python conventions

Here i will show you what are the python conventions.
First of all, in python the indentation does matter. Indentantion is the way that python recognize if a code block has ended. For example:
if (a < b):
counter + =1
print (counter)
This is wrong because the IF has nothing inside it, instead it will always add 1+ to the counter because is at the same level as the IF. This is not C++ or JS where you can tell the program when your if ends with {}. The right way to do it is this:
if ( a < b):
     counter += 1
print(counter)
Also here are some tips to give a standar python style to your code:
-Just do one statement per line
Please don´t do this:
 
def ejercicio3(diccionario): return ((“Homework promedio:”, sum(diccionario[“homework”])/len(diccionario[“homework” ])), (“Quizzes promedio:”, sum(diccionario[“quizzes”])/len(diccionario[“quizzes”])), (“Tests promedio:”, sum(diccionario[“tests”])/len(diccionario[“tests”])))
Yes, this is a python program that actually works. As you can see it is very hard to read and you will make others to have a bad time trying to understand what you want to do. Don´t be a smart a** and put order to your code so that everyone can understand it. 
-Keep spaces between variables if necessary, just to make it more readable
-Build your functions on the top part of the code
I think that this is clear, declare your functions first and call them below. Try to declare all the functions you can on the top part and write the main program after that, this will make your code easier to read because if someone wants to follow the executuion order of your code he/she doesn´t have to look for a specific function on all the code; otherwise, he/she will know where the functions are and you will save him/her time.
Keep your code simple
Here is an example of the last point:
a = input(“Write a number”))
a = int(a)
for i in range(0,50)
     if i/a % 0:
          counter = counter + 1
b = counter*2
c = b+18
print (c)
This code is really simple but it can be done in less words and space, the proper way to do it is:
a =  int (input(“Write a number” ))
for i in range( 0 , 50 )
     if (i/a) % 0:
          counter += 1
print(counter*2+18)

 

Mastery Number 8

DO THIS MASTERY GUYS, IT’S SO WISE AND COOL. Spoiler: It’s an Easter Egg. hey there m8

Mastery 8: C++ coding conventions

Hi.. Here is the video: https://youtu.be/poTQ6MlIwi0
Thanks for wtching! 🙂

Mastery08

In this post I will talk briefly about what are the C++ conventions. C++ Conventions Apparently the C++ coding conventions are a set of rules that guide the programming around the world. This rules are essential in order to create programs that can actually be useful in different parts of the world. Each programming language […]

Mastery08

In this post I will talk briefly about what are the C++ conventions. C++ Conventions Apparently the C++ coding conventions are a set of rules that guide the programming around the world. This rules are essential in order to create programs that can actually be useful in different parts of the world. Each programming language […]

What should you work on?

Week #12 and more partial exams for you.

For this week's readings:
C++ (TC1017) should either be looking at support for your project, ImageMagick C++ libraries are a good start.
Python (TC1014) should be finishing chapter 11 (Dictionaries).