Posts: 5
Threads: 1
Joined: Feb 2019
Reputation:
0
So I'm reading a python3 book and working with int(). I follow the directions everything is fine. They have me typing in the shell int('2') and see the result. I noticed if I type int(2) with no apostrophe i get the same result. So my question is this, is there a difference?
Posts: 3,237
Threads: 125
Joined: Jul 2014
Reputation:
0
Hello teage,
it can be used apostrophes where the integer is to print within a string using the speech marks " "
There is an example here https://www.programiz.com/python-program...ilt-in/int
Posts: 5
Threads: 1
Joined: Feb 2019
Reputation:
0
(02-06-2019, 02:26 AM)bitsnpcs link Wrote: Hello teage,
it can be used apostrophes where the integer is to print within a string using the speech marks " "
There is an example here https://www.programiz.com/python-program...ilt-in/int
So its a string that can be added, multiplied, divided etc?
example 1 of the url shows,
# integer
print("int(123) is:", int(123))
# float
print("int(123.23) is:", int(123.23))
# string
print("int('123') is:", int('123'))
so then I experiment with this,
>>> int('2')+int('2')
4
>>> int("2")+int("2")
4
>>> int(2)+int(2)
4
forgive me if my questions seem a bit silly, im just trying to wrap my head around it. :o
Posts: 3,237
Threads: 125
Joined: Jul 2014
Reputation:
0
02-06-2019, 03:22 AM
(This post was last modified: 02-06-2019, 05:01 AM by bitsnpcs.)
(02-06-2019, 02:50 AM)teage link Wrote: So its a string that can be added, multiplied, divided etc?
forgive me if my questions seem a bit silly, im just trying to wrap my head around it. :o
In this example yes.
Int can be used to convert a value into a number (an integer), then the calculations can be done on it etc.
The value can be one of any of the types.
What book are you using ?
It may be you are experimenting further than the current chapter covers, and things will be explained in more detail in future chapters .
You might need a faster paced book, or enjoy to make some projects extra to the book so you can experiment.
I am learning Python2, one book I use Python Crash Course by Eric Matthes I learn Python2 and Python3 along side, I am only on Chapter 3 of it, as I have been busy lately so only had time for 1 book to use for learning and that has been the Linux Command Line.
For when I complete my Python2 books, the first Python3 book I have and will use is called "O'Reilly Head First Python".
Posts: 3,237
Threads: 125
Joined: Jul 2014
Reputation:
0
02-06-2019, 04:16 PM
(This post was last modified: 02-06-2019, 04:22 PM by bitsnpcs.)
Different ways to learn code, or learn most things.
Method one looks so boring. The branches dont really do much.
Method 2 looks alive, each dot is the outcomes of the chaos merging to form a result/project you do whilst learning , notice how the branches all go somewhere , they have a use, and a result. In reality most people will have huge numbers of strands on the image 2.
Method2 is good way to increase the pace of learning compared to Method1, the central line are the book/s you are learning from.
Posts: 5
Threads: 1
Joined: Feb 2019
Reputation:
0
I'm actually reading two books, http://inventwithpython.com which has been so far vey easy to understand and follow, and I'm also reading the html version of five into python 3 that is installed under my docs folder. I agree I'm most likely jumping the gun a bit maybe the answer will come full circle as I progress through the book.
Posts: 5
Threads: 1
Joined: Feb 2019
Reputation:
0
I'm definitely using the method 2 approach. I have gotten about half way through Zeds book,( learn python the hard way ) about a year ago. He started to lose me just wasn't clicking. Since then I have found an interactive book I plan to read as soon as I'm done with these others. I'm all over the place.
Posts: 3,237
Threads: 125
Joined: Jul 2014
Reputation:
0
02-06-2019, 09:35 PM
(This post was last modified: 02-06-2019, 10:13 PM by bitsnpcs.)
I think when you want to jump forward it is a good sign you are enjoying learning Python and find it interesting.
On inventwithpython url which book are you using ?
I like Al Sweigart books a lot, he is a really good teacher for Python, I have these books by Al Sweigart -
Automate the boring stuff with Python - (it is the best first book to use to learn Python imo), I am using Chapter 2 of this book.
Invent your own computer games with Python - I am using Chapter 5 of this book. (another good first choice book)
Cracking codes with Python - just looked at Chapter 1, I had to wait for some tools to make the wheels nicely.
Making games with Python and Pygame - I haven't looked at this yet it is for doing last of the first books, I am not in to games, I like code, and to see results so it's an easy way to do that etc.
Online the majority I read recommended Zed Shaw - Learn Python the Hard way, I have the Python2 version, I am on Chapter 17 of this book, but have not been using it since I began with the other books, later I will return to it. Personally I don't like this book he has a nasty attitude, that is distracting/disruptive.
The 2 chapters of Automate the boring stuff with Python & 5 chapters of Invent your own computer games with Python were enough to start making my first software/apps, it was where I began trying this.
It took me 1+ year to complete the first app, from idea to finished how I was happy with it as a first one.
It's possible to do projects at the same time as learning, and in between using the books, whenever you feel like it, or have an idea you want to try out for fun, plus you can learn extra things doing your projects, it is all practice.
Posts: 3,237
Threads: 125
Joined: Jul 2014
Reputation:
0
(02-06-2019, 08:54 PM)teage link Wrote: I'm definitely using the method 2 approach. I have gotten about half way through Zeds book,( learn python the hard way ) about a year ago. He started to lose me just wasn't clicking. Since then I have found an interactive book I plan to read as soon as I'm done with these others. I'm all over the place.
I use method 2 also, by "my method" I mean it is belonging to whoever uses it, not me personally, even though I use this way too.
Method 2 is organic, free flowing and malleable, its a good way to learn.
Posts: 5
Threads: 1
Joined: Feb 2019
Reputation:
0
(02-06-2019, 09:35 PM)bitsnpcs link Wrote: I think when you want to jump forward it is a good sign you are enjoying learning Python and find it interesting.
On inventwithpython url which book are you using ?
I like Al Sweigart books a lot, he is a really good teacher for Python, I have these books by Al Sweigart -Automate the boring stuff with Python - (it is the best first book to use to learn Python imo), I am using Chapter 2 of this book.Invent your own computer games with Python - I am using Chapter 5 of this book. (another good first choice book)
Cracking codes with Python - just looked at Chapter 1, I had to wait for some tools to make the wheels nicely. Making games with Python and Pygame - I haven't looked at this yet it is for doing last of the first books, I am not in to games, I like code, and to see results so it's an easy way to do that etc.
Online the majority I read recommended Zed Shaw - Learn Python the Hard way, I have the Python2 version, I am on Chapter 17 of this book, but have not been using it since I began with the other books, later I will return to it. Personally I don't like this book he has a nasty attitude, that is distracting/disruptive.
The 2 chapters of Automate the boring stuff with Python & 5 chapters of Invent your own computer games with Python were enough to start making my first software/apps, it was where I began trying this.It took me 1+ year to complete the first app, from idea to finished how I was happy with it as a first one.
It's possible to do projects at the same time as learning, and in between using the books, whenever you feel like it, or have an idea you want to try out for fun, plus you can learn extra things doing your projects, it is all practice.
I am reading (Invent Your Own Computer Games with Python, 4th Edition). I like this book a lot. So much so that I bought a paper back copy on amazon. I am not much into games but the book is excellent and easy to understand. My son will love it he is very technical. I wish I had these resources when I was young : . I am interested in the cracking codes book too maybe I will check it out sometime down the road.
|