Introduction To Python Variables Datatypes InputOutput
Introduction To Python Variables Datatypes InputOutput
Introduction to
Python-IDLE-
Variables-Datatypes
WEEK 01
CONTENTS
01 02 03
Introduction to Python Python IDLE Input and Output
statements
04 05 06
Datatypes Variables Formatting Output and
Comments
Evolution of Python
Extensive Standard
Features Portable
Libraries
(Interactive Interpreter)
Python IDLE
• The print() function in Python is used to print a specified message on the screen.
• The message can be a string, or any other object, the object will be converted into a
string before written to the screen.
• Syntax:
print(object(s), sep=separator, end=end, file=file, flush=flush)
• Example code:
print(“Python”)
Examples
Output Statement
Example code:
number1=input(“Enter a number:”)
number1=int(number1)
number2=input(“Enter another number:”)
number2=int(number2)
print(“Result:”,number1+number2) Output:
Enter a number :5
Enter another number:6
Result:11
Fundamental Components
Operators Identifiers
Variables Datatypes
Identifiers
• Identifiers are names given to anything in the program that needs to be
identified.
• Helps to identify any item from any place of the program.
• Identifiers are case sensitive.
• They can start with an _ or an alphabet.
• They can have digits but cannot start with a digit.
• Identifiers cannot be keywords.
Example : Bill_id
_billid1
Variables
• Variables are Identifiers for input and output data in a program.
• Used to Identify the memory location of the data stored.
• Its value can be changed during the execution of the program.
• No declaration is needed for variables in python
Variables
Identify the
variable
Data held by
the variable
Datatypes
Basic Datatypes
Datatypes-Built-in functions
Example code:
#variable declaration
name=“Ajay”
age = 18 Output:
'''printing the output Name: Ajay
using the values stored in the variables''' Age: 18
A. Key
C
B. Brackets
C. Indentation
D. None of these
Workouts
1. A cashier has currency notes of denominations 10, 50 and 100. If the amount to be
withdrawn is input through the keyboard in tens, find the total number of currency
notes of each denomination the cashier will have to give to the withdrawer.
2. If the marks obtained by a student in five different subjects are input through the
keyboard, find out the aggregate marks and percentage marks obtained by the
student. Assume that the maximum marks that can be obtained by a student in
each subject is 100.
Department of Computer Science and
36
Engineering