python

python

basics of python

for a video tutorial go here https://youtube.com/playlist?list=PLu0W_9lII9agICnT8t4iYVSZ3eykIAOME

print(“syntax of print “)
#                                           use # for single line comment
”’multi line comment
is this .”’
#                                           syntax to remove space from end .
#                                            what we right between end=”” will come in between ‘””‘this
print(“for join two print statment “, end=””)
print(“for this “)
#                                               also this work
print(“for join two print statment”, “for this”)
#                                            to declere a variable
name = ‘hello world’
name1 = 65
#                                            to print variable
print(name)
print(name1)
#                                           \n is a new line charecter
#                                            to print \ in code you have to write
print(” your name is \\narry “)
#                                                   to write ” in code
print(” c: \”narry\” “)
#                                                \t is a tab space between them
print(“hello \t\t\t world”)
#                                               type of varriable
var1 = “hello”
var2 = 34
var3 = 67.8555
var4 = “world”
#                                               to print the type of variabe
print(type(var1))
#                                               concetinate the string
print(var1 + var4)
#                                               type casting  means changing one variable type to another
var10 = “32”
var11 = “45”
print(int(var10) + int(var11))
#                                               to print str more than one time
print(“hello ” * 3)
#                                               to take input from user
inpuut = input()
#                                                  inpuut variable will always be a str
print(type(inpuut))
#                                                   string slicing
str1 = “kavya is a good boy”
#                                                   we can slice like
#                                               the forth word will print
print(str1[4])
#                                                this will print 1 to 9 words including space’9th word will be excluded’
print(str1[1:9])
#                                          if in slicing [1:] it will take full
#                                         [:5] 0 as by default
#                                          [0:5:] till 5  [0:5:2] will skip one
#                                           [-4:-5 ] will also work
#                                             if we write print(str1.endswith(“boy”)) it will print true
#                                             print(str1.count(“b”) )    it will count all the b in my str
#                                              str1.capitalise     will capital full string
#                                               str1.find(“is”)    will find is in str
# list syntax
# same  slysing
grossery = (“harpic”, “deo”, “bhindi”, “pop”)
nim = (5, 6, 3, 5, 2, 0)
print(nim[2])
nim.append(1, 9, 8)  # will add this to end
#  tuple canot be change
tp = (1, 5, 8)
# to resevers two var   a,b = b, a
# dictonary
d1 = {“kavya”: “burger”, “han”: “egg”}
# del funtion will delete what you whish
del (d1[“han”])
# sytax of set
a=set(1, 3, 5, 7)
# set does not append same values
# syntax of if else
# if condition :
#   code
# else :
#   code

for intermediate and advanced python go here diceroll

Leave a Comment

Your email address will not be published. Required fields are marked *