Python Forum
Python Programming Projects for Beginners
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Programming Projects for Beginners
#1
1) Hello World
Ah, the all familiar "hello world," exercise that you do every time you start learning a new programming language. The goal here is to output a small message to introduce yourself to the language.

In Python, this is incredibly simple. All you need to do is open the interpreter and type the following:

print("Hello World")

print("My name is") #add your name after the word "is" obviously

If all goes well, you should see something like this:


> python3 #to call upon Python on MAC OS X use this command, for Windows use "python"

Python 3.5.1 (default, Jan 14 2016, 06:54:11)

[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> print("Hello World")

>>> print("My name is Bob")

Hello World

My name is Bob

Clearly, the command print is used to display content on the screen. Remember this command because you'll be using it often.

The text you see after the # symbol is called a comment. Comments do not appear at runtime, and are instead meant for the developers who will be working with the code. The comment we left above provides instructions for adding your name to the message. More often than not, comments will provide labels or quick descriptions for a snippet of code, so you can easily identify what a particular section is for.

2) Performing Calculations

Next, let's take a simple calculation and feed it through the interpreter to see what happens. Enter the following:
7 + 2
After typing in the equation above and hitting enter - to submit - you should see something like the following:

>>> 7 + 2
9

Notice how the interpreter automatically answers the equation and spits out the result?

3) Creating Your First String
A string is a sequence of characters that can be processed by a computer. The string is usually stored for manipulation later.

Strings must always begin and end with the same character, this is a requirement. In addition you can use either single or double quotations to signify a string, there is no difference between the two. The quotation marks only serve to inform Python that what's inside of them is a string.

Let's save your name as a string to call upon later. To do that, type the following into the interpreter:


>>> "Bob"

'Bob'

Congrats! You just created your first string, and this is signified by the information sent back to you. We can see that the name was saved as a string.

Now, we want to test out this string and see what kinds of things we can do with it. First, let's use multiple strings in tandem. Enter the following into the interpreter:


>>> "Hello there " + "my name is " + "Bob"

'Hello there my name is Bob'

Notice how Python adds the strings together before outputting the content?

Another neat trick you can do is multiply strings or manipulate them through equations.


>>> "Bob" * 4

'BobBobBobBob'

This may seem silly right now, as you would probably never need to multiply your name like this in the real world. However, this type of manipulation can really come in handy when you're working on large projects in Python that have a lot of strings.

To see your name in upper case - instead of using caps - try working with the following command:


>>> "Bob".upper()

'BOB'

Pretty cool, right?
Reply
#2
jack_sparrow007 Wrote:This may seem silly right now
Hmm. Don't you think a link to the official python tutorial is more efficient than this post?
Reply
#3
There is also the forum's own list of programming ideas and challenges.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#4
I just removed a link from the OP, which was spam buried in a bunch of stuff people are unlikely to read. I've added a warning for this user but this is probably plagiarism anyway, just try Googling "This may seem silly right now, as you would probably never need to multiply".
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Programming robots using Python OscarBoots 5 3,430 Oct-31-2021, 09:38 AM
Last Post: Larz60+
  Programming Difficult math in Python Huntern 6 4,758 Oct-17-2019, 06:32 AM
Last Post: Huntern
  Inconsistency in Python programming language? newbieAuggie2019 31 11,399 Oct-06-2019, 03:21 PM
Last Post: adt
  Programming Python as a MS Windows app? Brian123 8 4,238 Oct-17-2018, 10:26 PM
Last Post: Brian123
  Help with Python programming mediaos 5 3,753 Aug-08-2018, 01:02 PM
Last Post: Larz60+
  Python for machine learning, complete beginners pythonario 3 3,381 Dec-18-2017, 07:09 AM
Last Post: Terafy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020