Question

Write clear code with comments and follow coding convention. Comments should include your name, student number and subject coQuestion 3. How many random digits in each list? 11 Count List Compare List 2 1 2 2 Page 2 of 4 10 -Question 4_ The text exacQuestion 4 How many numbers in the list? 5 Enter list element: 10 Enter list element: 0 Enter list element: 200 Enter list elQuestion 5 List is currently empty: [ Enter index to insert element to list (enter Q to quit): 0 Enter a word to add to list:Enter index to insert element to list (enter Q to quit): 7 Index is too high Enter index to insert element to list (enter Q t

Objectives .Able to write clear code with comments and follow coding convention Able to use if-else statements Able to use lo

Write the code in python, if you cannot answer all the question please dont anser, thanx very much. Please gimme a screen shot for code.

Write clear code with comments and follow coding convention. Comments should include your name, student number and subject code on top of your code Question 1 Create a list to store all the subject codes that you are currently doing at UOW Then use for loop to display it in a table as in the following example The last column must display the subject codes in lower case The output must have the exact alignment, but the length of each column is up to your decision Question 1. Index Subject code Lower Case MATH111 math111 COMP 222 comp222 buss101 2 BUSS101 INFO201 info201 - Question 2 - Study the example below carefully and write a program that works exactly like the example. The text in bold indicates the user input. Your program must use loop statement Question 2. How many numbers to put into lists? 7 Here are the 2 lists: [100, 200, 300, 400, 500, 600, 700] [0, 2, 4, 6, 8, 10, 12] Question 3- Study the example below carefully and write a program that works exactly like the example. The text in bold indicates the user input. Your program must use loop statement The program has to generate 2 lists of random digits The output must have the exact alignment, but the length of each column is up to your decision.

Question 4 How many numbers in the list? 5 Enter list element: 10 Enter list element: 0 Enter list element: 200 Enter list element: 7 Enter list element:3 You have entered: List Index Reverse 10 1 200 2 200 10 Question 5--- Study the example below carefully and write a program that works exactly like the example. The text in bold indicates the user input. Your program must use a loop statement that runs forever until the user types Q to quit. If the user enters an index which is either too high or too low then your program must display the error message as in the example.
Question 5 List is currently empty: [ Enter index to insert element to list (enter Q to quit): 0 Enter a word to add to list: green The list is: ['green' Enter index to insert element to list (enter Q to quit): 1 Enter a word to add to list: eggs The list is: ['green','eggs' Enter index to insert element to list (enter Q to quit): 2 Enter a word to add to list: and The list is: ['green', 'eggs' and' Enter index to insert element to list (enter Q to quit): 3 Enter a word to add to list: ham The list is: ['green','eggs','and','ham Enter index to insert element to list (enter Q to quit):o Enter a word to add to list: i The list is: ['i', 'green', 'eggs'and 'ham' Enter index to insert element to list (enter Q to quit): 1 Enter a word to add to list: like list is: ['i', 'like', 'green', 'eggs', 'and', 'han'l The
Enter index to insert element to list (enter Q to quit): 7 Index is too high Enter index to insert element to list (enter Q to quit): 1 Enter a word to add to list: do The list is: ['','do', 'like', 'green', 'eggs', 'and','ham' Enter index to insert element to list (enter Q to quit) : -5 Index is too low Enter index to insert element to list (enter to quit):2 Enter a word to add to list: not The list is: ['i', 'do',not', 'like',green', 'eggs'and','ham' Enter index to insert element to list (enter Q to quit): Q Good bye!
Objectives .Able to write clear code with comments and follow coding convention Able to use if-else statements Able to use loop statements Able to use function » .Able to use string functionalities » Able to use list
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please go through comments,input and output and modify accordingly thank you images provided for coninience.

#Please include your details as comments as given in question
#please read comments for details .
#Thank You

sub=["math111","comp222","buss101","info201"] #List of subjects according to question please modify if required
print('{0: ^20}{1: <20}{2: <20}'.format('Index','Subject code','Lower Case')) #printed header
for code in sub:
print('{0: ^20}{1: <20}{2: >20}'.format(sub.index(code),code.upper(),code.lower())) #printed values accordingly

1 #PLease include your details as comments as given in question 2 #please read comments for details 3 #Thank You 4 sub-[math1

#Please include your details as comments as given in question
#please read comments for details .
#Thank You

num=input("How many numbers to put into lists? ") #input taken
num=int(num) #string into number conversion
l1=list() #lists created
l2=list()
for i in range(0,num): #inserting or appending values calculated accordingly
l1.append((i+1)*100)
l2.append(i*2)
print(l1) #printing lists
print(l2)

1 #PLease include your details as comments as given in question #please read comments for details . 3 #Thank You 4 5 nun- npu

#Please include your details as comments as given in question
#please read comments for details .
#Thank You
import random

num=input("How many random digits in each list? ") #input taken
num=int(num) #string into number conversion
l1=list() #lists created
l2=list()
print('{0: <15}{1: <15}{2: <15}{3: <15}'.format('Count','List 1','Compare','List 2'))
for i in range(0,num): #inserting or appending values calculated accordingly
l1.append(random.randint(0,10))
l2.append(random.randint(0,10)) #comparing values of list and printing accoudingly
if l1[i]<l2[i]:
print('{0: <15}{1: <15}{2: <15}{3: <15}'.format(i+1,l1[i],'<',l2[i]))
elif l1[i]==l2[i]:
print('{0: <15}{1: <15}{2: <15}{3: <15}'.format(i+1,l1[i],'=',l2[i]))
else:
print('{0: <15}{1: <15}{2: <15}{3: <15}'.format(i+1,l1[i],'>',l2[i]))

1 #P Lease Inc Lude your details as comments as given in question #please read comments for details 3 #Thank You 4 import ran

#Please include your details as comments as given in question
#please read comments for details .
#Thank You

num=input("How many numbers in lists? ") #input taken
num=int(num) #string into number conversion
l1=list() #list created
for i in range(0,num):#list append by user given number
l1.append(int(input("Enter list element: ")))
l2=list(reversed(l1)) #list reversed
print('{0: <15}{1: <15}{2: <15}'.format('Index','List','Reverse'))
for i in range(0,num):#list printed
print('{0: <15}{1: <15}{2: <15}'.format(i,l1[i],l2[i]))

1 #PLease include your details as comments as given in question #please read comments for details 3 #Thank You 4 5 nun-input(

#Please include your details as comments as given in question
#please read comments for details .
#Thank You

ls=list() #list created
print("List is currently empty: ",ls) #printing List
print()
while True: #loop that never ends
i=input("Enter index to insert element to list (enter Q to quit) : ")
if i is 'Q': #breaks only if entered value is Q
break
else: #index warnings
i=int(i)
if i < -1:
print("Index is too low")
print()
continue
elif i > len(ls):
print("Index is too high")
print()
continue
else: #word input taken and list printed
word=input("Enter a word to add to list: ")
ls.insert(i,word)
print("The list is: ",ls)
print()
print("Good bye!") #exited loop says good bye

1 #PLease include your details as comments as given in question #please read comments for details . 3 #Thank You 4 5 IS-11. (

List is currently empty: Enter index to insert element to list (enter Q to quit) Enter a word to add to list: green 0 The lis

Add a comment
Know the answer?
Add Answer to:
Write the code in python, if you cannot answer all the question please dont anser, thanx very much. Please gimme a scr...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the code in Python. The output should be exact the same as the given.

    Write the code in Python. The output should be exact the same as the given. Question 1. Study the examples below carefully and write a program for journal subscription Your program should work exactly as the following examples The text in bold indicates user input. Example 1: The user is a student, and the user subscribes to 2 journals Question 1 - Journal of Commodity Markets Journal of Sustainable Mining Journal of Asia-Pacific Biodiversity Student $21 $22 $27 Non-student $50...

  • Only use the code in Objectives and write the code in Python

    Only use the code in Objectives and write the code in Python Question 1. Study the examples below carefully and write a program for journal subscription Your program should work exactly as the following examples The text in bold indicates user input. Example 1: The user is a student, and the user subscribes to 2 journals Question 1 - Journal of Commodity Markets Journal of Sustainable Mining Journal of Asia-Pacific Biodiversity Student $21 $22 $27 Non-student $50 $60 $75 Are...

  • Code In Python Well Document Code Every Line Please * You cannot use any external Python...

    Code In Python Well Document Code Every Line Please * You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program should work...

  • Code In Python Well Document Code Every Line Please * You cannot use any external Python...

    Code In Python Well Document Code Every Line Please * You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program should work...

  • Code In Python Well Document Code Every Line Please 5 Stars * You cannot use any...

    Code In Python Well Document Code Every Line Please 5 Stars * You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program...

  • I need help please... Intro to Programming in C – small program 8 Project objective: To...

    I need help please... Intro to Programming in C – small program 8 Project objective: To compile, build, and execute an interactive program using character arrays and string.h functions **Submit source code (prog8.c) through Canvas • One source code file (unformatted text) will be submitted • The file name must match the assignment • The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas • The code must be submitted on time in...

  • Python please help! Thanks you Write a code to get an unlimited number of grades from...

    Python please help! Thanks you Write a code to get an unlimited number of grades from the user (the user can press enter to finish the grades input, or use a sentinel, for example-1), and then calculate the GPA of all the grades and displays the GPA To do this you might need some help. Try to follow the following process (and check your progress by printing different values to make sure they are as they supposed to be): 1-...

  • You are to write a program name Bank.java that maintains a list of records containing names...

    You are to write a program name Bank.java that maintains a list of records containing names and balance of customers. The program will prompt the user for a command, execute the command, then prompt the user for another command. The commands must be chosen from the following possibilities:           a    Show all records           r     Remove the current record           f     Change the first name in the current record           l     Change the last name in the current record           n    Add a new record           d   ...

  • Can you help me write a Python 3.7 code for this question? Write a program using...

    Can you help me write a Python 3.7 code for this question? Write a program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The...

  • Please write a code that will look like this. You CANNOT use ArrayLists or any type...

    Please write a code that will look like this. You CANNOT use ArrayLists or any type of List to store objects, Breaks, or continue statemets throughout the entire project. PLEASE only use basic Arrays Correctly use the “Prime the Read” method for inputting data before a sentinel loop. Note: You may not use any break or continue statements in your program to earn these points. like- (Items in green/underline are the user inputs. Your program should not print these items)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT