Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

You must login to add post.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

mcqoptions.com

mcqoptions.com Logo mcqoptions.com Logo

mcqoptions.com Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 418985
Next
In Process
Jamshed Dani
Jamshed Dani
Asked: 3 years ago2022-11-11T07:57:24+05:30 2022-11-11T07:57:24+05:30In: General Awareness

Explain cmp(tuplel, tuple2) with example.

Explain cmp(tuplel, tuple2) with example.
Parabola
  • 0
  • 11
  • 0
  • 0
  • 0
    • Report
  • Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
    • Share on WhatsApp
Leave an answer

Leave an answer
Cancel reply

Browse

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 12fe4
    2022-11-09T02:49:29+05:30Added an answer about 3 years ago

    cmp(tuple1, tuple2)

    Despription :

    The method cmp( ) compares elements of two tuples.

    Syntax :

    Following is the syntax for cmp( ) method :

    cmp (tuplel, tuple2)

    Parameters :

     tuple 1 – This is the first tuple to be compared

     tuple 2 – This is the second tuple to be compared

    Return Value :

    If elements are of the same type, perform the compare and return the

    result. If elements are different types, check to see if they are numbers.

     If numbers, perform numeric conversion if necessary and compare.

     If either element is a number, then the other element is “larger” (numbers

    are “smallest”).

     Otherwise, types are sorted alphabetically by name.

    If we reached the end of one of the tuples, the longer tuple is “larger”. If we

    exhaust both tuples and share the same data, the result is a tie, meaning that 0 is

    returned.

    Example :

    The following example shows the usage of cmp( ) method

    #!/user/bin/python

    tuple1, tuple2 = (123, ‘xyz’), (456, ‘abc’)

    print cmp(tuple1, tuple2);

    print cmp(tuple1, tuple1);

    tuple3 = tuple2 + (786,);

    print cmp (tuple2, tuple3)

    Let us compile and run the above program, this will produce the following result :

    -1

    1

    -1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
Aniruddh Das
Aniruddh Das
Asked: 3 years ago2022-10-30T06:50:01+05:30 2022-10-30T06:50:01+05:30In: General Awareness

Explain cmp(tuplel, tuple2) with example.

Explain cmp(tuplel, tuple2) with example.

Parabola
  • 0
  • 11
  • 0
  • 0
  • 0
    • Report
  • Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
    • Share on WhatsApp
Leave an answer

Leave an answer
Cancel reply

Browse

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 12742
    2022-11-11T03:16:20+05:30Added an answer about 3 years ago

    cmp(tuple1, tuple2) 

    Despription : 

    The method cmp( ) compares elements of two tuples. 

    Syntax :

    Following is the syntax for 

    cmp( ) method : cmp (tuplel, tuple2) 

    Parameters :

     tuple 1 – This is the first tuple to be compared 

    tuple 2 – This is the second tuple to be compared 

    Return Value : 

    If elements are of the same type, perform the compare and return the result. If elements are different types, check to see if they are numbers. 

    If numbers, perform numeric conversion if necessary and compare. 

    If either element is a number, then the other element is “larger” (numbers are “smallest”). 

    Otherwise, types are sorted alphabetically by name.

    If we reached the end of one of the tuples, the longer tuple is “larger”. If we exhaust both tuples and share the same data, the result is a tie, meaning that 0 is returned.

    Example :

    The following example shows the usage of cmp( ) method

    #!/user/bin/python tuple1, tuple2 = (123, ‘xyz’), (456, ‘abc’) 

    print cmp(tuple1, tuple2); 

    print cmp(tuple1, tuple1); 

    tuple3 = tuple2 + (786,); 

    print cmp (tuple2, tuple3)

    Let us compile and run the above program, this will produce the following result :

     -1 

    1 

    -1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 393k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Aditi Dugal

    How to approach applying for a job at a company ...

    • 7 Answers
  • Raghavan Prasad Hayer

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Ankita Dinesh Biswas

    What is a programmer’s life like?

    • 5 Answers
  • 47e0c
    47e0c added an answer Correct Answer - Increasing the yield of animals and improving… November 12, 2022 at 9:56 am
  • b6699
    b6699 added an answer Sender\'s addressDateReceivers name and addressSubjectContentYours faithfullyName November 12, 2022 at 9:56 am
  • 10eb8
    10eb8 added an answer Any uncertinity in measurment is known as errorDifference in true… November 12, 2022 at 9:56 am

Related Questions

  • The units of length, velocity and force are doubled. Which ...

    • 1 Answer
  • The penetration of light into the region of geometrical shadow ...

    • 1 Answer
  • if ` veca , vecb ,vecc ` are three vectors ...

    • 1 Answer
  • What is the value of isothermal bulk modulus of elasticity ...

    • 1 Answer
  • निम्न में से किस अणु का सेवाधिक द्विध्रुव आघूर्ण है ...

    • 1 Answer

Top Members

Trending Tags

Class 11 Parabola Polity Polynomials Probability Projectile Protists Quadrilaterals Rario Reasoning Sampling Social Solutions Spectroscopy Switchgear Thermodynamic Tourism Transients Upsc Wbjee

Explore

  • Home
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Tags
  • Badges
  • Users

Footer

mcqoptions.com

About

MCQOptions.com

Here are the top interview questions, example answers, tips for giving the best response.

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Follow

© 2022 MCQOptions. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.