0% found this document useful (0 votes)
8 views

Python II

Uploaded by

yoezerlhendup3
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Python II

Uploaded by

yoezerlhendup3
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Python

lesson -II
Lesson Outline:
• Recapitulation
• Use of input() function
• Demonstration to use input() function
• Python variable
• Assigning value to a variable
• Variable naming
• Rules for python variable naming
Python founder
THREE Code Editors other than IDLE
TWO IDLE windows
IDLE is an acronym for
Python file extension
function() which helps us to generate
the output
input() function:
 Is used to invoke the information from
the end user
 Example: Trying to invoke the end
user’s name
variable

function Answer to be stored

name=input(“What is your name?”)


print(name)

function to display When we run the program the output will be


the name that the end user has typed…
Demonstration
using input()
function
Learners’ Activity 01

Write a python
program to invoke
age of the end user
Learners’ Activity 01
Write a python program to ask about the favourite subject
then print the answer “My favourite subject is ………”

1.Declare the variable favourite_subject to store the


answer in it
2. Write the print command to print the answer
Variable in python:

•Variables are containers for storing


data values.
•Computers memory to store
value/information
Assigning value to variable:
•We use assignment operator (=)
•Example: value “Bhutan the land of thunder dragon”
to the variable country
=
•country “Bhutan the land of thunder dragon”
•country: variable name
•value assigned: Bhutan the land of thunder dragon
Variable Names

A variable can have a short name (like x and y) or


a more descriptive name
Eg. x="Ugyen Academy"
y="Ugyen Academy"
Myschool="Ugyen Academy"
My_School="Ugeyn Academy"
Variable naming rules:
 A variable name must start with a letter or the
underscore character
 A variable name cannot start with a number
 A variable name can only contain alpha-numeric
characters and underscores (A-z, 0-9, and _ )
 Variable names are case-sensitive (age, Age and
AGE are three different variables)
 No space(s) for the descriptive variable names
 No reserved(keywords) words as a variable
name
Identify the invalid variable name

123_subjects=“English”
_123=“Dzongkha”
My-fav-subject=“Mathematics”
Fav_subject=“ICT”
if_else=“conditional statement”
My school=“Ugyen Academy”
Learners’ Activity 02
Write a python program to ask
information from the end user and
accept the information. Let the
computer say other people's answers
in the following format:

eg. User enters Wangyal...output will


be generated as “Your name is
Wangyal”
Lesson wrap up questions:
1.What is the use of input function?
2.Define variable in python
3.What are the TWO types of variables?
4.Which operator do we use to assign value to a
variable?
5.What are the some of the rules to be kept in mind
while naming the variables?

You might also like