Tuesday, December 19, 2017

Python Variables and Types

  • Python is free to use. 
  • It's very easy to build packages in Python, which is code, that you can share with other people to solve specific problems. 
Currently, there are two common versions of Python, version 2.7 and 3.5 and later.

Variables and Types
Every time you type the variable's name, you are asking Python to change it with the actual value of the variable. Weight corresponds to 68.7, and height to 1.79.
You can check out the type of a value with the type () function. To see the type of our bmi value, simply write type and then bmi inside parentheses. You can see that it's a float, which is python's way of representing a real number, so a number which can have both an integer part and a fractional part.

Python also has a type for integers: `int`, like this example.
A string is Python's way to represent text. You can use both double and single quotes to build a string.

The Boolean is a type that can either be True or False.
For the integers, the values were summed, while for the strings, the strings were pasted together. The plus operator behaved differently for different data types. This is a general principle: how the code behaves depends on the types you're working with.

0 comments:

Post a Comment

Contact

Talk to us (+91-9738925800)