Professional Documents
Culture Documents
w4 Worksheet
w4 Worksheet
Write the code using python for these programs and print screen it with the
output and attach your answers
1. Write a Python program to print the following string in a specific format (see the
output).
Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the
world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder
what you are"
Output :
Twinkle, twinkle, little star,
How I wonder what you are!
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are
2. Write a Python program to inter your name and your age, display them in the screen,
then print Two goals for 2024.
3.Write a Python program that accepts the user's first and last name and prints them in
reverse order with a space between them.
Explanation:
This code prompts the user to input their first and last name, and then it prints a message
that combines the first name and last name in a specific order.
1. The first line fname = input("Input your First Name : ") gets the user's first name using the
input() function and assigns it to the variable 'fname'.
2. The second line lname = input("Input your Last Name : ") gets the user's last name using the
input() function and assigns it to the variable 'lname'.
3. The third line print ("Hello " + lname + " " + fname) prints a message that combines the last
name and first name, concatenating them with the + operator and separated by a space.
Flowchart: