avatarKaushik Katari

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

936

Abstract

Python.</p><p id="f920">By simply writing</p><p id="540d">x,y = y,x</p><p id="c32a">we can easily swap the integers.</p><figure id="74f1"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*gFCKqW7PQ14LPo78uqW-JQ.jpeg"><figcaption><b>. . . . . .</b></figcaption></figure><p id="7832"><b>2. Factorial:</b></p><p id="274d"><i>A factorial is calculated for integers greater than or equal to zero and is defined as:</i></p><p id="8f0f">n!=1×2×3×4×5…×n</p><figure id="0f2c"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*4fjBxhib1KelZOfs-v-LGg.jpeg"><figcaption>. . . . . .</figcaption></figure><p id="7ba7">Don’t forget to handle the cases for inputs < 0 and ==0.</p><p id="324d"><b>3. Reverse Digits:</b></p><p id="84aa">Given a number, reverse the number.</p><p id="7bd7">For example:</p><p id="715d">number = 12345</p><p id="def2">output = 54321</p><figure id="142f"><img src="https://cdn-images-1.read

Options

medium.com/v2/resize:fit:800/1*kWxNqAUDEZrFbjcNgbNPgg.jpeg"><figcaption>. . . . . .</figcaption></figure><p id="7a05"><b>4. Pattern Printing:</b></p><p id="490c">If anyone wants to master loop iterations, Pattern Printing is the best example.</p><p id="e067">Following is the pattern which needs to be printed.</p><figure id="319c"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*WAsMXTTJxOGelyWeXhAqLw.jpeg"><figcaption></figcaption></figure><figure id="5284"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*B_VZJPcQG5vVniOmVQFvBw.jpeg"><figcaption>. . . . . .</figcaption></figure><h1 id="d83e">Conclusion:</h1><p id="b384">These are some of the Basic concepts, which needs to be mastered before proceeding to high level concepts in Python.</p><p id="d273">There are some more concepts, which I will share in the coming week.</p><p id="4a74">Thanks for reading and Happy Coding.</p></article></body>

Python: Problems for Basics Reference — Swapping, Factorial, Reverse Digits, Pattern Print

I started learning Python in the last 6 months. But every time I learn any new concept in Python, I invariably refer to some of the basic problems which I’ve done while learning.

I’m just sharing those concepts with you guys, who are in similar situation or for whom, wants to learn basic concepts.

  1. Swapping:

You are given two integer variables, x and y. You have to swap the values stored in x and y. Without using 3rd variable.

Swapping two integers by using 3rd variable is easy. But without 3rd variable you can directly swap the integers in Python.

By simply writing

x,y = y,x

we can easily swap the integers.

. . . . . .

2. Factorial:

A factorial is calculated for integers greater than or equal to zero and is defined as:

n!=1×2×3×4×5…×n

. . . . . .

Don’t forget to handle the cases for inputs < 0 and ==0.

3. Reverse Digits:

Given a number, reverse the number.

For example:

number = 12345

output = 54321

. . . . . .

4. Pattern Printing:

If anyone wants to master loop iterations, Pattern Printing is the best example.

Following is the pattern which needs to be printed.

. . . . . .

Conclusion:

These are some of the Basic concepts, which needs to be mastered before proceeding to high level concepts in Python.

There are some more concepts, which I will share in the coming week.

Thanks for reading and Happy Coding.

Python
Swapping
Factorials
Reverse Digits
Patterns
Recommended from ReadMedium