Coding Exercise for Beginners in Python | Exercise 6| Python for Beginners #lec25

Coding Exercise for Beginners in Python | Exercise 6| Python for Beginners #lec25

Understanding Even and Odd Numbers in Python

Introduction to Conditional Statements

  • The video begins with a recap of previous lessons on conditional statements in Python, specifically focusing on if and if-else statements.
  • The instructor introduces a coding exercise where the goal is to determine if a given number is even or odd. An even number is defined as one that can be divided by 2 without any remainder.

Using the Modulo Operator

  • The modulo operator (%) is highlighted as essential for checking remainders when dividing numbers, which will help identify even numbers.
  • Viewers are encouraged to pause the video and attempt the coding exercise themselves, reinforcing hands-on learning.

Coding Exercise Steps

  • The instructor demonstrates how to create a new Python file named coding_exercise_6.py for this task.
  • Input from the user is taken using the input() function, which captures a number that needs to be checked for its parity (even or odd).

Implementing Conditions

  • A condition checks if the input number modulo 2 equals zero; if true, it prints "this is an even number."
  • If false, it indicates that "this is our number," implying it's odd. The instructor notes flexibility in using single or double quotes for strings in Python.

Running and Testing Code

  • Upon running the code with an example input of 34, it correctly identifies it as an even number.
  • When testing with 33, it shows that there’s a remainder of 1, confirming it's an odd number. This reinforces understanding through practical examples.
Video description

Best Python Tutorials for Beginners: https://www.youtube.com/playlist?list=PLdo5W4Nhv31bZSiqiOL5ta39vSnBxpOPT Notes of Today's Class: https://drive.google.com/file/d/190GIgf474zplMPKV6ZPKhoFTXHzilH6K/view?usp=sharing ********************************************* Connect & Contact Me: Jenny's Lecturers Hindi: https://www.youtube.com/@JennysLecturesHINDI My Second Channel Link: https://bit.ly/354n7C7 Facebook: https://www.facebook.com/Jennys-Lectures-CSIT-Netjrf-316814368950701/ Quora: https://www.quora.com/profile/Jayanti-Khatri-Lamba Instagram: https://www.instagram.com/jayantikhatrilamba/ Twitter: https://twitter.com/KhatriJenny ******************************************* More Playlists: Programming in C Tutorials: https://www.youtube.com/playlist?list=PLdo5W4Nhv31a8UcMN9-35ghv8qyFWD9_S C++ Tutorials for beginners: https://www.youtube.com/watch?v=KYxLEDF6kjs&list=PLdo5W4Nhv31YU5Wx1dopka58teWP9aCee Placement Series: https://www.youtube.com/playlist?list=PLdo5W4Nhv31YvlDpJhvOYbM9Ap8UypgEy Data Structures and Algorithms: https: https://www.youtube.com/playlist?list=PLdo5W4Nhv31bbKJzrsKfMpo_grxuLl8LU Design and Analysis of Algorithms(DAA): https://www.youtube.com/playlist?list=PLdo5W4Nhv31ZTn2P9vF02bkb3SC8uiUUn Dynamic Programming: https://www.youtube.com/playlist?list=PLdo5W4Nhv31aBrJE1WS4MR9LRfbmZrAQu Operating Systems tutorials: //www.youtube.com/playlist?list=PLdo5W4Nhv31a5ucW_S1K3-x6ztBRD-PNa DBMS Tutorials: https://www.youtube.com/playlist?list=PLdo5W4Nhv31b33kF46f9aFjoJPOkdlsRc #coding #pythonforbeginners #python #jennyslectures #pythonprogramming