Code
Code
Code
# Main program
dragons_score = 0
wizards_score = 0
for i in range(n):
shape = input('Enter the shape of card {}: '.format(i+1))
value = input('Enter the value of card {}: '.format(i+1))
Rahul Patwarika
Computer Science Practical File
Q2. numbers = []
for i in range(5):
number = int(input('Enter an integer: '))
numbers.append(number)
maximum = max(numbers)
minimum = min(numbers)
Q3.
def trafficLight():
color = input("Enter the color of the traffic light (RED, YELLOW, GREEN): ")
result = LIGHT(color)
if result == 0:
print("STOP, your life is precious")
elif result == 1:
print("Please WAIT, until the light is green")
elif result == 2:
print("GO! Thank you for being patient")
else:
print("Error: Invalid input. Please enter RED, YELLOW, or GREEN")
def LIGHT(color):
if color == "RED":
return 0
elif color == "YELLOW":
return 1
elif color == "GREEN":
return 2
else:
return -1
trafficLight()
print("SPEED THRILLS BUT KILLS")
Rahul Patwarika
Computer Science Practical File
Q4.
attempts = 0
if login(user_id, password):
break
else:
print("Invalid user ID or password. Please try again.")
attempts += 1
if attempts == 3:
print("Account blocked")
Q5.
def convert_to_roman(number):
roman_numerals = {
1000: "M",
900: "CM",
500: "D",
400: "CD",
100: "C",
90: "XC",
50: "L",
40: "XL",
10: "X",
9: "IX",
5: "V",
4: "IV",
1: "I"
}
roman_numeral = ""
Rahul Patwarika
Computer Science Practical File
return roman_numeral
Q6.
return rotated_word
Rahul Patwarika
Computer Science Practical File
Q7.
def find_triple_double_letters(word):
for i in range(len(word) - 5):
if word[i] == word[i+1] and word[i+2] == word[i+3] and word[i+4] == word[i+5]:
return word[i:i+6]
return None
Q8.
Q9.
def create_frequency_dict(word_list):
frequency_dict = {}
return result_dict
Q10.
def find_value_frequency(dictionary):
frequency_dict = {}
if value in frequency_dict:
frequency_dict[value] += 1
else:
frequency_dict[value] = 1
return frequency_dict
Rahul Patwarika