0% found this document useful (0 votes)
326 views

Python For Everyone

Answer for Python for Everyone course in Coursera

Uploaded by

kumararunlamba89
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
326 views

Python For Everyone

Answer for Python for Everyone course in Coursera

Uploaded by

kumararunlamba89
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

IT COMMUNITY

Python for specialization

MODULE 3
QUIZ CHAPTER 1
1. What would you like to do?
2. 20
3. .PY
4. BREAK AND IF
5. QUIT
6. CENTRAL PROCESSING UNIT
7. A SEQUENCE OF INSTRUCTIONS IN A PROGRAMMING
LANGUAGE
8. SECONDARY MEMORY
9. THE COMPUTER DID NOT UNDERSTAND THE STATEMENT
THAT YOU ENTERED
10.RANDOM STEPS

ASSIGNMENT CHAPTER 1 GRADED APP ITEM

print("hello world")

MODULE 4
CHAPTER 2

1. #THIS IS A TEST
2. 123abc
3. #spam
4. SPAM
5. RETRIEVE THE CURRENT VALUE FOR X, ADD TWO TO IT
AND PUT THE SUM BACK INTO X
6. PARENTHESES ()
7. 2
8. 5.0
9. 98
10.PAUSE THE PROGRAM AND READ DATA FROM THE USER

GRADED ASSIGNMENMT 2.2

# Get the user's name


name = input("Please enter your name: ")

# Welcome the user


print("Hello " + name)

ASSIGNMENT 2.3

# Get the hours and rate from the user


hours = float(input("Enter hours: "))
rate = float(input("Enter rate per hour: "))
# Compute the gross pay
gross_pay = hours * rate

# Print the result


print("Pay:", gross_pay)
MODULE 5
CHAPTER 3

1. Indent the line below the if statement


2. =
3. Depending on the value of x, either all three of the print statements will execute or none
of the statements will execute
4. You de-indent the next line past the if block to the same level of indent as
the original if statement
5. You have mixed tabs and spaces in the file
6. TOGGLE (INCORRECT)
7. SMALL ALL DONE
8. This code will never print 'Something else' regardless of the value for 'x'
9. 4 (INCORRECT)
10.-1

GRADED ASSIGNMENT
3.1
# Get hours and rate from user
hours = float(input("Enter hours worked: "))
rate = float(input("Enter rate per hour: "))
# Calculate pay
if hours <= 40:
pay = hours * rate
else:
pay = 40 * rate + (hours - 40) * rate * 1.5
print(pay)
GRADED ASSIGNMENT 3.3

score = float(input("Enter score: "))

if score < 0.0 or score > 1.0:


print("Error: Score must be between 0.0 and 1.0")
else:
if score >= 0.9:
print("A")
elif score >= 0.8:
print("B")
elif score >= 0.7:
print("C")
elif score >= 0.6:
print("D")
else:
print("F")
MODULE 6
CHAPTER 4
1. Def
2. You de-indent a line of code to the same indent level as the def keyword
3. A built-in function
4. There
5. X
6. 10 20
7. Print(‘WORLD’)
8. Bonjour Michael
9. 2
10.Avoiding writing the same non-trivial code more than once in your
program

Graded assignment 4.6

def computepay(hours, rate):


if hours <= 40:
pay = hours * rate
else:
pay = 40 * rate + (hours - 40) * rate * 1.5
return pay

hours = float(input("Enter hours: "))


rate = float(input("Enter rate per hour: "))

pay = computepay(hours, rate)

print("Pay", pay)
Module 7
CHAPTER 5

1. This loop will run forever


2. Exits the currently executing loop
3. Jumps to the "top" of the loop and starts the next iteration
4. 5
5. Friend
6. Sum all the elements of a list
7. -1
8. matches both type and value
9. while
10. 0

GRADED ASSIGNMENT 5.2

largest = None
smallest = None

while True:
user_input = input("Enter a number (or 'done' to finish): ")
if user_input.lower() == 'done':
break
try:
num = int(user_input)
if largest is None or num > largest:
largest = num
if smallest is None or num < smallest:
smallest = num
except ValueError:
print("Invalid input")

if largest is not None and smallest is not None:


print("Maximum is", largest)
print("Minimum is", smallest)
else:
print("No valid numbers entered")

You might also like