This lecture discusses fundamentals of programming in Python including values and types, variables, expressions, operators, input/output, and debugging. Some key points:
- Values have types like integers, floats, and strings which can be identified using the type() function.
- Variables store and reference values and are created using assignment statements. Variable names must follow specific rules.
- Expressions combine values and operators to evaluate to new values. Operators include +, -, *, / and order of operations follows PEMDAS rules.
- User input is obtained using the input() function which returns a string. Type conversion may be needed for mathematical operations.
- Comments starting with # are used to
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 programming with Python. It discusses key concepts like code, syntax, output, and consoles. It also covers compiling vs interpreting languages, with Python being an interpreted language. The document explains expressions, variables, basic math operations, and functions in Python like print and input. It introduces control structures like if/else statements, for loops, and while loops. It also covers different data types in Python including numbers, strings, lists, and dictionaries.
Python is an interpreted programming language that can be used to perform calculations, handle text, and control program flow. It allows variables to store values that can later be used in expressions. Common operations include arithmetic, printing output, accepting user input, and repeating tasks using for loops and conditional statements like if/else. The interpreter executes Python code directly without a separate compilation step required by other languages.
The document provides an introduction to programming with Python. It discusses key concepts like code, syntax, output, and consoles. It also covers compiling vs interpreting languages, with Python being an interpreted language. The document explains expressions, variables, basic math operations, and functions in Python like print and input. It introduces control structures like if/else statements and for/while loops. It also covers different data types in Python including numbers, strings, lists, and dictionaries.
This document provides an overview of the Python programming language. It discusses what a program and programming language are, and then describes key features of Python like being simple, interactive, and object-oriented. It explains how to install Python and work in interactive and script modes. The document also covers Python concepts like variables, data types, functions, operators, and control structures like conditional statements and loops.
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
Python
Language
is uesd in engineeringStory adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they s
Excellence Academy Is The Renowned & Best Python Training Institute In Chandigarh That Provides 100% Job-Oriented .Python Training Institute In Mohali Our Course Is Designed Especially For Students, Housewives & Other Who Are Looking For Python Training In Chandigarh.
Excellence Academy Is The Renowned & Best Python Training Institute In Chandigarh That Provides 100% Job-Oriented .Python Training Institute In Mohali Our Course Is Designed Especially For Students, Housewives & Other Who Are Looking For Python Training In Chandigarh.
This document provides an introduction and overview of the Python programming language. It describes Python as a general-purpose, object-oriented programming language with features like high-level programming capabilities, an easily understandable syntax, portability, and being easy to learn. It then discusses Python's characteristics like being an interpreted language, supporting object-oriented programming, being interactive and easy to use, having straightforward syntax, being portable, extendable, and scalable. The document also outlines some common uses of Python like for creating web and desktop applications, and provides examples of using Python's interactive and script modes.
This document provides an overview of key concepts in programming and Python. It defines terms like code, syntax, output, console, compiling, interpreting, and variables. It explains Python as an interpreted language and shows examples of printing output, taking user input, performing calculations with numbers and math commands, using variables, and basic control structures like if/else and loops. It also covers data types like integers, floats, strings, lists, and how to modify and format them.
The document provides an introduction to Python programming. It discusses key concepts like variables, data types, operators, and sequential data types. Python is presented as an interpreted programming language that uses indentation to indicate blocks of code. Comments and documentation are included to explain the code. Various data types are covered, including numbers, strings, booleans, and lists. Operators for arithmetic, comparison, assignment and more are also summarized.
This document discusses variables, data types, expressions, and functions in Python. It defines a variable as a name that represents a stored value in memory. It describes different data types in Python including integers, floats, strings, Booleans, and others. It also discusses expressions, which represent computations that evaluate to a value, and different expression types like arithmetic, relational, logical, and compound expressions. Finally, it introduces functions as blocks of code that perform tasks and can return values.
The document discusses Python control structures including if-else statements, indentation, and loops. It provides examples of if statements, if-else statements, nested if statements, and elif statements to test conditions and execute code blocks accordingly. It also discusses for loops and the range() function to iterate through sequences and generate number sequences to repeat code. Loops simplify problems by allowing code to repeat without rewriting and help traverse data structures.
The document provides an overview of the Python programming language. It discusses why Python is useful for students and professionals, its major features like being object-oriented and having a large standard library. The document also covers Python's history, how to install it and set the environment variables, basic syntax like variables and data types, operators, and common programming constructs like conditionals and loops.
Gurukul Skills Schedule for the Month of March
Time Cohort-10 Cohort-11 Cohort-12
8.00 to 09.25 Revision Revision Revision
5 Minutes Short Break
9.30 to 11.30 Chartered Accountants Chartered Accountants ENGLISH/SOFT SKILLS
15 Minutes Short Break
11.45 to 01.45 ICT ENGLISH/SOFT SKILLS R&A
45 Minutues Lunch Break
2.30 to 04.30 ENGLISH/SOFT SKILLS R&A ICT
15 Minutes Short Break
4.45 to 06.30 R&A ICT ACCOUNTS
5 Minutes Short Break
6.35 to 08.00 Assingments Assingments Assingments
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
The document discusses Java syntax and concepts including:
1. It introduces primitive data types in Java like int, float, boolean and String.
2. It covers variables, operators, and expressions - how they are used to store and manipulate data in Java.
3. It explains console input and output using Scanner and System.out methods for reading user input and printing output.
4. It provides examples of using conditional statements like if and if-else to control program flow based on conditions.
Helpmeinhomework Experts provides the most trusted and reliable online Programming assignment help . Programming is one of the most widely taught subjects across the universities. The complexity of subjects make students seek for quality and affordable online guidance. We at helpmeinhomework.com Experts cater to such needs of the students. Our programming experts provide assignment help to students across UK, USA and Australia for multiple programming languages i.e. Java, Python, HTML, PHP, Assembly language, C ,Linux ,Unix etc.
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
Python
Language
is uesd in engineeringStory adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they s
Excellence Academy Is The Renowned & Best Python Training Institute In Chandigarh That Provides 100% Job-Oriented .Python Training Institute In Mohali Our Course Is Designed Especially For Students, Housewives & Other Who Are Looking For Python Training In Chandigarh.
Excellence Academy Is The Renowned & Best Python Training Institute In Chandigarh That Provides 100% Job-Oriented .Python Training Institute In Mohali Our Course Is Designed Especially For Students, Housewives & Other Who Are Looking For Python Training In Chandigarh.
This document provides an introduction and overview of the Python programming language. It describes Python as a general-purpose, object-oriented programming language with features like high-level programming capabilities, an easily understandable syntax, portability, and being easy to learn. It then discusses Python's characteristics like being an interpreted language, supporting object-oriented programming, being interactive and easy to use, having straightforward syntax, being portable, extendable, and scalable. The document also outlines some common uses of Python like for creating web and desktop applications, and provides examples of using Python's interactive and script modes.
This document provides an overview of key concepts in programming and Python. It defines terms like code, syntax, output, console, compiling, interpreting, and variables. It explains Python as an interpreted language and shows examples of printing output, taking user input, performing calculations with numbers and math commands, using variables, and basic control structures like if/else and loops. It also covers data types like integers, floats, strings, lists, and how to modify and format them.
The document provides an introduction to Python programming. It discusses key concepts like variables, data types, operators, and sequential data types. Python is presented as an interpreted programming language that uses indentation to indicate blocks of code. Comments and documentation are included to explain the code. Various data types are covered, including numbers, strings, booleans, and lists. Operators for arithmetic, comparison, assignment and more are also summarized.
This document discusses variables, data types, expressions, and functions in Python. It defines a variable as a name that represents a stored value in memory. It describes different data types in Python including integers, floats, strings, Booleans, and others. It also discusses expressions, which represent computations that evaluate to a value, and different expression types like arithmetic, relational, logical, and compound expressions. Finally, it introduces functions as blocks of code that perform tasks and can return values.
The document discusses Python control structures including if-else statements, indentation, and loops. It provides examples of if statements, if-else statements, nested if statements, and elif statements to test conditions and execute code blocks accordingly. It also discusses for loops and the range() function to iterate through sequences and generate number sequences to repeat code. Loops simplify problems by allowing code to repeat without rewriting and help traverse data structures.
The document provides an overview of the Python programming language. It discusses why Python is useful for students and professionals, its major features like being object-oriented and having a large standard library. The document also covers Python's history, how to install it and set the environment variables, basic syntax like variables and data types, operators, and common programming constructs like conditionals and loops.
Gurukul Skills Schedule for the Month of March
Time Cohort-10 Cohort-11 Cohort-12
8.00 to 09.25 Revision Revision Revision
5 Minutes Short Break
9.30 to 11.30 Chartered Accountants Chartered Accountants ENGLISH/SOFT SKILLS
15 Minutes Short Break
11.45 to 01.45 ICT ENGLISH/SOFT SKILLS R&A
45 Minutues Lunch Break
2.30 to 04.30 ENGLISH/SOFT SKILLS R&A ICT
15 Minutes Short Break
4.45 to 06.30 R&A ICT ACCOUNTS
5 Minutes Short Break
6.35 to 08.00 Assingments Assingments Assingments
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
The document discusses Java syntax and concepts including:
1. It introduces primitive data types in Java like int, float, boolean and String.
2. It covers variables, operators, and expressions - how they are used to store and manipulate data in Java.
3. It explains console input and output using Scanner and System.out methods for reading user input and printing output.
4. It provides examples of using conditional statements like if and if-else to control program flow based on conditions.
Helpmeinhomework Experts provides the most trusted and reliable online Programming assignment help . Programming is one of the most widely taught subjects across the universities. The complexity of subjects make students seek for quality and affordable online guidance. We at helpmeinhomework.com Experts cater to such needs of the students. Our programming experts provide assignment help to students across UK, USA and Australia for multiple programming languages i.e. Java, Python, HTML, PHP, Assembly language, C ,Linux ,Unix etc.
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYijscai
With the increased use of Artificial Intelligence (AI) in malware analysis there is also an increased need to
understand the decisions models make when identifying malicious artifacts. Explainable AI (XAI) becomes
the answer to interpreting the decision-making process that AI malware analysis models use to determine
malicious benign samples to gain trust that in a production environment, the system is able to catch
malware. With any cyber innovation brings a new set of challenges and literature soon came out about XAI
as a new attack vector. Adversarial XAI (AdvXAI) is a relatively new concept but with AI applications in
many sectors, it is crucial to quickly respond to the attack surface that it creates. This paper seeks to
conceptualize a theoretical framework focused on addressing AdvXAI in malware analysis in an effort to
balance explainability with security. Following this framework, designing a machine with an AI malware
detection and analysis model will ensure that it can effectively analyze malware, explain how it came to its
decision, and be built securely to avoid adversarial attacks and manipulations. The framework focuses on
choosing malware datasets to train the model, choosing the AI model, choosing an XAI technique,
implementing AdvXAI defensive measures, and continually evaluating the model. This framework will
significantly contribute to automated malware detection and XAI efforts allowing for secure systems that
are resilient to adversarial attacks.
Value Stream Mapping Worskshops for Intelligent Continuous SecurityMarc Hornbeek
This presentation provides detailed guidance and tools for conducting Current State and Future State Value Stream Mapping workshops for Intelligent Continuous Security.
Passenger car unit (PCU) of a vehicle type depends on vehicular characteristics, stream characteristics, roadway characteristics, environmental factors, climate conditions and control conditions. Keeping in view various factors affecting PCU, a model was developed taking a volume to capacity ratio and percentage share of particular vehicle type as independent parameters. A microscopic traffic simulation model VISSIM has been used in present study for generating traffic flow data which some time very difficult to obtain from field survey. A comparison study was carried out with the purpose of verifying when the adaptive neuro-fuzzy inference system (ANFIS), artificial neural network (ANN) and multiple linear regression (MLR) models are appropriate for prediction of PCUs of different vehicle types. From the results observed that ANFIS model estimates were closer to the corresponding simulated PCU values compared to MLR and ANN models. It is concluded that the ANFIS model showed greater potential in predicting PCUs from v/c ratio and proportional share for all type of vehicles whereas MLR and ANN models did not perform well.
This paper proposes a shoulder inverse kinematics (IK) technique. Shoulder complex is comprised of the sternum, clavicle, ribs, scapula, humerus, and four joints.
π0.5: a Vision-Language-Action Model with Open-World GeneralizationNABLAS株式会社
今回の資料「Transfusion / π0 / π0.5」は、画像・言語・アクションを統合するロボット基盤モデルについて紹介しています。
拡散×自己回帰を融合したTransformerをベースに、π0.5ではオープンワールドでの推論・計画も可能に。
This presentation introduces robot foundation models that integrate vision, language, and action.
Built on a Transformer combining diffusion and autoregression, π0.5 enables reasoning and planning in open-world settings.
Taking AI Welfare Seriously, In this report, we argue that there is a realist...MiguelMarques372250
In this report, we argue that there is a realistic possibility that some AI systems
will be conscious and/or robustly agentic in the near future. That means that the
prospect of AI welfare and moral patienthood — of AI systems with their own
interests and moral significance — is no longer an issue only for sci-fi or the
distant future. It is an issue for the near future, and AI companies and other actors
have a responsibility to start taking it seriously. We also recommend three early
steps that AI companies and other actors can take: They can (1) acknowledge that
AI welfare is an important and difficult issue (and ensure that language model
outputs do the same), (2) start assessing AI systems for evidence of consciousness
and robust agency, and (3) prepare policies and procedures for treating AI systems
with an appropriate level of moral concern. To be clear, our argument in this
report is not that AI systems definitely are — or will be — conscious, robustly
agentic, or otherwise morally significant. Instead, our argument is that there is
substantial uncertainty about these possibilities, and so we need to improve our
understanding of AI welfare and our ability to make wise decisions about this
issue. Otherwise there is a significant risk that we will mishandle decisions about
AI welfare, mistakenly harming AI systems that matter morally and/or mistakenly
caring for AI systems that do not.
The idea behind this session is to equip you with a practical, collaborative method to deeply understand your domain — not just from a technical perspective, but through a lens that aligns with how the business actually works.
By the end, you’ll walk away with a new mindset and tools you can take back to your team.
Dust Suppressants: A Sustainable Approach to Dust Pollution ControlJanapriya Roy
This journal explores the growing field of bio-organic dust suppressants as a sustainable solution to dust pollution. It reviews the working principles of dust suppression, key performance indicators, and the latest research on using natural materials like polysaccharides, lignin, proteins, and agricultural wastes. It also highlights current challenges and future directions to enhance the durability, cost-effectiveness, and environmental safety of bio-based dust control technologies. A valuable reference for researchers, environmental engineers, and industry professionals seeking eco-friendly dust management solutions.
Dust pollution, whether natural or anthropogenic, poses significant threats to both the environment and public health. Effective dust suppression technologies are essential in mitigating airborne particulate matter, especially in industrial, mining, and construction settings. Recently, bio-organic materials have emerged as promising raw materials for eco-friendly dust suppressants. This paper explores the working principles of dust suppressants, key performance evaluation indices, and the current progress in developing bio-based dust control agents using polysaccharides, lignin, proteins, microorganisms, and agricultural or forestry waste. It also discusses existing challenges and future research directions for enhancing the efficiency and applicability of bio-organic dust suppressants.
Working Principles of Dust Suppressants
Dust suppressants operate primarily through three interrelated mechanisms: wetting, coagulation, and consolidation.
Wetting: This mechanism involves the application of dust suppressants to reduce the surface tension of water, allowing it to penetrate and coat dust particles. This increases the weight and cohesion of the particles, causing them to settle quickly. Surfactants and hygroscopic agents are commonly used in this approach.
Coagulation: Dust particles are brought together to form larger aggregates through electrostatic interactions or binding agents, which helps in accelerating their settling.
Consolidation: A more long-term effect where the suppressant forms a crust or mesh-like structure over the dust-prone surface, physically stabilizing it and preventing re-entrainment of particles by wind or vehicle movement.
Bio-Organic Materials in Dust Suppressants
The shift toward natural, renewable, and biodegradable components has led to extensive research on the use of various bio-organic substances, including:
Polysaccharides: Starch, cellulose derivatives, and chitosan can form gels or films that stabilize surfaces.
Lignin: A byproduct of the paper industry, lignin offers strong binding capacity and is naturally water-resistant.
Proteins: Derived from agricultural waste, proteins like casein and soy protein can enhance binding and wetting.
Microorganisms: Certain bacteria and fungi can produce biofilms or exopolysaccharides that trap dust particles.
Agricultural and Forestry Wastes: Residues su
2. Welcome
Congratulations for deciding to participate
in a 7 days of Introduction to Python
Course.
In this course you will learn the basics of
programming using Python.
3. Course Introduction
This course is designed for beginners and
intermediate who want to learn python
programming language.
In this course the topics are broken down
into 7 days, where each day contains several
topics with easy-to-understand
explanations, real-world examples, many
hands on exercises and a final project.
4. Why Python?
Python is a programming language which is
very close to human language and because
of that it is easy to learn and use.
Python is used by various industries and
companies (including Google).
It has been used to develop web
applications, desktop applications, system
administration, and machine learning
libraries.
5. Installing Python
To run a python script you need to install python.
Let's download python from
https://www.python.org/.
6. Installing VS Code
Visual Studio Code is a code editor (much like
any other editor like Notepad) helpful in writing
and editing codes.
We download it from here
https://code.visualstudio.com/
7. Basic Data-types
Boolean
A boolean data type is either a True or False value. T and F
should be always uppercase.
Integers (default for numbers)
z = 5
Floats
x = 3.1416
Complex Numbers
x = 1+2j
8. Basic Data-types
Strings
• Can use “ ” or ‘ ’ to specify strings
• a = “Nepal”
• b = ‘Kantipur Engineering College’
• “abc” == ‘abc’
• Use “ ” if ’ already in string eg: “matt’s”
• Use triple double-quotes for multi-line strings or strings
than contain both ‘ and “ inside of them:
“““a‘b“c”””
9. Checking Data Types
To check the data type of certain data/variable we
use the type function.
>>> type(15)
<class ‘int’>
>>> type(3.14)
<class ‘float’>
>>> type(1+2j)
<class ‘complex’>
>>> str = “Hello World”
>>> type(str)
<class ‘string’>
10. Naming Rules
Names are case sensitive and cannot start with a
number.
They can contain letters, numbers, and
underscores.
bob Bob _bob _2_bob_ bob_2 BoB
There are some reserved words:
and, assert, break, class, continue, def, del, elif, else,
except, exec, finally, for, from, global, if, import, in, is,
lambda, not, or, pass, print, raise, return, try, while
Can’t do this
• for = 12 #for is a reserved word
11. Assignment
Assign value to variables
>>> x = 2
You can assign to multiple names at the same time
>>> x, y = 2, 3
>>> x
2
>>> y
3
This makes it easy to swap values
>>> x, y = y, x
Assignments can be chained
>>> a = b = x = 2
14. Mathematical Operators
Exercise: For a given temperature in celsius stored in
variable ‘t_c’, get the Fahrenheit temperature in ‘t_f’ and
display result.
• Let t_c = 100
• ans = 212
15. Checking Data Types
Exercise: What would be the data-type of?
>>> a = 4/3
>>> type(a)
>>> n = 4//3
>>> type(a)
>>> num = ‘2080’
>>> type(num)
16. Type Casting
Converting one data type to another data type.
We use int(), float(), str()
>> # float to int
>> gravity = 9.81
>> print(int(gravity))
17. Type Casting
When we do arithmetic operations string numbers
should be first converted to int or float otherwise it
will return an error.
>> #str to int or float
>> num_str = '10.6‘
>> print('num_int', int(num_str))
>> print('num_float', float(num_str))
19. Comparison Operators
In programming we compare values, we use
comparison operators to compare two values. We
check if a value is greater or less or equal to other
value.
>> 2 == 2
>> 3.14 == 3.1416
>> print(123 == ‘123’)
>> print(123 == int(‘123’))
>> a = ‘mango’
>> b = ‘orange’
>> a == b
>> a < b What does this show?
21. Logical Operators
Logical operators are used to combine conditional
statements:
>> 2 == 2 and 2 < 4
True
>> print()
>>
>> a = ‘mango’
>> b = ‘orange’
>> a == b
>> a < b What does this show?
22. Conditionals
In python the key word if is used to check if a
condition is true and to execute the block code.
Remember the indentation after the colon.
a = 10
if a > 3:
print(a, “is greater than 3”)
if else
a = 3
if a > 0:
print(a, “is positive number”)
else:
print(a, “is negative”)
23. Conditionals
if elif else
a = 3
if a > 0:
print(a, “is positive number”)
elif a < 0:
print(a, “is negative number”)
else:
print(a, “is zero”)
24. Operators and Conditionals
Exercise:
How do you check if a number is between 5 and 10
inclusive?
Note: Use if statement here
>>> if condition_1 and condition_2:
... choice_1
>>> else:
... choice_2
>>>
25. Operators and Conditionals
Exercise:
How do you check if a number is even or not using
python?
Note: Use if statement here
>>> if condition:
... choice_1
>>> else:
... choice_2
>>>
26. Program for the Day
Calculate Electricity Bill (15A)
KWh Minimum Charge Charge per KWh
0 to 20 50 4.00
21 to 30 75 6.50
31 to 50 75 8.00
51 to 100 100 9.50
101 to 250 125 9.50
250 above 175 11
Ans: 2330 for 250 units
27. Loops
In programming we also do lots of repetitive tasks. In order
to handle repetitive task programming languages use loops.
Python programming language also provides the following
types of two loops:
• while loop
• for loop
28. While Loop
count = 0
while count < 5:
print(count)
count = count + 1 #prints from 0 to 4
29. for Loop
# syntax
for iterator in range(start, end, step):
#loop statements
for i in range(1,10,1):
print(i)
30. for Loop
num_list = [1,2,3,4,5]
for num in num_list:
print(num)
it_companies = ['Facebook', 'Google', 'Microsoft',
'Apple', 'IBM', 'Oracle',
‘Amazon‘]
for company in it_companies:
print(company)
32. Program for the Day
Student Grading SEE and NEB
For a given students’ mark in percentage, display
letter grade for each student.
marks = 90
Your code should display “Outstanding”
33. Program for the Day
Student Grading SEE and NEB
For a list of students’ marks in percentage, display
letter grade for each student.
marks = [95, 42, 78, 45, 89, 90]
Use for loop