0% found this document useful (0 votes)
10 views3 pages

Python Conditional Statements Assignment

The Python programming assignment focuses on practicing conditional statements using if, elif, and else. Students are required to complete tasks related to age checks, grading systems, weather advice, and a mini chatbot, all while adding comments to their code. The completed assignment must be saved as 'conditionals_assignment.py' and submitted via GitHub by May 16, 2025.

Uploaded by

riftflixstudios
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Python Conditional Statements Assignment

The Python programming assignment focuses on practicing conditional statements using if, elif, and else. Students are required to complete tasks related to age checks, grading systems, weather advice, and a mini chatbot, all while adding comments to their code. The completed assignment must be saved as 'conditionals_assignment.py' and submitted via GitHub by May 16, 2025.

Uploaded by

riftflixstudios
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Programming Assignment – Lesson: Conditional Statements

📅 Submission Deadline: 16th May 2025


👉 Upload your Python file to GitHub and submit the link in the lesson's "About" section.

Assignment Objective:
This assignment helps you practice using if, elif, and else statements to make decisions in your
code — like checking age, grades, or even weather!

📘 Instructions:
1.​ Complete all the tasks below in one Python file.​

2.​ Add comments to explain your code.​

3.​ Save your file as conditionals_assignment.py.​

4.​ Upload it to GitHub and submit the link in the lesson's About section.​

✍️ Tasks:
✅ Task 1: Check Age
●​ Create a variable age.​

●​ Use an if statement to check if age is 18 or older.​

●​ If true, print "You are an adult."​


✅ Task 2: Age Check with Else
●​ Expand Task 1 using else:​

○​ If age is less than 18, print "You are not an adult."​

✅ Task 3: Grading System


●​ Create a variable marks.​

●​ Use if, elif, and else to print grades:​

○​ marks >= 90 → "Grade: A"​

○​ marks >= 70 → "Grade: B"​

○​ marks >= 50 → "Grade: C"​

○​ Otherwise → "Fail"​

✅ Task 4: Weather Advice


●​ Create a variable weather and set it to "rainy", "sunny", or "cloudy".​

●​ Use conditionals to print:​

○​ "Take an umbrella" if rainy​

○​ "Wear sunglasses" if sunny​

○​ "It might rain later" if cloudy​


✅ Task 5: Quiz – Feeling Hungry?
●​ Create a variable hungry = True or False.​

●​ If hungry is True, print "Go eat something!"​

●​ If not, print "Maybe have a snack later."​

🏆 Bonus Fun Task: Mini Chatbot


Ask the user how they're feeling:

mood = input("How are you feeling today? ")

●​ If mood is "happy" → print "That's great to hear!"​

●​ If "sad" → print "I hope your day gets better."​

●​ If "bored" → print "Try reading a book or going for a walk."​

●​ Otherwise → print "Thanks for sharing your mood!"​

📤 Submission Steps:
1.​ Save your file as conditionals_assignment.py​

2.​ Upload it to GitHub.​

3.​ Submit your GitHub link in the About section of the lesson before 16th [Month] 2025.​

Common questions

Powered by AI

Uploading code to a platform like GitHub is a critical step in the programming learning process as it introduces learners to version control, collaborative tools, and sharing practices prevalent in the professional environment. By doing so, learners become familiar with documenting progress, maintaining a history of changes, and getting feedback from peers or educators. This not only prepares them for industry practices but also helps to cultivate a responsible and systematic approach to coding projects. Additionally, the act of sharing one's code encourages openness and learning from the programming community.

Setting a specific deadline for assignment submissions is important in academic practices as it instills discipline and time management skills in students. Deadlines like 16th May 2025 encourage learners to prioritize tasks, plan their study schedule, and work efficiently within a set timeframe. These deadlines simulate real-world conditions where timelines play a critical role, thus better preparing students for professional responsibilities where meeting deadlines is crucial for project success and maintaining productivity.

Using comments within your code is essential for improving code readability and maintainability, especially when implementing conditional statements. As emphasized in the assignment instructions, comments help explain the purpose and functionality of specific code sections, making it easier for others (and the programmer) to understand the logic and modifications made to the code over time. This practice is particularly important in educational contexts where learning and sharing knowledge are key goals.

Conditional statements such as if, elif, and else are fundamental in Python programming as they allow the code to make decisions based on certain conditions. By leveraging these statements, programmers can execute different blocks of code based on dynamic input or data, thereby making the program responsive and adaptable. For instance, checking if a user is an adult with appropriate print statements ensures that the program provides relevant feedback based on age criteria specified, such as in Task 1 and Task 2. Additionally, they enable the grading system (Task 3) to assign the correct grade based on the range of marks, enhancing user interactivity and customization.

The sequential ordering of tasks facilitates the logical development of programming skills by incrementally increasing complexity and reinforcing prior learning. Starting with simple if and else statements to check an age range in Tasks 1 and 2 introduces the basic syntax and logic without overwhelming the learner. Progressively, Task 3 introduces elif for handling multiple conditions, leveraging previously gained knowledge. This staircase approach helps solidify understanding and creates a robust foundation before tackling more complex subjects like weather predictions and mood-based input in additional tasks. Each step builds upon the last, promoting cumulative learning and skills advancement.

When developing a simple chatbot using Python's conditional statements, several considerations ensure effective interaction. One must accurately handle user input with precise if statements to match expected moods such as 'happy', 'sad', or 'bored' as outlined in the bonus task instructions. It is crucial to include an 'else' statement to handle unexpected or undefined user inputs gracefully, providing a fallback response, as this improves user experience by acknowledging any input. Moreover, maintaining simplicity and clarity in the script's logic is essential to avoid confusion and ensure the chatbot responds as intended. This involves testing the chatbot's responses to various inputs for robustness.

The task design involving variable assignments and condition checking contributes to learning programming in Python by encouraging active engagement with core programming concepts. Assigning values to variables and applying conditional checks provides a practical approach to understanding how data can be manipulated and evaluated in real scenarios. This aids in recognizing patterns, understanding program control flows, and developing problem-solving strategies. By implementing tasks like age and weather checking, learners acquire hands-on experience, reinforcing their comprehension of abstract programming principles through tangible applications, which solidifies foundational coding skills.

Incorporating tasks like 'Feeling Hungry?' illustrates the practical applications of Python's logic structures by showing how they can be used in everyday decision-making scenarios. Conditional logic allows programs to offer contextual responses based on user needs or states, like determining actions for hunger states. It demonstrates the application of simple true/false conditions to drive decisions in programmatic solutions, reflecting real-world processes and simplifying coding tasks for interactive user experiences. This underscores the utility of conditional logic beyond theoretical exercise into practical daily applications, reinforcing its importance in development.

Implementing a weather advisory system using if-elif-else statements can present challenges such as ensuring the accuracy of condition checks and handling unexpected input values. In Task 4, for instance, the correct implementation is contingent upon the 'weather' variable being accurately defined as either 'rainy', 'sunny', or 'cloudy'. If the variable's value does not match these strings exactly, none of the conditions will be satisfied, leading to a lack of any advisory output. Additionally, designing the system to be extendable and maintainable when encountering new weather conditions can be complex.

Adding a feature to check user input, such as mood, extends the functionality of conditional statements by allowing programs to interact with users more dynamically and contextually. When Python processes user inputs through conditionals, as detailed in the bonus task, it reacts to real-time data by tailoring outputs to various mood states ('happy,' 'sad,' 'bored'). This interactive capability transforms static code into an adaptive system capable of nuanced interactions, thereby enhancing user engagement. Implementing such features also demonstrates advanced programming skills, emphasizing flexibility and adaptability within software applications.

You might also like