Lecture 2 - R & Python: Nirma University, MBA FT, July-Sep, 2020
Lecture 2 - R & Python: Nirma University, MBA FT, July-Sep, 2020
• Keywords
• Identifiers / Variables
• Operators
• Delimiters
• Literals
Literals
• 78
• 21.98
• ‘Q’
• “Hello”
• ‘Hello World’
• type(‘Hello World’)
• type(123)
Keywords
• and
• class
• Else
• If
• Elif
• Break
• Continue and more …
Operators
• + - * / // % ** - Arithmetic operators
• == != >= <= - Relational operators
• And not or – Logical operators
• & | - Bitwise operators
Delimiters
• () {} []
• ,:.‘=;
• Etc.
Identifiers / Variables
• Starts with _ or letter of lower case / upper case with any length
• Cannot start with digit or keyword
Core Data Types
• P = Q = R = 100
• P=Q+1
•P
input
• A=2
• B=3
• X = eval(‘A+B’)
• X
• Age = eval('print("Hello")')
• print(Age)
Formatting float
• Print(format(10.345, “10.2f”))
• Print(format(10, “10.2f”))
• Print(format(10.32245, “10.2f”))
abs
• abs(-2)
• abs(4)
ASCII values
• Ord(‘A’)
• Ord(‘Z’)
• Ord(‘a’)
• Chr(90)
• Chr(65)
• Chr(122)
Thank you – [email protected]