Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
assignment help
#1
HELLO THERE !
I need help with an "assignment ". Don´t worry it Angel has nothing to do with homeworks , certeficates , etc .
I am doing it on a free website , that "tutors" python for free .
task 1 : Write a function called check_nums that takes a list as its parameter, and contains a while loop that only stops once the element of the list is the number 7. What is returned is a list of all of the numbers up until it reaches 7.

task 2 : Write a function, sublist, that takes in a list of strings as the parameter. In the function, use a while loop to return a sublist of the input list. The sublist should contain the same values of the original list up until it reaches the string “STOP” (it should not contain the string “STOP”).


task 3: Write a function called stop_at_z that iterates through a list of strings. Using a while loop, append each string to a new list until the string that appears is “z”. The function should return the new list.

task4 : Below is a for loop that works. Underneath the for loop, rewrite the problem so that it does the same thing, but using a while loop instead of a for loop. Assign the accumulated total in the while loop code to the variable sum2. Once complete, sum2 should equal sum1
Reply
#2
We are glad that you shared with us your not-a-homework-assignment verbatim. Now you need to show your code (in python tags), any errors - in error tags, and ask specific questions(s).
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Here are some examples I tried to make :

return [x for x in list if x > 5]
    return [x for x in mylist if x < 5]
def check_nums (data):
    import itertools

data_ = [0,2,4,2,3,6,8,12,14,7,9,10,8,3]

def check_nums(data):
    result = list(itertools.takewhile(lambda x: x != 9, data))
    return result

print (check_nums(data_))

Hello? Please somebody help !!!!!!!
Reply
#4
Here is task 1. I understood that 7 needs to be included in the list. The other tasks you can try by yourself.
Code removed
https://python-forum.io/misc.php?action=help&hid=52 Wrote:Do not post solutions to threads in the homework section or possible homework-related threads elsewhere in which the author does not provide effort.
...
Reply
#5
sammmy: you need to put in a lot more effort here. For a specific question, you need to provide your code, an English description of what it does relative to what you want it to do, the full error message if there is one, etc. The first block of code you posted makes absolutely no sense. In the second block you're doing really weird stuff, so it would actually probably be a good idea for you to comment each line saying what you think it does.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020