11 Replies - 323 Views - Last Post: 27 October 2017 - 09:10 PM Rate Topic: -----

#1 desolatewonders  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-October 17

Help with a List Program

Posted 27 October 2017 - 02:48 AM

need help with this code in python 2.7 as show below. I am a new programmer so all of this is fairly new and frustrating to me.
Your task in this programming assignment is to write a Python program that generates a list of integers, such that both its length and the integers added to the list are provided by the user. Subsequently, display the list, followed by information about the list. Here's output of a sample run (user input is shown in bold red):
How many integers would you like to add to the list? 7
Enter an integer: 54
Enter an integer: 91
Enter an integer: 23
Enter an integer: 8
Enter an integer: -66
Enter an integer: 39
Enter an integer: 2
The original list: [54, 91, 23, 8, -66, 39, 2]
The length of the list is 7.
The minimum value in the list is -66.
The maximum value in the list is 91.
The sorted list: [-66, 2, 8, 23, 39, 54, 91]
The reverse sorted list: [91, 54, 39, 23, 8, 2, -66]
To help clarify, here are some specifics and/or constraints: (1) Generating the list (including its length) must be done in a function that is called from the main part of the program (see the template for more details); (2) You must use the list functions discussed in class to add integers to the list and to display information about the list (i.e., its length, the minimum and maximum values in the list, sorting the list, and reverse sorting the list); (3) You must use the provided source code template; and (4) You must submit your source code as a single .py file.
This was an example. If you could help a new programmer out, that'd be awesome!! Also, I am not asking anyone to do the whole problem for me but for them to help define functions and what i can and cant use. Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Help with a List Program

#2 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,763
  • Joined: 12-December 12

Re: Help with a List Program

Posted 27 October 2017 - 03:22 AM

What have you thought about or considered?

(Presumably you've attended some classes so the assignment isn't a complete mystery to you?)
Was This Post Helpful? 0
  • +
  • -

#3 desolatewonders  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-October 17

Re: Help with a List Program

Posted 27 October 2017 - 03:26 AM

View Postandrewsw, on 27 October 2017 - 03:22 AM, said:

What have you thought about or considered?

(Presumably you've attended some classes so the assignment isn't a complete mystery to you?)


i know i have to add while functions and append the list with the integer put in, its just im not quite sure how to do it
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,763
  • Joined: 12-December 12

Re: Help with a List Program

Posted 27 October 2017 - 03:51 AM

So, you've attended some classes?

If you are completely lost then you should speak to your tutor. Otherwise, we need to see some demonstration of initial effort from yourself. We won't guide you without some effort shown.
Was This Post Helpful? 0
  • +
  • -

#5 desolatewonders  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-October 17

Re: Help with a List Program

Posted 27 October 2017 - 03:59 AM

View Postandrewsw, on 27 October 2017 - 03:51 AM, said:

So, you've attended some classes?

If you are completely lost then you should speak to your tutor. Otherwise, we need to see some demonstration of initial effort from yourself. We won't guide you without some effort shown.


ive seen multiple tutors but they arent very helpful. Ive plugged in muliple things and just get errors

View Postdesolatewonders, on 27 October 2017 - 03:58 AM, said:

View Postandrewsw, on 27 October 2017 - 03:51 AM, said:

So, you've attended some classes?

If you are completely lost then you should speak to your tutor. Otherwise, we need to see some demonstration of initial effort from yourself. We won't guide you without some effort shown.


ive seen multiple tutors but they arent very helpful. Ive plugged in muliple things and just get errors


again im not sure if this is right or not, or if im in the ballpark

my_list = []

for i in range(5):
my_list.append(int(input()))

print(my_list)
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,763
  • Joined: 12-December 12

Re: Help with a List Program

Posted 27 October 2017 - 04:13 AM

You are trying to do everything at once. Break it down into steps.

Quote

write a Python program that generates a list of integers, such that both its length and the integers added to the list are provided by the user.
... Here's output of a sample run (user input is shown in bold red):
How many integers would you like to add to the list? 7


You will ask the user "how many integers...". How can you ask this question and store their response? When they type "7", for example, how will you store this?
Was This Post Helpful? 0
  • +
  • -

#7 DK3250  Icon User is offline

  • Pythonian
  • member icon

Reputation: 318
  • View blog
  • Posts: 1,048
  • Joined: 27-December 13

Re: Help with a List Program

Posted 27 October 2017 - 04:13 AM

Remember to place code between code tags (found right above the input window).
my_list = []

for i in range(5):
    my_list.append(int(input()))

print(my_list) 

This is your code, - does it work?
If yes, you are now in progress; what is the question here?
Was This Post Helpful? 0
  • +
  • -

#8 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,763
  • Joined: 12-December 12

Re: Help with a List Program

Posted 27 October 2017 - 04:13 AM

It is also important on this forum with Python code that you wrap it in code tags. Look in the box where you type a post, it shows there how to do this.
Was This Post Helpful? 0
  • +
  • -

#9 desolatewonders  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-October 17

Re: Help with a List Program

Posted 27 October 2017 - 04:22 AM

i think i have it down, but i need help with adding the input questions such as "enter an integer"
Was This Post Helpful? 0
  • +
  • -

#10 desolatewonders  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-October 17

Re: Help with a List Program

Posted 27 October 2017 - 04:29 AM

View Postandrewsw, on 27 October 2017 - 04:13 AM, said:

It is also important on this forum with Python code that you wrap it in code tags. Look in the box where you type a post, it shows there how to do this.


or entering a specific ammount
Was This Post Helpful? 0
  • +
  • -

#11 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,763
  • Joined: 12-December 12

Re: Help with a List Program

Posted 27 October 2017 - 04:50 AM

You could have a look at the docs for input(), but presumably you examined this function in class and have some reading/reference material?

How many classes did you attend?
What did they cover in the classes?
What course materials do you have?
Was This Post Helpful? 1
  • +
  • -

#12 albert003  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 367
  • Joined: 15-December 14

Re: Help with a List Program

Posted 27 October 2017 - 09:10 PM

We're not here to do your homework. If the class gave you homework, then the homework they assigned you would be on topics you covered in class like andrewsw said.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1