Page 253 - CTS - CSA TP - Volume 2
P. 253
COMPUTER SOFTWARE APPLICATION - CITS
2 String Concatenation and Repetition:
• str1 + “ is “ * 3 + str2: String concatenation of str1, the repeated string “ is “ three times, and str2.
3 Result Display:
• The final result of the string concatenation and repetition is stored in the variable result.
• The program prints the result to the console using print(“Result:”, result).
4 Observation:
• Users can input any strings, and the program will demonstrate the concatenation of strings and the repetition
of the middle string based on the precedence of string concatenation and repetition.
Output:
Related Exercises:
1 String Operations:
• Question 1: Write a Python program to concatenate two strings and print the result.
2 Date Operations:
• Question 2: Create a Python program that prints the current date and the date exactly one week from now.
3 User Input and Output:
• Question 3: Develop a Python program that takes user input for their name and greets them using the input.
4 Output Formatting:
• Question 4: Write a Python program that compares two numbers and prints the result in a formatted string.
5 Bitwise Operations:
• Question 5: Implement a Python program that takes two integers as input, performs bitwise AND and OR
operations, and prints the result.
238
CITS : IT & ITES - Computer Software Application - Exercise 124