You are Here:
Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section



Beginning with Python

Author (Read 39776 times)

0 Members and 21 Guests are viewing this topic.

Re: Beginning with Python
« Reply #29 on: April 15, 2017, 10:27:55 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
I noticed a lot of people (and me too) have trouble with this one initially, so I decided to add it here to save people time so they can understand it sooner and continue the learning rather than get hung up on more advanced details if searching about it.

% - Modulus explained -

100-25*3%4
answer 97

Why -
25*3%4
25*3=75
75%4
answer 3

How it works -
75 divided into 4= 18 times
18x4=72
75-72= r3
%=3

Actual calculation at the final stage is -
100-3
so it is why the answer was 97


First of the ex3 explained

3+2+1-5+4%2-1/4+6

3+2+1=6
6-5=1
4%2=0  (4 divided into 2=2, zero remains, modulus %=0)
1+0=1
1/4=0 (1 cannot divide into 4 using whole numbers)
1-0=1
1+6=7
so it is why the answer was 7

I used Python calculating to work it out.
Just open python in terminal then trial error the various breakdowns until I understood what was happening.
Which was part of the #2 extra practices, so it also means can multi-task and 2 things at same time, if trying this.

I hope it helps someone else learning if they get stuck on modulus.
« Last Edit: April 15, 2017, 10:30:30 AM by bitsnpcs »
 

Re: Beginning with Python
« Reply #28 on: April 14, 2017, 02:12:03 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
I finished these 15 exercise now, other than the self learning in exercise 15 which I will use The Linux Command Line book for, 3 are covered in Chapter 9 and the first is covered in Chapter 17, being only on Chapter 4 its a long way off for me.

I didn't find any other errors as such.
But... exercise 13 -
he says to create a test2.txt then cat it, he does not say to type that contents in to the file so it will produce zero results, and will waste your time.
Better to cat test.txt to see the lines from previous exercise, he writes after exercise 13 in the "You learned this", also to cat test.txt and see the output from last exercise, it was the only way I managed to understand wtf he was on about.
Hopefully it will save someone not to waste their time also on exercise 13, and to read after the exercise ,what you have learned, before learning it, then you will actually be able to learn it etc.

The printed url for the Bash Cheat Sheet under title Unix Bash References is incorrect it has cli at the start of the url and this goes to the sales page not the free pdf.
This is the correct url


I am hoping the Python chapters are of a better quality.

Update -
They are.
I have completed the Python exercise 0, 1, 2, and began 3, (before my available time ran out), his style of writing in the Python Chapters is very different to the command line course. It's extremely easy to follow and learn from. 8) (even for me)
« Last Edit: April 14, 2017, 06:32:32 PM by bitsnpcs »
 

Re: Beginning with Python
« Reply #27 on: April 03, 2017, 11:40:17 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
Hello,

for those using the book "Learn Python the Hard Way" I have found an error in the book.

Page 253 - Exercise 5 - Command Line Crash Course

Line 30 reads

cd ../../ ..

It needs to read

cd ../ ../ ../

I had tried the exercise 3 or 4 times and got an error in the terminal each time, eventually I cd back to home and began further on in the exercise, and where the cd ../ is used later to move up 7 levels with no error, after completing the exercise I then tried the line 30 adding the final / like is in the later part of the exercise, this command then didn't give an error.
I redone the entire exercise with that added to line 30 and there were no errors produced in the terminal.

So I think he has made a mistake, that you will need to add in the book a / to the end of line 30 to complete the exercise.

I am using the Third Edition.

If you found any errors when using the book, or find any errors as you work through the book please can you also add them in the thread to help each other.
« Last Edit: April 03, 2017, 11:42:36 AM by bitsnpcs »
 

Re: Beginning with Python
« Reply #26 on: February 21, 2017, 07:34:50 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
I noticed in July 2017 the follow on book called - "Learn More Python the Hard Way - Zed Shaw" comes out, it is now available on Amazon pre-order, with a small discount of the price.


 

Re: Beginning with Python
« Reply #25 on: February 13, 2017, 03:27:38 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
Yes, it helps thank you  :)
 

Re: Beginning with Python
« Reply #24 on: February 12, 2017, 11:19:16 PM »
 

LL-user

  • I come here a lot
  • *****
  • 455
    Posts
  • Reputation: 214
  • Linux Lite Member
    • View Profile
You're welcome :)

Regarding gedit (I'm also using more and more instead of leafpad), sorry I don't get your question.
Here is some general info in the hope it provides you some answer. Otherwise let us know :)

[1] Syntax highlighting

gedit provides syntax highlighting for a wide range of markup, programming, and scientific languages. If gedit recognizes the syntax being used when you open a file, it will automatically highlight the text.

If your syntax or language is not highlighted upon startup, you can select the appropriate syntax or language by clicking View ▸ Highlight Mode, and then choosing the desired syntax. Alternately, you can select the syntax name from a list at the bottom of the gedit window.

[2] How do I add a syntax highlighter format to Gedit?

[3] Create a custom syntax highlight in gedit

Hope that helps :)
 

Re: Beginning with Python
« Reply #23 on: February 12, 2017, 07:44:32 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
Hello LL-user,
Thank you  :)

At the base of Gedit it has a menu, by default it reads "Plain text", are these colours a guideline set for the chosen input, or are they specific to the one chosen, eg; I want to use the colours for CSS setting on this theme for Python.
 
« Last Edit: February 12, 2017, 07:51:36 PM by bitsnpcs »
 

Re: Beginning with Python
« Reply #22 on: February 12, 2017, 05:18:23 PM »
 

LL-user

  • I come here a lot
  • *****
  • 455
    Posts
  • Reputation: 214
  • Linux Lite Member
    • View Profile
Hi bitsnpcs,

If you have a look at the ownership and permissions of the folder you want to write to, you'll see it's owned by root (the Linux name for the administrator) and only root has write permission. Therefore the menu option for paste is greyed out for any other user.

If you would like to copy/move the files there with your file manager, right click on the folder and choose "Open as Administrator".

Via command line:
Code: [Select]
sudo cp -va monokai-exteded /usr/share/gtksourceview-3.0/styles/assuming you run this command within the folder monokai-exteded is located in. Otherwise you need to hand over the path.

Hope that helps :)
 

Re: Beginning with Python
« Reply #21 on: February 12, 2017, 12:18:12 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
I will save your instructions until I get used to doing this. :)

I have tried to install a theme "monokai-exteded" by adding it to this folder using copy/paste
 /usr/share/gtksourceview-3.0/styles/

When I right click inside the folder the menu option for paste is greyed out, how do I change this so I can add the theme ?
Will the theme still work if I change its filename before moving it has missing n.
 

Re: Beginning with Python
« Reply #20 on: February 12, 2017, 11:47:18 AM »
 

torreydale

  • PayPal Supporter
  • Platinum Level Poster
  • *****
  • 1588
    Posts
  • Reputation: 261
  • * Forum Moderator *
    • View Profile

  • CPU: Intel i5-3230M (4) @ 3.200GHz

  • MEMORY: 16Gb

  • VIDEO CARD: Intel 3rd Gen Core processor Graphics

  • Kernel: 5.x
You don't need to download Python, by the way.  It is already installed with Linux Lite and most Unix based operating systems by default, including Mac.  All you have to do in Linux Lite is open a terminal and type in the word "python," and you'll be in the Python interpreter.  To run a python program, you type in python and the filename, eg. python test.py.  You have to be sure you either include the full directory path of the file or that you're running the command from the directory where that file resides.
« Last Edit: February 12, 2017, 12:04:58 PM by torreydale »
Want to thank me?  Click my [Thank] link.
 

Re: Beginning with Python
« Reply #19 on: February 12, 2017, 11:27:56 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
Thank you torreydale, :) I have installed Gedit, it sounds ideal in your description as I don't want to feel overwhelmed with features either.
 

Re: Beginning with Python
« Reply #18 on: February 12, 2017, 08:54:00 AM »
 

torreydale

  • PayPal Supporter
  • Platinum Level Poster
  • *****
  • 1588
    Posts
  • Reputation: 261
  • * Forum Moderator *
    • View Profile

  • CPU: Intel i5-3230M (4) @ 3.200GHz

  • MEMORY: 16Gb

  • VIDEO CARD: Intel 3rd Gen Core processor Graphics

  • Kernel: 5.x
I use Geany and Gedit.  I'd probably use Gedit exclusively because I like the Cobalt theme and I don't feel overwhelmed with features, but Gedit doesn't have column select.  Geany and Gedit are both available via the repository (ie. Install/Remove Software).
Want to thank me?  Click my [Thank] link.
 

Re: Beginning with Python
« Reply #17 on: February 11, 2017, 04:46:47 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
Is the included Python in LL suitable full for learning with IDE, or is it for functionality in LL, and I need to download it ?

I am looking for newbie suitable recommendations of an IDE for Python, on Linux Lite, it will be -
 
1/ without too many panes.
2/ no auto complete, or it can be turned off. Indent is okay if it's not error prone.
3/ not white pane background, or has function to change this.
4/ can load projects to test within/internally, and provide error jump to code line, or log of project, or produce errors gui.

I am also looking for recommendation of nice gui creator for use with the above.
 

Re: Beginning with Python
« Reply #16 on: January 26, 2017, 08:21:23 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
Thanks Hans  :)



 

Re: Beginning with Python
« Reply #15 on: March 22, 2015, 04:42:24 AM »
 

Hans

  • New to Forums
  • *
  • 36
    Posts
  • Reputation: 8
  • Linux Lite Fellow
    • View Profile
Hi All,

I've found this course on YT and I'm following it. So far, I think it's the most comprehensive python set of tutorials I've watched.

"...But don't forget the songs that made you cry
And the songs that saved your life
Yes, you're older now
And you're a clever swine
But they were the only ones who ever stood by you"
 

 

-->
X Close Ad

Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section