PF - Assignment
PF - Assignment
Exercise 2: Print the sum of the current number and the previous number.
Write a program to iterate the first 10 numbers, and in each iteration, print the sum of the current
and previous numbers.
Exercise 3: Print characters from a string that are present at an even index number
Write a program to accept a string from the user and display characters that are present at an
even index number.
For example, str = "pynative" so you should display ‘p’, ‘n’, ‘t’, ‘v’.
For example:
remove_chars("pynative", 4) so output must be tive. Here, we need to remove the first four
characters from a string.
remove_chars("pynative", 2) so output must be native. Here, we need to remove the first two
characters from a string.
Note: n must be less than the length of the string.
Exercise 5: Check if the first and last number of a list is the same.
Write a program to print “First and Last Numbers are same” if the first and last numbers of a
given list are the same. If the numbers are different then print “Not Same”.
Iterate the given list of numbers and print only those numbers which are divisible by 5
1
22
333
4444
55555
A palindrome number is a number that is the same after reverse. For example, 545, is the
palindrome numbers
Exercise 9: Create a new list from two list using the following condition
Create a new list from two list using the following condition
Given two list of numbers, write a program to create a new list such that the new list should
contain odd numbers from the first list and even numbers from the second list.
Exercise 10: Write a Program to extract each digit from an integer in the reverse order.
For example, If the given int is 7536, the output shall be “6 3 5 7“, with a space separating the
digits.