Tutorial by Examples: c

A module is a file containing Python definitions and statements. Function is a piece of code which execute some logic. >>> pow(2,3) #8 To check the built in function in python we can use dir(). If called without an argument, return the names in the current scope. Else, return an alph...
Just execute lsb_release -a. On Debian: $ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux testing (stretch) Release: testing Codename: stretch On Ubuntu: $ lsb_release -a No LSB modules are available. Distributor ID: Ubun...
The most common way to create a Symbol object is by prefixing the string identifier with a colon: :a_symbol # => :a_symbol :a_symbol.class # => Symbol Here are some alternative ways to define a Symbol, in combination with a String literal: :"a_symbol" "a_symbol&quot...
Given a String: s = "something" there are several ways to convert it to a Symbol: s.to_sym # => :something :"#{s}" # => :something
Given a Symbol: s = :something The simplest way to convert it to a String is by using the Symbol#to_s method: s.to_s # => "something" Another way to do it is by using the Symbol#id2name method which is an alias for the Symbol#to_s method. But it's a method that is unique to the...
UIAlertView and UIActionSheet are Deprecated in iOS 8 and Later. So Apple introduced a new controller for AlertView and ActionSheet called UIAlertController , changing the preferredStyle, you can switch between AlertView and ActionSheet. There is no delegate method for it because all button events a...
NSDictionary *inventory = @{ @"Mercedes-Benz SLK250" : @(13), @"BMW M3 Coupe" : @(self.BMWM3CoupeInventory.count), @"Last Updated" : @"Jul 21, 2016", @"Next Update" : self.nextInventoryUpdateString };
NSDictionary *inventory = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:13], @"Mercedes-Benz SLK250", [NSNumber numberWithInt:22], @"Mercedes-Benz E350", [NSNumber numberWithInt:19], @"BMW M3 Coupe", [NSNumber numberWithInt:16],...
If a code module does not contain Option Explicit at the top of the module, then the compiler will automatically (that is, "implicitly") create variables for you when you use them. They will default to variable type Variant. Public Sub ExampleDeclaration() someVariable = 10 ...
If you have a value that never changes in your application, you can define a named constant and use it in place of a literal value. You can use Const only at module or procedure level. This means the declaration context for a variable must be a class, structure, module, procedure, or block, and can...
The Dim statement should be reserved for local variables. At module-level, prefer explicit access modifiers: Private for private fields, which can only be accessed within the module they're declared in. Public for public fields and global variables, which can be accessed by any calling code. Fr...
You can open the VB editor in any of the Microsoft Office applications by pressing Alt+F11 or going to the Developer tab and clicking on the "Visual Basic" button. If you don't see the Developer tab in the Ribbon, check if this is enabled. By default the Developer tab is disabled. To enab...
Rails provides several ways to organize your routes. Scope by URL: scope 'admin' do get 'dashboard', to: 'administration#dashboard' resources 'employees' end This generates the following routes get '/admin/dashboard', to: 'administration#dashboard' post '/admin/empl...
Example for reading file data_file.csv such as: File: index,header1,header2,header3 1,str_data,12,1.4 3,str_data,22,42.33 4,str_data,2,3.44 2,str_data,43,43.34 7, str_data, 25, 23.32 Code: pd.read_csv('data_file.csv') Output: index header1 header2 header3 0 1 str_dat...
Models are typically defined in the models.py file under your application subdirectory. The Model class of django.db.models module is a good starting class to extend your models from. For example: from django.db import models class Book(models.Model): title = models.CharField(max_length=100...
Once your virtual environment has been activated, any package that you install will now be installed in the virtualenv & not globally. Hence, new packages can be without needing root privileges. To verify that the packages are being installed into the virtualenv run the following command to che...
Assuming python and python3 are both installed, it is possible to create a virtual environment for Python 3 even if python3 is not the default Python: virtualenv -p python3 foo or virtualenv --python=python3 foo or python3 -m venv foo or pyvenv foo Actually you can create virtual ...
The method nextInt(int bound) of Random accepts an upper exclusive boundary, i.e. a number that the returned random value must be less than. However, only the nextInt method accepts a bound; nextLong, nextDouble etc. do not. Random random = new Random(); random.nextInt(1000); // 0 - 999 int num...
NSArray *array = [NSArray arrayWithObjects:@"Nick", @"Ben", @"Adam", @"Melissa", nil]; NSPredicate *aPredicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] 'a'"]; NSArray *beginWithA = [array filteredArrayUsingPredicate:bPredicate]; ...
Simple record {-# LANGUAGE TemplateHaskell #-} import Control.Lens data Point = Point { _x :: Float, _y :: Float } makeLenses ''Point Lenses x and y are created. let p = Point 5.0 6.0 p ^. x -- returns 5.0 set x 10 p -- returns Point { _x = 10.0, _y = 6.0 } p & x +~ ...

Page 70 of 826