UrbanPro

Learn Python Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How do I do this in Python: for (I=0, j=n; I=0; I++, j--)?

Asked by Last Modified  

Follow 1
Answer

Please enter your answer

Enhance your skill set with quick courses in 'python', 'javascript' & 'sap ui5 / fiori / abap'

There may be a typo in the question. however this could be the corrected question..... for (I=0, j=n; I<n; I++, j--) >>> # for (I=0, j=n; I<n; I++, j--)>>> j=n=10 # we initialize 'n' and 'j'>>> # i<10 is the terminating condition, so we loop 'n' times. >>>...
read more

There may be a typo in the question. however this could be the corrected question.....

for (I=0, j=n; I<n; I++, j--)

 

>>> # for (I=0, j=n; I<n; I++, j--)
>>> j=n=10    # we initialize 'n' and 'j'
>>> # i<10 is the terminating condition, so we loop 'n' times. 
>>> for i in range(n):
              #in your case you are incrementing i by 1 repeatedly
              #and in the end i==n. j will be decremented by 1, n times.
              #In Python, we simulate the 'for' loop with range() and the the Range object will have a
              #sequence of int objects from 0 to 9. (ie.n-1). The 'for' construct will iterate thru the 
              #Range object according to its size and stop,after which it will execute the 'else' block. 
              #In Python, 'else' is an independent construct that can be used when ever a condition is checked.
              #'else' will execute when a condition is 'False'. We initialize 'n' and 'j' outside the 'for' construct.
              #The range() will construct a Range object of ints from 0 to n. All we need to do is decrement j.
              #On successful completion of the 'for', the 'else' will execute. Here, we add 1 to 'i' to make i==n.

              j-=1
else:
              i+=1
              print('i= ',i,'\n','j= ',j)


i= 10 
j= 0
>>>

read less
Comments

Related Questions

Hi, I am pursuing MBA 1st Year. I want to learn Digital Marketing. Is it right for career growth, or should I choose to learn some other technologies? If yes, please give me your suggestions that help me to get a JOB in the IT Sector.
Hi Sai, To find right career path you need to try things ( Which is long way). I would suggest you to learn multiple things ( implementation is important part) and then find your intrest and dive in to...
Sai
Can I build iPhone apps using Python?
Yes, you can use PyMob app where apps can be written purely in Python, and the compiler tool flow converts them in native source codes for various platforms. But there are some cons on using PyMob, the...
Sunil
0 0
5

How do apprach to an unknown problem to construct its solution? Especially when do you face any programming challenge.

First approach your teacher or tutor about problem statement and ask for solution to get it solved.. Next practise similar kind of things by using other books or google or youtube help... If you u facing any challenges...
Tanmoy Gupta
0 0
8
Is Python an easy language to learn?
While Python is considered one of the easiest programming languages for a beginner to learn, it can be hard to master. Anyone can learn Python if they work hard enough at it, but becoming a Python Developer...
Hariprasad
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Python programming - Applications
If you’re thinking of learning Python? Or if you recently started learning it? You may be asking yourself: "What exactly can I use Python for?" There are so many applications for python, but there...

Why Python
Python can be used in any futuristics technology A= Analytics Data Science Artificial Intelligence(AI) Neural Network(NN) Natural Language Processing(NLP) Computer Vision(OpenCV) In Analytics...

map function in python
The function map takes a function and an iterable as arguments and returns a new iterable with the function applied to each argument. Example: def add_five(x): return x+5 nums = result = list(map(add_five,...

Back Reference In Python Regex
What if your interviewer asks about this? We know Regex have some useful functions like: match ( Ex: re.match(pattern,dataSource) ) search ( Ex: re.search(pattern,dataSource) ) sub ...

Learn Python : Slicing out an email address
We take a small task of slicing out the username and domain name from an email address. We ask the user to type his email address. We take his email address and slice out first his username and then the...
B

Biswanath Banerjee

0 0
0

Recommended Articles

Python is one of the most popular programming languages in the world. It is general-purpose, object oriented, high-level programming language used in a number of programming fields. Python is a great programming language to learn as it will introduce you to the world of programming. If you are from the technical background...

Read full article >

Applications engineering is a hot trend in the current IT market.  An applications engineer is responsible for designing and application of technology products relating to various aspects of computing. To accomplish this, he/she has to work collaboratively with the company’s manufacturing, marketing, sales, and customer...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Looking for Python Training classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Python Training Classes?

The best tutors for Python Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Python Training with the Best Tutors

The best Tutors for Python Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more