0% found this document useful (0 votes)
21 views2 pages

Python Beginner Exercises - Day2

Uploaded by

mahghe
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)
21 views2 pages

Python Beginner Exercises - Day2

Uploaded by

mahghe
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 beginner exercises- Day2‬

‭ dd or Even‬
O
‭Ask the user to enter a number and determine whether it is odd or even.‬
‭Hint: Use the input() function to get the number from the user, and the modulus operator (%)‬
‭to check if the number is divisible by 2.‬

‭ ositive or Negative‬
P
‭Ask the user to enter a number and determine whether it is positive, negative, or zero.‬
‭Hint: Use the input() function to get the number from the user, and simple comparison‬
‭operators (<, >, ==) to check the sign of the number.‬

‭ rade Calculator‬
G
‭Ask the user to enter their grade and print out a message based on the following criteria:‬
‭A (90-100): "Excellent!"‬
‭B (80-89): "Very good!"‬
‭C (70-79): "Good"‬
‭D (60-69): "Needs improvement"‬
‭F (below 60): "Failed"‬
‭Hint: Use the input() function to get the grade from the user, and a series of elif statements to‬
‭check the range of the grade.‬

‭ eap Year‬
L
‭Ask the user to enter a year and determine whether it is a leap year or not.‬
‭Hint: Use the input() function to get the year from the user, and check if it is divisible by 4‬
‭(and additionally check if it is divisible by 100 and 400 for edge cases).‬

‭ aximum of Three Numbers‬


M
‭Ask the user to enter three numbers and find the maximum of the three.‬
‭Hint: Use the input() function to get the three numbers from the user, and a series of if and‬
‭max() functions to find the maximum.‬

‭ ay of the Week‬
D
‭Ask the user to enter a day of the week (1-7, where 1 is Monday and 7 is Sunday) and print‬
‭the name of the day.‬
‭Hint: Use the input() function to get the day number from the user, and a series of if-elif-else‬
‭statements to print the corresponding day name.‬

‭ assword Validation‬
P
‭Ask the user to enter a password and check if it meets the following requirements:‬
‭At least 8 characters long‬
‭Contains at least one uppercase letter‬
‭Contains at least one lowercase letter‬
‭Contains at least one digit‬
‭Hint: Use the input() function to get the password from the user, len() function to check the‬
‭length, and any() function with appropriate string methods to check the presence of‬
‭uppercase, lowercase, and digits.‬

‭ owel or Consonant‬
V
‭Ask the user to enter a character and determine whether it is a vowel or a consonant.‬
‭Hint: Use the input() function to get the character from the user, and check if it is in the set of‬
‭vowels using the in operator or a series of if-elif statements.‬
‭ riangle Type‬
T
‭Ask the user to enter the lengths of three sides of a triangle and determine whether it is an‬
‭equilateral, isosceles, or scalene triangle.‬
‭Hint: Use the input() function to get the three side lengths from the user, and check the‬
‭conditions for equilateral (all sides equal), isosceles (two sides equal), and scalene (all sides‬
‭unequal) using a series of if-elif statements.‬

‭ ock, Paper, Scissors‬


R
‭Simulate the game of Rock, Paper, Scissors. Ask the user to choose rock, paper, or‬
‭scissors, and then randomly generate the computer's choice. Determine the winner based‬
‭on the rules of the game.‬
‭Hint: Use the input() function to get the user's choice, import the random module to generate‬
‭the computer's choice, and use a series of if-elif statements to determine the winner based‬
‭on the game rules.‬

You might also like