M1 - Python For Machine Learning - Maria S
M1 - Python For Machine Learning - Maria S
Category : Minor
Offered by : Dept. of Computer Science and Engg.
Faculty in charge : Jaseela Beevi S
Basic coding skills - Working with data types, Numeric data types and Character sets, Keywords,
Variables and Assignment statement, Operators, Expressions, Working with numeric data, Type
conversions, Comments in the program. Input, Processing, and Output. Formatting output. How
Python works. Detecting and correcting syntax errors. Using built in functions and modules in
math module.
üPython is Interactive − You can actually sit at a Python prompt and interact with
the interpreter directly to write your programs.
• It provides very high-level dynamic data types and supports dynamic type
checking.
• It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
Quit Command
Leaving help and returning to the python interpreter
Dept. of CSE, TKMCE 7
Input, Processing, and Output
• In terminal-based interactive programs, the input source is the keyboard,
and the output destination is the terminal display.
Inputs : Python expressions or statements.
outputs : Results displayed in the shell.
output functions
üprint(<expression>) - Python first evaluates the expression and
then displays its value.
>>> print('Hi there')
Hi there
3) This byte code is next sent to another software component, called the
Python virtual machine (PVM), where it is executed. If another error
occurs during this step, execution also halts with an error message.
Request:
The customer requests a program that computes a person’s income tax.
Analysis:
Analysis often requires the programmer to learn some things about the problem
domain, in this case, the relevant tax law.
Testing:
Only thorough testing can build confidence that a program is working correctly.
Testing is a deliberate process that requires some planning and discipline on the
programmer’s part.
A correct program produces the expected output for any legitimate input.
Testing all of the possible combinations of inputs would be impractical. The
challenge is to find a smaller set of inputs, called a test suite, from which we can
conclude that the program will likely be correct for all inputs.
Programmers use all uppercase letters for the names of variables that contain values that the
program never changes. Such variables are known as symbolic constants.
assignment statement
<variable name> = <expression>
The Python interpreter first evaluates the expression on the right side of the assignment
symbol and then binds the variable name on the left side to this value. When this happens to
the variable name for the first time, it is called defining or initializing the variable.
Dept. of CSE, TKMCE 26
year = 2020
name = 'Ammu'
2020
memory Year
Ammu
Name
1. Let the variable x be "dog" and the variable y be "cat". Write the values returned
by the following operations:
a. x + y
b. "the " + x + " chases the " + y
c. x * 4
• Python’s ord() and chr() functions convert characters to their numeric ASCII
codes and back again, respectively.
>>> ord('a')
97
>>> ord('A')
65
>>> chr(65)
'A'
>>> chr(66)
'B'
3. Write the values of the following floating-point numbers in Python’s scientific notation:
a. 355.76
b. 0.007832
c. 4.3212
• End-of-line comments - These comments begin with the # symbol and extend to
the end of a line. An end-of-line comment might explain the purpose of a variable or
the strategy used by a piece of code.