Skip to content

rishikeshs soln2 for 2_arrays_exercise.md #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions data_structures/2_Arrays/2_arrays_exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,

Expand All @@ -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)