coderz.py

Keep Coding Keep Cheering!

Find the Reverse of a Number

When a number is reversed, the digits are rearranged in reverse order, starting with the last digit, then the second-to-last digit, and so on, with the first digit appearing last. Program Code: Output: Note: also read about Armstrong Number in C++ Follow Me Please follow me to read my latest post on programming and technology if you […]

November 27, 2022 | C++ | 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

Python Lists

As we have already seen in Data Types in Python that Python Lists are just like dynamically sized arrays, declared in other languages (vector in C++ and ArrayList in Java). Let us take a look at them in a more detailed way. Characteristics of Lists: The list has the following characteristics: The lists are ordered. The list’s […]

November 25, 2022 | python | No comments

String Functions – II

Table of Python String Methods. Function Name  Description capitalize() The string’s first character is changed to an uppercase (capital) letter. casefold() Implements caseless string matching center() Add the requested character to the string as padding. count() Returns the number of occurrences of a substring in the string. encode() Encodes strings with the specified encoding scheme […]

November 24, 2022 | python | No comments

String Functions in Python

Built-in String Functions: Many functions are built into the Python interpreter and are always available. You’ll see a few that work with strings and character data in this lesson: Note: Every string method returns a new string with the modified attributes rather than altering the original string. Following are some of the commonly used string functions: […]

November 24, 2022 | python | No comments

Strings in Python

A Python string is a collection of characters enclosed by single, double, or triple quotes. The string is an immutable sequence data type. The computer does not understand the characters; instead, it stores the manipulated character as a combination of 0’s and 1’s internally. Each character is encoded in either ASCII or Unicode. As a […]

November 23, 2022 | python | No comments

Armstrong Number in C++

What is Armstrong Number? The Armstrong number is a number that is equal to the sum of its digits’ cubes. Armstrong numbers include 0, 1, 153, 370, 371, and 407. Let’s look at why 371 is amrstrong in nature: Approach: The approach is to first count the number of digits (or find the order). Let […]

November 23, 2022 | C++ | No comments

Factorial of a given Number

What is Factorial of a number? The product of all positive descending integers is the factorial of n. n! represents the factorial of n. As an example: 4! is pronounced “4 factorial” in this context, and it is also known as “4 bang” or “4 shriek.” The factorial is typically used in Combinations and Permutations […]

November 23, 2022 | C++ | No comments

Data Types in Python

The classification or categorization of data items is referred to as data types. It represents the type of value that specifies which operations can be performed on a given piece of data. Because everything in Python programming is an object, data types are classes, and variables are instances (objects) of these classes. The data types […]

November 21, 2022 | python | No comments

Program to Find GCD

The largest number that divides two or more numbers is the Greatest Common Divisor (GCD) for those numbers. For example: Let’s say we have two numbers 45 and 27. So, the GCD of 95 and 30 is 5. Program Code: Output: gcd() is a recursive function in the preceding program. It contains two parameters, a […]

November 20, 2022 | C++ | No comments

Advertisement