Write a program that prints a list with separated by a comma

Assignment Help Programming Languages
Reference no: EM131878823

Comma Code -

Say you have a list value like this:

listToPrint = ['apples', 'bananas', 'tofu', 'cats']

Write a program that prints a list with all the items separated by a comma and a space, with and inserted before the last item. For example, the above list would print 'apples, bananas, tofu, and cats'. But your program should be able to work with any list not just the one shown above. Because of this, you will need to use a loop in case the list to print is shorter or longer than the above list.

You can use the following code to start your program. It will let the user type a list

listToPrint = []

while True:

newWord = input("Enter a word to add to the list (press return to stop adding words) > ")

if newWord == "":

break

else:

listToPrint.append(newWord)

Backpack of stuff -

Complete the following code. Fill in the two sections of code identified in the comments.

import sys

itemsInBackpack = ["book", "computer", "keys", "travel mug"]

while True:

print("Would you like to:")

print("1. Add an item to the backpack?")

print("2. Check if an item is in the backpack?")

print("3. Quit")

userChoice = input()

if(userChoice == "1"):

print("What item do you want to add to the backpack?")

itemToAdd = input()

####### YOUR CODE HERE ######

#add the item to the backpack

####### YOUR CODE HERE ######

if(userChoice == "2"):

print("What item do you want to check to see if it is in the backpack?")

itemToCheck = input()

####### YOUR CODE HERE ######

#Print out if the user's item is in the backpack

####### YOUR CODE HERE ######

if(userChoice == "3"):

sys.exit()

Character Picture Grid -

Say you have a list of lists where each value in the inner lists is a one-character string, like this:

grid =

[['.', '.', '.', '.', '.', '.'],

['.', 'O', 'O', '.', '.', '.'],

['O', 'O', 'O', 'O', '.', '.'],

['O', 'O', 'O', 'O', 'O', '.'],

['.', 'O', 'O', 'O', 'O', 'O'],

['O', 'O', 'O', 'O', 'O', '.'],

['O', 'O', 'O', 'O', '.', '.'],

['.', 'O', 'O', '.', '.', '.'],

['.', '.', '.', '.', '.', '.']]

You can think of grid[x][y] as being the character at the x- and y-coordinates of a "picture" drawn with text characters. The (0, 0) origin will be in the upper-left corner, the x-coordinates increase going right, and the y-coordinates increase going down.

Copy the previous grid value, and write code that uses it to print the image.

..OO.OO..

.OOOOOOO.

.OOOOOOO.

..OOOOO..

...OOO...

....O....

Attachment:- Assignment File.rar

Reference no: EM131878823

Questions Cloud

Prepare a project spend plan or budget with cumulative cost : Using the example in the ISA Project documents and using the example of building a project spend plan or budget with cumulative cost curve.
Design a database : Part 1: Using Microsoft Sql Server Express or Microsoft Access, design a database with one table to store the following information:
Operating leverage at financial break-even level of output : What is the degree of operating leverage at the financial break-even level of output?
Depreciation is straight-line to zero over life of project : Assume that depreciation is straight-line to zero over the life of the project. What are the best-case NPV and the worst-case NPV respectively?
Write a program that prints a list with separated by a comma : Write a program that prints a list with all the items separated by a comma and a space, with and inserted before the last item
What is the average accounting return for the given machine : Gallatin inc is considering an investment of 380,000 in an asset with an economic life of five years. What is the average accounting return for this machine?
Determine funds received and use the text to column feature : In this project, you will be assigned the task to record money received for a school fundraiser and create an Excel spreadsheet to record your receipts.
Discuss the factors related to leadership of the lab : What are the factors which make the Langer lab very successful in technology commercialization?
Identify and research not-for-profit organization : Identify and research one (1) not-for-profit organization and provide the Web link to the most recent financial report of the organization.

Reviews

len1878823

2/26/2018 12:31:51 AM

This criterion is linked to a Learning Outcome Comma Code. 50.0 pts - Program works and code is well organized. 38.0 pts - Code runs but may not work correctly for some inputs. Code may not be well organized. 33.0 pts - Code doesn't run. Code shows some understanding of the programming concepts but needs significant changes to work on all inputs. 28.0 pts - Code doesn't run. Code doesn't display an understanding of programming concepts.

len1878823

2/26/2018 12:31:45 AM

Hint: You will need to use a loop in a loop in order to print grid[0][0], then grid[1][0], then grid[2][0], and so on, up to grid[8][0]. This will finish the first row, so then print a newline. Then your program should print grid[0][1], then grid[1][1], then grid[2][1], and so on. The last thing your program will print is grid[8][5]. Also, remember to pass the end keyword argument to print() if you don’t want a newline printed automatically after each print() call.

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd