Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 What is wrong please fix my mistakes Exercise 7. Boolean Expressions Complete the following quizzes.py program by writing the missing expressions. The program

image text in transcribed

image text in transcribed

image text in transcribed

Python 3 What is wrong please fix my mistakes

Exercise 7. Boolean Expressions Complete the following quizzes.py program by writing the missing expressions. The program reads three quizzes grades from the command line, and check whether the users passed all the quizzes (passed_all), or failed some at least (failed_some): nl = int (sys.argv[1]) n2 = int (sys.argv[-]) n3 = int (sys.argv[]) passed_all = failed_some = Exercise 8. Leap Year Compose a program leap.py that takes a positive integer command line argument representing a year number and prints True if the year is leap and False otherwise. A leap year is a year divisible by 4 but not by 100, or is divisible by 400. You may not use nested if statements of if/elif/else statements. You can use boolean expression that evaluates to the correct true/false answer, or simple if / Else statement. Exercise 9. Separating Digits Write a program that allows a user to enter an integer, and separates it into individual digits, and prints the digits with three spaces between them. Exercise 10. Vowels in a String Write a program that counts the number of vowels existing in a specific string s. Assume that s is all lower case letters. A letter is a vowel if it is one of the following: a, e, o, i, u. Exercise 11. Square Root of a Number Write a program mysqrt.py that reads a float from the command line and computes/prints its square root. The algorithm for computing the square root of a positive number 'd' works as follows: given any estimate x of the square root, an improved estimate can be computed as (x + a/x)/2. Therefore your algorithm can start from an initial estimate (say a) and iterate until x2 is equal to a to within a small tolerance, say 10-7. > python mysqrt.py 10.0 3.162277665175675 exercise 8 In [26]; import sys # main function def main(): # get year year int(sys.argv[1]) #check if leap year or not if(yearX400 o or (year 4 year%100 = 0)): print (True) else: print(False) and # PROGRAN EXECUTION STARTS HERE main() File "", line 5 year = int(sys. argv[1] IndentationError: expected an indented block exercise 9 In [20]; import sys #main function def main(); # get integer n = int(sys.argv[1]) #print all digits listN = 0 while(n = 0) listn.append(n%10) int(n/10) #print for i in range(0, len(listN)) : print(listN[len(listN)-i-1), enda print) # PROGRAM EXECUTION STARTS HERE main() File "", line 5 int(sys.argv[1]) n = n = IndentationError: expected an indented block exercise 10 In [21]: import sys # main function def main() : # get string S = str(sys.argv[1]) #print all digits count for i in s: if(i in ['a', 'e',N,'o', u']): count += 1 print("Vowels *+str(count)) # PROGRAM EXECUTION STARTS HERE main() File "", line 5 s = str(sys.argv[1]) IndentationError: expected an indented block exercise 11 n = In [22]: import sys import math # main function def maino: # get number float(sys.argv[1]) # print the square root print(math.sqrt(n)) # PROGRAM EXECUTION STARTS HERE main File ""; n = float( sys.argv[1]) line 6 IndentationError: expected an indented block

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is MYCINs problem domain?

Answered: 1 week ago

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago