Page 300 - CTS - CSA TP - Volume 2
P. 300
COMPUTER SOFTWARE APPLICATION - CITS
Related Exercises
1 Write a program that takes an ASCII code as input and prints the corresponding character using the chr()
function.
2 Write a program that compares two integers and prints whether they are equal, greater, or smaller using the
cmp() function.
3 Create a program that takes a Python code snippet as input, compiles it using the compile() function, and then
executes it using exec().
4 Write a program that defines a list and uses the dir() function to get its attributes. Print the list of attributes.
5 Develop a program that prompts the user for a mathematical expression, evaluates it using eval(), and prints
the result.
6 Create a program that defines a list of numbers and uses the filter() function to obtain only the even numbers.
7 Write a program that takes a string as input, computes its hash using the hash() function, and prints the result.
8 Develop a program that uses the input() function to get the user’s name and then prints a personalized
greeting.
9 Create a program that takes a string as input and prints its length using the len() function.
10 Write a program that defines some local variables, uses the locals() function to obtain their dictionary, and
prints the result.
11 Develop a program that defines a list of numbers, uses the max() function to find the maximum value, and
prints the result.
12 Create a program that takes base and exponent values as input, calculates the power using pow(), and prints
the result.
13 Write a program that takes a string as input, uses slicing to extract a substring, and prints the result.
14 Develop a program that defines a list and converts it into a tuple using the tuple() function. Print the resulting
tuple.
15 Write a program that defines some variables, uses the vars() function to obtain their dictionary, and prints the
result.
285
CITS : IT & ITES - Computer Software Application - Exercise 132