Python For Beginners 1
Python For Beginners 1
Welcome! Are you completely new to prograrnrning? If not then we presume you will be
looking for information about why and how to get started with Python. Fortunately an
pick
experienced programmer in any prograrnming language (whatever it may be) can
up Python very quickly. It's also easy for beginners to use and learn, so jump in!
Installing
distributions
Installing Python is generally easy, and nowadays many Linux and UNIX
include a recent Python. Even some Windows computers (notably those from HP) now
confi
come with Python already installed. If you do need to install Python and aren't
dent about the task you can find a few notes on the BeginnersGuide/Download wiki
page, but installation is unremarkable on most platforms.
Learning
tai
Before getting started, you may want to find out which IDEs and text editors are
lored to make Python editing easy, browse the list of introductory books, or look at
code samples that you might find helpful.
fairly brief tutorial that gives you basic information about the language and gets you
started. You can follow this by looking at the library reference for a full description of
Python's many libraries and the language reference for a complete (though somewhat
dry)explanation of Python's syntax. If youare looking for common Python recipes and
patterns, you can browse the ActiveState Python Cookbook
areference to the Monty Python script of that name). There is also asearch page for a
numberof sources of Python-related information. Failing that, just Google for a phrase
including the word "python'" and you may well get the result you need. If all else fails,
askon the python newsgroup and there's agood chance someone will put you on the
right track.
About Python Programming
" Free and open-source -You can freely use and distribute Python, even for
commercial use.
. Easy to learn -Python has a very simple and elegant syntax. It's much easier
to read and write Python programs compared to other languages like C+t,
Java, C#.
" Portable- Youcan move Python programs from one platform toanother, and
run it without any changes.
The popularity of Python is growing rapidly. Now it's one of the most popular
programming languages.
. Python tutorial from Programiz -We provide step by step Python tutorials,
examples, and references. Get started with Python.
. OfficialPython tutorial -Might be hard to follow and understand for
beginners.Visit the official Python tutorial.
Example : Using a flag variable
# Program to check if a number is prime or not
num = 29
if num 1
print (nu, "is not a prime number")
elif num > 1:
heck for factors
for i in range(2, num):
if (nun % i) s 0:
# if factor is found, set flag to True
flag True
# break out of loop
break
Run Code »
Output
29 is a prime number
In this program, we have checked if num is prime or not. Numbers less than or
equalto 1are not prime numbers. Hence, we only proceed if the num is greater
than 1.
You can change the value of variable num in the above source code to check
whether a number is prime or not for other integers.
In Python, we can also use the for...else statement to do this task without
using an additional flag variable.