Exercises¶
Here are the exercises to evaluate about some of the pre-defined functions to manipulate strings and dates.
Convert Case and Concatenate Strings¶
Create 2 variables of type string.
first_name with value Donald.
last_name with value Duck.
Concatentate both the variables with “, ” in between and assign to a new variable full_name.
full_name should be in upper case.
Print full_name and output should be DONALD, DUCK.
Check if the string is palindrome¶
Use these string literals and confirm if they are palindromes or not. You can get the definition of palindrome by googling it. You should ignore the case while checking if the string is a palindrome.
String 1: ITVersity
String 2: level
String 3: RaceCar
Getting Day for a given Date¶
Use existing Python libraries and get the day for the given date.
Create a variable by name some_date using format yyyy-MM-dd (2020-10-18).
Get the day in 3 character format Sun. Assign it to a variable day.
Print the value of day and it should be Sun.
Get the Student Name¶
Create a string variable by name student with this value
student_id=1;student_name=Some X;join_date=2020-10-02
.Get student_name from student and assign it to a variable student_name.
Print the value of student_name and it should be Some X
Get the Student Joining Date¶
Create a string variable by name student with this value
student_id=1;student_name=Some X;join_date=2020-10-02
.Get join date and assign it to variable called as join_date. It should only contain 2020-10-02
Convert the string to date type. The date is in the format of yyyy-MM-dd.
yyyy - 4 digit year
MM - 2 digit month
dd - 2 digit day.
Format and print the date using
%Y-%b-%d
. The output should be 2020-Oct-02