Uploaded by M.Bilawal Khan

Python notes

advertisement
python
. use of variables
eg:
name = "Mahnooor"
school = "LGS"
grade = "ten"
gender = "she"
print(" These \n are \n
print("There is a girl
"who studies in grade "
print("she studies in "
three \n siblings,")
named " + name + ","
+ grade + "," )
+ school+ ".")
. print(x.upper/lower()) inorder to upper case
or lower case all the letters
. print(len(x)) to check the number of
characters in x
. print(x[0-n]) to check which number
corresponds to the letters in x
. print(x.index("letter in string")) to check
which letter corresponds to the number in
"letter in string"
. print(x.replace("any letter or word in
string" , "any word we want to replace"))
. use of absolute valued fuctions
print(abs(x))
. print(pow(a,n)) to the power of
. max or min functions print(max/min(a,b))
. usage of input with the help of variables
. lists x = ["n" , "nx"]
. print(x) or print(x[0/1]) or print (x[1:n])
(<--- This will print the elements from one
till n)
. usage of functions
eg: def welcome_the_user(name , age):
print("Hey " + name + " Waddup")
print("How ya doin buddy?")
print("you are " +age+ " years old")
def tell_him_about_the_goat(goat ,
shirt_number):
print("The Greatest player in the history
of football is " + goat + " and his shirt
number is " + shirt_number)
print("The program has started here")
welcome_the_user("Bilawal" , "16")
tell_him_about_the_goat("CR7" , "7")
Download