Python (Data Analysis) cleaning and visualizeIruolagbePius
This document provides an overview of Python programming language. It discusses Python features, uses, variables, data types, operators, decision making statements, and loops. Specifically, it covers:
- Python features like being easy to learn and read, having an interactive mode, and being portable.
- Python variables, naming rules, and basic data types like numbers, strings, booleans.
- Operators for arithmetic, comparison, assignment, and logic.
- Conditional statements like if, elif, else for decision making.
- Looping structures like while and for loops, with examples of using break, continue, else, range().
- How to write comments, take user input, and
The document provides an introduction to Python programming, including details about Python's history, versions, data types, strings, and code execution. It discusses how to install Python and write basic programs. Key reasons for using Python are its object-oriented nature, readability, large standard library, cross-platform capabilities, and ease of use. The document also covers string methods and slicing, numeric data types, installing Python, and running code in interactive and script modes.
The document provides an introduction to Python programming. It discusses that Python is a high-level, interpreted, object-oriented, and general purpose programming language. It can be used for web development, scientific computing, desktop applications, and more. The document then covers Python basics like data types, variables, literals, operators, control flow statements, functions, modules and packages. It also discusses installing Python on Windows and writing the first Python program.
This document provides an overview of Python and introduces some of its key concepts. It discusses Python's origins in the late 1980s and its increasing popularity today. The document outlines Python's main features like being easy to use, interpreted, high-level, dynamically typed, extensible, and having many available libraries. It also lists some common uses of Python like for web applications, data analytics, AI/ML, business, and more. Finally, the document introduces lessons on installing Python/PyCharm, understanding data types, working with numbers and strings, and using tuples and lists.
This document provides an introduction to programming with Python. It discusses what Python is, how to install it, and how to write basic Python programs. It then covers key Python concepts like variables, data types, conditionals, loops, functions, modules, and more. Code examples are provided throughout to demonstrate the various Python constructs. The document is intended to teach programming fundamentals to beginners using the Python language.
The document provides an introduction to the Python programming language. It discusses that Python was created by Guido Van Rossum in 1991 and was named after the Monty Python comedy troupe. Python is an open source, interpreted language that can be used for both procedural and object-oriented programming. It has a simple syntax and supports features like graphical user interfaces, integration with other languages, and is used widely in applications like web development, artificial intelligence, and data science. The document also covers Python concepts like variables, data types, operators, input/output and comments.
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.
Introduction to Python for Data Science and Machine Learning ParrotAI
This document provides an introduction and overview of Python for data science and machine learning. It covers basics of Python including what Python is, its features, why it is useful for data science. It also discusses installing Python, using the IDLE and Jupyter Notebook environments. The document then covers Python basics like variables, data types, operators, decision making and loops. Finally, it discusses collection data types like lists, tuples and dictionaries and functions in Python.
Python is an open source programming language created by Guido van Rossum in 1991. It is named after the comedy group Monty Python and is based on the ABC language. Python supports both procedural and object-oriented programming and can be used for web development, data analysis, artificial intelligence, and more. It has a simple syntax and large standard library that make it easy to learn and use for various applications.
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.
- The document discusses Python programming concepts such as data types, variables, operators, and syntax. It provides examples of Python code for variables, comments, strings, numbers, and more.
- Python is a popular programming language used for web development, software development, mathematics, and more. It runs on different platforms and has a simple, readable syntax.
- Key features of Python include dynamic typing, automatic memory management, and an intuitive syntax that uses indentation rather than brackets.
This document provides instructions for installing Python and an overview of key Python concepts. It begins with an outline of topics to be covered, including Python datatypes, flow control, functions, files, exceptions, and projects. Detailed step-by-step instructions are given for installing Python on Windows. Short summaries are then provided of Python's history and name, the Python prompt and IDE, comments, identifiers, operators, keywords, None, as, and datatypes. Examples and explanations are provided of Python's core datatypes including numbers, strings, lists, tuples, sets, and dictionaries.
- Python is an interpreted, object-oriented programming language that is beginner friendly and open source. It was created in the 1990s and named after Monty Python.
- Python is very suitable for natural language processing tasks due to its built-in string and list datatypes as well as libraries like NLTK. It also has strong numeric processing capabilities useful for machine learning.
- Python code is organized using functions, classes, modules, and packages to improve structure. It is interpreted at runtime rather than requiring a separate compilation step.
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.
The document provides an introduction to Python programming including its features, uses, history, and installation process. Some key points covered include:
- Python is an interpreted, object-oriented programming language that is used for web development, scientific computing, and desktop applications.
- It was created by Guido van Rossum in 1991 and named after the Monty Python comedy group.
- To install Python on Windows, users download the latest version from python.org and run the installer, which also installs the IDLE development environment.
- The document then covers basic Python concepts like variables, data types, operators, and input/output functions.
Python is a multi-paradigm programming language created in 1989 by Guido van Rossum. It is based on ABC and Modula-3 and was named after Monty Python. Python has a simple syntax and dynamic typing and memory management. It can be used for web development, data science, scientific computing, and more. The core philosophy is summarized in the Zen of Python document. Python code is written, tested, and executed using integrated development environments like PyCharm or directly from the command line.
Python is a general purpose programming language that can be used for both programming and scripting. It is an interpreted language, meaning code is executed line by line by the Python interpreter. Python code is written in plain text files with a .py extension. Key features of Python include being object-oriented, using indentation for code blocks rather than brackets, and having a large standard library. Python code can be used for tasks like system scripting, web development, data analysis, and more.
The document provides an introduction to Python programming. It discusses that Python is a high-level, interpreted, object-oriented, and general purpose programming language. It can be used for web development, scientific computing, desktop applications, and more. The document then covers Python basics like data types, variables, literals, operators, control flow statements, functions, modules and packages. It also discusses installing Python on Windows and writing the first Python program.
This document provides an overview of Python and introduces some of its key concepts. It discusses Python's origins in the late 1980s and its increasing popularity today. The document outlines Python's main features like being easy to use, interpreted, high-level, dynamically typed, extensible, and having many available libraries. It also lists some common uses of Python like for web applications, data analytics, AI/ML, business, and more. Finally, the document introduces lessons on installing Python/PyCharm, understanding data types, working with numbers and strings, and using tuples and lists.
This document provides an introduction to programming with Python. It discusses what Python is, how to install it, and how to write basic Python programs. It then covers key Python concepts like variables, data types, conditionals, loops, functions, modules, and more. Code examples are provided throughout to demonstrate the various Python constructs. The document is intended to teach programming fundamentals to beginners using the Python language.
The document provides an introduction to the Python programming language. It discusses that Python was created by Guido Van Rossum in 1991 and was named after the Monty Python comedy troupe. Python is an open source, interpreted language that can be used for both procedural and object-oriented programming. It has a simple syntax and supports features like graphical user interfaces, integration with other languages, and is used widely in applications like web development, artificial intelligence, and data science. The document also covers Python concepts like variables, data types, operators, input/output and comments.
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.
Introduction to Python for Data Science and Machine Learning ParrotAI
This document provides an introduction and overview of Python for data science and machine learning. It covers basics of Python including what Python is, its features, why it is useful for data science. It also discusses installing Python, using the IDLE and Jupyter Notebook environments. The document then covers Python basics like variables, data types, operators, decision making and loops. Finally, it discusses collection data types like lists, tuples and dictionaries and functions in Python.
Python is an open source programming language created by Guido van Rossum in 1991. It is named after the comedy group Monty Python and is based on the ABC language. Python supports both procedural and object-oriented programming and can be used for web development, data analysis, artificial intelligence, and more. It has a simple syntax and large standard library that make it easy to learn and use for various applications.
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.
- The document discusses Python programming concepts such as data types, variables, operators, and syntax. It provides examples of Python code for variables, comments, strings, numbers, and more.
- Python is a popular programming language used for web development, software development, mathematics, and more. It runs on different platforms and has a simple, readable syntax.
- Key features of Python include dynamic typing, automatic memory management, and an intuitive syntax that uses indentation rather than brackets.
This document provides instructions for installing Python and an overview of key Python concepts. It begins with an outline of topics to be covered, including Python datatypes, flow control, functions, files, exceptions, and projects. Detailed step-by-step instructions are given for installing Python on Windows. Short summaries are then provided of Python's history and name, the Python prompt and IDE, comments, identifiers, operators, keywords, None, as, and datatypes. Examples and explanations are provided of Python's core datatypes including numbers, strings, lists, tuples, sets, and dictionaries.
- Python is an interpreted, object-oriented programming language that is beginner friendly and open source. It was created in the 1990s and named after Monty Python.
- Python is very suitable for natural language processing tasks due to its built-in string and list datatypes as well as libraries like NLTK. It also has strong numeric processing capabilities useful for machine learning.
- Python code is organized using functions, classes, modules, and packages to improve structure. It is interpreted at runtime rather than requiring a separate compilation step.
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.
The document provides an introduction to Python programming including its features, uses, history, and installation process. Some key points covered include:
- Python is an interpreted, object-oriented programming language that is used for web development, scientific computing, and desktop applications.
- It was created by Guido van Rossum in 1991 and named after the Monty Python comedy group.
- To install Python on Windows, users download the latest version from python.org and run the installer, which also installs the IDLE development environment.
- The document then covers basic Python concepts like variables, data types, operators, and input/output functions.
Python is a multi-paradigm programming language created in 1989 by Guido van Rossum. It is based on ABC and Modula-3 and was named after Monty Python. Python has a simple syntax and dynamic typing and memory management. It can be used for web development, data science, scientific computing, and more. The core philosophy is summarized in the Zen of Python document. Python code is written, tested, and executed using integrated development environments like PyCharm or directly from the command line.
Python is a general purpose programming language that can be used for both programming and scripting. It is an interpreted language, meaning code is executed line by line by the Python interpreter. Python code is written in plain text files with a .py extension. Key features of Python include being object-oriented, using indentation for code blocks rather than brackets, and having a large standard library. Python code can be used for tasks like system scripting, web development, data analysis, and more.
This document discusses several algorithms for drawing lines in computer graphics, including their requirements, properties, and steps. It describes the digital differential analyzer (DDA) algorithm, which uses incremental differences between line endpoints to plot pixels along the line. Bresenham's line algorithm is also summarized, which uses integer calculations to determine pixel positions with good visual quality. A parallel line algorithm is mentioned that can partition line drawing computations across multiple processors to calculate pixel positions efficiently in parallel.
This document provides an overview of the history of the web and languages and tools used for web programming. It discusses the evolution of the web from the 1960s to today. It also covers topics like client-side versus server-side programming, HTML, databases, SQL, servlets, common gateway interface (CGI), and n-tier architectures. The document is intended as an introduction to web programming concepts and technologies.
How to Create a Rainbow Man Effect in Odoo 18Celine George
In Odoo 18, the Rainbow Man animation adds a playful and motivating touch to task completion. This cheerful effect appears after specific user actions, like marking a CRM opportunity as won. It’s designed to enhance user experience by making routine tasks more engaging.
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.
This presentation was provided by Jennifer Gibson of Dryad, during the first session of our 2025 NISO training series "Secrets to Changing Behavior in Scholarly Communications." Session One was held June 5, 2025.
Artificial intelligence Presented by JM.jmansha170
AI (Artificial Intelligence) :
"AI is the ability of machines to mimic human intelligence, such as learning, decision-making, and problem-solving."
Important Points about AI:
1. Learning – AI can learn from data (Machine Learning).
2. Automation – It helps automate repetitive tasks.
3. Decision Making – AI can analyze and make decisions faster than humans.
4. Natural Language Processing (NLP) – AI can understand and generate human language.
5. Vision & Recognition – AI can recognize images, faces, and patterns.
6. Used In – Healthcare, finance, robotics, education, and more.
Owner By:
Name : Junaid Mansha
Work : Web Developer and Graphics Designer
Contact us : +92 322 2291672
Email : [email protected]
Pests of Rice: Damage, Identification, Life history, and Management.pptxArshad Shaikh
Rice pests can significantly impact crop yield and quality. Major pests include the brown plant hopper (Nilaparvata lugens), which transmits viruses like rice ragged stunt and grassy stunt; the yellow stem borer (Scirpophaga incertulas), whose larvae bore into stems causing deadhearts and whiteheads; and leaf folders (Cnaphalocrocis medinalis), which feed on leaves reducing photosynthetic area. Other pests include rice weevils (Sitophilus oryzae) and gall midges (Orseolia oryzae). Effective management strategies are crucial to minimize losses.
How to Manage & Create a New Department in Odoo 18 EmployeeCeline George
In Odoo 18's Employee module, organizing your workforce into departments enhances management and reporting efficiency. Departments are a crucial organizational unit within the Employee module.
How to Manage Maintenance Request in Odoo 18Celine George
Efficient maintenance management is crucial for keeping equipment and work centers running smoothly in any business. Odoo 18 provides a Maintenance module that helps track, schedule, and manage maintenance requests efficiently.
A short update and next week. I am writing both Session 9 and Orientation S1.
As a Guest Student,
You are now upgraded to Grad Level.
See Uploads for “Student Checkin” & “S8”. Thx.
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.
Session Practice, For Reference:
Before starting a session, Make sure to check your environment. Nothing stressful. Later, You can decorate a space as well.
Check the comfort level, any needed resources (Yoga/Reiki/Spa Props), or Meditation Asst?
Props can be oils, sage, incense, candles, crystals, pillows, blankets, yoga mat, any theme applies.
Select your comfort Pose. This can be standing, sitting, laying down, or a combination.
Monitor your breath. You can add exercises.
Add any mantras or affirmations. This does aid mind and spirit. It helps you to focus.
Also you can set intentions using a candle.
The Yoga-key is balancing mind, body, and spirit.
Finally, The Duration can be long or short.
Its a good session base for any style.
Next Week’s Focus:
A continuation of Intuition Development. We will review the Chakra System - Our temple. A misguided, misused situation lol. This will also serve Attunement later.
For Sponsor,
General updates,
& Donations:
Please visit:
https://ldmchapels.weebly.com
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
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.
Rose Cultivation Practices by Kushal Lamichhane.pdfkushallamichhame
This includes the overall cultivation practices of Rose prepared by:
Kushal Lamichhane (AKL)
Instructor
Shree Gandhi Adarsha Secondary School
Kageshowri Manohara-09, Kathmandu, Nepal
Parenting Teens: Supporting Trust, resilience and independencePooky Knightsmith
For more information about my speaking and training work, visit: https://www.pookyknightsmith.com/speaking/
SESSION OVERVIEW:
Parenting Teens: Supporting Trust, Resilience & Independence
The teenage years bring new challenges—for teens and for you. In this practical session, we’ll explore how to support your teen through emotional ups and downs, growing independence, and the pressures of school and social life.
You’ll gain insights into the teenage brain and why boundary-pushing is part of healthy development, along with tools to keep communication open, build trust, and support emotional resilience. Expect honest ideas, relatable examples, and space to connect with other parents.
By the end of this session, you will:
• Understand how teenage brain development affects behaviour and emotions
• Learn ways to keep communication open and supportive
• Explore tools to help your teen manage stress and bounce back from setbacks
• Reflect on how to encourage independence while staying connected
• Discover simple strategies to support emotional wellbeing
• Share experiences and ideas with other parents
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.
This presentation was provided by Nicole 'Nici" Pfeiffer of the Center for Open Science (COS), during the first session of our 2025 NISO training series "Secrets to Changing Behavior in Scholarly Communications." Session One was held June 5, 2025.
2. Why should we learn Python?
Python is a higher level programming language.
Its syntax allows programmers to express concepts in
fewer lines of code.
Python is a programming language that lets you work
quickly and integrate systems more efficiently.
One can plot figures using Python.
One can perform symbolic mathematics easily using
Python.
It is available freely online.
3. Python versions
Python was first released on February 20, 1991 and later on developed by
Python Software Foundation.
Major Python versions are – Python 1, Python 2 and Python 3.
• On 26th January 1994, Python 1.0 was released.
• On 16th October 2000, Python 2.0 was released with many new
features.
• On 3rd December 2008, Python 3.0 was released with more testing and
includes new features.
Latest version - On 2nd
October 2023, Python 3.12 was released.
To check your Python version
i) For Linux OS type python -V in the terminal window.
ii) For Windows and MacOS type import sys print(sys.version) in the
interactive shell.
6. Python Interpreter
The program that translates Python instructions and then executes
them is the Python interpreter. When we write a Python program,
the program is executed by the Python interpreter. This interpreter
is written in the C language.
There are certain online interpreters like
https://ide.geeksforgeeks.org/,
http://ideone.com/ ,
http://codepad.org/
that can be used to start Python without installing an interpreter.
7. Python IDLE
Python interpreter is embedded in a number of larger programs that
make it particularly easy to develop Python programs. Such a
programming environment is IDLE
( Integrated Development and Learning Environment).
It is available freely online. For Windows machine IDLE
(Integrated Development and Learning Environment) is installed
when you install Python.
8. Running Python
There are two modes for using the Python interpreter:
1) Interactive Mode
2) Script Mode
Options for running the program:
• In Windows, you can display your folder contents, and
double click on madlib.py to start the program.
• In Linux or on a Mac you can open a terminal window,
change into your python directory, and enter the command
python madlib.py
12. Running Python
2) in script mode:
Programmers can store Python script source code in a file
with the .py extension, and use the interpreter to execute the
contents of the file.
For UNIX OS to run a script file MyFile.py you have to type:
python MyFile.py
13. Data Types
Python has various standard data types:
Integer [ class ‘int’ ]
Float [ class ‘float’ ]
Boolean [ class ‘bool’ ]
String [ class ‘str’ ]
14. Integer
Int:
For integer or whole number, positive or negative, without decimals of
unlimited length.
>>> print(2465635468765)
2465635468765
>>> print(0b10) # 0b indicates binary number
2
>>> print(0x10) # 0x indicates hexadecimal number
16
>>> a=11
>>> print(type(a))
<class 'int'>
15. Float
Float:
Float, or "floating point number" is a number, positive or negative.
Float can also be scientific numbers with an "e" to indicate the power of 10.
>>> y=2.8
>>> y
2.8
>>> print(0.00000045)
4.5e-07
>>> y=2.8
>>> print(type(y))
<class 'float'>
16. Boolean and String
Boolean:
Objects of Boolean type may have one of two values, True or False:
>>> type(True)
<class 'bool'>
>>> type(False)
<class 'bool'>
String:
>>> print(‘Science college’)
Science college
>>> type("My college")
<class 'str'>
17. Variables
One can store integers, decimals or characters in variables.
Rules for Python variables:
• A variable name must start with a letter or the underscore character
• A variable name cannot start with a number
• A variable name can only contain alpha-numeric characters and underscores (A-z,
0-9, and _ )
• Variable names are case-sensitive (age, Age and AGE are three different variables)
a= 100 # An integer assignment
b = 1040.23 # A floating point
c = "John" # A string
18. List, Tuple, Set, Dictionary
Four built-in data structures in Python:-
list, tuple, set, dictionary
- each having qualities and usage different from the other three.
List is a collection of items that is written with square brackets. It is mutable,
ordered and allows duplicate members. Example: list = [1,2,3,'A','B',7,8,[10,11]]
Tuple is a collection of objects that is written with first brackets. It is immutable.
Example: tuple = (2, 1, 10, 4, 7)
Set is a collection of elements that is written with curly brackets. It is unindexed and
unordered. Example: S = {x for x in 'abracadabra' if x not in 'abc'}
Dictionary is a collection which is ordered, changeable and does not allow duplicates.
It is written with curly brackets and objects are stored in key: value format.
Example: X = {1:’A’, 2:’B’, 3:’c’}
20. print function
>>>print(‘Workshop’, ‘on’, ‘Python’, sep=’n’)
# sep=‘n’ will put each word in a new line
Output:
Workshop
on
Python
>>>print(‘Workshop’, ‘on’, ‘Python’, sep=’, ’)
# sep=‘, ’ will print words separated by ,
Output:
Workshop, on, Python
21. print function
%d is used as a placeholder for integer value.
%f is used as a placeholder for decimal value.
%s is used as a placeholder for string.
a = 2
b = ‘tiger’
print(a, ‘is an integer while’, b, ‘is a string.’)
Output:
2 is an integer while tiger is a string.
Alternative way:
print(“%d is an integer while %s is a string.”%(a, b))
Output:
2 is an integer while tiger is a string.
22. print function
# printing a string
name = “Rahul”
print(“Hey ” + name)
Output:
Hey Rahul
print(“Roll No: ” + str(34)) # “Roll No: ” + 34 is incorrect
Output:
Roll No: 34
# printing a bool True / False
print(True)
Output:
True
23. print function
int_list = [1, 2, 3, 4, 5]
print(int_list) # printing a list
Output: [1, 2, 3, 4, 5]
my_tuple = (10, 20, 30)
print(my_tuple) # printing a tuple
Output: (10, 20, 30)
my_dict = {“language”: “Python”, “field”: “data science”}
print(my_dict) # printing a dictionary
Output: {“language”: “Python”, “field”: “data science”}
my_set = {“red”, “yellow”, “green”, “blue”}
print(my_set) #printing a set
Output: {“red”, “yellow”, “green”, “blue”}
25. print function
items = [ 1, 2, 3, 4, 5]
for item in items:
print(item)
Output:
1
2
3
4
5
items = [ 1, 2, 3, 4, 5]
for item in items:
print(item, end=’ ‘)
Output:
1 2 3 4 5
26. Operators
Addition + Subtraction -
Multiplication * Exponentiation **
Division / Integer division / /
Remainder %
Binary left shift << Binary right shift >>
And & Or |
Less than < Greater than >
Less than or equal to <= Greater than or equal to >=
Check equality == Check not equal !=
27. Precedence of operators
Parenthesized expression ( ….. )
Exponentiation **
Positive, negative, bitwise not +n, -n, ~n
Multiplication, float division, int division, remainder *, /, //, %
Addition, subtraction +, -
Bitwise left, right shifts <<, >>
Bitwise and &
Bitwise or |
Membership and equality tests in, not in, is, is
not, <, <=, >, >=, !=, ==
Boolean (logical) not not x
Boolean and and
Boolean or or
Conditional expression if ….. else
28. Precedence of Operators
Examples:
a = 20
b = 10
c = 15
d = 5
e = 2
f = (a + b) * c / d
print( f)
g = a + (b * c) / d - e
print(g)
h = a + b*c**e
print(h)
29. Multiple Assignment
Python allows you to assign a single value to several variables
simultaneously.
a = b = c = 1.5
a, b, c = 1, 2, " Red“
Here, two integer objects with values 1 and 2 are assigned to
variables a and b respectively and one string object with the
value "Red" is assigned to the variable c.
30. Special Use of + and *
Examples:
x = "Python is "
y = "awesome."
z = x + y
print(z)
Output:
Python is awesome.
print(‘It is’ + 2*’very ’ + ’hot.’)
Output:
It is very very hot.
31. Use of ”, n, t
Specifying a backslash () in front of the quote character in a string
“escapes” it and causes Python to suppress its usual special meaning. It is
then interpreted simply as a literal single quote character:
>>> print(" ”Beauty of Flower” ")
”Beauty of Flower”
>>> print('Red n Blue n Green ')
Red
Blue
Green
>>> print("a t b t c t d")
a b c d
32. Comments
Single-line comments begins with a hash ( # ) symbol and is useful in mentioning
that the whole line should be considered as a comment until the end of line.
A Multi line comment is useful when we need to comment on many lines. In python,
triple double quote(“ “ “) and single quote(‘ ‘ ‘)are used for multi-line commenting.
Example:
“““ My Program to find
Average of three numbers ”””
a = 29 # Assigning value of a
b = 17 # Assigning value of b
c = 36 # Assigning value of c
average = ( a + b + c)/3
print(“Average value is ”, average)
33. id( ) function, ord( ) function
id( ) function: It is a built-in function that returns the unique identifier of
an object. The identifier is an integer, which represents the memory address
of the object. The id( ) function is commonly used to check if two variables
or objects refer to the same memory location.
>>> a=5
>>> id(a)
1403804521000552
ord( ) function: It is used to convert a single unicode character into its
integer representation.
>>> ord(‘A’)
65
>>> chr(65)
‘A’
34. Control Flow Structures
1. Conditional if ( if )
2. Alternative if ( if else )
3. Chained Conditional if ( if elif else )
4. While loop
5. For loop
36. Alternative if
Example:
A = int(input(‘Enter the marks '))
if A >= 40:
print("PASS")
else:
print("FAIL")
Output:
Enter the marks 65
PASS
37. # Test if the given letter is vowel or not
letter = ‘o’
if letter == ‘a’ or letter == ‘e’ or letter == ‘i’ or letter == ‘o’
or letter == ‘u’ :
print(letter, ‘is a vowel.’)
else:
print(letter, ‘is not a vowel.’)
Output:
o is a vowel.
38. # Program to find the greatest of three different numbers
a = int(input('Enter 1st no’))
b = int(input('Enter 2nd no'))
c= int(input('Enter 3rd no'))
if a > b:
if a>c:
print('The greatest no is ', a)
else:
print('The greatest no is ', c)
else:
if b>c:
print('The greatest no is ', b)
else:
print('The greatest no is ', c)
Output:
Enter 1st no 12
Enter 2nd no 31
Enter 3rd no 9
The greatest no is 31
39. Chained conditional if
# Program to guess the vegetable
color = “green”
if color == “red”:
print(‘It is a tomato.’)
elif color == “purple”:
print(‘It is a brinjal.')
elif color == “green”:
print(‘It is a papaya. ')
else:
print(‘There is no such vegetable.’)
Output:
It is a papaya.
40. # Program to find out the greatest of four different numbers
a=int(input('Enter 1st no ‘))
b=int(input('Enter 2nd no ‘))
c=int(input('Enter 3rd no ‘))
d=int(input('Enter 4th no ‘))
if (a>b and a>c and a>d):
print('The greatest no is ', a)
elif (b>c and b>d):
print('The greatest no is ', b)
elif (c>d):
print('The greatest no is ', c)
elif d>c :
print('The greatest no is ', d)
else:
print('At least two values are equal')
Output:
Enter 1st no 23
Enter 2nd no 10
Enter 3rd no 34
Enter 4th no 7
The greatest no is 34
41. # Program to find out Grade
marks = int(input('Enter total marks ‘))
total = 500 # Total marks
percentage=(marks/total)*100
if percentage >= 80:
print('Grade O')
elif percentage >=70:
print('Grade A')
elif percentage >=60:
print('Grade B')
elif percentage >=40:
print('Grade C')
else:
print('Fail‘)
Output:
Enter total marks 312
Grade B
42. While loop
# Python program to find first ten Fibonacci numbers
a=1
print(a)
b=1
print(b)
i=3
while i<= 10:
c=a+b
print(c)
a=b
b=c
i=i+1
43. For loop
# Program to find the sum of squares of first n natural numbers
n = int(input('Enter the last number '))
sum = 0
for i in range(1, n+1):
sum = sum + i*i
print('The sum is ', sum)
Output:
Enter the last number 8
The sum is 204
44. For loop
# Program to find the sum of a given set of numbers
numbers = [11, 17, 24, 65, 32, 69]
sum = 0
for no in numbers:
sum = sum + no
print('The sum is ', sum)
Output:
The sum is 218
45. # Program to print 1, 22, 333, 444, .... in triangular form
n = int(input('Enter the number of rows '))
for i in range(1, n+1):
for j in range(1, i+1):
print(i, end='')
print()
Output:
Enter the number of rows 5
1
22
46. # Program to print opposite right triangle
n = int(input('Enter the number of rows '))
for i in range(n, 0, -1):
for j in range(1, i+1):
print('*', end='')
print()
Output:
*****
****
***
47. # Program to print opposite star pattern
n = int(input('Enter the number of rows '))
for i in range(0, n):
for j in range(0, n-i):
print(' ', end='')
for k in range(0, i+1):
print('*’, end='')
print('')
Output:
*
**
***
****
*****
48. # Program to print A, AB, ABC, ABCD, ......
ch = str(input('Enter a character '))
val=ord(ch)
for i in range(65, val+1):
for j in range(65, i+1):
print(chr(j), end='')
print()
Output:
A
AB
ABC
49. # Program to test Palindrome numbers
n=int(input('Enter an integer '))
x=n
r=0
while n>0:
d=n%10
r=r*10+d
n=n//10
if x==r:
print(x,' is Palindrome number’)
else:
print(x, ' is not Palindrome number')
50. # Program to print Pascal Triangle
n=int(input('Enter number of rows '))
for i in range(0, n):
for j in range(0, n-i-1):
print(end=' ')
for j in range(0, i+1):
print('*', end=' ')
print()
Output:
Enter number of rows 6
*
* *
* * *
* * * *
* * * * *
* * * * * *
51. Break and Continue
In Python, break and continue statements can alter the flow of a normal
loop.
# Searching for a given number
numbers = [11, 9, 88, 10, 90, 3, 19]
for num in numbers:
if(num==88):
print("The number 88 is found")
break
Output:
The number 88 is found
52. Break and Continue
# program to display only odd numbers
for num in [20, 11, 9, 66, 4, 89, 44]:
# Skipping the iteration when number is even
if num%2 == 0:
continue
# This statement will be skipped for all even numbers
else:
print(num)
53. File
A file is some information or data which stays in the computer
storage devices.
Files are of two types:
text files
binary files.
Text files:
We can create the text files by using the following syntax:
Variable name = open (“file.txt”, file mode)
Example:
f= open ("hello.txt","w+“)
54. File modes
Mode Description
‘r’ This is the default mode. It Opens file for reading.
‘w’ This Mode Opens file for writing.
If file does not exist, it creates a new file.
If file exists it truncates the file.
‘x’ Creates a new file. If file already exists, the operation fails.
‘a’ Open file in append mode.
If file does not exist, it creates a new file.
‘t’ This is the default mode. It opens in text mode.
‘b’ This opens in binary mode.
‘+’ This will open a file for reading and writing (updating)
.
56. # Write a python program to open and read a file
a=open(“one.txt”, ”r”)
content = a.read()
print(content)
a.close( )
# Write a python program to open and write “hello world” into a file.
f=open("file.txt","a")
f.write("hello world")
f.close( )
57. # Python program to write the content “Hi python programming” for the existing file.
f=open("MyFile.txt",'w')
f.write("Hi python programming")
f.close()
# Write a python program to open and write the content to file and read it.
f=open("abc.txt","w+")
f.write("Python Programming")
print(f.read())
f.close()