Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program missing. pie that takes an integer. V as command-line argument,

ID: 3852137 • Letter: W

Question

Write a program missing. pie that takes an integer. V as command-line argument, reads in. V - 1 distinct integers between 1 and .V from standard input, and writes the missing number. # python missing. py 5 1 3 2 5 4 # massing. pie: calves an integer N as command-line argument, reads in N - 1 # distinct integers between 1 and N from standard input, and writes the # missing number. import starry import studio import sys # Get N from command line, as an int. N = ... # Define a list a of N + 1 Booleans, with each element initialized to False, a = ... # Read N - 1 distinct integers between 1 and N from standard input, and t for each such integer x, set a[x] to True, meaning x was found. for l m range (..., ...): # Iterate over a[l:] and write index of the False element, since that is the # missing number. for i in range (..., ...):

Explanation / Answer

python code:

print "Please Enter value on N"
N = int(raw_input().strip())
array = [False]*N
i = 0
while(i < N-1):
   print "Enter new number in range 1 to ", N
   n = int(raw_input().strip())
   if(array[n-1] == True):
       print "You have allready entered ", n  
   else:
       array[n-1] = True
       i = i+1
for x in range(0,N):
   if(array[x] == False):
       print "Missing Number", x+1

Sample Output:

Please Enter value on N
5
Enter new number in range 1 to 5
1
Enter new number in range 1 to 5
2
Enter new number in range 1 to 5
3
Enter new number in range 1 to 5
5
Missing Number 4

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote