LINUX LITE 7.2 FINAL RELEASED - SEE RELEASE ANNOUNCEMENTS SECTION FOR DETAILS


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
int(3) and int('3') is there a difference? (python3.5)
#11
I use paper copies of the books too, I find pdf's very hard to use when learning but read other books as these. So tend to use the paper books. I have this stand for whichever book I use it has two bars to hold it open on the page you choose I put this next to the monitor to its right then I can read from it and the screen, with no light or info changes on screen. It has been really useful. You can tilt the angle of it there are steps/slots at the back and a bar to slot in to whichever angle you want.
Cracking Codes with Python is interesting it has a lot of historical information of how code was used for privacy and the methods. One day I'll get around to going to visit Bletchley Park, I liked the Drama show about it too. It was where they cracked the codes in WW2, one group of the crackers were all women.

Other Python books I have are -
The definitive Guide Series - Python - the beginners guide, I have used a fair amount of this.
Make games with Python - it is a Raspberry Pi book, available free as a pdf too, on MagPi website.
Think Python - O'Reilly
My partner got me these ones at christmas and said to do them in this order after all of the first books above -
Effective Computation in Physics
Learning Python
Programming Python
Python Pocket Reference

The Learning & Programming Python books are aka "the pink kettle bells", as this is what I was told was inside the box, my extraction of info is obviously in serious need of improvement based on that fail lol.
Reply
#12
Python is one of my favourite languages.

I think they only mentioned int('2') to demonstrate that int() can convert string data to integer data.

Quote:So its a string that can be added, multiplied, divided etc?

No, a string is more like a list of characters. If you multiply a string by a number, you get a string:

Code:
print("l" + "ol" * 5)

An integer is a numeric value that rounds to the nearest whole number. If you multiply an integer by another numeric value, you get a numeric value.

Code:
print(2.7 * 5)

type is a great command in Python. Here are some things you can try:

Code:
>>> type('5')

>>> type(5.0)

>>> type(int(5))

>>> type(int('5'))

>>> type(str(5))

>>> int('5.0')

>>> float('5.0')

>>> type(float('5.0'))

>>> int(float('5.0'))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)