Assignment 4

docx

School

CUNY New York City College of Technology *

*We aren’t endorsed by this school

Course

1111

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

1

Uploaded by AmbassadorSardine3318

Report
Assignment 3: if - else (5 points) Algorithm Workbench 1. Write an i f statement that assigns 20 to the variable y, and assigns 40 to the variable z if the variable x is greater than 100. 2. Write an i f statement that assigns 10 to the variable b, and 50 to the variable c if the variable a is equal to 100. 3. Write an if-else statement that assigns O to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to the variable b. 4. The following code contains several nested if-else statements. Unfortunately, it was written without proper alignment and indentation. Rewrite the code and use the proper conventions of alignment and indentation. if score >= A_score: print('Your grade is A.') else: if score >= B_score: print('Your grade is B.'") else: if score >= C_score: print('Your grade is C."') else: if score >= D_score: print('Your grade is D.') else: print('Your grade is F.'") 5. Write nested decision structures that perform the following: If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2. 6. Write an if-else statement that assigns True to the again variable if the score vari- able is within the range of 40 to 49. If the score variable’s value is outside this range, assign False to the again variable. 7. Write an if-else statement that determines whether the points variable is outside the range of 9 to 51. If the variable’s value is outside this range it should display “Invalid points.” Otherwise, it should display “Valid points.”
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help