Day 07 - Practice Class

Practice Python Concepts

Question 01: Number Check (If-Else)

Ask the student to input a number and check if it is positive, negative, or zero using if-elif-else.

# Hint: Use input() and int() to get number
# if number > 0 -> print "Positive"
# elif number < 0 -> print "Negative"
# else -> print "Zero"

Question 02: Pass or Fail (If-Else)

Ask the student to input marks and check if the student passes (>=35) or fails.

# Hint: Use input() and int() to get marks
# if marks >= 35 -> print "Pass"
# else -> print "Fail"

Question 03: Day of Week (Match-Case)

Ask the student to input a number (1-7) and display the day of the week using match-case.

# Hint: Use match number:
# case 1 -> print "Monday"
# case 2 -> print "Tuesday"
# ...
# case _ -> print "Other Day"

Question 04: Access List Items

Ask the student to create a list of names and access individual items by index.

# Hint: names = ["Arun", "Hasvanth", "Ayyappan"]
# print first and last item using index

Question 05: Modify List

Ask the student to add a new name to the list and remove an existing one using list methods.

# Hint: names.append("NewName")
# names.remove("Ayyappan")
# print(names)

Question 06: Unique Numbers with Set

Ask the student to create a list with duplicate numbers and convert it into a set to get unique numbers.

# Hint: nums = [1,2,2,3,3,3]
# unique_nums = set(nums)
# print(unique_nums)

Question 07: Modify Set

Ask the student to add a number to a set and remove a number from it.

# Hint: my_set = {1,2,3}
# my_set.add(4)
# my_set.remove(2)
# print(my_set)

Question 08: Access Dictionary

Ask the student to create a dictionary of student marks and access values using keys.

# Hint: marks = {"Arun":45, "Hasvanth":50, "Ayyappan":38}
# print marks of Arun and Ayyappan

Question 09: Update Dictionary

Ask the student to update an existing key and add a new key-value pair in the dictionary.

# Hint: marks["Arun"] = new_value
# marks["NewStudent"] = value
# print(marks)

Question 10: Check Key in Dictionary

Ask the student to check whether a specific key exists in the dictionary and print a message.

# Hint: if "Arun" in marks:
#     print("Arun exists")
# else:
#     print("Not found")