Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Assigment 4 se alfaisal university so important for students first year, Assignments of Programming for Engineers

python assignment Assignment 4 se al-Faisal university so important for students first year

Typology: Assignments

2022/2023

Uploaded on 10/30/2022

3mor.7
3mor.7 🇸🇦

1 document

1 / 6

Toggle sidebar

Related documents


Partial preview of the text

Download Assigment 4 se alfaisal university so important for students first year and more Assignments Programming for Engineers in PDF only on Docsity! Alfaisal University - College of Engineering Software Engineering Department SE 100: Programming for Engineers Assignment #4 Fall 2022 - Due Date: Oct 06, 2022 at 11:59pm (midnight) Student Name: Amr Issa Student Number: 230265 Student Signature: (a digital signature is acceptable) Instructions and guidelines: 1. This is an individual work assignment and not a group assignment. It must be your original work, any copy from other students will be considered plagiarism. 2. Submit the assignment solution on Moodle before the due date as follows: • This document in a single PDF file. The file name should be written as: StudentName_StudentID_Assignment#.pdf. 3. You may be asked to demonstrate your solution. 4. No late assignment submissions will be accepted. 5. The report should include: • Evidence of testing (source code and screenshots) • Proper naming conventions • Comments on necessary parts of the code Course Learning Outcomes (ABET SO) CLO1 Learn the basic components and structure of a high-level programming language Alfaisal University - College of Engineering Software Engineering Department SE 100: Programming for Engineers Assignment #4 Fall 2022 - Due Date: Oct 06, 2022 at 11:59pm (midnight) This assignment should be completed using if, if-else, and if-elif-else statements together with the concepts that were introduced in Chapters 1 and 2. The assignment has three questions. Question #1: [30 marks] A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is Here, s is the length of a side. Write a program that prompts the user to enter the number of sides and the length of a regular polygon and displays its area rounded to three decimal places. Here is a sample run: Figure 1: Sample Run Hint: start your program with the following statement, which allows you to use the tan function and pi constant. from math import tan, pi Example: print(tan(pi)) #answer is -1.2246467991473532e-16 Source Code: [Instruction: copy and paste the source code here] from math import tan, pi num=int(input("Enter number of sides: ")) sides=float(input("Enter the side length: ")) Area=num*(sides**2)/(4*tan(pi/num)) print ("The area of the polygon is", format(Area,".3f")) Alfaisal University - College of Engineering Software Engineering Department SE 100: Programming for Engineers Assignment #4 Fall 2022 - Due Date: Oct 06, 2022 at 11:59pm (midnight) Question #3: [35 marks] At a particular university, letter grades are mapped to grade points in the manner given in Figure 4. Write a program that begins by reading a letter grade from the user. Then, your program should compute and display the equivalent number of grade points. Ensure that your program generates an appropriate error message if the user enters an invalid letter grade. Figure 5: Grading System Note: You can use .upper() to convert any lowercase letters entered by the user to uppercase letters, storing the result back into the same variable. Figure 6: Valid Sample Run Figure 7: Invalid Sample Run Alfaisal University - College of Engineering Software Engineering Department SE 100: Programming for Engineers Assignment #4 Fall 2022 - Due Date: Oct 06, 2022 at 11:59pm (midnight) Source Code: [Instruction: copy and paste the source code here] LR=(input("Enter a letter grade: ")) lr=LR.upper() if (lr=="A" or lr=="A+"): print("A(n)",lr,"is equal to 4.0 grade points ") elif (lr=="A-"): print("A(n)",lr,"is equal to 3.7 grade points ") elif (lr=="B+"): print("A(n)",lr,"is equal to 3.3 grade points ") elif (lr=="B"): print("A(n)",lr,"is equal to 3.0 grade points ") elif (lr=="B-"): print("A(n)",lr,"is equal to 2.7 grade points ") elif (lr=="C+"): print("A(n)",lr,"is equal to 2.3 grade points ") elif (lr=="C"): print("A(n)",lr,"is equal to 2.O grade points ") elif (lr=="C-"): print("A(n)",lr,"is equal to 1.7 grade points ") elif (lr=="D+"): print("A(n)",lr,"is equal to 1.3 grade points ") elif (lr=="D"): print("A(n)",lr,"is equal to 1.0 grade points ") elif (lr=="F"): print("A(n)",lr,"is equal to 0 grade points ") else: print ("That was'nt a valid letter grade") Evidence of Testing: [Instruction: paste the screenshot of your output here]
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved