coderz.py

Keep Coding Keep Cheering!

Iterable and Iterator in Python

What is an Iterable? In Python, an iterable is an object that can be looped over, such as a list, tuple, or string. An iterator is an object that represents a stream of data, and it can be used to traverse through all the elements of an iterable. The built-in function iter() can be used […]

January 12, 2023 | python | No comments

Loops in Python

There may be times when you need to execute a block of code several times. A loop statement allows us to repeat a statement or group of statements. To handle looping requirements, the Python programming language provides the following types of loops. for loop: Sequential traversal is accomplished with for loops. This loop repeats a […]

December 5, 2022 | python | No comments

Iterate over a list in Python

In Python, there are several different ways to iterate through a list. Let’s examine every method for iterating over a list in Python and compare their performance. Using For loop: The “for” loop in Python is a way to run a repetitive block of code traversing over a sequence of any kind. For instance, Output: […]

November 26, 2022 | python | No comments

Convert Decimal to Binary

Given a decimal number as input, we need to write a program to convert the given decimal number into an equivalent binary number. Examples:  Algorithm for Converting Decimal to Binary: Step 1: Divide the number by 2 and store the remainder in an array (modulus operator). Step 2: Divide the number by 2 using the […]

November 17, 2022 | C++ | No comments

Pattern Program Using Star

 C++ implementation for pattern printing. Pattern 1: Program code: Output: Pattern 2: Program code: Output: Pattern 3: Program code: Output: Pattern 4: Program code: Output: Note: also read about Sum Of Series 1 + 2 + 4 + 8 + 16 + 32 + . . n Follow Me Please follow me to read my latest […]

November 7, 2022 | C++ | No comments

Sum Of Series 1 + 1 / 2 ^ 2 +. . . . 1 / n ^ n

A program to compute the sum of a given series 1 + 1/2^2 + 1/3^3 + …..+ 1/n^n. For this, we will be given the value of n, and our task will be to add up each term, beginning with the first, to find the sum of the given series. Program code: Output: Note: also […]

November 5, 2022 | C++ | No comments

Loops in C++

In C++ programming language, the repetitive operation is done through loop control instruction. There are three methods by which we can repeat a part of a program.  Types of Loops: Entry Controlled Loops: The test condition is tested before entering the loop body in this type of loop. Entry-controlled loops are For Loop and While […]

September 28, 2022 | C++ | No comments

Jump Statements

The jump statements unconditionally transfer program control within a function. Java has three statements that perform an unconditional branch: return break continue Of these, you may use return anywhere in the program, whereas break and continue are used inside the smallest enclosing like loops, etc. The break statement: A break statement skips the rest of […]

May 6, 2022 | Java | No comments

More about loops

Multiple initialization and update Expression: A for loop may contain multiple initialization and/or multiple update expression. Optional Expression: All the three expressions of the for loop are optional. Infinite Loop: An infinite loop is an endless loop which can be created by omitting the test-expression. Empty Loop: This is also known as a time delay […]

May 6, 2022 | Java | No comments

Iteration Statements(Loops)

The iteration statements allow a set of instructions to be performed repeatedly until a certain condition is fulfilled. The iteration statements are also called loops or looping statements. Java provides three kinds of loops: for loop, while loop, and do-while loop. All three loop constructs of Java repeat a set of statements as long as […]

May 4, 2022 | Java | No comments

Advertisement