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

PROGRAMMING EXERCISES P3.1 Write a program that reads an integer and prints whet

ID: 3878155 • Letter: P

Question


PROGRAMMING EXERCISES P3.1 Write a program that reads an integer and prints whether it is negative, zero, or positive. Write a program that reads a floating-point number and prints "zero" if the number is zero. Otherwise, print "positive" or "negative". Add "small" if the absolute value of the number is less than 1, or "large" if it exceeds 1,000,000. .P3.2 Write a program that reads an integer and prints how many digits the number has, by check- ing whether the number is z 10, 2 100, and so on. (Assume that all integers are less than ten billion.) If the number is negative, first multiply it by-1 P3.3 Write a program that reads three numbers and prints "all the same" if they are all the same, all different" if they are all different, and "neither" otherwise. P3.4 Write a program that reads three numbers and prints "increasing" if they are in increasing or- der, "decreasing" if they are in decreasing order, and "neither" otherwise. Here, "increasing" means "strictly increasing", with each value larger than its predecessor. The sequence 3 44 P3,5 would not be considered increasing. P3.6 Repeat Excrciss .P3.5, but before reading the numbers, ask the user whether increasing/de- creasing should be "strict" or "lenient". In lenient mode, the sequence 3 4 4 is increasing and the sequence 4 4 4 is both increasing and decreasing. .. P3.7 Write a program that reads in three integers and prints "in order" if they are sorted in ascend- ing or descending order, or "not in order" otherwise. For example. 1 2 5 152 5 21 122 in order not in order in order in order Write a program that reads four integers and prints "two pairs" if the input consists of two matching pairs (in some order) and "not two pairs" otherwise. For example, P3.8 1221 two pairs 1 2 23 not two pairs 222 2 two pairs the letter C for Celsius or F for Fahren- Write a program that reads a temperature value and heit. Print whether water is liquid, solid, or gaseous at the given temperature at sea level. P3.9 The boiling point of water drops by about one degree Celsius for every 300 meters (or 1,000 feet) of altitude. Improve the program of Exercise P39 to allow the user to supply the P3.10 alti- tude in meters or feet. Add error handling to Exercise P3.10. If the user provides an invalid unit for the altitude print an error message and end the program. - P3.11 Write a program that translates a letter grade into a number grade. Letter grades are A, B, C D, and F, possibly followed by + or-Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or F-.A+increases the numeric value by 0.3, a -decreases it by 0.3. However, an A+ value 4.0 P3.12 Enter a letter grade: B- The numeric value is 2.7 Write a program that translates a number between 0 and 4 into the closest letter grade. For ample, the number 2.8 (which might have been the average of several grades) would be co verted to B- Break ties in favor of the better grade; for example 2.85 should be a B P3.13

Explanation / Answer

# python 3.5 language is using

# Code 1:
#reading the integer
n=int(input())
if n==0:
print("Zero")
elif n>0:
print("Positive")
else:
print("Negative")

#Code 2:

n=float(input())
if n==0:
print("Zero")
elif n>0:
print("Positive")
else:
print("Negative")
if abs(n)<1:
print("small")
elif abs(n)>1000000:
print("Large")

#Code 3:
n=int(input())
if n<0:
n=n*(-1)
# create a for loop to check whether number >10 or >100 or >1000 and so on
for i in range(1,11):
if n<10**i:
print("No. of digits: ",i)
break

#Code 4:
x=int(input())
y=int(input())
z=int(input())
if x==y and y==z:
print("all the same")
elif x!=y and y!=z and z!=x:
print("all different")
else:
print("neither")

#Code 5:
x=int(input())
y=int(input())
z=int(input())
#we can compare one by one
#like x<y and y<z then increasing
if x<y and y<z:
print("increasing")
elif x>y and y>z:
print("decreasing")
else:
print("neither")

#Code 7:
arr=[] #create a list or array
for i in range(3):
arr.append(int(input())) #read all three elements in list

# first sort in increasing order and compare to original list
# then sort in decreasing order and compare with original list
#sorted method returns a sorted list without changing original list
inc=sorted(arr)  
dec=sorted(arr,reverse=True)
if inc==arr or dec==arr:
print("in order")
else:
print("not in order")

#Code 9:
n=int(input())
t=input()
if t=="C":
if n<100 and n>0:
print("liquid")
elif n>=100:
print("gaseous")
else:
print("solid")
elif t=="F":
if n<212 and n>32:
print("liquid")
elif n>=212:
print("gaseous")
else:
print("solid")

#use dictionary datatype for question 8

#time limit excceds so i can't answer further

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