- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 448 Articles for Programming Scripts
93 Views
The Number.MAX_SAFE_INTEGER property of the Number object represents the maximum safe integer in JavaScript (i.e. 253 - 1).SyntaxIts Syntax is as followsNumber.MAX_SAFE_INTEGERExample Live Demo JavaScript Example var result = Number.MAX_SAFE_INTEGER; document.write("Maximum safe integer: " + result); OutputMaximum safe integer: 9007199254740991
588 Views
To reduce concurrency issues in C#, use the volatile keyword. Let us seen an example.The following is how you use a volatile keyword for public variable −class Program { public volatile int a; public void Program(int _a) { i = _i; } }Let us see another example: We have two static variables. Set them in a new method −_out = "Welcome!"; _new = true;We declared them as static before using volatile −static string _out; static volatile bool new;Now you need to run the method on a thread −new Thread(new ThreadStart(volatileFunc)).Start();Read the value of the ... Read More
134 Views
Adding an element to an array can be done using different functions for different positions.Adding an element at the end of the arrayThis can be accomplished using the push method. For example, let veggies = ["Onion", "Raddish"]; veggies.push("Cabbage"); console.log(veggies);This will give the output −["Onion", "Raddish", "Cabbage"]You can also use this to push multiple items at the same time as it supports a variable number ofarguments. For example, let veggies = ["Onion", "Raddish"]; veggies.push("Cabbage", "Carrot", "Broccoli"); console.log(veggies);This will give the output −["Onion", "Raddish", "Cabbage", "Carrot", "Broccoli"]Adding an element at the start of the arrayThis can be accomplished using the unshift method. ... Read More
9K+ Views
You can assign a dictionary value to a variable in Python using the access operator []. For example,Examplemy_dict = { 'foo': 42, 'bar': 12.5 } new_var = my_dict['foo'] print(new_var)OutputThis will give the output −42This syntax can also be used to reassign the value associated with this key. For example,Examplemy_dict = { 'foo': 42, 'bar': 12.5 } my_dict['foo'] = "Hello" print(my_dict['foo'])OutputThis will give the output −Hello
4K+ Views
You can combine multiple print statements per line using, in Python 2 and use the end argument to print function in Python 3.examplePython2.x print "Hello", print " world" Python3.x print ("Hello", end='') print (" world")OutputThis will give the output −Hello worldAnother thing you could do is put all the things in an array and call ''.join(array). examplearr = ["Hello", "world"] print(' '.join(arr))OutputThis will give the output −Hello world
501 Views
You can use the PEP8 guide as a holy grail. Almost all python world uses this guide to write clean understandable and standard python code. This is available as an extension as a linter for all modern text editors. You can check it out at http://www.python.org/dev/peps/pep-0008/Properly Structure your folders. All projects need proper structuring. This helps organize code better. Python has an opinionated folder structure that you should use.README.rst LICENSE setup.py requirements.txt sample/__init__.py sample/core.py sample/helpers.py docs/conf.py docs/index.rst tests/test_basic.py tests/test_advanced.pyUse doctests. The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to ... Read More
2K+ Views
We can print multiple blank lines in python by using the character the number of times we need a blank line. For example, If you need 5 blank lines, you can use −Python 2.x: print "" Python 3.x: print("")You can use features like repetition operator in python to make this easier. For example,Python 2.x: print "" * 5 Python 3.x: print("" * 5)All of these commands will print 5 blank lines on the STDOUT.
945 Views
HTML5 enabled browsers to have a video element that you can use to play a video on your site. To let you know, flowplayer and other flash based video streaming players use the FLV format. It has the same encoding as H.264. FFMPEG can convert videos to FLV, feel free to work it with flowplayer. Use the flvtool2 for reading and writing FLV metadata from and to the file. Use the tools to create your videos and stream them through flowplayer.
122 Views
Web Sockets is a next-generation bidirectional communication technology for web applications that operates over a single socket and is exposed via a JavaScript interface in HTML 5 compliant browsers. Once you get a Web Socket connection with the web server, you can send data from browser to server by calling a send() method, and receive data from server to browser by an onmessage event handler.Two way communication between the browsing contexts is called channel messaging. It is useful for communication across multiple origins.While creating messageChannel, it internally creates two ports to sending the data and forwarded to another browsing context. ... Read More