Recent Posts

Type conversion

Type conversion



Exercise 3 : Converting to an integer


We will try to run a program, but we will see some errors. In the exercise, we will need to find somebody's age.
We will find some errors. That's because we need to convert it to an integer.





1980 is different for '1980'  ..One is an integer the other is a string.So basically python doesn't know how to evaluate this expression: 2019-'1980'

We need to transform birth year into an integer with int(birth_year)



Every time we get Input we need to convert into integer or float



Exercise 4: Converting to a float

We will use an exercise where we will convert to float. Here  we will calculate the weight in Kilos 

My weight in libs. is 180 . we can see the results




We can get the first character of a string based on 01234



We can get the second last for example
We can get a sequence

We can get a string after 0, the first one




We can get more variations based on that



Type conversion Type conversion Reviewed by ohhhvictor on May 04, 2019 Rating: 5

No comments:

Facebook

 photo imagen120.jpg
Theme images by 5ugarless. Powered by Blogger.