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

Lecture 1 Notes (1)

Uploaded by

Shehroz Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lecture 1 Notes (1)

Uploaded by

Shehroz Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

# >>> output some thing # >>> double and single quotes difference

print("Hello, World!")
x = "John"

# is the same as
# >>> no brackets
x = 'John'
if 5 > 2:
print("Five is greater than two!")

# >>> Variable names are case-sensitive.


# >>> my first program a=4
a = 10 A = "Sally"
print(a) #A will not overwrite a

# >>> multi line comments # >>> Variable name rules


#This is a comment # A variable name must start with a letter or the
underscore character
#written in
# A variable name cannot start with a number
#more than just one line
# A variable name can only contain alpha-numeric
print("Hello, World!")
characters and underscores (A-z, 0-9, and _)

# Variable names are case-sensitive (age, Age and AGE


# >>> Paragraph comments are three different variables)

""" myvar = "John"

This is a comment my_var = "John"

written in _my_var = "John"

more than just one line myVar = "John"

""" MYVAR = "John"

print("Hello, World!") myvar2 = "John"

# >>> Changing types of a value #Camel Case Variables

x = str(3) # x will be '3' myVariableName = "John"


y = int(3) # y will be 3
#Pascal Case Variables
z = float(3) # z will be 3.0
MyVariableName = "John"

#Snake Case Variables


# >>> Check type of a variable
my_variable_name = "John"
x=5

y = "John"

print(type(x))

print(type(y))
# >>> Assigning multiple values # >>> Global Variables

x, y, z = "Orange", "Banana", "Cherry" x = "awesome"

print(x) def myfunc():

print(y) x = "fantastic"

print(z) print("Python is " + x)

myfunc()

x = y = z = "Orange" print("Python is " + x)

print(x) # concept

print(y) x = "awesome"

print(z) def myfunc():

global x

# >>> Unpack a list x = "fantastic"

fruits = ["apple", "banana", "cherry"] myfunc()

x, y, z = fruits print("Python is " + x)

print(x)

print(y)

print(z)

# >>> Output variables

x = "Python is awesome"

print(x)

x = "Python"

y = "is"

z = "awesome"

print(x, y, z)

x = "Python "

y = "is "

z = "awesome"

print(x + y + z)

You might also like