Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Presentation

python programming introduction

Rating
-
Sold
-
Pages
34
Uploaded on
29-09-2022
Written in
2022/2023

my document contains python basics, how to do python coding and how to make games and websites using python programming

Institution
Course

Content preview

PYTHON INTRODUCTION
Variable and Value

A variable is a memory location where a programmer can store a value. Example : roll_no, amount, name etc.
Value is either string, numeric etc. Example : "Sara", 120, 25.36
Variables are created when first assigned.
Variables must be assigned before being referenced.
The value stored in a variable can be accessed or updated later.
No declaration required
The type (string, int, float etc.) of the variable is determined by Python
The interpreter allocates memory on the basis of the data type of a variable.

Python Variable Name Rules

Must begin with a letter (a - z, A - B) or underscore (_)
Other characters can be letters, numbers or _
Case Sensitive
Can be any (reasonable) length
There are some reserved words which you cannot use as a variable name because Python uses them for other t

,Python Assignment Statements

The assignment statement creates new variables and gives them values. Basic assignment statement in Python i
Syntax

<variable> = <expr>

Where the equal sign (=) is used to assign value (right side) to a variable name (left side). See the following state

>>> Item_name = "Computer" #A String
>>> Item_qty = 10 #An Integer
>>> Item_value = 1000.23 #A floating point
>>> print(Item_name)
Computer
>>> print(Item_qty)
10
>>> print(Item_value)
1000.23
>>>
One thing is important, assignment statement read right to left only.
Example :
a = 12 is correct, but 12 = a does not make sense to Python, which creates a syntax error.

,Multiple Assignment
The basic assignment statement works for a single variable and a single expression. You can also assign a single
more than one variables simultaneously.
Syntax

var1=var2=var3...varn= <expr>

Example :

x=y=z=1

>>> x = y = z = 1
>>> print(x)
1
>>> print(y)
1
>>> print(z)
1

, Here is an another assignment statement where the variables assign many values at the same time.
Syntax

<var>, <var>, ..., <var> = <expr>, <expr>, ..., <expr>
Example :
x, y, z = 1, 2, "abcd“

In the above example x, y and z simultaneously get the new values 1, 2 and "abcd".

>>> x,y,z = 1,2,"abcd"
>>> print(x)
1
>>> print(y)
2
>>> print(z)
abcd

Written for

Institution
Course

Document information

Uploaded on
September 29, 2022
Number of pages
34
Written in
2022/2023
Type
PRESENTATION
Person
Unknown

Subjects

$8.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
Eeswara

Get to know the seller

Seller avatar
Eeswara Lovely professional university
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
3 year
Number of followers
1
Documents
3
Last sold
3 year ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions