You are on page 1of 4

# for simply print the words as lines

# lettre = '''
# hello sir
# How are you today
# '''
# print(lettre)

# for choosing the range of characteres that you want to print


# weather = "19 degree on tangier \ 20 degree on tetouan"
# print(weather[5])
# print(weather[-1])
# print(weather[0:-1])

# formated strings
# name = "louis"
# lastname = "bostin"
# strage = f"{name} {lastname} is a student "
# print(strage)
# name = input('my name : ')
# lastname = input('my lastname : ')
# result =f'{name} {lastname} is a winner'
# print(result)

# len\upper\lower\(\n)\index
# sentence ="hello sir , can i help you"
# print(len(sentence)) # count the letters
# print(sentence.upper()) # Convert to big letters
# print(sentence.lower()) # Convert to small letters
# print(sentence.isupper()) # check if thesentences have big
# print(sentence.islower()) # check if thesentences have small
# print(sentence.upper().isupper()) # convert then check
# print(sentence. lower().islower()) # convert then check .
# print("zero\"one")
# print(sentence.index("sir")) # give you the place of this lettre on the
sentence
# print(sentence.replace("sir”, "ms"))
# print(sentence.find("sir")) # give you the place of this lettre on the sentence
# print("yahia hachmi \nmy age is 19\ni am done ") # \n let you back to new lien

# for convet int to float \ boolean


# value = 18.45
# value2 = int(value)
# is_value_int = True # to check if it int
# is_value2_float = False # to check if it float
# print(value2)
# print(is_value_int)
# print(is_value2_float)

# Numbers
# y = -8
# x = 2.5
# print(abs(y)) # back to positive number
# print(round(x)) # back to real number
# print (pow (3,2)) # like 3 ** 2 or 3^2
# print (min (5,6))
# print (max (8,1))

# If condition
# x =6
# y=3
# If x > 0:
# print ("x is positive")
# elif x < 0:
# print ("x is negative")
# elif x == 0:
# print ("x equal 0")
# else:
# print("Error")
# text = "you can do it"
# If text:
# print ("text is not empty")
# else:
# print ("text is empty")

# for loop
# devices = ["phone”, "airphone”, "laptop”, "TV"]
# for variable in devices:
# print(variable)
# my_list = []
# for count in range(1, 6):
# my_list.append(count)
# print(my_list)

# While loop
# While x < 15:
# print(x)
# x += 5
# result = "x greater than y" if x > y else "x is less or eqaul y"
# print(result)
# Functions
# def names(name,question,sentence):
# print("hello " + name + "!" )
# print("hello " + name + "!" + question + "," + sentence)
# def questions(question):
# print(question)
# names("yahia")
# names(" bilal " , " how are you ? " , " hope you are fine ")
# questions ("how are you ? ")
# def numbers(num1,num2):
# return num1+num2
# print(numbers (3,4))

# # list
# songs = ["pop”, "rap" , "rock" ,"jazz"]
# countries =["Morocco_1" , "U.S.E_2" ,"Canada_3" ,"Germany_4"]
# print(songs [0])
# songs.extend(countries) # to fuse 2 lists
# songs += countries # to double the list
# songs [1] = "metal" # to change an element from list
# songs.remove("rap")
# songs.sort() # for organized it by alpha
# print(songs)
# countries.append("Japan_5") # to add an element
# countries.insert(2,"Russia_6") # to add an element in specific position
# countries.clear() # to delete all the list
# countries.pop() #remove the last one
# print(countries)
# # print(countries.index("Morocco_1")) # search if its exist
# # print(songs.count("pop")) # count how much time this element get reapet
# classification = countries.copy() #to copy the list in another list
# print(classification)

# Tuples fix values cannot modify


# tuple = (“Hight”, "clap" , "round" )
# print(tuple)
# print (tuple [1])

# # # dictioner
# Songs = {"pop”: "katy perry",
# "rap”: "nicky minaj",
# 2024: [1,2,3,4]}
# print (Songs["pop"]) # to print the value of the key pop
# print (Songs.get("rape" , "no value for that key")) # check if it exist
# print(Songs.get(2024)) # if it exist it'll be printed

# # Set (only for unique things \ cannot have more than one same value)
# list =[2,3,4,2,5,3,5,6,7,2,3,4,5,6,8,9,5,2,5,8,0,9,8,7,5]
# unique_list = []
# for lists in list :
# if lists not in unique_list :
# unique_list.append(lists)
# print(unique_list) # to print unique numbers
# unique_set = set(list) # to print the element of the list organized
# print(unique_set)
# print(type(unique_set))
# print(dir(unique_set))

# numbers = [14,24,433,155,93]
# min_number = min(numbers)
# max_number = max(numbers)
# somme = sum(numbers)
# moyen = sum(numbers) / len(numbers)
# print(moyen)

You might also like