Python is a high-level, general-purpose programming language that was created by Guido van Rossum in 1985. It is an interpreted, interactive, object-oriented language with features like dynamic typing and memory management. This document provides an overview of Python 3 and its basic syntax, data types, operators, decision making structures like if/else statements, and loops. It covers topics like variables, numbers, strings, lists, tuples, dictionaries, and type conversion between data types.
This document provides an overview of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented language and was created by Guido van Rossum. It then covers getting and installing Python, writing basic Python programs, variables and data types, operators, control flow statements like if/else, and other core concepts like functions, modules, and exceptions.
Python is a general-purpose programming language that is highly readable. It uses English keywords and has fewer syntactical constructions than other languages. Python supports object-oriented, interactive, and procedural programming. It has various data types like numbers, strings, lists, tuples and dictionaries. Python uses constructs like if/else, for loops, functions and classes to control program flow and structure code.
The document provides an overview of the basics of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented scripting language. It also covers Python's history and describes it as being easy to learn and read, easy to maintain, portable, and extensible. The document then details Python's core data types including numbers, strings, lists, tuples, and dictionaries. It provides examples of how to define and manipulate variables of each data type in Python.
This document provides an overview of the Python programming language in 3 paragraphs. It discusses that Python is a high-level, interpreted, interactive and object-oriented scripting language. It was created by Guido van Rossum in the late 1980s and derived from languages like C and C++. The document then covers some key features of Python, including that it is easy to learn and read, portable, extensible and supports object-oriented programming. It provides examples of Python's basic syntax including indentation, variables, data types, operators and more.
The document provides an overview of the Python programming language. It discusses what Python is, its history and naming, features like being dynamically typed and interpreted, popular applications like web development, machine learning, and its architecture. It also covers Python constructs like variables, data types, operators, and strings. The document compares Python to other languages and provides examples of common Python concepts.
This document provides an overview of Python data types including numeric, string, sequence, mapping, boolean, and set data types. It describes the main classes for each data type such as int, float, complex for numeric types, str for strings, list, tuple, range for sequences, dict for mappings, bool for booleans, and set, frozenset for sets. It includes examples of defining variables of each data type and using functions like type() and isinstance() to check the data type. It also summarizes key aspects of each data type like how they can be indexed, sliced, concatenated, and repeated.
unit (1)INTRODUCTION TO PYTHON course.pptxusvirat1805
This document provides an introduction to the Python programming language. It discusses what Python is, its history and features. It describes common uses of Python in industries like CIA, Google, Facebook, NASA. It also covers Python building blocks like identifiers, variables, keywords. Additionally, it explains Python data types like numeric, strings, lists, tuples and dictionaries. Finally, it discusses taking input in Python and type casting.
This document provides an overview of the basics of the Python programming language. It discusses Python's history and features, data types like numbers, strings, lists, tuples and dictionaries. It also covers Python concepts like variables, operators, control flow statements and functions. Specific topics covered include Python interpreters, comments, variables and scopes, data structures, conditional statements like if/else, and exceptions handling.
Python can be used as both an interpreted, interactive language and a scripting language. It supports common data types like integers, floats, strings, lists, and tuples. Tuples are immutable ordered sequences while lists are mutable. Strings support common sequence operations. Python code is indented with whitespace instead of braces. Variables are dynamically typed and assigned with '=' and objects can be sliced and tested for membership with operators like '+' and 'in'.
This document provides an agenda and overview for a Python training course. The agenda covers key Python topics like dictionaries, conditional statements, loops, functions, modules, input/output, error handling, object-oriented programming and more. The introduction section explains that Python is an interpreted, interactive and object-oriented language well-suited for beginners. It also outlines features like rapid development, automatic memory management and support for procedural and object-oriented programming. The document concludes by explaining Python's core data types including numbers, strings, lists, tuples and dictionaries.
Python is a general-purpose, high-level programming language that can be used for web development, software development, data analysis, and more. It was created in the 1980s by Guido van Rossum. The document discusses why Python is useful, including that it is interpreted, dynamically typed, strongly typed, requires less code than other languages, and works on many platforms. Basic Python syntax and data types are also covered.
Python Course In Ghaziabad. Scode network is best training institute for Python which provides Online Python course with complete certificates at an affordable price.
Here are the answers to the exercises:
1. The len() method is used to find the length of a string.
2. To get the first character of the string txt, it would be:
txt="hello"
x=txt[0]
3. The strip() method removes any whitespace from the beginning or the end of a string.
Python is an interpreted, object-oriented, high-level programming language with dynamic typing and dynamic binding. Its simple, easy to learn syntax emphasizes readability and it uses significant indentation to delimit code blocks rather than curly braces or keywords. Python supports modules and packages, which encourages program modularity and code reuse. It also has a large standard library.
A readable, dynamic, pleasant, flexible, fast and powerful language.
@ Kindly Follow my Instagram Page to discuss about your mental health problems-
-----> https://instagram.com/mentality_streak?utm_medium=copy_link
@ Appreciate my work:
-----> behance.net/burhanahmed1
Thank-you !
Kosmik is the best institute for Python training in Hyderabad Kukatpally/KPHB. kosmik provides lab facilities with complete real-time training with live sessions
call now: +91-8712186898, +91-8179496603, +91-6309565721
This document provides an introduction to the Python programming language. It discusses what Python is, its history and creator, why it is popular, who uses it, and how to get started with the syntax. Key topics covered include Python's readability, dynamic typing, standard library, and use across many industries. The document also includes code examples demonstrating basic Python concepts like variables, strings, control flow, functions, and file input/output.
How to Configure Vendor Management in Lunch App of Odoo 18Celine George
The Vendor management in the Lunch app of Odoo 18 is the central hub for managing all aspects of the restaurants or caterers that provide food for your employees.
The document provides an overview of the Python programming language. It discusses what Python is, its history and naming, features like being dynamically typed and interpreted, popular applications like web development, machine learning, and its architecture. It also covers Python constructs like variables, data types, operators, and strings. The document compares Python to other languages and provides examples of common Python concepts.
This document provides an overview of Python data types including numeric, string, sequence, mapping, boolean, and set data types. It describes the main classes for each data type such as int, float, complex for numeric types, str for strings, list, tuple, range for sequences, dict for mappings, bool for booleans, and set, frozenset for sets. It includes examples of defining variables of each data type and using functions like type() and isinstance() to check the data type. It also summarizes key aspects of each data type like how they can be indexed, sliced, concatenated, and repeated.
unit (1)INTRODUCTION TO PYTHON course.pptxusvirat1805
This document provides an introduction to the Python programming language. It discusses what Python is, its history and features. It describes common uses of Python in industries like CIA, Google, Facebook, NASA. It also covers Python building blocks like identifiers, variables, keywords. Additionally, it explains Python data types like numeric, strings, lists, tuples and dictionaries. Finally, it discusses taking input in Python and type casting.
This document provides an overview of the basics of the Python programming language. It discusses Python's history and features, data types like numbers, strings, lists, tuples and dictionaries. It also covers Python concepts like variables, operators, control flow statements and functions. Specific topics covered include Python interpreters, comments, variables and scopes, data structures, conditional statements like if/else, and exceptions handling.
Python can be used as both an interpreted, interactive language and a scripting language. It supports common data types like integers, floats, strings, lists, and tuples. Tuples are immutable ordered sequences while lists are mutable. Strings support common sequence operations. Python code is indented with whitespace instead of braces. Variables are dynamically typed and assigned with '=' and objects can be sliced and tested for membership with operators like '+' and 'in'.
This document provides an agenda and overview for a Python training course. The agenda covers key Python topics like dictionaries, conditional statements, loops, functions, modules, input/output, error handling, object-oriented programming and more. The introduction section explains that Python is an interpreted, interactive and object-oriented language well-suited for beginners. It also outlines features like rapid development, automatic memory management and support for procedural and object-oriented programming. The document concludes by explaining Python's core data types including numbers, strings, lists, tuples and dictionaries.
Python is a general-purpose, high-level programming language that can be used for web development, software development, data analysis, and more. It was created in the 1980s by Guido van Rossum. The document discusses why Python is useful, including that it is interpreted, dynamically typed, strongly typed, requires less code than other languages, and works on many platforms. Basic Python syntax and data types are also covered.
Python Course In Ghaziabad. Scode network is best training institute for Python which provides Online Python course with complete certificates at an affordable price.
Here are the answers to the exercises:
1. The len() method is used to find the length of a string.
2. To get the first character of the string txt, it would be:
txt="hello"
x=txt[0]
3. The strip() method removes any whitespace from the beginning or the end of a string.
Python is an interpreted, object-oriented, high-level programming language with dynamic typing and dynamic binding. Its simple, easy to learn syntax emphasizes readability and it uses significant indentation to delimit code blocks rather than curly braces or keywords. Python supports modules and packages, which encourages program modularity and code reuse. It also has a large standard library.
A readable, dynamic, pleasant, flexible, fast and powerful language.
@ Kindly Follow my Instagram Page to discuss about your mental health problems-
-----> https://instagram.com/mentality_streak?utm_medium=copy_link
@ Appreciate my work:
-----> behance.net/burhanahmed1
Thank-you !
Kosmik is the best institute for Python training in Hyderabad Kukatpally/KPHB. kosmik provides lab facilities with complete real-time training with live sessions
call now: +91-8712186898, +91-8179496603, +91-6309565721
This document provides an introduction to the Python programming language. It discusses what Python is, its history and creator, why it is popular, who uses it, and how to get started with the syntax. Key topics covered include Python's readability, dynamic typing, standard library, and use across many industries. The document also includes code examples demonstrating basic Python concepts like variables, strings, control flow, functions, and file input/output.
How to Configure Vendor Management in Lunch App of Odoo 18Celine George
The Vendor management in the Lunch app of Odoo 18 is the central hub for managing all aspects of the restaurants or caterers that provide food for your employees.
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...parmarjuli1412
The document provides an overview of therapeutic communication, emphasizing its importance in nursing to address patient needs and establish effective relationships. THERAPEUTIC COMMUNICATION included some topics like introduction of COMMUNICATION, definition, types, process of communication, definition therapeutic communication, goal, techniques of therapeutic communication, non-therapeutic communication, few ways to improved therapeutic communication, characteristics of therapeutic communication, barrier of THERAPEUTIC RELATIONSHIP, introduction of interpersonal relationship, types of IPR, elements/ dynamics of IPR, introduction of therapeutic nurse patient relationship, definition, purpose, elements/characteristics , and phases of therapeutic communication, definition of Johari window, uses, what actually model represent and its areas, THERAPEUTIC IMPASSES and its management in 5th semester Bsc. nursing and 2nd GNM students
Different pricelists for different shops in odoo Point of Sale in Odoo 17Celine George
Price lists are a useful tool for managing the costs of your goods and services. This can assist you in working with other businesses effectively and maximizing your revenues. Additionally, you can provide your customers discounts by using price lists.
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecdrazelitouali
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Exploring Ocean Floor Features for Middle SchoolMarie
This 16 slide science reader is all about ocean floor features. It was made to use with middle school students.
You can download the PDF at thehomeschooldaily.com
Thanks! Marie
Completed Sunday 6/8. For Weekend 6/14 & 15th. (Fathers Day Weekend US.) These workshops are also timeless for future students TY. No admissions needed.
A 9th FREE WORKSHOP
Reiki - Yoga
“Intuition-II, The Chakras”
Your Attendance is valued.
We hit over 5k views for Spring Workshops and Updates-TY.
Thank you for attending our workshops.
If you are new, do welcome.
Grad Students: I am planning a Reiki-Yoga Master Course (As a package). I’m Fusing both together.
This will include the foundation of each practice. Our Free Workshops can be used with any Reiki Yoga training package. Traditional Reiki does host rules and ethics. Its silent and within the JP Culture/Area/Training/Word of Mouth. It allows remote healing but there’s limits As practitioners and masters, we are not allowed to share certain secrets/tools. Some content is designed only for “Masters”. Some yoga are similar like the Kriya Yoga-Church (Vowed Lessons). We will review both Reiki and Yoga (Master tools) in the Course upcoming.
S9/This Week’s Focus:
* A continuation of Intuition-2 Development. We will review the Chakra System - Our temple. A misguided, misused situation lol. This will also serve Attunement later.
Thx for tuning in. Your time investment is valued. I do select topics related to our timeline and community. For those seeking upgrades or Reiki Levels. Stay tuned for our June packages. It’s for self employed/Practitioners/Coaches…
Review & Topics:
* Reiki Is Japanese Energy Healing used Globally.
* Yoga is over 5k years old from India. It hosts many styles, teacher versions, and it’s Mainstream now vs decades ago.
* Anything of the Holistic, Wellness Department can be fused together. My origins are Alternative, Complementary Medicine. In short, I call this ND. I am also a metaphysician. I learnt during the 90s New Age Era. I forget we just hit another wavy. It’s GenZ word of Mouth, their New Age Era. WHOA, History Repeats lol. We are fusing together.
* So, most of you have experienced your Spiritual Awakening. However; The journey wont be perfect. There will be some roller coaster events. The perks are: We are in a faster Spiritual Zone than the 90s. There’s more support and information available.
(See Presentation for all sections, THX AGAIN.)
Ray Dalio How Countries go Broke the Big CycleDadang Solihin
A complete and practical understanding of the Big Debt Cycle. A much more practical understanding of how supply and demand really work compared to the conventional economic thinking. A complete and practical understanding of the Overall Big Cycle, which is driven by the Big Debt Cycle and the other major cycles, including the big political cycle within countries that changes political orders and the big geopolitical cycle that changes world orders.
Unit- 4 Biostatistics & Research Methodology.pdfKRUTIKA CHANNE
Blocking and confounding (when a third variable, or confounder, influences both the exposure and the outcome) system for Two-level factorials (a type of experimental design where each factor (independent variable) is investigated at only two levels, typically denoted as "high" and "low" or "+1" and "-1")
Regression modeling (statistical model that estimates the relationship between one dependent variable and one or more independent variables using a line): Hypothesis testing in Simple and Multiple regression models
Introduction to Practical components of Industrial and Clinical Trials Problems: Statistical Analysis Using Excel, SPSS, MINITAB®️, DESIGN OF EXPERIMENTS, R - Online Statistical Software to Industrial and Clinical trial approach
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...EduSkills OECD
Deborah Nusche, Senior Analyst, OECD presents at the OECD webinar 'Trends Spotting: Strategic foresight for tomorrow’s education systems' on 5 June 2025. You can check out the webinar on the website https://oecdedutoday.com/webinars/ Other speakers included: Deborah Nusche, Senior Analyst, OECD
Sophie Howe, Future Governance Adviser at the School of International Futures, first Future Generations Commissioner for Wales (2016-2023)
Davina Marie, Interdisciplinary Lead, Queens College London
Thomas Jørgensen, Director for Policy Coordination and Foresight at European University Association
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
In the seventh century, the rule of Sindh state was in the hands of Rai dynasty. We know the names of five kings of this dynasty- Rai Divji, Rai Singhras, Rai Sahasi, Rai Sihras II and Rai Sahasi II. During the time of Rai Sihras II, Nimruz of Persia attacked Sindh and killed him. After the return of the Persians, Rai Sahasi II became the king. After killing him, one of his Brahmin ministers named Chach took over the throne. He married the widow of Rai Sahasi and became the ruler of entire Sindh by suppressing the rebellions of the governors.
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxArshad Shaikh
Diptera, commonly known as flies, is a large and diverse order of insects that includes mosquitoes, midges, gnats, and horseflies. Characterized by a single pair of wings (hindwings are modified into balancing organs called halteres), Diptera are found in almost every environment and play important roles in ecosystems as pollinators, decomposers, and food sources. Some species, however, are significant pests and disease vectors, transmitting diseases like malaria, dengue, and Zika virus.
How to Create Quotation Templates Sequence in Odoo 18 SalesCeline George
In this slide, we’ll discuss on how to create quotation templates sequence in Odoo 18 Sales. Odoo 18 Sales offers a variety of quotation templates that can be used to create different types of sales documents.
Adam Grant: Transforming Work Culture Through Organizational PsychologyPrachi Shah
This presentation explores the groundbreaking work of Adam Grant, renowned organizational psychologist and bestselling author. It highlights his key theories on giving, motivation, leadership, and workplace dynamics that have revolutionized how organizations think about productivity, collaboration, and employee well-being. Ideal for students, HR professionals, and leadership enthusiasts, this deck includes insights from his major works like Give and Take, Originals, and Think Again, along with interactive elements for enhanced engagement.
Analysis of Quantitative Data Parametric and non-parametric tests.pptxShrutidhara2
This presentation covers the following points--
Parametric Tests
• Testing the Significance of the Difference between Means
• Analysis of Variance (ANOVA) - One way and Two way
• Analysis of Co-variance (One-way)
Non-Parametric Tests:
• Chi-Square test
• Sign test
• Median test
• Sum of Rank test
• Mann-Whitney U-test
Moreover, it includes a comparison of parametric and non-parametric tests, a comparison of one-way ANOVA, two-way ANOVA, and one-way ANCOVA.
Analysis of Quantitative Data Parametric and non-parametric tests.pptxShrutidhara2
Ad
introduction to python programming concepts
1. What is
Python?
Python is a high-level, interpreted, interactive and object-oriented scripting language.
Python is designed to be highly readable. It uses English keywords frequently where as
other languages use punctuation.
Python is Interpreted: Python is processed at runtime by the interpreter. You do not
need to compile your program before executing it. This is similar to PERL and PHP.
Python is Interactive: You can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.
Python is Object-Oriented: Python supports Object-Oriented style or technique of
programming that encapsulates code within objects.
Python is a Beginner's Language: Python is a great language for the beginner-level
programmers and supports the development of a wide range of applications from
simple text processing to WWW browsers to games.
2. History of
Python
Python was developed by Guido van Rossum in the
late eighties and early nineties at the National
Research Institute for Mathematics and Computer
Science in the Netherlands.
Python is derived from many other languages,
including ABC, Modula-3, C, C++, Algol-68,
SmallTalk, and Unix shell and other scripting
languages.
3. Features of
Python
Easy-to-learn : few keywords, simple structure, and a clearly defined
Easy-to-read: code is more clearly defined and visible to the eyes.
Easy-to-maintain: source code is fairly easy-to-maintain
A broad standard library: Bulk of the library compatible on UNIX, Windows,
and Macintosh.
Interactive Mode: interactive testing and debugging of snippets
Portable: can run on a wide variety of hardware platforms
Extendable: add low-level modules to the Python interpreter.
Databases: provides interfaces to all major commercial databases.
GUI Programming: supports GUI applications
Scalable: provides a better structure and support for large programs
4. Getting
Python
Official Website for Download
https://www.python.org/
Official Website for Documentation
https://www.python.org/doc/
5. First Python
Program
There are two ways to execute of Python program
1. Interactive Mode : Invoking the interpreter without passing a script file as
a parameter brings up the following prompt.
2. Scripting Mode: Invoking the interpreter with a script parameter begins
execution of the script and continues until the script is finished. When the script
is finished, the interpreter is no longer active.
Interactive Mode
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print("Welcome to class")
Welcome to class
>>>
Scripting Mode : write a simple Python program in a script and save the file
with .py extension.
6. Python
Identifiers
A Python identifier is a name used to identify a variable, function, class,
module or other object. An identifier starts with a letter A to Z or a to z or an
underscore (_) followed by zero or more letters, underscores and digits (0 to 9).
Python does not allow punctuation characters such as @, $, and %
within identifiers.
Python is a case sensitive programming language. Thus, World and world
are two different identifiers in Python.
Class names start with an uppercase letter. All other identifiers start with
a lowercase letter.
7. Reserved
Words
And Exec not assert
Finally or Break For
Pass Class From Print
Continue Global Raise Def
If Return Del import
Try Else
Lambda
Elif
Is
yield
In
With
while
except
8. Lines and
Indentation
Python provides no braces to indicate blocks of code for class and function
definitions or flow control. Blocks of code are denoted by line indentation,
which is rigidly enforced.
E.g.
if True:
print ("True")
else:
print ("False“)
However, the following block generates an error
if True:
print ("Answer“)
print ("True")
else:
print ("Answer“)
print ("False")
9. Multi-Line
Statements
Statements in Python typically end with a new line. Python does, however, allow the
use of the line continuation character () to denote that the line should continue.
E.g.
a=10
b=20
c=30
total
= a +
b +
c
print(total)
Statements contained within the [], {}, or () brackets do not need to use the line
continuation character. For example −
days = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday']
print(days)
10. Quotation in
Python
Python accepts single ('), double (") and triple (''' or """) quotes to denote string
literals, as long as the same type of quote starts and ends the string.
The triple quotes are used to span the string across multiple lines. For example, all
the following are legal −
word = 'word'
sentence = "This is a sentence."
paragraph = """This is a
paragraph. It is
made up of
multiple
lines and
sentences."
""
print(word)
print(sentence)
print(paragraph)
11. Comments in
Python
A hash sign (#) that is not inside a string literal begins a comment. All characters
after the # and up to the end of the physical line are part of the comment and the
Python interpreter ignores them.
Single line Comment
# First comment
print "Hello, Python!" # second comment
Multiline Comment
'''
This is a multiline
comment.
'''
print('Hello...')
12. Run Time
Input
var= input('Enter your namen') # Return String Value
print('Welcome '+var)
OR
var= input("Enter your name
n") print("Welcome"+var)
Multiple Statements on a
Single Line
import sys; x = 'foo';
sys.stdout.write(x + 'n')
13. Variable
Assignment
rollNo = 100
height =
5.6
# An integer
assignment # A floating
point
name = "John" # A string
print (rollNo)
print
(height)
print (name)
Type
Casting
rollNo = 100
height = 5.6
name =
"John"
# An integer
assignment # A floating
point
# A string
print ('Your roll no. is '+str(rollNo))
print ('Your height is '+str(height))
print ('Your name is '+name)
14. Variable
Multiple Assignment:
e.g.
a = b = c = 1
print('The value of a : '+str(a))
print('The value of b :
'+str(b)) print('The value of
c : '+str(c))
e.g.
a,b,c = 1,2,"john"
print('The value of a : '+str(a))
print('The value of b :
'+str(b)) print('The value of
c : '+c)
15. Data
Types
Python has five standard data types −
1. Numbers
2. String
3. List
4. Tuple
5. Dictionary
Python Numbers
Number data types store numeric values. Number objects are created when you
assign a value to them. For example −
var1 = 1 var2 = 10
Note: You can also delete the reference to a number object by using the del
statement. The syntax of the del statement is −
del var1[,var2[,var3[....,varN]]]] OR del
var
del var_a, var_b
16. Data
Types
String
Strings in Python are identified as a contiguous set of characters represented in the
quotation marks. Subsets of strings can be taken using the slice operator ([ ] and [:] )
with indexes starting at 0 in the beginning of the string and working their way from -1 at
the end.
“+” Concatenation Operator
“*” (asterisk) Repetition Operator
str = 'Hello World!'
print str
print str[0]
print str[2:5]
print str[2:]
print str * 2
print str +
"TEST"
# Prints complete string
# Prints first character of the string
# Prints characters starting from 3rd to 5th
# Prints string starting from 3rd character
# Prints string two times
# Prints concatenated string
17. Data
Types
Python Lists
Lists are the most versatile of Python's compound data types. A list contains items separated by
commas and enclosed within square brackets ([]). To some extent, lists are similar to arrays in
C. One difference between them is that all the items belonging to a list can be of different data
type.
list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']
print list
print list[0]
print list[1:3]
print list[2:]
print tinylist * 2
print list + tinylist
# Prints complete list
# Prints first element of the list
# Prints elements starting from 2nd till 3rd
# Prints elements starting from 3rd
element # Prints list two times
# Prints concatenated
lists
18. Data
Types
Python Tuples:
A tuple is another sequence data type that is similar to the list. A tuple consists of a number of
values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.
The main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] ) and their
elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be
updated. Tuples can be thought of as read-only lists.
tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
tinytuple = (123, 'john')
print tuple
print tuple[0]
print tuple[1:3]
print tuple[2:]
print tinytuple * 2
print tuple + tinytuple
# Prints complete list
# Prints first element of the list
# Prints elements starting from 2nd till 3rd
# Prints elements starting from 3rd element
# Prints list two times
# Prints concatenated lists
19. Data Types
Python Dictionary:
Python's dictionaries are kind of hash table type. They work like associative arrays or hashes
found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type, but
are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object.
dict = {}
dict['one'] = "This is one"
dict[2] = "This is two“
tinydict = {'name': 'john','code':6734,
'dept': 'sales'}
print tinydict.values()
print dict['one']
print dict[2]
print tinydict
print
tinydict.keys()
# Prints value for 'one' key
# Prints value for 2 key
# Prints complete dictionary
# Prints all the keys
# Prints all Values
20. Operator
Python language supports the following types of operators-
1. Arithmetic Operators (basic operator + new // and **operators)
2. Comparison (Relational) Operators
3. Assignment Operators
4. Logical Operators
5. Bitwise Operators
6. Membership Operators
7. Identity Operators
21. Operator
Note: We have learn about first five operator in previous classes
Membership Operators: Python’s membership operators test for
membership in a sequence, such as strings, lists, or tuples. There are two
membership operators as explained below-
E.g.
a = 10
b = 20
list = [1, 2, 3, 4, 5 ]
if ( a in list ):
print ("Line 1 - a is available in the given list")
else:
print ("Line 1 - a is not available in the given list")
if ( b not in list ):
print ("Line 2 - b is not available in the given list")
else:
print ("Line 2 - b is available in the given list")
22. Operator
Learn first five operator from tutorials.
Identity Operators: Identity operators compare the memory locations of two objects. There
are two Identity operators is and is not.
a = 20
b = 20
print ('Line 1','a=',a,':',id(a), 'b=',b,':',id(b))
if ( a is b ):
print ("Line 2 - a and b have same identity")
else:
print ("Line 2 - a and b do not have same identity")
if ( id(a) == id(b) ):
print ("Line 3 - a and b have same identity")
else:
print ("Line 3 - a and b do not have same identity")
b = 30
print ('Line 4','a=',a,':',id(a), 'b=',b,':',id(b))
if ( a is not b ):
print ("Line 5 - a and b do not have same
identity")
else:
print ("Line 5 - a and b have same identity")
24. Decision
Making
If Else
number= int(input("Enter the number :"))
if(number<0):
print("Negative Number")
else:
print("Positive
Number")
Elif
mark= int(input("Enter the Marksn"))
if(mark>=40 and mark<50):
print("Grade 'C'")
elif (mark>=50 and mark<60):
print("Grade 'B'")
elif(mark>=60 and
mark<75): print("Grade
'A'")
elif(mark>=75 and
mark<=100): print("Grade
'A+'")
else:
print("Fail“)
26. Loo
p
Type of Loop:
1. While Loop
2. For Loop
3. Nested Loop
While Loop: E.g.
number= int(input("Enter the
range :"))
Sum=0 i=1
while i<=number: Sum= Sum+i i=i+1
if(Sum%2==0):
print("The calculated sum "+str(Sum)+" is an even number")
else:
print("The calculated sum "+str(Sum)+" is anodd number")
27. Loo
p
For Loop : The for loop in Python is used to iterate over a sequence (list, tuple,
string) or other iterable objects. Iterating over a sequence is called traversal.
Syntex:
for val in sequence:
Body of for
28. Loo
p
For Loop : The for loop in Python is used to iterate over a sequence (list, tuple,
string) or other iterable objects. Iterating over a sequence is called traversal.
Syntex:
for val in sequence:
Body of for
# Program to find the sum of all numbers stored in a list
# List of numbers
# variable to store the sum
# iterate over the list
# Output: The sum is 48
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]
sum = 0
for val in numbers:
sum = sum+val
print("The sum is", sum)
29. Loo
p
Range Function: The built-in function range() is the right function to iterate over a
sequence of numbers. It generates an iterator of arithmetic progressions.
for counter in range(1,16,2):
print(counter)
Nested Loop: Python programming language allows the use of one loop inside
another loop.
Syntax:
While expression:
while expression:
statement(s)
statement(s)
for iterating_var in
sequence:
for
iterating_var in
sequence:
statements(s)
30. Loo
p
E.g.
for i in range(1,11):
for j in range(1,11):
k=i*j
print (k, end=' ')
print()
Using elseStatement with Loops
Python supports having an else statement associated with a loop
statement.
• If the else statement is used with a for loop, the else statement is executed when
the loop has exhausted iterating the list.
• If the else statement is used with a while loop, the else statement is executed
when the condition becomes false.
31. Loo
p
E.g.
count = 0
while count < 5:
print (count, " is less than
5") count = count + 1
else:
print (count, " is not less
than 5")
Break Statement
The break statement is used for
premature termination of the
current loop.