Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

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

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

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

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

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:01:03+00:00 2026-06-12T13:01:03+00:00

Can anybody explain me the following code. I did not understand what % does.

  • 0

Can anybody explain me the following code. I did not understand what % does. As I know it returns remainder, but I did not get the output i was expecting. What is remainder itself? can you please explain output step by step.

for num in range(20):
    if num % 4 == 0:
        print num 
    if num % 16 == 0:
        print('XYZ')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:01:04+00:00Added an answer on June 12, 2026 at 1:01 pm

    That operator is called the modulus operator, and what it does is, basically, continues subtracting the right hand side from the left hand side until it can’t go any more (So, subtracting again would make the result negative). The number that’s left at the point it cannot subtract anymore is called the remainder.

    It’s like doing division, but throwing away the quotient.

    Try running the code:

     for i in xrange(10):
          print str(i) + " : " + str((i % 2))
    

    See the pattern?

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

Sidebar

Related Questions

can anybody explain why the following bash code involving compound operators is not behaving
I wanted to know if anybody can explain me the following piece of Javascript
Can anybody explain what does JdClient is in this code: public JdClient client =
Can anybody explain the working of following code...? interface myInterface{} public class Main {
I know that string is immutable and StringBuilder is mutable. But can anybody explain
Can anybody explain the following Perl code for me, please? I think its in
I have a problem with the following statement trace(10.12+13.75) //output 23.869999999999997 Can anybody explain
Was just wondering if anybody can look at the following code and explain to
Can anybody explain me why below code is working on private member variable? public
Can anybody explain the difference between cerr cout and clog and why does different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.