Python is used to print different patterns easily within less time as per the user requirement. In the same way, we can print the letter K using the alphabets available in the English language. Example In this example we will create the letter K by using the K alphabet. The below is the code. string="" j = 7 i = 0 for Row in range(0, 10): for Col in range(0, 10): if (Col == 1 or ((Row == Col ... Read More
Python helps us to develop code as per the developer requirement and application. It provides multiple modules, packages, functions and classes which makes the code more efficient. Using python language, we can check if a string contains any special character or not. There are several ways to check the string for the specials characters in it, let’s see one by one. Using a Regular Expression The re module in Python provides support for regular expressions, which are patterns used to match character combinations in strings. The regular expression pattern [^a−zA−Z0−9\s] matches any non−alphanumeric character (excluding whitespace) in the string. The ... Read More
A torch tensor defined on CPU can be moved to GPU and vice versa. For high-dimensional tensor computation, the GPU utilizes the power of parallel computing to reduce the compute time.High-dimensional tensors such as images are highly computation-intensive and takes too much time if run over the CPU. So, we need to move such tensors to GPU.SyntaxTo move a torch tensor from CPU to GPU, following syntax/es are used −Tensor.to("cuda:0") or Tensor.to(cuda)And, Tensor.cuda()To move a torch tensor from GPU to CPU, the following syntax/es are used −Tensor.to("cpu")And, Tensor.cpu()Let's take a couple of examples to demonstrate how a tensor can be ... Read More
To install the MSI file with PowerShell, we can use cmdlet Start-Process.Let say we want to install the 7ZIP MSI file on the local computer and we have downloaded and stored the source file on the C:\temp location. Once we run the below command it will start the MSI installation.Start-Process C:\Temp\7z1900-x64.msiThe above command will open the GUI to install the MSI file but we use PowerShell to avoid GUI interaction so we can add the argument to install the file.If you check which arguments are available to run the MSI file, use the below command.C:\Temp\7z1900-x64.msi /?It will popup box like ... Read More
Factors are the numbers we multiply to get another number.factors of 14 are 2 and 7, because 2 × 7 = 14.Some numbers can be factored in more than one way.16 can be factored as 1 × 16, 2 × 8, or 4 × 4.A number that can only be factored as 1 times itself is called a prime number.The first few primes are 2, 3, 5, 7, 11, and 13.The list of all the prime-number factors of a given number is the prime factors of a number. The factorization of a number into its prime factors and expression of ... Read More
The logic that we implement to convert Fahrenheit to Celsius is as follows −celsius = (fahrenheit - 32)*5/9;AlgorithmRefer to the algorithm given below to convert Fahrenheit to Celsius.Step 1: Declare two variables farh, cels Step 2: Enter Fahrenheit value at run time Step 3: Apply formula to convert Cels=(farh-32)*5/9; Step 4: Print celsExampleFollowing is the C program to convert Fahrenheit to Celsius − #include int main(){ float fahrenheit, celsius; //get the limit of fibonacci series printf("Enter Fahrenheit: "); scanf("%f",&fahrenheit); celsius = (fahrenheit - 32)*5/9; printf("Celsius: %f ", celsius); return 0; }OutputWhen the above program is executed, it produces the following result −Enter Fahrenheit: 100 Celsius: 37.777779
RSA is a cryptosystem for public-key encryption, and it is broadly used for securing sensitive information, specifically when being sent over an insecure network including the Internet.RSA algorithm is the most popular asymmetric key cryptographic algorithm depends on the mathematical fact that it is simply to discover and multiply large prime numbers but complex to factor their product. It needs both private and public key.Example of RSA AlgorithmLet us take an example of this procedure to learn the concepts. For ease of reading, it can write the example values along with the algorithm steps.Choose two large prime numbers P and ... Read More
A thread is a lightweight process that can be managed independently by a scheduler. It improves the application performance using parallelism.A thread shares information like data segment, code segment files etc. with its peer threads while it contains its own registers, stack, counter etc.The two main types of threads are user-level threads and kernel-level threads. A diagram that demonstrates these is as follows −User - Level ThreadsThe user-level threads are implemented by users and the kernel is not aware of the existence of these threads. It handles them as if they were single-threaded processes. User-level threads are small and much ... Read More
Instruction includes a set of operation codes and operands that manage with the operation codes. Instruction format supports the design of bits in an instruction. It contains fields including opcode, operands, and addressing mode.The instruction length is generally preserved in multiples of the character length, which is 8 bits. When the instruction length is permanent, several bits are assigned to opcode, operands, and addressing modes.The function of allocating bits in the instruction can be interpreted by considering the following elements −Number of addressing modesNumber of operandsNumber of CPU registersNumber of register setsNumber of address linesThe figure displayed the general IA-32 ... Read More
A synchronous motor is not inherently self-starting. Therefore, it requires some auxiliary means of starting. In order to start a synchronous motor, there are following two methods −Starting with an external prime moverStarting with damper windingsSynchronous Motor Starting with an External Prime MoverIn this method of starting a synchronous motor, an external motor is used to drive the synchronous motor as shown in Figure-1.The external motor brings the synchronous motor to synchronous speed and then the synchronous motor is synchronised with the AC supply as a synchronous generator. Then the prime mover (i.e., the external motor) is disconnected. Once synchronised, ... Read More