0% found this document useful (0 votes)
0 views

Document

The document outlines a series of programming tasks that involve user input and string manipulation in Python. It includes creating a greeting program, calculating age based on birth year, summing and averaging five numbers, and demonstrating string creation with single and double quotes. Each task is accompanied by example code and expected output.

Uploaded by

ancy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Document

The document outlines a series of programming tasks that involve user input and string manipulation in Python. It includes creating a greeting program, calculating age based on birth year, summing and averaging five numbers, and demonstrating string creation with single and double quotes. Each task is accompanied by example code and expected output.

Uploaded by

ancy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

The Greeter
Write a program that asks for the user's name tells them hello.
name = input("Enter your name: ")
print("Hello", Ancy)
Output: Enter your name: Ancy
Hello, Ancy
2. What's My Age Again?
Ask for their year of birth and compute their age. Print out their age in the
following format:
year = int(input("Enter your year of birth: "))
yearnow= 2021 - year
print("Your age is", yearnow)
Output: Enter your year of birth:1998
Your age is 23
3. Sum and Mean
Read five numbers in.
Print out their sum and mean.
sum=0
for i in range (5):
sum+= int(input("Enter integer: "))
mean= sum/5
print("Sum:", sum )
print("mean:", mean )
Output: Enter integer: 1
Enter integer: 2
Enter integer: 3
Enter integer: 4
Enter integer: 5
Sum: 15
mean: 3.0
4. Create a string containing a single quote.
print(“Hello ‘Beautiful’”)
Output: Hello ‘Beautiful’

Create a string containing a double quote.


print('Hello "Beautiful"')
Output: Hello “Beautiful”

5. Create a string containing both a single quote a double quote


print('Hello \'Beautiful\' Hello \"Asia\"')

Output: Hello ‘Beautiful’ Hello “Asia”

Create a triple quoted string that contains single and double quotes.
print("""hello “Ancy” . Are you from‘Asia’ """)

Output: hello "Ancy" . Are you from “Asia”

Create a character "a".


char=input("a")
print (char)

Output: a

You might also like