For those who are confuse with the last example,refer to last post
It mean that you are are a newbie,jus like me!Hence,we are going to start from the very basic.Do copy and paste the code in the box to run!
First,we are going to start with string by printing the string "Mr morton"
String
#remember the hex sign is equal to comment?
#To print a string you need to enclose it in a bracket , " "
# print are all in small letter ,if PRINT or Print it will give an error
print("Mr. Morton")
Output
Integer
Next, we are going to print and add up the integer
Next, we are going to print and add up the integer
#the " " make it become a string,hence it print out 53 + 28
print("53 + 28")
#notice,there is no " " for integer,hence it print out the sum of the two integer
print(53 + 28)
Variable
Next,we are going to print a variable.We are going to first assign a variable and print it out
#assign "Mr. Morton" to teacher
Teacher = "Mr. Morton"
#print the variable
print(Teacher)
#we can also assign integer to variable
#The number 5 is assigned to First, and
#the number 3 was assigned to Second. Then we printed the sum of the two.
First = 5
Second = 3
print(First + Second)
# you can also assign multiple variable
MyTeacher = "Mrs. Goodyear"
YourTeacher = MyTeacher
print(MyTeacher)
print(YourTeacher)
Quotes
#Python are also not too fussy on whether you use single quotes or double quote
#printing double quote examples
print("Mr. Morton")
#printing single quotes examples
print('Mr. Morton')
##assigning variable in double quotes
teacher = "Mr. Morton"
print(teacher)
#assigning variable in single quotes
teacher = 'Mr. Morton'
print(teacher)






No comments:
Post a Comment