The elif Statement

--Originally published at Waste your time

The elif statement allows you to check multiple expressions for TRUE and execute a block of code as soon as one of the conditions evaluates to TRUE.

So….. Whast the diference with Else???? isn`t just the same??

562947_original

unlike else, for which there can be at most one statement, there can be an arbitrary number of elif statements following an if.

Can you show me an example raw-3

if country == "US":
    if total <= "50":
        print "Shipping Costs $6.00"
    elif total <= "100":
            print "Shipping Costs $9.00"
    elif total <= "150":
            print "Shipping Costs $12.00"
    else:
        print "FREE"

Reference

https://www.tutorialspoint.com/python/python_if_else.htm


Conditional IF

--Originally published at Waste your time

well if you dont know about this you can go with this dude luis-eduardo-falcon-10

he can teach you about this,  plus the good thing its that you can find him in the campus.

He is legend…… wait fot it… dary, Legendary!

I can try to explain you really easy so IF is use to  create true or false statemente so for example:

its like  if you already get laid more less than  4 times(assuming your not an ISC right) send losser, if is more than 4 send   Nice bro!

so the thing you wnat to do is you want to type:

Laid = int(raw_input(“Virgin: “) )

if Virgin >=  4

print”Nice Bro!”

if Virgin < 4

print”LOSER, you are probably an engineering”

 

BYE!

 

 


Using modules

--Originally published at Waste your time

first of all we need to know what is a module! its like if you want to use a playstation without knowing what is a playtation, right ?raw

well, A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended.

its really easy to understand right?

for using a library you use import. i really dont think i can explain you better than this video so i lilve you the link right here

Enjoy!


Functions

--Originally published at Waste your time

A function is a reusable code that is used to perform a single, related action.

Functions provide better modularity for your application and a high degree of code reusing.

So the most awesome thing is that you actually can make your own function. These functions are called user-defined functions.

  • Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).

  • Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.

  • The first statement of a function can be an optional statement – the documentation string of the function or docstring.

  • The code block within every function starts with a colon (:) and is indented.

  • The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None.

i found something else that i didnt know, is that it exist Anonymus Functions, i founf out how  is permited using them and how to put it, but im not sure how to use them, so if annyone in #TC101 knows how and when its better to use a Annonymus Functions Please Share this with me

also i found this really cool website, its like Python For dommies, so if you are feelling like a dummy and you want to lear Python just click here

source here


Basic data Types

--Originally published at Waste your time

the basic data type is booleans , numeric, sequences , and mapping

Booleans are values that can only be True or False,

sin-titulo3

Python supports four different numerical types −

  • int (signed integers): They are often called just integers or ints, are positive or negative whole numbers with no decimal point.
  • long (long integers ): Also called longs, they are integers of unlimited size, written like integers and followed by an uppercase or lowercase L.
  • float (floating point real values) : Also called floats, they represent real numbers and are written with a decimal point dividing the integer and fractional parts. Floats may also be in scientific notation, with E or e indicating the power of 10 (2.5e2 = 2.5 x 102 = 250).
  • complex (complex numbers) : are of the form a + bJ, where a and b are floats and J (or j) represents the square root of -1 (which is an imaginary number). The real part of the number is a, and the imaginary part is b. Complex numbers are not used much in Python programming.

 

 

Source HERE

A mapping object

maps immutable values to arbitrary objects. Mappings are mutable objects. There is currently only one standard mapping type, the dictionary. A dictionary’s keys are almost arbitrary values. Only values containing lists, dictionaries or other mutable types (that are compared by value rather than by object identity) may not be used as keys.

 

 

 


Using If & Else to set an alarm.

--Originally published at Waste your time

Nicee !!!

Carolina's Blog Site

So, Alex (@hkael.wordpress.com) and I created a program using if and else statements to set an alarm. It took awhile, and at the end, we realized:

a) it doesn’t take into account minutes, which would make it a more complex piece of code, and we like, don’t know how to do it-YET!

b) Ken told us there’s actually already a module that does this.

Lol. It was fun though.

Enjoy the screenshots.

alarm final extra fibal

SO…..Later today I had a life altering realization. I thought the print function would only display strings, so I also converted integer values to strings and displayed all of them using +++. But I just discovered you can totally print stuff that has strings and integers, as long as you separate them with ,,,,. Whoa.

I know this doesn’t seem like much of a difference, but I feel like it’s always better to be zenny about it and write…

View original post 4 more words


Input python

--Originally published at Waste your time

inputs are functions that allows us to make a sequence.

Today we are going to see he diference between using an input, a raw_input
First we are gonna start with inputs.

inputs allows the users to modify a variable,

sin-titulo2
Input Example

“raw_input” doesn’t convert the input and takes the input as it is given. Its advisable to use raw_input for everything.

You insert the raw input the same way as an input!! 


Comments in Python

--Originally published at Waste your time

I´m not an expert on python but like in any other languague comments are really helpfull and they have 3 main purposes;

1°for people that are reading your code: imagine you are working with more people, they need to be able to know what you have just done.

2° for you: when you are programming, the codes are really long and some times over the time you want to go back to correct something, so it´s easier to know what you done and where it is.

3°  reference

 When you are writting something you want to make sure to use comments, fpr this reasons,

¿how do you put comments in python?

with a #

So everithing after the # python its going to ignore, and it wont put it as a part of the command

and there are two ways you can put it 

alone in a line

in a line with code ( make sure the code is before the # )

comments