Practical_4: Flow control#
Exercise 1:#
Write a Python program that checks if a number is positive or negative.
# Exercise 1
Exercise 2:#
Write a Python function that checks if a string starts with a vowel.
# Exercise 2
Exercise 3:#
Write a Python program that takes a list of integers and prints “Even” for each even number and “Odd” for each odd number.
# Exercise 3
Exercise 4:#
Write a Python program that checks if a given year is a leap year.
# Exercise 4
Exercise 5:#
Write a Python function that checks if a number is divisible by both 3 and 5.
# Exercise 5
Exercise 6:#
Write a Python program that prints “Hot” if the temperature is above 30, “Warm” if it is between 15 and 30, and “Cold” if it is below 15.
# Exercise 6
Exercise 7:#
Write a Python program that checks if a string contains the letter ‘a’.
# Exercise 7
Exercise 8:#
Write a Python function that checks if two numbers are equal, or which one is larger.
# Exercise 8
Exercise 9:#
Write a Python program that checks if a list is empty.
# Exercise 9
Exercise 10:#
Write a Python function that takes two strings and checks if they are anagrams.
# Exercise 10
Exercise 11:#
Write a Python program that checks if a number is prime.
# Exercise 11
Exercise 12:#
Write a Python program that checks if a list of numbers is sorted in ascending order.
# Exercise 12
Exercise 13:#
Write a Python function that takes a character and checks if it is a digit.
# Exercise 13
Exercise 14:#
Write a Python function that checks if a string contains only uppercase letters.
# Exercise 14
Exercise 15:#
Write a Python program that checks if a number is a multiple of 10.
# Exercise 15
Exercise 16:#
Write a Python function that checks if a list contains any duplicates.
# Exercise 16
Exercise 17:#
Write a Python program that prints “Teenager” if the age is between 13 and 19, otherwise it prints “Not a teenager.”
# Exercise 17
Exercise 18:#
Write a Python function that checks if a list contains an element greater than 100.
# Exercise 18
Exercise 19:#
Write a Python program that checks if a number is even or odd.
# Exercise 19
Exercise 20:#
Write a Python function that checks if a string ends with a punctuation mark.
# Exercise 20
Exercise 21:#
Write a Python program that prints “Yes” if the number is between 1 and 100, otherwise it prints “No.”
# Exercise 21
Exercise 22:#
Write a Python program that checks if two strings have the same length.
# Exercise 22
Exercise 23:#
Write a Python function that checks if a number is greater than its reverse.
# Exercise 23
Exercise 24:#
Write a Python program that checks if a password contains both letters and numbers.
# Exercise 24
Exercise 25:#
Write a Python program that checks if a number is between two given numbers.
# Exercise 25
Exercise 26:#
Write a Python function that checks if all characters in a string are unique.
# Exercise 26
Exercise 27:#
Write a Python program that checks if a number is a perfect square.
# Exercise 27
Exercise 28:#
Write a Python function that checks if a word is a palindrome.
# Exercise 28
Exercise 29:#
Write a Python program that prints “Fizz” if a number is divisible by 3, “Buzz” if it is divisible by 5, and “FizzBuzz” if divisible by both.
# Exercise 29
Exercise 30:#
Write a Python program that checks if the sum of the digits of a number is even.
# Exercise 30
Exercise 31:#
Write a Python program that checks if a string is a valid email address.
# Exercise 31
Exercise 32:#
Write a Python function that checks if a number is within 10 of 100 or 200.
# Exercise 32
Exercise 33:#
Write a Python program that checks if a given string is a valid URL.
# Exercise 33
Exercise 34:#
Write a Python program that checks if a list contains all even numbers.
# Exercise 34
Exercise 35:#
Write a Python program that checks if a word is longer than a given length.
# Exercise 35
Exercise 36:#
Write a Python program that checks if a list contains only positive numbers.
# Exercise 36
Exercise 37:#
Write a Python function that checks if a year is a century year (i.e., divisible by 100).
# Exercise 37
Exercise 38:#
Write a Python program that checks if the sum of a list of numbers is greater than 100.
# Exercise 38
Exercise 39:#
Write a Python function that checks if a given word is a substring of another string.
# Exercise 39
Exercise 40:#
Write a Python program that checks if a number is a power of 2.
# Exercise 40
Exercise 41:#
Write a Python function that checks if a string contains no spaces.
# Exercise 41
Exercise 42:#
Write a Python program that prints “Yes” if a number is divisible by both 2 and 3, otherwise it prints “No.”
# Exercise 42
Exercise 43:#
Write a Python program that checks if a number is a palindrome.
# Exercise 43
Exercise 44:#
Write a Python function that checks if a string is made of only lowercase letters.
# Exercise 44
Exercise 45:#
Write a Python program that checks if a string starts with a specific prefix.
# Exercise 45
Exercise 46:#
Write a Python function that checks if a number is divisible by any number in a given list.
# Exercise 46
Exercise 47:#
Write a Python program that prints “Yes” if a string has more than one occurrence of the same letter.
# Exercise 47
Exercise 48:#
Write a Python function that checks if a number is prime by dividing it by numbers up to its square root.
# Exercise 48
Exercise 49:#
Write a Python program that checks if a number is within 1 of a multiple of 10.
# Exercise 49
Exercise 50:#
Write a Python program that prints “In range” if a number is between 10 and 20 (inclusive), otherwise it prints “Out of range.”
# Exercise 50