|
| 1 | +# print("I love to play football") |
| 2 | +# print("I can play it anytime") 1 |
| 3 | +# first_name = "bro" |
| 4 | +# second_name = "code" |
| 5 | +# full_name = first_name + " " + second_name |
| 6 | +# print("hello "+full_name) #2 |
| 7 | +# print(type(name)) |
| 8 | +# age = 21 |
| 9 | +# age += 1 |
| 10 | +# print("your age is : "+str(age)) |
| 11 | +# print(age) |
| 12 | +# print(type(age)) |
| 13 | +# height = 150.5 |
| 14 | +# print("your height is : "+str(height)) |
| 15 | +# print(type(height)) |
| 16 | +# human = True |
| 17 | +# print(type(human)) |
| 18 | +# print("are you a human : "+str(human)) #time:17:01 |
| 19 | + |
| 20 | +# MULTIPLE ASSIGNMENT BY BRO CODE (18:04) |
| 21 | +# name , age , attractive = "rudraksh" , 20 , True |
| 22 | +# print(name) |
| 23 | +# print(age) |
| 24 | +# print(attractive) # if all elements have similar value then below: |
| 25 | +# gopu = muniya = raghav = chotu = 20 |
| 26 | +# print(gopu) |
| 27 | +# print(raghav) |
| 28 | +# print(muniya) |
| 29 | +# print(chotu) |
| 30 | +# name = "rudraksh bohra" #len function also counts spaces so instead of 13 it's going to print 14 |
| 31 | +# print(len(name)) |
| 32 | +# print(name.find("r")) # find function only gives the index of first element to be found for eg i there are 3 r then it will give the index of first r to be found |
| 33 | +# print(name.capitalize()) # it will not capitalize the word after space |
| 34 | +# print(name.upper()) # will convert into upper case similarly we can use .lower |
| 35 | +# print(name.isdigit()) #return true if our string is numeric value else false |
| 36 | +# print(name.isalpha()) # if there is alphabets in string then true but if there is space between two alphabets then it will return false |
| 37 | +# print(name.count("r")) #prints the count of characters within our string |
| 38 | +# print(name.replace("r","m")) # if we want to replace certain character with other character |
| 39 | +# print(name*3) #if we want to print name multiple times |
| 40 | + |
| 41 | +#TYPECASTING IN PYTHON 25:22 |
| 42 | +# x = 1 #int |
| 43 | +# y = 2.0 #float |
| 44 | +# z = "3" #str |
| 45 | +# y = int(y) #this is permanent tye cast in which if we print y we will get it value 2 |
| 46 | +# print(x) |
| 47 | +# print(int(y)) # this is not permanent typecast |
| 48 | +# print(z) |
| 49 | +# print("x is "+z) |
| 50 | +# print("x is "+x) #it will print error so we have to typecast int and float value in string value in this situation |
| 51 | + |
| 52 | +#HOW WE CAN ACCEPT SOME USER INPUT IN PYTHON(31:00) |
| 53 | +# name = input("what is your name?: ") |
| 54 | +# age = int(input("how old are you?: ")) |
| 55 | +# height = float(input("how tall are you?: ")) |
| 56 | +# age = age + 1 |
| 57 | +# print("Hello "+name) |
| 58 | +# print("you are "+str(age)+" year old") |
| 59 | +# print("you are "+str(height)+"cm tall") |
| 60 | + |
| 61 | +#USEFUL FUNCTIONS RELATED TO NUMBERS IN PYTHON(37:09) |
| 62 | +# import math |
| 63 | +# pi = 3.14 # "import math" to access these functions |
| 64 | +# print(round(pi)) |
| 65 | +# print(math.ceil(pi)) # use to rounded up for the particular value |
| 66 | +# print(math.floor(pi)) #rounded down for the particular value |
| 67 | +# print(abs(pi)) #give the absolute value i.e. how much the value is far from zero |
| 68 | +# print(pow(pi, 2)) #print the power of any certain value |
| 69 | +# print(math.sqrt(pi)) # to find the square root of any value |
| 70 | +# x = 1 |
| 71 | +# y = 2 |
| 72 | +# z = 3 |
| 73 | +# print(max(x,y,z)) # print the maximum of these values |
| 74 | +# print(min(x,y,z)) # min for lowest |
| 75 | + |
| 76 | +#STRING SLICING IN PYTHON(41:05) slicing creates a substring by extracting elements from another string |
| 77 | +# two ways by indexing[] or by slice() function [start:stop:step] |
| 78 | +# name = "rudraksh bohra" |
| 79 | +# first_name = name[0:8] #can also be done by name[:8] , empty space will take default start value |
| 80 | +# print(first_name) |
| 81 | +# second_name = name[9:14] # can also be done by name[9:] , default stop value |
| 82 | +# print(second_name) |
| 83 | +# funky_name = name[13:-15:-1] # we can also do it by name[::-1] or name[13::-1] |
| 84 | +# print(funky_name) |
| 85 | +# print(name[::2]) |
| 86 | +#STRING SLICING USING SLICE FUNCTION |
| 87 | +# website1 = "http://google.com" |
| 88 | +# website2 = "http://linkedIn.com" |
| 89 | + |
| 90 | +# slice = slice(7,-4) |
| 91 | + |
| 92 | +# print(website1[slice]) |
| 93 | +# print(website2[slice]) |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
0 commit comments