0% found this document useful (0 votes)
4 views1 page

Python Day1 Lab

The document outlines five programming tasks involving logical operators, string concatenation, string slicing, and string formatting. Task 1 requires checking if a number is within a range, Task 2 assesses discount eligibility based on age and coupon possession, Task 3 involves creating a greeting message, Task 4 extracts initials from a full name, and Task 5 formats a sentence with a person's name and age. Each task specifies the desired output and coding requirements.

Uploaded by

momansour2624
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Python Day1 Lab

The document outlines five programming tasks involving logical operators, string concatenation, string slicing, and string formatting. Task 1 requires checking if a number is within a range, Task 2 assesses discount eligibility based on age and coupon possession, Task 3 involves creating a greeting message, Task 4 extracts initials from a full name, and Task 5 formats a sentence with a person's name and age. Each task specifies the desired output and coding requirements.

Uploaded by

momansour2624
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Tasks

Task 1: Logical Operators

Use logical operators to determine if a number is within a specified range.

1. Write code to check if the variable number is between start and end (inclusive). Print
True if it is, and False otherwise.

Task 2: Logical AND, OR, NOT

Use logical operators to check multiple conditions.

1. Write code to determine if a person is eligible for a discount based on their age and
whether they have_coupon. A person is eligible if they are either under 18 or over 65, or
if they have a coupon. Print True if they are eligible, and False otherwise.

Task 3: String Concatenation

Combine strings to form a complete sentence.

1. Write code to create a greeting message using the variable name. The greeting should be
in the format: "Hello, Name!".

Task 4: String Slicing

Extract specific parts of a string.

1. Write code to get the initials of a person using the variable full_name. The initials
should be the first letter of the first name and the first letter of the last name.

Task 5: String Formatting

Format strings using different methods.

1. Write code to create a sentence using the variables name and age. The sentence should be
in the format: "Name is Age years old."

You might also like