Python Session 1 Exercise
Python Session 1 Exercise
Exercise
Practice Questions?
1) What do the following expressions evaluate to?
'Hello world!'[1]
'Hello world!'[0:5]
'Hello world!'[:5]
'Hello world!'[3:]
2) What do the following expressions evaluate to?
'Hello'.upper()
'Hello'.upper().isupper()
'Hello'.upper().lower()
3) What do the following expressions evaluate to?
Write a Program to Compute the distance between two points given its
corresponding (x,y) co ordinates?
Write a Program to Compute the BMI of a Person given inputs Weight (In
Kgs) and Height (in cm)
Exercise #2
Read a given string, change the character at a given index and then print
the modified string.
Inputs
The first accept the string .
The next accept an integer , denoting the index location and then accept a
character separated by a space.
Source: https://www.hackerrank.com/challenges/python-mutations/problem
Exercise #3
You are given a string and your task is to swap cases. In other words,
convert all lowercase letters to uppercase letters and vice versa.
Input : Accept single line containing a string .
Output: Print the modified string .
Exercise #4
Write a The program takes a string and replaces all occurrences of ‘a’
with ‘$’.
Input : Accept single line containing a string .
Output: Print the modified string .
Exercise #5