Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

WEEK 4 + 5

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:

4. Create a program that asks the user:


• Their name
• Their address
• Their email address
• Output on the screen as:
• Name in capitals
• Address in sentence form
• Email address all lowercase

You might also like