SOME PHYTHON PRACTICE SCARTCH
def main():
pass
if __name__ == '__main__':
if __name__ == '__main__':
main()
#while loop in lists
students=["a","b","c","d","e"]
for student in students:
if student == "c":
break;
print(student)
students=["a","b","c","d","e"]
for student in students:
if student == "b":
continue;
print(student)
#tupple is a operation where after executing you cant chaqnge it
marks = (50,53,55,55,55,55)
print(marks.count(55))
print(marks.index(55))
#note
#[]=lists
#()=tupple
#{}=set
#set
#[]=lists
#()=tupple
#{}=set
#set
marks = {50,53,55,55,55,55}
print(marks)
#dictionary
marks = {"eng" : 56, "odi" : 84}
print(marks["odi"])
marks["it"]=86
print(marks)
marks["eng"]=65
print(marks)
#function(operation performer)
#module function
#module function
import math
print(dir(math))
from math import sqrt
print(sqrt(25))
from math import *
print(sqrt(25))
#user defined funtions
#SYNTAX
#def function_name (parameters)
# //do something
#SYNTAX
#def function_name (parameters)
# //do something
def print_sum (first,second):
print(first+second)
print_sum(1,2)
def print_sum (first,second=5):
print(first+second)
print_sum(1)
Comments
Post a Comment