0% found this document useful (0 votes)
33 views2 pages

PF - Assignment

Uploaded by

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

PF - Assignment

Uploaded by

mf2744805
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PF: Assignment

Exercise 1: Calculate the multiplication and sum of two numbers.


Given two integer numbers, return their product only if the product is equal to or lower than
1000. Otherwise, return their sum.

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’.

Exercise 4: Remove first n characters from a string


Write a program to remove characters from a string starting from zero up to n and return a new
string.

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”.

Exercise 6: Display numbers divisible by 5 from a list.

Iterate the given list of numbers and print only those numbers which are divisible by 5

Exercise 7: Print the following pattern.

1
22
333
4444
55555

Exercise 8: Check Palindrome Number

Write a program to check if the given number is a palindrome number.

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.

You might also like