Comments
Single-line Comment #
Multiline comment "' three single quotes or three double quotes" "
"Use three quotes to assign a multiple line
User interaction Input
string concatenation
+ ""% () "". Format () recommended
Name = input ("Name:")
age = Int (input (' Age: '))
Sex = input ("Sex:")
Example: +
# string concatenation +
INFO1 = '----info in ' + name + '---
Name: ' + name + '
Age: "+ Age +" "
Sex: ' + sex + '
'''
optional else block attached, which is used primarily to handle the break statements contained in a for statement.
If the For loop is not terminated by a break, the statement in the else block is executed.
Break terminates the For loop when needed
Continue skips the following statement and starts the next round of loops.
The For statement is formatted as follows:
>>>for
.. if
.. break
.. if
...
Python,c#,java inside are similar to the structure of a foreach, STL inside although there is for_each this function, but feel the use is still too cumbersome some, so I realized one. First look at the STL inside the For_each function, the official document on the prototype is as follows:
function For_each (inputiterator, inputiterator, function f);
The sample code is as follows:
For_each Example#include #include #include using namespace Std;void M
output 5? The obvious answer is that printing a 5,1000ms immediately after almost simultaneous output of 5 5; why???As explained above, for a loop once, a Settimeou task is added to the task queue (the task is to execute a callback function after 1000ms), so the loop ends with 5 settimeou tasks in the Task list, and when the stack is empty in the main thread, the task list starts to stack , wait for 1000ms
For Loop example
For Loop Syntax:
for VARIABLE in 1 2 3 4 5 .. Ndo command1 command2 commandNdone#!/bin/bashfor i in 1 2 3 4 5doecho "Welcome $i times"doneBash version 3.0 +Version#!/bin/bash for i in {1..5}do echo "Welcome $i times"doneBash version 4Version#!/bin/bashecho "Bash version ${BASH_VERSION}..."for i in {0..10..2} do echo
loop:Copy codeThe Code is as follows:/* While Loop$ I = 0;While ($ I Echo "paxster $ I ++;}// Do... while loop -------- first execute and then judge, at least once/* $ Do = 0;Do {Echo '$ Do = $ do + 1;} While ($ do
The combination of while loop and switch selection statement:
Constant:Copy codeThe Code is as follows:// Define constants ----- two methodsDefine
the loops
Are you sure you want to go to the total page number? thinkphp with the page display should be {$page}, the default display is the number of n records, the previous page, the next page, the first page, the last page, to show the total page configuration page.class.php in the $config item
How do I combine loops and functions in a thinkphp in a template?
You query this out is a two-dimensional array, in the template has a special label for the loop
The examples in this paper describe the usage of thinkphp loop structure. Share to everyone for your reference. The implementation method is as follows:
Loop structure, the variable does not add $ sign in the loop output
Example 1.forCopy the Code code as follows:
Lt Positive sequence step is the pace value plu
This example describes the use of the For loop control statement in Python. Share to everyone for your reference. The specific analysis is as follows:
First: Find the prime number between 50-100
?
1 2 3 4 5 6 7
Import math for I in range (1): With J in range (2, int (math.sqrt (i)) + 1): If I% j = = 0:break Else:print I
The output is as follows:
?
1 2 3 4 5 6 7 8 9
The while loop is the simplest loop in PHP, and its basic format is:while (expr) { statement}Orwhile (expr): statementendwhile;This syntax means that as long as the expr expression is true, the statement is executed until expr is false, and statement represents the action or logic to be executed.The example loops out 1 to 10.Original address: http://www.man
This article is mainly for you in detail the C # WinForm cycle to play a number of video related materials, with a certain reference value, interested in small partners can refer to
The example of this article for everyone to share the WinForm cycle to play a number of video specific code for your reference, the specific content as follows
Environment: vs2015 +winform
First of all, the VS comes with the component is very convenient, so, with the Wind
Example of phpsmarty second-level classification code and template loop. The structure of the data table of level 2 classification is as follows: the PHP code is as follows ** @ document category contains Level 2 classification @ paramint $ rootnum -- number of level 1 categories @ paramint $ childnu the structure of the data table of level 2 classification is as follows:
The code is as follows:
The PHP
SDL2.0 plays a sound file in a loop and adds a comment./* load and loop a WAV file *//* loopwaves.c is much more robust in handling WAVE files--this are only for simple waves*/#include " Sdl_config.h "#include SDL2.0 Example Code Analysis---Loop to play WAV Loopwav
Example one: age=20count=0whiletrue:ifcount==5: breakguess=int (Input ("Age: ")) ifGUESS==AGE: print ("itisright!") breakelifGUESS> Age:print ("itisbigger!") else:print ("Itissmall!") count+=1ifcount==5:print ("You Havatriedtoomanytimes! ") Example two: _user= "root" _passwd= "okooo123" Count=0whilecountThe three examples above all implement the basics of a while loop
: ${string%%substring}Echo ${message%%t*}
# Find and replace: ${string/pattern/replacement}Book_name= "Catch Eye Eye"Echo ${book_name/eye/cat}# Find and replace all match: ${string//pattern/replacement}Echo ${book_name//eye/cat}
File_path= "/usr/local/bin"# only replace when match the beginning: ${string/#pattern/replacement}Echo ${file_path/#\/usr/tmp}# only replace when match ' end: ${string/%pattern/replacement}Echo ${file_path/%bin/tmp}
# string IndexStringz=abcabc123abcabcecho ' expr
Example of PHP array search function based on the binary method [loop and recursive algorithms], binary Recursion
This example describes how PHP performs array search based on the binary method. We will share this with you for your reference. The details are as follows:
Binary classification. Use the while loop method
The example in this article describes the for loop and switch statement usage in the thinkphp template. Share to everyone for your reference, specific as follows:
1.for usage
Case
resolves to
For ($i =1 $i
2.switch usage
Case
You can also use variables for the Value property of the case, for example
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.