# WEEK FIVE(5) REPORT OF MY SOFTWARE ENGINEERING JOURNEY AT BLOCKFUSE LABS.. We have been doing a lot at blockfuse labs lately. we are getting deap into python, blockfuse labs has biuld me from grown zero to where am i today. the week was started with the revision of what we where though last week. >varaible which we said it is a memory location in the ram and the practical aspect of it was shown like this >-Defind the variable -> Name >-Assignment oprator -> = >-Value to saved in the variable -> "Value" >which will look like this: >Name = "Value" ``` #this are variable User_name = "solomon" User_age = 20 #this are are both variable ``` And we start for the new week with data type in python: Python provide several Build-in data types to store different kind of values. and we look at some of them as: ###### 1. Some data types - int (integars): whole number, positive or negetive number with out decimal place ``` #this is an example of int Age = 20 ``` - float (floating point numbers): Numbers with decimal point ``` #this is an example of float Amount = 17.99 ``` - complex (complex number): Numbers with a real and imerginary part ``` #this is an example of complex z = 3 + 4j ``` - str(strings):sequens of characters enclose with single or double qoute ``` #this is an example of strings Name = "solex" Surname = 'monday' ``` Anything inside a qoute is a string weather a numbers or words. we also look string formatting. it control the appearance and enhance reability the primary are: - f-string (formatted string literals):An f-string is create by prifixing the string with f or F and enclosing the expresion with curly braces{} ``` Name = solomon Age = 20 Message = f"my name is {Name} and i am {Age} year old" print(Message) #output: my name is solomon and i am 20 year old ``` - string.format method: it uses curly braces {} too as placeholder within the string, and the value to be inserted are pass as argument in the .format() method ``` quantity = 3 item = apple price = 49.00 order = "i want {} pice of {} for {:.2f} niara" print = (order.format(quantity,item,price)) #output: i want 3 pice of apple for 49.00 niara ``` We look at slicing and indexing: - slicing allow the extraction of a portion from a larg seqeunce by specifing the rage of the indicies. the syntex for slicing is -> sequence[start:stop:step] the start is the index where the slice beging. if omited the defualt is 0 then the stop is the index where the slice end. if omited the defualt is the end of the sequence and the step is the increment between element in the slice(optional).if omited,it's defualt to 1. practical example: ``` my_string = "Python" print(my_string[1:4]) # Output: "yth" (elements from index 1 up to, but not including, index 4) print(my_string[:3]) # Output: "Pyt" (elements from the beginning up to index 3) print(my_string[2:]) # Output: "thon" (elements from index 2 to the end) print(my_string[::2]) # Output: "Pto" (every second element) print(my_string[::-1]) # Output: "nohtyP" (reverses the string) ``` - Indexing refers to accessing a single element within a sequence using its position. Python uses zero-based indexing, meaning the first element is at index 0, the second at index 1, and so on. Negative indices can also be used to access elements from the end of the sequence, where -1 refers to the last element, -2 to the second to last, and so forth. practical example: ``` my_list = [10, 20, 30, 40, 50] print(my_list[0]) # Output: 10 (accesses the first element) print(my_list[3]) # Output: 40 (accesses the fourth element) print(my_list[-1]) # Output: 50 (accesses the last element) ``` We did a lot this week which we wrote a test on the friday which the questions where: ###### 1. prompt a user to enter his/her date of birth and when he/she enter then it should tell him his age. ``` DOB = print("enter your date of birth:\n>>>") AGE = int(2025) - int(DOB) print(AGE) ``` ###### 2. an account balance was given as 10000 and we are ask to prompt a user to enter the amount the want to spend and then thier balance should pop up ``` Account_balance = 10000 Amount_to_spend = input("How much do you want to spend:\n>>>") Current_balance = float(Account_balance) - float(Amount_to_spend) print(f.your current balance is {Current_balance:,.2f}) ``` ###### 3. A sentence "rpyoagrhmotn is cool" was given and we are to extract the word "python" from it using slicing ``` Word = "rpyoagrhmotn is cool" py = Word[1:3] t = Word[10:11] h = Word[7:8] o = Word[-2:-1] n = Word[11:12] Rewrite_word = py + t + h + o + n print(Rewrite_word) ``` # NEVER SETTLE :100: