The document outlines rules for variable declarations in programming languages such as Java and JavaScript, highlighting naming conventions and initialization options. It also presents a lab exercise that features basic Python programs demonstrating variable usage, including displaying names, family members, and arithmetic tables. The summary includes examples of code and expected outputs for each program.
These slides outline the rules for variable declaration in programming. Topics include naming conventions, case sensitivity, and restrictions on characters.
The slides introduce basic Python programming through simple examples. They illustrate printing names and family members as well as a multiplication table.
Slides continue showcasing Python print statements with outputs for multiplication and personal favorites. It emphasizes outputting formatted strings.
The presentation concludes with a thank you message.
RULES FOR VARIABLEDECLARATION
O Variable name only start with a letter, an underscore ( _ ), of a dollar sign
( $ ).
O The variable name should start with only letters
O White spaces are not allowed between characters of variable but
undersores are approved.
O The variable name is case sensitive –TEMP and temp is different
variable.
O No two variables of same name are allowed to be declared in the same
scope.
O Every variable used must be declared.
O Javascript allows declaration statements anywhere in the list of
statements.
O Variable declarations announce what variables will be used in the
program.
O A variable must be declared before it can be used.
O Declaration statements can also be used to store an initial value into
declared variables.
O Variable name cannot start with a number.
3.
RULES FOR VARIABLEDECLARATION
O In java a variable name cannot start with a didit or hyphen.
O Al variable can be “31” character long for many compiler.
O Key word are not used as variable name.
O Blank spaces special symbols commas are not used.
O The first letter of the variable must be character of
underscore.
O The java languafe is case sensitive which implies that the
variable num in lowercase is different from variable num in
upper case.
O Declaring an initial value of variable in the declaration
statement is optional.
O Variable may be declared in a list.
O Both lower case and higher case digits are distinct.
4.
Purpose of lab1
O It was a general lab. In lab 1 we have studied about
of python and learned about how to join google class.
O Program 1:
O This program will display my name.
O Code: Print (“Shaher Bano”)
O Output:
O Mr. Usman
O Program 2:
O This program will display members of my family.
O Code: Print (“there are four members in my family.”)
O Output:
O there are four members in my family.
5.
Program 3:
O Thisprogram will display the table of two.
Code:
O Print (“2x1=2”)
O Print (“2x2=4”)
O Print (“2x3=6”)
O Print (“2x4=8”)
O Print (“2x5=10”)
O Print (“2x6=12”)
O Print (“2x7=14”)
O Print (“2x8=16”)
O Print (“2x9=18”)
O Print (“2x10=20”)
O Program 4:
OThis program will display my favorite book.
O Code: Print (“Mathematics”)
O Output:
O Mathematics
O Program 5:
O This program will display the addition of three
digits.
O Code: Print (“2+2+3”)
O Output:
O 2+2+3