# While loops assignment

Page 1 of 1

## 4 Replies - 1406 Views - Last Post: 03 October 2012 - 05:47 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=293304&amp;s=ed5dfeaf498be54fe1482e94b8192b3d&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 kehara15

• New D.I.C Head

Reputation: 0
• Posts: 42
• Joined: 13-September 12

# While loops assignment

Posted 26 September 2012 - 11:49 AM

This is the assignment I am given from my professor

Write a function SumofEvens. This function must have one input argument that is a list of integers.
1) Calculate the sum of even numbers in the input list using while loop
2) Return the sum of even numbers contained in the input list

So far I know that I start like this:

```def SumofEvens()
```

In the parenthesis it is saying that the function must have one input argument that is a list of integers. What is an input argument?

Is This A Good Question/Topic? 0

## Replies To: While loops assignment

### #2 jon.kiparsky

• Pancakes!

Reputation: 8636
• Posts: 14,906
• Joined: 19-March 11

## Re: While loops assignment

Posted 26 September 2012 - 11:57 AM

Read here. Grab some tutorials (slide your eyes to your right a little) Shake the google tree a little.

Sorry, but you're going to have to at least pretend to try a little.

### #3 atraub

• Pythoneer

Reputation: 821
• Posts: 2,198
• Joined: 23-December 08

## Re: While loops assignment

Posted 26 September 2012 - 10:07 PM

An input argument, or parameter, is the data required for your function to run. For example, if I wanted to write a function that would take someone's age and return their age in dog years, I might want to have their age as a parameter.

If you have any further questions, show us your progress with your code. We give much more help when the OP shows much more effort.

This post has been edited by atraub: 26 September 2012 - 10:07 PM

### #4 Failor

• New D.I.C Head

Reputation: 0
• Posts: 9
• Joined: 03-September 09

## Re: While loops assignment

Posted 27 September 2012 - 06:49 AM

the while loop works while some condition is true so it should look something like that:

```def sumEven(lst):
While <condition( n your case even numbers)>:
<the action to be performed>
return <the product of the action above>
```

Also you need a string that requests a user for the input (list of numbers in your case)
and then sends this string into the function.

### #5 Tayacan

• D.I.C Regular

Reputation: 145
• Posts: 275
• Joined: 18-January 11

## Re: While loops assignment

Posted 03 October 2012 - 05:47 AM

Failor, on 27 September 2012 - 01:49 PM, said:

Also you need a string that requests a user for the input (list of numbers in your case)
and then sends this string into the function.

From what OP says, he doesn't have to worry about user input. He just has to write the function.

kehara15, you're going to need to read up on functions. Here's a fairly good tutorial on the topic. I recommend typing in the code as you read through it.