how to code python  

Page 1 / 6
  RSS

Robotics Lab
(@robotics-lab)
Active Member
Joined: 5 months ago
Posts: 15
2020-01-11 6:33 pm  

Hi everyone,  where would a good place to start learning python/C++ code?  is python or C++ code harder to learn? I have an Arduino (and will probably get a raspberry pi sometime) and I would love to learn to code it much better then I do now. 


Quote
Topic Tags
Robotics Lab
(@robotics-lab)
Active Member
Joined: 5 months ago
Posts: 15
2020-01-11 6:43 pm  

how do I give a suggestion for a new video? 


ReplyQuote
casey
(@casey)
Reputable Member
Joined: 10 months ago
Posts: 359
2020-01-11 6:44 pm  

I taught myself everything from books. When I bought an Arduino kit it came with a book "Getting started with Arduino". When I bought a Raspberry Pi I found a book "Programming the Raspberry Pi and Getting started with Python". The internet has lots of tutorials for beginners on just about everything. Just try them out and see which one fits your mode of learning.

Probably worth checking the date of the tutorials.

 

This post was modified 3 months ago 2 times by casey

ReplyQuote
DroneBot Workshop
(@dronebot-workshop)
Workshop Guru Admin
Joined: 10 months ago
Posts: 460
2020-01-11 7:50 pm  

@robotics-lab

Posted by: @robotics-lab

how do I give a suggestion for a new video? 

To suggest a new video please create a new topic in the "Suggest New Content" section!

?

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


ReplyQuote
byron
(@byron)
Estimable Member
Joined: 10 months ago
Posts: 197
2020-01-11 8:07 pm  

IMHO python is a lot easier to use than C++.   Make sure you learn on python 3.x as there are still loads of tutorials based on 2.x which is now ending its support life.   Note that Arduino Code is basically just C and does not usually use any of the ++ bits.  As @casey suggests loads of good free stuff on the web.   My very favourite for Python is Corey Schafer on youtube.  A lot of his videos are advanced topics but look for his playlist 'Python Programming Beginners Tutorials'.    However I did have programming experience (C programming way back in the 1970's and some basic/Visual basic in the 80's and 90's) when I came to these tutorials so its hard for me to judge how a complete beginner would find them.   


ReplyQuote
casey
(@casey)
Reputable Member
Joined: 10 months ago
Posts: 359
2020-01-11 8:45 pm  

Python is a high level language and simply due to its popularity and professional support (libraries) you need to learn how to use it. Python is probably much easier to write complex programs but their performance will depend on the libraries you use. C++ allows low level programming but requires a lot more expertise to use. With Python using the editors and including libraries in your code is simple whereas trying to do the same with a C++ ide is a nightmare. Beyond the basics C++ is useless, as is any language, without being able to include libraries.

Personally I prefer books as they are easier to reference.
Sadly the technical bookshops have been wiped out by Amazon. I like to handle and look at things before buying to see if they are worth buying in the first place.

books

 


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 9 months ago
Posts: 384
2020-01-12 2:53 am  

@byron

Posted by: @byron

Note that Arduino Code is basically just C and does not usually use any of the ++ bits

Hold your horses! - I believe it's actually the other way around 🙂

 


ReplyQuote
byron
(@byron)
Estimable Member
Joined: 10 months ago
Posts: 197
2020-01-12 7:03 am  
Posted by: @frogandtoad

@byron

Posted by: @byron

Note that Arduino Code is basically just C and does not usually use any of the ++ bits

Hold your horses! - I believe it's actually the other way around 🙂

 

Strickly speaking it is c++ but because of the small memory the programming habits of oo are not a good idea and in effect one is using the syntax of C.  A beginner would be advised to learn C rather than C++ for getting up to speed with Arduino, although probably even better just follow a book on programming Arduino


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 9 months ago
Posts: 384
2020-01-12 9:22 am  

@byron

Indeed, it is C++!

Posted by: @byron

A beginner would be advised to learn C rather than C++ for getting up to speed with Arduino

Um... sorry to disagree with you again, but most of what you do in Arduino today is actually C++ using that OOP stuff! 🙂

That beloved String type with it's internal member functions is all that OOP C++ stuff, so is that Serial stuff with it's member functions, and that Stepper and Servo stuff with their member functions, other libraries, etc...

You may be unaware of it, but you are almost always using C++ OOP features when coding in Arduino, so it's not wrong to start learning C++ right off the bat.

Indeed, there is a lot of common core language, but C != C++.


ReplyQuote
byron
(@byron)
Estimable Member
Joined: 10 months ago
Posts: 197
2020-01-12 9:35 am  

@frogandtoad 

Hey, don't be sorry to disagree, my waffling should be challenged.  Its always interesting to hear of other experiences.   I agree that a lot of stuff one does in Arduino is supported by libraries written in C++, but I still think that a beginner would not look beyond including the libraries in their code and learning C++ just for Arduio would be a tremendously unnecessary burden.   But then I also think that using micro-python or python on an Arduino comparative board would also be the best route for a beginner. ? 


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 9 months ago
Posts: 384
2020-01-12 9:53 am  

@byron

No worries 🙂

Posted by: @byron

I still think that a beginner would not look beyond including the libraries in their code and learning C++ just for Arduio would be a tremendously unnecessary burden.

On the contrary... if you want to learn Arduino, even the most basic libraries use classes with member functions, so learning about OOP and how to pass objects around will make you (IMO), a better Arduino developer. 

C++ is a beautiful language IMO, and spending a little time to learn it can really open up some creativity 🙂

 


ReplyQuote
Pugwash
(@pugwash)
Prominent Member
Joined: 10 months ago
Posts: 969
2020-01-12 10:18 am  
Posted by: @frogandtoad

@byron

No worries 🙂

Posted by: @byron

I still think that a beginner would not look beyond including the libraries in their code and learning C++ just for Arduio would be a tremendously unnecessary burden.

On the contrary... if you want to learn Arduino, even the most basic libraries use classes with member functions, so learning about OOP and how to pass objects around will make you (IMO), a better Arduino developer. 

C++ is a beautiful language IMO, and spending a little time to learn it can really open up some creativity 🙂

 

OOP is far too complex for absolute beginners! Until variables, conditionals. loops and possibly function calling has been thoroughly mastered, advanced topics like OOP, as practical as they are, should not be approached. This is definitely subject matter for intermediate users.

I consider programming and coding as two different entities, but in the amateur world is usually embodied in one person. Programming, by my definition, being the logical control or flow control of a program. Whereas coding is the ability to use syntax, grammar and punctuation as the last interaction between humans and the machine to make sure that the concept works correctly.

If someone could just write line by line, and in plain English, how they would they could print out every prime number between one and a million, then they have already made a huge step into programming but they still can't code. But this logical flow can be translated into every programming language from C++ to Python to Java.

SteveC - Topple Rudd Poltman


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 9 months ago
Posts: 384
2020-01-12 11:00 am  

@pugwash

Posted by: @pugwash

OOP is far too complex for absolute beginners!

I think it all depends on what exactly you mean by that?
The message I'm trying to send, is that everyone who programs in the Arduino IDE is already programming in OOP, even though they don't know it, so it's a little contradictory to say it's a bit too complex, no?

For example... when you write:

    Serial.begin(9600);    // This is OOP
    Serial.print("foo\n"); // This is OOP

    Servo.write(42); // This is OOP

    Stepper.step(42); // This is OOP

Why deprive people from knowing they're already using OOP?
Why not encourage it's use instead?

Indeed, programming concepts are the most critical aspect of any programming skill set, but such basic concepts of iteration, conditions and program structure are not inherent to OOP, but all programming languages in general.


ReplyQuote
Pugwash
(@pugwash)
Prominent Member
Joined: 10 months ago
Posts: 969
2020-01-12 11:15 am  

@frogandtoad

I see where you are coming from, but my question is "Do they NEED to know that they are calling an object method with a parameter?" before they have learnt basic program control!

I don't think so and it can be explained in detail later. For the beginner, how to get a response on the serial monitor should suffice to begin with.

The more complexity thrown at the beginner, the more off putting it will be.

SteveC - Topple Rudd Poltman


ReplyQuote
byron
(@byron)
Estimable Member
Joined: 10 months ago
Posts: 197
2020-01-12 11:18 am  

In the world of hobby programming just how much use is OOP.   (tin hat required? ? )

In the Python world there is some debate amongst proper Python experts (I'm just a dabbler) about the over use of classes whereas it would be much better in most cases just to use functions.  Much easier to read the code without that class self.xxx stuff.   Classes easier to re-use than functions? - well in most cases just rewriting the function in a future code will probably be just as easy...  etc etc,  or so the debate goes.   I do think they have a point especially for the hobby programmer.  A good understanding of classes may be useful to follow through some of the libraries available in Python such as xyPython for GUI programming for example, but this can all come after the basics have been studied.

And from the zen of Python 'Simple is better than complex' and 'Readability counts'  I couldn't agree more.

As for the ++ in C.. consider it a C- for me.


ReplyQuote
Page 1 / 6

Please Login or Register