The document discusses Python programming concepts such as data types, variables, operators, and input/output. It provides examples of Python code and explains key features like:
- Python supports several data types including integers, floats, booleans, strings, and lists.
- Variables store and label values that can be of different data types. Variables are created using names.
- Operators like arithmetic, comparison, and logical operators are used to manipulate values.
- User input and output is handled through functions like print() and input().
- Comments, indentation, and quotation are syntax elements in Python code.
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.
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.
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.
Python is a general purpose programming language created by Guido van Rossum in 1991. It is an interpreted, interactive, object-oriented language with a simple syntax. Python supports cross-platform development and is widely used for scripting, game development, and building desktop and mobile applications. To use Python, developers must download the Python interpreter and can write and run code using the interactive shell or integrated development environments like IDLE. The document then discusses Python's multi-paradigm programming style, advantages like rapid development, and how to install Python and write basic programs using variables, operators, and data types.
Python is a general purpose programming language created by Guido van Rossum in 1991. It is designed to be simple, powerful, and has an easy to read syntax. Python supports cross-platform development and code can run on Windows, Linux, and Mac OS. It is widely used for tasks such as desktop applications, web development, data analysis, and game development. To use Python, one must download the Python interpreter from python.org and then write and run Python code using the interactive shell or IDEs like IDLE. Python code makes use of variables, data types, operators, conditionals, loops, functions, classes and modules. Common data types in Python include integers, floats, strings, lists, tuples, and
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
This document provides a tutorial on Python programming. It introduces core Python concepts over several sections. The first section discusses what will be covered, including an introduction to the Python language and becoming comfortable writing basic programs. Subsequent sections cover specific Python topics like data types, operators, conditional and loop execution, functions, modules and packages for code reusability. The document emphasizes consistent indentation and readability in Python code.
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 and introduction to Python programming. It discusses Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also covers commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics. The document is intended as a whistle-stop tour to cover the most common aspects of Python.
This document provides a high-level summary of an introduction to Python programming course. The summary includes an overview of Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also discusses commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics.
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. 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.
This document outlines the objectives and content of the course GE3151 Problem Solving and Python Programming. The course is intended to teach students the basics of algorithmic problem solving using Python. It covers topics like computational thinking, Python data types, control flow, functions, strings, lists, tuples, dictionaries, files and modules. The course contains 5 units that will teach students how to define problems, develop algorithms, implement solutions in Python using conditionals, loops, functions and data structures, perform input/output with files and use modules and packages.
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.
This tutorial provides an introduction to the Python programming language. It will cover Python's core features like syntax, data types, operators, conditional and loop execution, functions, modules and packages to enable writing basic programs. The tutorial is intended for learners to learn Python together through questions, discussions and pointing out mistakes.
This document provides an introduction and overview of the Python programming language course CSE 120 handled by G.Gandhi Jaba Kumar. It discusses that Python is an interpreted, object-oriented, and interactive programming language used for web development, software development, mathematics, and system scripting. The document then covers Python syntax including indentation, comments, keywords, variables, data types, operators, and basic programming concepts like conditionals and loops. It provides examples to illustrate Python code and best practices.
Python is a multi-paradigm programming language that is object-oriented, imperative and functional. It is dynamically typed, with support for complex data types like lists and strings. Python code is commonly written and executed using the interactive development environment IDLE.
Python is a multi-paradigm programming language that supports object-oriented, imperative and functional programming styles. It is dynamically typed and supports complex data types like lists, dictionaries and objects. Some key features of Python include being highly readable, having extensive libraries, and being cross-platform.
Python is a general purpose programming language created by Guido van Rossum in 1991. It is an interpreted, interactive, object-oriented language with a simple syntax. Python supports cross-platform development and is widely used for scripting, game development, and building desktop and mobile applications. To use Python, developers must download the Python interpreter and can write and run code using the interactive shell or integrated development environments like IDLE. The document then discusses Python's multi-paradigm programming style, advantages like rapid development, and how to install Python and write basic programs using variables, operators, and data types.
Python is a general purpose programming language created by Guido van Rossum in 1991. It is designed to be simple, powerful, and has an easy to read syntax. Python supports cross-platform development and code can run on Windows, Linux, and Mac OS. It is widely used for tasks such as desktop applications, web development, data analysis, and game development. To use Python, one must download the Python interpreter from python.org and then write and run Python code using the interactive shell or IDEs like IDLE. Python code makes use of variables, data types, operators, conditionals, loops, functions, classes and modules. Common data types in Python include integers, floats, strings, lists, tuples, and
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
This document provides a tutorial on Python programming. It introduces core Python concepts over several sections. The first section discusses what will be covered, including an introduction to the Python language and becoming comfortable writing basic programs. Subsequent sections cover specific Python topics like data types, operators, conditional and loop execution, functions, modules and packages for code reusability. The document emphasizes consistent indentation and readability in Python code.
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 and introduction to Python programming. It discusses Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also covers commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics. The document is intended as a whistle-stop tour to cover the most common aspects of Python.
This document provides a high-level summary of an introduction to Python programming course. The summary includes an overview of Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also discusses commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics.
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. 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.
This document outlines the objectives and content of the course GE3151 Problem Solving and Python Programming. The course is intended to teach students the basics of algorithmic problem solving using Python. It covers topics like computational thinking, Python data types, control flow, functions, strings, lists, tuples, dictionaries, files and modules. The course contains 5 units that will teach students how to define problems, develop algorithms, implement solutions in Python using conditionals, loops, functions and data structures, perform input/output with files and use modules and packages.
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.
This tutorial provides an introduction to the Python programming language. It will cover Python's core features like syntax, data types, operators, conditional and loop execution, functions, modules and packages to enable writing basic programs. The tutorial is intended for learners to learn Python together through questions, discussions and pointing out mistakes.
This document provides an introduction and overview of the Python programming language course CSE 120 handled by G.Gandhi Jaba Kumar. It discusses that Python is an interpreted, object-oriented, and interactive programming language used for web development, software development, mathematics, and system scripting. The document then covers Python syntax including indentation, comments, keywords, variables, data types, operators, and basic programming concepts like conditionals and loops. It provides examples to illustrate Python code and best practices.
Python is a multi-paradigm programming language that is object-oriented, imperative and functional. It is dynamically typed, with support for complex data types like lists and strings. Python code is commonly written and executed using the interactive development environment IDLE.
Python is a multi-paradigm programming language that supports object-oriented, imperative and functional programming styles. It is dynamically typed and supports complex data types like lists, dictionaries and objects. Some key features of Python include being highly readable, having extensive libraries, and being cross-platform.
This presentation highlights project development using software development life cycle (SDLC) with a major focus on incorporating research in the design phase to develop innovative solution. Some case-studies are also highlighted which makes the reader to understand the different phases with practical examples.
This document provides information about the Fifth edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
May 2025: Top 10 Read Articles Advanced Information Technologyijait
International journal of advanced Information technology (IJAIT) is a bi monthly open access peer-reviewed journal, will act as a major forum for the presentation of innovative ideas, approaches, developments, and research projects in the area advanced information technology applications and services. It will also serve to facilitate the exchange of information between researchers and industry professionals to discuss the latest issues and advancement in the area of advanced IT. Core areas of advanced IT and multi-disciplinary and its applications will be covered during the conferences.
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODSsamueljackson3773
In this paper, the author discusses the concerns of using various wireless communications and how to use
them safely. The author also discusses the future of the wireless industry, wireless communication
security, protection methods, and techniques that could help organizations establish a secure wireless
connection with their employees. The author also discusses other essential factors to learn and note when
manufacturing, selling, or using wireless networks and wireless communication systems.
Rearchitecturing a 9-year-old legacy Laravel application.pdfTakumi Amitani
An initiative to re-architect a Laravel legacy application that had been running for 9 years using the following approaches, with the goal of improving the system’s modifiability:
・Event Storming
・Use Case Driven Object Modeling
・Domain Driven Design
・Modular Monolith
・Clean Architecture
This slide was used in PHPxTKY June 2025.
https://phpxtky.connpass.com/event/352685/
David Boutry - Mentors Junior DevelopersDavid Boutry
David Boutry is a Senior Software Engineer in New York with expertise in high-performance data processing and cloud technologies like AWS and Kubernetes. With over eight years in the field, he has led projects that improved system scalability and reduced processing times by 40%. He actively mentors aspiring developers and holds certifications in AWS, Scrum, and Azure.
Python unit 2 is added. Has python related programming content
1. UNIT 02: BASICS OF PYTHON
PROGRAMMING
Introduction-Python Interpreter-Interactive and
script mode -Values and types, variables,
operators, expressions, statements, precedence
of operators, Multiple assignments, comments,
input function, print function, Formatting
numbers and strings, implicit/explicit type
conversion.
2. Introduction to PYTHON
• Python is a general-purpose interpreted, interactive, object-oriented,
and high level programming language.
• It was created by Guido van Rossum during 1985- 1990.
• Python is interpreted: Python is processed at runtime by the
interpreter. You do not need to compile your program before
executing it.
• 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.
3. Python Features
• Easy-to-learn: Python is clearly defined and easily readable. The structure of the
program is very simple. It uses few keywords.
• Easy-to-maintain: Python's source code is fairly easy-to-maintain.
• Portable: Python can run on a wide variety of hardware platforms and has the
same interface on all platforms.
• Interpreted: Python is processed at runtime by the interpreter. So, there is no
need to compile a program before executing it. You can simply run the program.
• Extensible: Programmers can embed python within their C,C++,Java
script ,ActiveX, etc.
• Free and Open Source: Anyone can freely distribute it, read the source code, and
edit it.
• High Level Language: When writing programs, programmers concentrate on
solutions of the current problem, no need to worry about the low level details.
• Scalable: Python provides a better structure and support for large programs than
shell scripting.
4. Python Interpreter
• A python interpreter is a computer program that converts each
high-level program statement into machine code.
• Translating it one line at a time
• Compiler: To translate a program written in a high-level language
into a low-level language all at once
5. Difference between Interpreter and
Compiler
Compilers Interpreters
Compilers translate the entire source code into
machine code before execution.
Interpreters translate and execute the source
code line by line.
Compiled code runs faster because it's already
translated into machine code.
Interpreted code runs slower because it must be
translated on the fly.
Compilers generate an executable file that can
be run independently.
Interpreters require the source code to be
present at runtime.
Compilers display all errors at once after
compilation.
Interpreters display errors one at a time during
execution.
Compiled languages include C, C++, and Java. Interpreted languages include Python, Ruby, and
JavaScript.
Compilers have a longer development cycle due
to the compilation step.
Interpreters have a shorter development cycle as
code can be tested immediately.
Compiled code is platform-dependent. Interpreted code is platform-independent.
7. Interactive mode
• Interactive Mode, as the name suggests, allows us to interact with
OS.
• When we type Python statement, interpreter displays the result(s)
immediately.
Advantages:
Python, in interactive mode, is good enough to learn, experiment or
explore.
Working in interactive mode is convenient for beginners and for
testing small pieces of code.
Drawback:
We cannot save the statements and have to retype all the statements
once again to re-run them
9. Script mode
• In script mode, we type python program in a file and then use
interpreter to execute the content of the file.
• Scripts can be saved to disk for future use. Python scripts have the
extension .py, meaning that the filename ends with .py
• Save the code with filename.py and run the interpreter in script
mode to execute the script.
12. Integrated Development Learning Environment (IDLE):
• Is a graphical user interface which is completely written in Python.
• It is bundled with the default implementation of the python language and
also comes with optional part of the Python packaging.
• Features of IDLE:
• Multi-window text editor with syntax highlighting.
• Auto completion with smart indentation.
• Python shell to display output with syntax highlighting.
13. Values and types
Value: Value can be any letter ,number or string.
Eg, Values are 2, 42.0, and 'Hello, World!'. (These values belong to
different data types.)
Data type: Every value in Python has a data type. It is a set of values,
and the allowable operations on those values.
15. Numeric Data Types
type() function is used to determine the type of Python data type.
• Integers – This value is represented by int class. It contains positive or
negative whole numbers (without fractions or decimals). In Python,
there is no limit to how long an integer value can be.
• Float – This value is represented by the float class. It is a real number
with a floating-point representation. It is specified by a decimal point.
Optionally, the character e or E followed by a positive or negative
integer may be appended to specify scientific notation.
• Complex Numbers – A complex number is represented by a complex
class. It is specified as (real part) + (imaginary part)j . For example – 2+3j
17. Sequence
• A sequence is an ordered collection of items, indexed by positive
integers.
• It is a combination of mutable (value can be changed) and
immutable (values cannot be changed) data types.
1.Strings (Immutable)
2. Lists( mutable)
3. Tuples(Immutable)
18. Strings
• A String in Python consists of a sequence of characters - letters, numbers, and special
characters.
• Strings are marked by quotes:
• single quotes (' ') Eg, 'This a string in single quotes'
• double quotes (" ") Eg, "'This a string in double quotes'"
• triple quotes(""" """) Eg, This is a paragraph. It is made up of multiple lines and
sentences.""“
• Individual character in a string is accessed using a subscript (index).
• Characters can be accessed using indexing and slicing operations.
• Strings are immutable i.e. the contents of the string cannot be changed after it is
created.
19. Indexing
String A H E L L 0
Positive Index 0 1 2 3 4
Negative Index -5 -4 -3 -2 -1
Example: A[0] or A[-5] will display “H”
Example: A[1] or A[-4] will display “E”
Str=‘Python Program’
Str[-3]
Str[3]
Str[6]
Str[7]
21. Indexing Accessing the item in the position
Slicing Slice operator is used to extract part of a data type
Concatenation Adding and printing the characters of two strings.
Repetition multiple copies of the same string
in, not in
(membership
operator)
Using membership operators to check a particular
character is in string or not. Returns true if present.
29. Lists
• List is an ordered sequence of items. Values in the list
are called elements / items.
• It can be written as a list of comma-separated items
(values) between square brackets[ ].
• Items in the lists can be of different data types.
31. Indexing Accessing the item in the particular position
Slicing Slice operator is used to extract part of a string, or some
part of a list Python
Concatenation Adding and printing the items of two lists.
Repetitions multiple copies of the same string
Updating the list Updating the list using index value
Inserting an element Inserting an element in 2nd position
Removing an element Removing an element by giving the element directly
35. Updating the list
Inserting an element
Removing an element
Note:
Update,Insert:Need
to give Position
Remove:give value
alone
36. Tuple
• A tuple is same as list, except that the set of elements is enclosed in
parentheses instead of square brackets.
• A tuple is an immutable list. i.e. once a tuple has been created, you can't
add elements to a tuple or remove elements from the tuple.
• Tuples are faster than lists
39. Dictionaries
• Lists are ordered sets of objects, whereas dictionaries are
unordered sets.
• Dictionary is created by using curly brackets. i,e. {}
• Dictionaries are accessed via keys and not via their
position.
41. Variables
• Rules:
• A variable allows us to store a value by assigning it to a name,
which can be used later.
• Named memory locations to store values.
• Programmers generally choose names for their variables that are
meaningful.
• It can be of any length. No space is allowed.
• We don't need to declare a variable before using it. In Python, we
simply assign a value to a variable and it will exist.
42. Assigning a single value to several variables simultaneously:
Assigning multiple values to multiple variables
a=b=c=10,20,"Ram"
print(c)
(10, 20, 'Ram')
print(a)
(10, 20, 'Ram')
a=b=c=100
print(a)
100
print(c)
100
43. Expressions and Statements
• Statements:
• Instructions that a Python interpreter can executes are called statements.
• A statement is a unit of code like creating a variable or displaying a value.
• Expressions:
• An expression is a combination of values, variables, and operators.
>>> n = 17
>>> print(n)
a=2
a+3+2
7
str=("Good"+"Morning")
print(str)
GoodMorning
44. Multiple assignments
• same value to multiple variables
• Assign multiple values to multiple variables
a=b=c=10
print(a)
10
print(b)
10
x, y, z = "Orange", "Banana", "Cherry"
print(x)
Orange
45. Comments
• Comments are the kind of statements that are written in the
program for program understanding purpose.
• In Python, we use the hash (#) symbol to start writing a comment.
• Python Interpreter ignores comment.
• If we have comments that extend multiple lines, one way of doing it
is to use hash (#) in the beginning of each line.
# This is comment line
print(“I love my country”)
percentage = (minute *
100) / 60 # calculating
percentage of an hour
#This is
#another example
#of comment statement
46. OPERATORS
• Operators are the constructs which can manipulate the value of operands.
• Consider the expression 4 + 5 = 9.
• Here, 4 and 5 are called operands and + is called operator
48. Arithmetic operators
• They are used to perform mathematical operations like addition,
subtraction, multiplication etc
49. Operator Description
+ Addition Adds values on either side of the operator
- Subtraction Subtracts right hand operand from left hand operand.
* Multiplication Multiplies values on either side of the operator
/ Division Divides left hand operand by right hand operand
% Modulus Divides left hand operand by right hand operand and
returns remainder
** Exponent Performs exponential (power) calculation on operators
// Floor Division - The division of operands where the result is
the quotient in which the digits after the decimal point are
removed
51. Comparison (Relational) Operators
• Comparison operators are used to compare values.
• It either returns True or False according to the condition. Assume, a=10 and b=5
==,<
>
<=
>=
!=
54. Operator Description Example
= Assigns values from right side operands to
left side operand
c = a + b assigns value of a
+ b into c
+= Add
AND
It adds right operand to the left operand
and assign the result to left operand
c += a
is equivalent to c = c + a
-= Subtract
AND
It subtracts right operand from the left
operand and assign the result to left
operand
c -= a
is equivalent to c = c - a
*= Multiply
AND
It multiplies right operand with the left
operand and assign the result to left
operand
c *= a
is equivalent to c = c * a
**=
Exponent
AND
Performs exponential (power) calculation
on operators and assign value to the left
operand
c **= a
is equivalent to c = c ** a
//= Floor
Division
It performs floor division on operators and
assign value to the left operand
c //= a is equivalent to c = c
// a
56. Logical Operators
• Logical operators are the and, or, not operators
And True if both the operands are True
Or True if either of the operands is true
not True if operands is false
58. Bitwise Operators
• A bitwise operation operates on one or more bit patterns
at the level of individual bits
• Let x = 10 (0000 1010 in binary) and
y = 4 (0000 0100 in binary)
59. x = 10 (0000 1010 in binary) and
y = 4 (0000 0100 in binary)
& Bitwise AND X&Y= (0000 0000)
| Bitwise OR X|y= (0000 1110)
~ Bitwise Not -x=(1111 0101)
^ Bitwise XOR x ^ y =(1111 0001)
>> Bitwise right shift X >>2=(0000 0010)
<< Bitwise left shift X <<2=(0010 1000)
60. Membership Operators
• Evaluates to find a value or a variable is in the specified sequence
of string, list, tuple, dictionary or not.
• Let, x=[5,3,6,4,1]. To check particular item in list or not, in and not in
operators are used.
61. Identity Operators
• They are used to check if two values (or variables) are
located on the same part of the memory.
• If the two values are identical: True
62. Precedence of operators
• When an expression contains more than one operator, the order of
evaluation depends on the order of operations.
• PEMDAS (Parentheses, Exponentiation, Multiplication, Division, Addition,
Subtraction)
64. Input function
• Input is data entered by user (end user) in the program.
• input () function
x=input("enter the name:")
enter the name:hhh
y=int(input("enter the number"))
enter the number 3
65. Output function
• Output can be displayed to the user using Print statement
print (expression/constant/variable)
print("Hello")
Hello
print(2+4)
6
print(6)
6
66. Type Casting(Type Conversion)
• Is the process of converting the value of one data type to another
Python Implicit Type Conversion
Python Explicit Type Conversion
67. Implicit Type Conversion
• In this, method, Python converts the data type into
another data type automatically. Users don’t have to
involve in this process.
a=10
b=12.0
c=a+b
print(c)
22.0
68. Explicit Type Conversion
• This involves converting a data type explicitly using predefined
functions like int(), float(), str(), etc., where the programmer
specifically directs the type of conversion required.
a=10
print(type(a))
<class 'int'>
print(float(a))
10.0
b=12.24
print(type(b))
<class 'float'>
print(int(b))
12
c=15.78
print(int(c))
15
69. • Convert string to int: (Value Error)
• Converting string to int datatype in Python with int() function. If the given
string is not number, then it will throw an error.
a="Hema"
print(int(a))
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
print(int(a))
ValueError: invalid literal for int() with base
10: 'Hema'
a="5"
print(int(a))
5
70. Formatting numbers and strings
price = 49
txt ="The price is {price} dollars"
print(txt)
Output:
The price is {price} dollars
price = 49
txt =f"The price is {price} dollars"
print(txt)
Output:
The price is 49 dollars
71. • Celsius to Fahrenheit:
F = [(C*9/5) +32]
• convert kilometers to miles
Miles=0.62*km