Found 27104 Articles for Server Side Programming

Draw a Tic Tac Toe Board Using Python – Turtle

Utkarsha Nathani
Updated on 11-Oct-2023 15:22:58

581 Views

The wide range of libraries and tools makes python a popular and widely used programming language. One of the library which we will use in this article to complete the task of drawing a tic tac toe is Turtle. This library helps in creating graphics by using a virtual turtle. The commands are given to the virtual turtle on the window. In this article, we will use simple functions of the turtle library to draw the tic tac toe. What is Tic Tac Toe Board? Tic tac toe is a popular game, played on a 3*3 grid board. The ... Read More

Draw a Sun Using Arcade Library Python

Utkarsha Nathani
Updated on 13-Sep-2023 11:21:01

263 Views

Python is a highly multipurpose programming language with a vast network of libraries and frameworks that has capabilities beyond the standard language features. Arcade is one of the libraries used for creating graphics and handling user input. It uses basic shapes like circles and lines, a gradient approach, and many other techniques for creating attractive graphics. In this article, we will learn different methods for drawing a sun using the Arcade library in Python. Arcade Library and Its Features Arcade library is a Python library built on top of Pyglet, a multimedia library for python. It is a python library ... Read More

Tech number in Swift

Ankita Saini
Updated on 08-Sep-2023 15:59:09

94 Views

If the given number contains an even number of digits and the digits of the number can be divided into two equal parts from the middle. After dividing the digits sum up the divided digits and find the square of the final sum. If the square is equal to the sum itself then the given number is a tech number otherwise not. Example Demonstration Input 3025 Output Yes the given number is a tech number Input 2341 Output No the given number is not a tech number Here, 3025 is a ... Read More

Swift Program to Print Floyd’s Triangle

Ankita Saini
Updated on 08-Sep-2023 15:56:06

141 Views

Floyd triangle is right angle triangled which is named after Rober Floyd. It is created with the help of natural numbers starting from 1 in the top left corner and then the consecutive numbers are filled in the specified rows. Example Demonstration Input 4 Output 1 2 3 4 5 6 7 8 9 10 Here, the size of Floyd’s triangle is 4. So it will print Floyd’s triangle until 4 rows. In Swift, we can print Floyd’s triangle using the following methods: Using for−in loop Using while loop Using recursive function Algorithm ... Read More

How to Write Calculator Program using Switch Case in Swift

Ankita Saini
Updated on 08-Sep-2023 15:51:06

492 Views

A Calculator is an electronic device which is used to perform different types of mathematical operations like subtraction, addition, division, multiplication, etc. We can also create a calculator using Switch case and simple arithmetic operations in Swift programming. It will also perform the same mathematical operations as the original calculator. Example Demonstration Enter any two numbers: Number 1: 43 Number 2: 234 SIMPLE CALCULATOR 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Percentage Choose (1/2/3/4/5): 2 Result = -191.0 Here, we first enter the numbers on which we want to perform the ... Read More

How to Swap Pair of Characters in Swift?

Ankita Saini
Updated on 08-Sep-2023 15:35:03

216 Views

Swapping pair of characters is a process of interchanging the position of two characters in the given string. This operation is commonly used in various programming languages and applications to manipulate data. Example Input “mumbai” Output umbmia Input “Prita” Output rPtia Here, we divide the given string into a pair of characters like “mumbai”: “mu”, “mb”, “ai”. Now we swap the positions of the characters: “um”, “bm”, and “ia” and create the resultant string: “umbmia”. Similarly for input 2. In Swift, we can swap the pair of characters present in the given ... Read More

How to Calculate the Volume of a Tetrahedron in Swift?

Ankita Saini
Updated on 08-Sep-2023 15:30:27

58 Views

Tetrahedron is a triangular base pyramid. It is a platonic solid with four triangular faces, six straight edges and four vertex corners. Where each vertex is connected with every other vertex and each face is of an equilateral triangle. In Swift, we can calculate the volume of a tetrahedron using the following formula: Formula $$\mathrm{Area=(x*x*x*\sqrt{2})/12}$$ Here, x represents the sides of the tetrahedron. Algorithm Step 1 − Create a function which takes the side of the tetrahedron as a parameter and returns the volume. Step 2 − Inside the function, we use the mathematical formula to find the volume ... Read More

How to Calculate the Value of nPr in Swift?

Ankita Saini
Updated on 08-Sep-2023 18:37:42

72 Views

nPr is known as n permutation r, where n represents the total numbers and r represents the arrangement of the elements. A permutation is known as the arrangement of elements in a specified order. Elements can arrange either in a sequence or in a linear order, for example, we have a set of elements [2, 4], so the permutation is: [4, 2], [2, 4]. In permutation the order of elements matters whereas in combination the order of the elements does not matters. We can calculate the value of nPr with the help of the following formula: Formula nPr = ... Read More

How to Calculate the Area of a Tetrahedron in Swift?

Ankita Saini
Updated on 08-Sep-2023 15:04:47

44 Views

Tetrahedron is a 3−D triangular pyramid shape whose base is also a triangle. Generally, a tetrahedron contains four equilateral triangles, hence it has interior angles of 60 degrees. In Swift, we can calculate the area of a tetrahedron using the following formula: Formula $$\mathrm{Area=\sqrt{3}*X*X}$$ Here, x represents the side of the tetrahedron. If you wish to find the area of one side of a tetrahedron then you can use the following formula: Formula $$\mathrm{Area\:of\:one\:side\:of\:tetrahedron =(\sqrt{3}*y*y)/4}$$ Here, y represents the side of the tetrahedron. Algorithm Step 1 − Create a function which takes the side of the tetrahedron ... Read More

Golang Program to Iterate Map Elements using the Range

Akhil Sharma
Updated on 07-Sep-2023 17:15:48

309 Views

Maps in Golang provide a convenient way to store and access the given data in format of key−value pairs. Iterating over a map allows us to process each key−value pair and perform operations on them. In this article, we will explore different methods to iterate map elements using the range, that includes using the range keyword, using keys and values slices, and using the reflect package. Syntax for key, value := range mapName { // Perform operations on key-value pair } This syntax uses the range keyword to iterate over the elements of ... Read More

Advertisements