diff --git a/data_structures/2_Arrays/2_arrays_exercise.md b/data_structures/2_Arrays/2_arrays_exercise.md index 81d65f4..909168f 100644 --- a/data_structures/2_Arrays/2_arrays_exercise.md +++ b/data_structures/2_Arrays/2_arrays_exercise.md @@ -8,6 +8,25 @@ 5. May - 2190 Create a list to store these monthly expenses and using that find out, +#solution +expenses=[2200,2350,2600,2130,2190] +print("in feb,how many dollars spent extra compared to jan",expenses[1]-expenses[0]) +print("total expenses in first quarter of year",expenses[0]+expenses[1]+expenses[2]) +print("did i spend exactly 2000 in any month?") +for i in expenses: + if i==2000: + return true + break + else: + return false +expenses.append(1980) +expenses[3]=expenses[3]-200 +print("got refund in april",expenses[3]) + + + + + 1. In Feb, how many dollars you spent extra compare to January? 2. Find out your total expense in first quarter (first three months) of the year. @@ -23,6 +42,12 @@ Create a list to store these monthly expenses and using that find out, ``` heros=['spider man','thor','hulk','iron man','captain america'] ``` +print(len(heros)) +heros.append('black panther') +heros.pop(6) +heros.insert(3,'black panther') +heros[1:3]='doctor strange' +heros.sort() Using this find out, @@ -41,5 +66,15 @@ Using this find out, 3. Create a list of all odd numbers between 1 and a max number. Max number is something you need to take from a user using input() function +int max_num=print("enter your max odd num ",int(input()) +oddnos=[] + for i in range(1,max_num) + if(i%2==0) + oddnos.append(i) + + + + + [Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/2_Arrays/Solution/3_odd_even_numbers.py) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy