GithubHelp home page GithubHelp logo

assignment-1-functions-'s Introduction

assignment-1-Functions practice

1)Write a function fact accepting a number as parameter and returns factorial of a given number. 2)WAP to calculate and display binomial coefficient for the given values of n and r using function.[nCr = n!/r!(n-r)!]
3)Write a function to return addition, subtraction, multiplication and division of two numbers recieved as parameter from the calling function display the result. 4)Write a function that recieves a number as parameter and return one if it is a palindrome number otherwise return zero display the appropriate message. 5)Write a program to calculate and display power of base and exponent that is a raise to pwer b using user defined function. If the exponent is not passed by the user then the square of the given number should be calculated. Impliment the above program for both situations. 6)Write the output of the following :- def Convert(X=45,Y=30): X=X+Y
Y=X-Y
print(X,"&",Y) return X A=250 B=150 A=Convert(A,B) print(A,"&",B) B=Convert(B) print(A,"&",B) A=Convert(A) print(A,"&",B) 7) Write a function bsort() to sort a list of numbers in ascending order using bubble sort where the list is passed as parameter. WAP to input a list of numbers sort the list using function and display the result. 8) Write a function isort() to sort a list of numbers in ascending order using insertion sort where the list is passed as parameter. WAP to input a list of numbers sort the list using function and display the result.

                                                                 #assignment 1 functions
  1. Write a function sumseries( ) having two parameters X and n which returns the sum of following series given below :−−− Note : ے2 means factorial of number 2 1 _ X + X 2 _ X 3

6ے 4ے 2ے 2. XYZ store plans to give festival discount to its customers. The store management has decided to give discount on the following criteria: Shopping Amount Discount Offered

=500 and< 1000 5% =1000 and < 2000 8% =2000 10% An additional discount of 5% is given to customers who are the members of the store. Create a program using user defined function that accepts the shopping amount as a parameter and calculates discount and net amount payable on the basis of the following conditions: Net Payable Amount = Total Shopping Amount – Discount.

  1. Write a program using a user defined function that displays sum of first n natural numbers, where n is passed as an argument.
  2. Write a program using a user defined function myMean() to calculate the mean of floating values stored in a list.5. Write a program using a user defined function that accepts the first name and lastname as arguments, concatenate them to get full name and displays the output as: Hello full name
  3. Write a program that accepts numerator and denominator of a fractional number and calls a user defined function mixedFraction() when the fraction formed is not a proper fraction. The default value of denominator is 1. The function displays a mixed fraction only if the fraction formed by the parameters does not evaluate to a whole number.
  4. Write a program using user defined function that accepts length and breadth of a rectangle and returns the area and perimeter of the rectangle.
  5. Write a program with a user defined function to count the number of times a character (passed as argument) occurs in the given string.
  6. Write a program with a user defined function with string as a parameter which replaces all vowels in the string with '*'.
  7. Write a program which reverses a string passed as parameter and stores the reversed string in a new string. Use a user defined function for reversing the string.
  8. Write a program using a user defined function to check if a string is a palindrome or not. (A string is called palindrome if it reads same backwards as forward. For example, Kanak is a palindrome.)
  9. Write a program to read a list of n integers and find their median using user defined function which accepts list as parameter and returns median Note: The median value of a list of values is the middle one when they are arranged in order. If there are two middle values then take their average.
  10. Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements, i.e., all elements occurring multiple times in the list should appear only once. Use user defined function which accepts list as parameter Note : Do not use other list .
  11. Write a user defined function that receives two string arguments and checks whether they are same length strings ; returns True if same in length else returns False
  12. Write a user defined function that takes two numbers and returns the number that has minimum one’s digit. e.g. if number passed are 491 and 278 the function will return 491 because it has got minimum one’s digit out of two given numbers(491’s 1 is < 278’s 8)
  13. Write a user defined function arrangelements(X),that accepts a list X of integers and sets all the negative elements to the left and all positive elements to the right of the list. Eg: if L =[1,-2,3,4,-5,7] , the output should be: [-2,-5,1,3,4,7]
  14. Write a method in python to display the elements of list thrice if it is a number and display the element terminated with '#' if it is not a number. For example, if the content of list is as follows: ThisList=['41','DROND','GIRIRAJ','13','ZARA'] 414141 DROND# GIRlRAJ# 131313 ZARA#

assignment-1-functions-'s People

Contributors

rpj09 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.