Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

The opacity property defines the transparency of an element. The opacity takes value from 0.0 to 1.0.
To include opacity in the image include
img {
opacity 0.4
}
to your stylesheet.

To make any text or other element transparent use
div {
opacity 0.6
}

Transparency can be added using RGBA. Use
div {
background : rgba(76, 175, 80, 0.7)
}
3 years ago
Sometimes we need a delay between the execution of two instructions. Python has inbuild support for putting the program to sleep. The time module has a function sleep(). Here is an example to use sleep().
***
import time
print("hello")
time.sleep(1.2) # sleep for 10=.2 sec
print("world)
***

For adding time delay in the loop
***
import time
text="hello world"
for i in text:
print(i)
time.sleep(5)
***
Using asyncio.sleep() function
***
import asyncio
print("Hello world")

async def display():
await asyncio.sleep(5)
print("Time sleep added")
asyncio.run(display)
***
*Using Timer*
***
from threading import Timer

print('Hello world')

def display():
print('Timer used')

t = Timer(5, display)
t.start()
***
3 years ago
A pointer variable in C++ holds the memory address of a variable whereas a reference variable is an alias, that is an original variable with another name.
A pointer can be initialized with NULL values whereas a reference cannot have a NULL value.
A pointer has its own memory address whereas a reference has the same address as the original value.
*Example*
// pointer
int x=5;
int *p;
p=&x;

//reference
int x=5;
int &r=x
3 years ago
*malloc()* and *Calloc()* both are used for dynamic memory allocations. The difference between malloc() and calloc() are :
malloc() takes a single argument that is the number of bytes where as calloc() takes two arguments, the number of blocks, and the size of the block.
malloc() does not initialize memory whereas calloc() initializes allocated memory to zero.
malloc() is faster than calloc().
3 years ago
++i and i++ both are unary operators used for incrementing value by one. ++i is called a pre-increment operator as it first increments the value and then it assigns to variable whereas i++ is a post-increment operator which first assigns the value to the variable and then it increments the value.
***
#include
int main()
{
int i ,j ,x,z;
i=10;
j=10;
x=++i; //pre-increment
z=j++; //post increment
printf("the result = %d ",x);
printf("the result = %d ",z);
return 0;
}
***
Run this program and you will find that x has been assigned incremented value whereas z has been assigned the original value.
For loop, pre-increment can be preferred as it takes less time for internal computation.
But in case if you are using the previous value then use the post-increment operator.
3 years ago