Tag Archives: #TC101

#QUIZ10 #TC1017

Use of comments in Python

 – Use of comments in Python                                                                          @PablO_CVi

Comments are tracks that the programer can add to the code, this won`t change anything in the program, this is just for helping the person that is going to use the code. For adding a comment in Python you just have to put a hashtag like this:   goes your comment. This is how you can add comments to your code in python. Here you can see that this does not modify the program.

Here is the code i used for this program: https://github.com/PablOCVi/Mastery/blob/master/Mastery07.py

def Factorial!

 – Factorial Calculator                                                                                             @PablO_CVi

Create a program that asks the user for a non-negative integer (let’s call that number x) and display for them the value of x! (x factorial).

 

After showing them the answer, ask them if they would like to try another number (with a simple y/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered x).

Fun With Numbers(Pro Version)

 -Fun with numbers 2                                                                                          @PablO_CVi

Write a function for each calculation. Each function should define two parameters (in this example of type int) and return the correct value as an integer as well.

 

  • The sum of the two numbers.
  • The difference of the two numbers.
  • The product of the two numbers.
  • The integer based division of the two numbers (so no decimal point). First divided by second.
  • The remainder of integer division of the two numbers

Here is my code: https://github.com/PablOCVi/WSQ/blob/master/WSQ08.py  

Using elif…

 – Use of “elif” with a conditional                                                                   @PablO_CVi

The keyword elif is short for ‘else if’, and is useful to introduce lots of if in the code.

my code is: https://github.com/PablOCVi/Mastery/blob/master/Mastery17.py

If into a While

 – Nesting of conditional statements                                                                   @PablO_CVi

My code is: https://github.com/PablOCVi/Mastery/blob/master/Mastery18.py

Using Print

 – Basic output (print) in Python                                                                      @PablO_CVi

Here is my code: https://github.com/PablOCVi/Mastery/blob/master/Mastery10.py

Featuring the Work

 – Submit work via Blog RSS and GitHub                                                          @PablO_CVi

This is the use of while.