SDU CSS 115 Programming Fundamentals 1 (Python) Fall 2024 Practice 4 PDF
Document Details
Uploaded by SilentIntelligence7488
SDU University
2024
Tags
Related
Summary
This document provides practice exercises and instructions for programming fundamentals tasks using Python, covering if-elif-else statements, Python statements Part 1. This material also features detailed tasks, examples, and instructions.
Full Transcript
CSS 115 - Programming Fundamentals 1 (Python) Fall 2024 Practice 4 Plan Checking Homework (Practice 3) Python statements Part 1: if, elif, else Practice Quiz 1 Questions Homework Complete tasks of Practice 3 ...
CSS 115 - Programming Fundamentals 1 (Python) Fall 2024 Practice 4 Plan Checking Homework (Practice 3) Python statements Part 1: if, elif, else Practice Quiz 1 Questions Homework Complete tasks of Practice 3 Python Statements Part 1 if, elif,else https://drive.google.com/drive/folders/10bxiONJ5m2MldyQvQuJXsOt h693XRIHB Task # 1 - Instructions To experiment with if and else a What will the output be if you run this piece of code in the IPython bit, have a look at this code Shell? sample: small medium large The syntax is incorrect; this code will produce an error. Task # 2 - Instructions if It’s time to take a closer look around in your house. # Define variables Two variables are defined in the room = "kit" sample code: room, a string that tells you which room of the house we’re area = 14.0 looking at, and area, the area of that room. Examine the if statement that prints # if statement for room out "looking around in the if room == "kit" : kitchen." if room equals "kit". Write another if statement that prints print("looking around in the out “big place!” if area is greater than kitchen.") 15. Task # 3 - Instructions Add else # Define variables In the script, the if construct for room room = "kit" area = 14.0 has been extended with an else statement so that “looking around elsewhere.” is printed if the condition # if-else constructed for room room == "kit" evaluates to False. if room == "kit" : Can you do a similar thing to add more print("looking around in the kitchen.") functionality to the if construct for else : area? print("looking around elsewhere.") Add an else statement to the second control structure so that “pretty small.” # if-else construct for area : is printed out if area > 15 evaluates to if area > 15 : False. print("big place!") Task # 4 - Instructions Customize further: elif # Define variables It’s also possible to have a look around room = "bed" in the bedroom. The sample code area = 14.0 contains an elif part that checks if room equals “bed”. In that case, # if-elif-else constructed for room “looking around in the bedroom.” is if room == "kit" : print("looking around in the kitchen.") printed out. It’s up to you now! Make a similar elif room == "bed": print("looking around in the bedroom.") addition to the second control structure else : to further customize the messages for print("looking around elsewhere.") different values of area. Add an elif to the second control # if-elif-else construct for area structure such that “medium size, if area > 15 : nice!” is printed out if area is greater print("big place!") than 10. Task # 5 Instructions Quiz 1 (03P) Format: paper based Grade: 10% (multiple choice questions) Time: 4:30 - 5:00 PM Duration: 30 min Number of questions: 20 Topics: Lecture 1, 2 and 3, Practice 1,2 and 3. Rules Do not forget to write your name surname and ID to the paper Do not you look at to someone's paper Don't talk with neighbor If you have any questions raise your hand Do not try to cheat (from notebook, from internet and so on sources) If you break any of the mentioned above rules you will automatically get 0 for your Quiz 1. Quiz 1 (02P) Format: paper based Grade: 10% (test multiple choice questions) Time: 9:30 - 10:00 AM Duration: 30 min Number of questions: 20 Topics: Lecture 1, 2 and 3, Practice 1,2 and 3. Quiz 1 (04P) Format: paper based Grade: 10% (test multiple choice questions) Time: 4:30 - 5:00 PM Duration: 30 min Number of questions: 20 Topics: Lecture 1, 2 and 3, Practice 1,2 and 3. Questions