element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog My Very First Ever Python Programme and on a Raspberry Pi
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Raspberry Pi requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dubbie
  • Date Created: 14 Mar 2020 1:08 PM Date Created
  • Views 353 views
  • Likes 8 likes
  • Comments 18 comments
  • python;
  • rpi-bc
Related
Recommended

My Very First Ever Python Programme and on a Raspberry Pi

dubbie
dubbie
14 Mar 2020

I wished to join the Raspberry Pi day activity so I decided that I would combine this with writing my very first own Python programme as well. I recently did an online Python course which had some directed programmes in but I wanted to make up my own unassisted. As I am shortly going out for lunch this had to be very short so I decided on

 

print("Hello and Happy Pi Day")

 

Next I needed my Raspberry Pi which is still integrated into my HoloPiBot (HoloPiBot #10 : It Actually Works - It Really Does! ) so I just plugged in cables, keyboards, mouse and eventually power supply  (when I found it!) as I vaguely remembered how to do. Turned it on and amazingly it still all worked. I must have learned something after all. There is a bit of video of this, but the battery on my camera ran out - it doesn't seem to be charging so I might need a new camera - and this is all I captured.

 

You don't have permission to edit metadata of this video.
Edit media
x
Upload Preview

 

Following this I needed to start Python. I had no idea whether my Pi had Python so I decided to Google it, using my Pi, of course. Seems that it does have Python so I just went to the command line, typed in Python, then the programme above and it worked! If I have time over this weekend I might now try flashing an LED on and off - no promises though.

 

The Power of computing.

 

 

Dubbie

Anonymous

Top Comments

  • airbornesurfer
    airbornesurfer over 2 years ago in reply to dubbie +4

    Sudo ("superuser do") is basically the shorthand for all elevated privileges in Linux. Or, as Randall Munroe so eloquently illustrated:

  • beacon_dave
    beacon_dave over 2 years ago in reply to dubbie +4

    You may find this MagPi beginner's guide on the Python GPIO Zero library of interest:

    https://www.raspberrypi.org/magpi-issues/Essentials_GPIOZero_v1.pdf

  • shabaz
    shabaz over 2 years ago in reply to beacon_dave +4

    With newer versions of Python 3, there's another option too - really nice:

     

    import math
    print(f"Hello and Happy {math.pi} Day")

     

    The Jive syntax highlighting has not kept up though! : )

Parents
  • clem57
    clem57 over 2 years ago

    Not a bad beginning dubbie . For flashing led, you may need sudo.

    Clem

    • Cancel
    • Up +3 Down
    • Reply
    • More
    • Cancel
  • dubbie
    dubbie over 2 years ago in reply to clem57

    Clem,

     

    I was under the impression that you can control Pi I/O directly from Python. Is this not true? Also, what is sudo? I've seen it mentioned before and I've probably typed it in but I do not know/understand what it does.

     

    Dubbie

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
  • clem57
    clem57 over 2 years ago in reply to dubbie

    This gives administrator permission usually root. Unless your I'd is added to a special group, you need this to work on the hardware level.

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 2 years ago in reply to dubbie

    You may find this MagPi beginner's guide on the Python GPIO Zero library of interest:

    https://www.raspberrypi.org/magpi-issues/Essentials_GPIOZero_v1.pdf

    • Cancel
    • Up +4 Down
    • Reply
    • More
    • Cancel
  • dubbie
    dubbie over 2 years ago in reply to airbornesurfer

    Matthew,

     

    That's make sense.

     

    Dubbie

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
  • dubbie
    dubbie over 2 years ago in reply to clem57

    Clem,

     

    This also makes sense. However, if I can give myself permission to use the hardware level, it doesn't seem to confer much protection. Is it like being Administrator in Windows?

     

    Dubbie

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
  • dubbie
    dubbie over 2 years ago in reply to beacon_dave

    Dave,

     

    Thanks for this. I have downloaded this eBook and will review it later. Will these commands also work with an ordinary Pi?

     

    Dubbie

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
Comment
  • dubbie
    dubbie over 2 years ago in reply to beacon_dave

    Dave,

     

    Thanks for this. I have downloaded this eBook and will review it later. Will these commands also work with an ordinary Pi?

     

    Dubbie

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
Children
No Data
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube