Python3 command line arguments; there are unknown number of arguments, 'only number // number and the length of the argument is three' is a valid argument,for example,2//5,3//5 are valid arguments,a//2,b//4,7//0,b//k are not valid arguments, calculate each valid argument and the number of valid arguments, and then print
hint: split is very useful
restrictions: [1:], for loop, slicing, lambda function, 'in' keyword,isdigit(), isalpha() cannot be used. Exception handling must be used, it is recommended to use while loop to solve this problem.
![Cuser@sahara ]$ python Q3.py 2//0 a//b 3//a b//2 8//3 9//4 5/2 8//3 2 9//4 2 There are 2 valid arguments Cuser@sahara ~] pyth](http://img.homeworklib.com/questions/5e3f2050-cc68-11ea-b5bb-3b9a53de2ce2.png?x-oss-process=image/resize,w_560)
Here is the answer...
CODE:
import sys
def find(s):
i=0
#print(s)
while(i<len(s)):
if s[i]=='/':
return i
i+=1
def join(l):
i=0
s=""
while(i<len(l)):
s+=l[i]+" "
i+=1
return s
length=len(sys.argv)
sys.argv=join(sys.argv)
a=sys.argv.split(" ")
#print(a)
index=1
l=[]
while(index<length):
l.append(a[index]) #append each argument to list
index+=1
j=0
count=0 #to take 3 number// number
valid=0 #for valid count
while(j<len(l)): #iterate through list of numbers
i=0
#print(l[j])
k=find(l[j]) #find the // operator in argument
#print(k)
if(count==3): #if count 3 break
break
s1="" #for storing first number
while(i<k):
s1+=l[j][i] #concatenate to string
i+=1
i+=2
#print(i)
s2="" #for denominator/second number
while(i<len(l[j])):
s2+=l[j][i] #concatenate to second string
i+=1
#print(s1,s2)
j+=1 #for next argument
try:
a=int(s1) #convert first number to integer
b=int(s2) #convert second number to integer
#print(a,b)
count+=1 #count the number//number arguments
#if possible then print and count valid arguments
print(a,"//",b," = ",a//b)
valid+=1
except:
print(end="") #cathing the raised exception and do nothing
print("There are ",valid," valid arguments") #print valid
arguments
CODE Snapshot:

![s1- $2 k-find(1[j]) #find the // operator in argument #print(k) if(count==3): #if count 3 break break #for storing first nu](http://img.homeworklib.com/questions/5f38cbe0-cc68-11ea-8926-4f1536a958ec.png?x-oss-process=image/resize,w_560)
OUTPUT:

If you have any doubts please COMMENT...
If you understand the answer please give THUMBS UP....
Python3 command line arguments; there are unknown number of arguments, 'only number // number and the...
Python3: Write the function findLongestStreak(lst) which takes a list of numbers, lst, and returns the longest streak of numbers which occur in the list. A streak of numbers is a list of numbers where each number is one greater than the one that occurred before it- for example, [4, 5, 6, 7]. So findLongestStreak([3, 4, 8, 2, 3, 4, 5, 7, 8, 9]) would return [2, 3, 4, 5]. If there is more than one streak with the longest length,...
Python3: Write the function longestSubpalindrome(s), that takes a string s and returns the longest palindrome that occurs as consecutive characters (not just letters, but any characters) in s. so longestSubpalindrome("ab-4-be!!!") returns "b-4-b".If there is a tie, return the lexicographically larger value -- in Python, a string s1 is lexicographically greater than a string s2 if (s1 > s2). So: longestSubpalindrome("abcbce") returns "cbc", since ("cbc" > "bcb"). Note that unlike the previous functions, this function is case-sensitive (so "A" is not...
Python3 please use while loop to solve this question,specific
information is on the graph
Question 2 - 15 marks Write the function read_file_center50 (filename). The function returns a list of 50 strings that are at the center of the file. A file has n lines, then is the center. A list of length 50 is returned, where the first line is 25 and the last line is 2 + 25. If the file has n < 50 lines, then only...
Your task is to write a C++ program that consumes integer values as command line arguments and returns the arithmetic mean of these values. To increase the flexibility of the program, there should be no set number of arguments. To overcome this, we will require the argument argv[1] to be the number of integers the user enters. For example, if the user wants to calculate the arithmetic mean of 4 numbers, they would pass in 4 as the first argument...
Problem 3 Rewrite Program 2. This is you must use keyword arguments to pass number of kWh and customer type to the bill_calculator function when it is called. Save your Python program in a file named Lab07P3.py. Submit the file to Blackboard for credit.This is what i wrote for prgram 2:(): kwh = (()) cus = (()) cus.upper() bill_calculator(kwhcus) (kwhcus): kwh <= cus == : price = kwh * kwh > cus == : price = * + ((kwh - ) * ) kwh <= cus == : price = kwh * kwh > cus == : price = * + ((kwh - ) * ) (.format(price))
how to write this code in python?
please don't print the space for each row last number.
Pascal's Triangle Pascal's Triangle is a number pattern with many interesting and useful properties. For example: Each number in the triangle is the sum of the two numbers above it. The number at row n and column k is equal to the binomial coefficient () "n choose k." 1 21 133 1 1 4 6 4 1 Write a program that prints Pascal's...
A. Write a Python script so that the user can enter any number of grades. Create a calcavg() function so that it takes the number of grades as a parameter and returns the regular average (not a weighted average). You must loop through the grades for full credit. Add a try/except block so that if a non-numeric value is entered, you get the error message shown below. You cannot use lists. Input: c. python …\IT2430\FirstLastname\assign5-2.py 96.7 95.6 87.0 d. python...
Python3 : question about object-oriented programming, Please
write program in the template(critter.py),specific information is
on the graphs
the missing words in the 4th line are 'To save an attribute,
attach it to this self keyword'
W11 - Critters Implement the Critter class. Each critter C has attributes species, size, and age The constructor accepts arguments for the attributes above, in the order above. You can expect size and age to be numeric values Each critter C has a can_eat) method,...
Use python!!! need to match the execution result that is provided. Part One – Keyword Arguments and Default Values Write an invoice function. The function will generate a simple invoice and will have two required arguments and two keyword arguments. The two required arguments are unitPrice and quantity. The first keyword argument is shipping, and it has a default value of 10. The second keyword argument is handling, and it has a default value of 5. Test it twice from...