1589527329
While it may take two weeks to a month to learn HTML and CSS, it will take a bit longer to learn JavaScript. So what is the best course of action? This article explores some paths to gaining expert JavaScript proficiency.
If you are new to coding, you may wonder if you can get a grasp of a programming language within weeks. The answer is simply: no. It’s next to impossible to gain expert knowledge of all the programming languages in demand and obtain a junior developer job in such a short amount of time.
Luckily, many companies will hire junior developers who are still gaining proficiency in certain in-demand languages. One of those languages is JavaScript.
JavaScript is the most common language for making webpages interactive. To really grab the attention of visitors to your website, you will want it to have interactive features.
But how long will it really take to learn the basics of JavaScript? Let’s dive in and see.
#javascript #programming
1672928580
Bash has no built-in function to take the user’s input from the terminal. The read command of Bash is used to take the user’s input from the terminal. This command has different options to take an input from the user in different ways. Multiple inputs can be taken using the single read command. Different ways of using this command in the Bash script are described in this tutorial.
read [options] [var1, var2, var3…]
The read command can be used without any argument or option. Many types of options can be used with this command to take the input of the particular data type. It can take more input from the user by defining the multiple variables with this command.
Some options of the read command require an additional parameter to use. The most commonly used options of the read command are mentioned in the following:
Option | Purpose |
---|---|
-d <delimiter> | It is used to take the input until the delimiter value is provided. |
-n <number> | It is used to take the input of a particular number of characters from the terminal and stop taking the input earlier based on the delimiter. |
-N <number> | It is used to take the input of the particular number of characters from the terminal, ignoring the delimiter. |
-p <prompt> | It is used to print the output of the prompt message before taking the input. |
-s | It is used to take the input without an echo. This option is mainly used to take the input for the password input. |
-a | It is used to take the input for the indexed array. |
-t <time> | It is used to set a time limit for taking the input. |
-u <file descriptor> | It is used to take the input from the file. |
-r | It is used to disable the backslashes. |
The uses of read command with different options are shown in this part of this tutorial.
Example 1: Using Read Command without Any Option and variable
Create a Bash file with the following script that takes the input from the terminal using the read command without any option and variable. If no variable is used with the read command, the input value is stored in the $REPLY variable. The value of this variable is printed later after taking the input.
#!/bin/bash
#Print the prompt message
echo "Enter your favorite color: "
#Take the input
read
#Print the input value
echo "Your favorite color is $REPLY"
Output:
The following output appears if the “Blue” value is taken as an input:
Example 2: Using Read Command with a Variable
Create a Bash file with the following script that takes the input from the terminal using the read command with a variable. The method of taking the single or multiple variables using a read command is shown in this example. The values of all variables are printed later.
#!/bin/bash
#Print the prompt message
echo "Enter the product name: "
#Take the input with a single variable
read item
#Print the prompt message
echo "Enter the color variations of the product: "
#Take three input values in three variables
read color1 color2 color3
#Print the input value
echo "The product name is $item."
#Print the input values
echo "Available colors are $color1, $color2, and $color3."
Output:
The following output appears after taking a single input first and three inputs later:
Example 3: Using Read Command with -p Option
Create a Bash file with the following script that takes the input from the terminal using the read command with a variable and the -p option. The input value is printed later.
#!/bin/bash
#Take the input with the prompt message
read -p "Enter the book name: " book
#Print the input value
echo "Book name: $book"
Output:
The following output appears after taking the input:
Example 4: Using Read Command with -s Option
Create a Bash file with the following script that takes the input from the terminal using the read command with a variable and the -s option. The input value of the password will not be displayed for the -s option. The input values are checked later for authentication. A success or failure message is also printed.
#!/bin/bash
#Take the input with the prompt message
read -p "Enter your email: " email
#Take the secret input with the prompt message
read -sp "Enter your password: " password
#Add newline
echo ""
#Check the email and password for authentication
if [[ $email == "admin@example.com" && $password == "secret" ]]
then
#Print the success message
echo "Authenticated."
else
#Print the failure message
echo "Not authenticated."
fi
Output:
The following output appears after taking the valid and invalid input values:
Example 5: Using Read Command with -a Option
Create a Bash file with the following script that takes the input from the terminal using the read command with a variable and the -a option. The array values are printed later after taking the input values from the terminal.
#!/bin/bash
echo "Enter the country names: "
#Take multiple inputs using an array
read -a countries
echo "Country names are:"
#Read the array values
for country in ${countries[@]}
do
echo $country
done
Output:
The following output appears after taking the array values:
Example 6: Using Read Command with -n Option
Create a Bash file with the following script that takes the input from the terminal using the read command with a variable and the -n option.
#!/bin/bash
#Print the prompt message
echo "Enter the product code: "
#Take the input of five characters
read -n 5 code
#Add newline
echo ""
#Print the input value
echo "The product code is $code"
Output:
The following output appears if the “78342” value is taken as input:
Example 7: Using Read Command with -t Option
Create a Bash file with the following script that takes the input from the terminal using the read command with a variable and the -t option.
#!/bin/bash
#Print the prompt message
echo -n "Write the result of 10-6: "
#Take the input of five characters
read -t 3 answer
#Check the input value
if [[ $answer == "4" ]]
then
echo "Correct answer."
else
echo "Incorrect answer."
fi
Output:
The following output appears after taking the correct and incorrect input values:
The uses of some useful options of the read command are explained in this tutorial using multiple examples to know the basic uses of the read command.
Original article source at: https://linuxhint.com/
1624298400
This complete 134-part JavaScript tutorial for beginners will teach you everything you need to know to get started with the JavaScript programming language.
⭐️Course Contents⭐️
0:00:00 Introduction
0:01:24 Running JavaScript
0:04:23 Comment Your Code
0:05:56 Declare Variables
0:06:15 Storing Values with the Assignment Operator
0:11:31 Initializing Variables with the Assignment Operator
0:11:58 Uninitialized Variables
0:12:40 Case Sensitivity in Variables
0:14:05 Add Two Numbers
0:14:34 Subtract One Number from Another
0:14:52 Multiply Two Numbers
0:15:12 Dividing Numbers
0:15:30 Increment
0:15:58 Decrement
0:16:22 Decimal Numbers
0:16:48 Multiply Two Decimals
0:17:18 Divide Decimals
0:17:33 Finding a Remainder
0:18:22 Augmented Addition
0:19:22 Augmented Subtraction
0:20:18 Augmented Multiplication
0:20:51 Augmented Division
0:21:19 Declare String Variables
0:22:01 Escaping Literal Quotes
0:23:44 Quoting Strings with Single Quotes
0:25:18 Escape Sequences
0:26:46 Plus Operator
0:27:49 Plus Equals Operator
0:29:01 Constructing Strings with Variables
0:30:14 Appending Variables to Strings
0:31:11 Length of a String
0:32:01 Bracket Notation
0:33:27 Understand String Immutability
0:34:23 Find the Nth Character
0:34:51 Find the Last Character
0:35:48 Find the Nth-to-Last Character
0:36:28 Word Blanks
0:40:44 Arrays
0:41:43 Nest Arrays
0:42:33 Access Array Data
0:43:34 Modify Array Data
0:44:48 Access Multi-Dimensional Arrays
0:46:30 push()
0:47:29 pop()
0:48:33 shift()
0:49:23 unshift()
0:50:36 Shopping List
0:51:41 Write Reusable with Functions
0:53:41 Arguments
0:55:43 Global Scope
0:59:31 Local Scope
1:00:46 Global vs Local Scope in Functions
1:02:40 Return a Value from a Function
1:03:55 Undefined Value returned
1:04:52 Assignment with a Returned Value
1:05:52 Stand in Line
1:08:41 Boolean Values
1:09:24 If Statements
1:11:51 Equality Operator
1:13:18 Strict Equality Operator
1:14:43 Comparing different values
1:15:38 Inequality Operator
1:16:20 Strict Inequality Operator
1:17:05 Greater Than Operator
1:17:39 Greater Than Or Equal To Operator
1:18:09 Less Than Operator
1:18:44 Less Than Or Equal To Operator
1:19:17 And Operator
1:20:41 Or Operator
1:21:37 Else Statements
1:22:27 Else If Statements
1:23:30 Logical Order in If Else Statements
1:24:45 Chaining If Else Statements
1:27:45 Golf Code
1:32:15 Switch Statements
1:35:46 Default Option in Switch Statements
1:37:23 Identical Options in Switch Statements
1:39:20 Replacing If Else Chains with Switch
1:41:11 Returning Boolean Values from Functions
1:42:20 Return Early Pattern for Functions
1:43:38 Counting Cards
1:49:11 Build Objects
1:50:46 Dot Notation
1:51:33 Bracket Notation
1:52:47 Variables
1:53:34 Updating Object Properties
1:54:30 Add New Properties to Object
1:55:19 Delete Properties from Object
1:55:54 Objects for Lookups
1:57:43 Testing Objects for Properties
1:59:15 Manipulating Complex Objects
2:01:00 Nested Objects
2:01:53 Nested Arrays
2:03:06 Record Collection
2:10:15 While Loops
2:11:35 For Loops
2:13:56 Odd Numbers With a For Loop
2:15:28 Count Backwards With a For Loop
2:17:08 Iterate Through an Array with a For Loop
2:19:43 Nesting For Loops
2:22:45 Do…While Loops
2:24:12 Profile Lookup
2:28:18 Random Fractions
2:28:54 Random Whole Numbers
2:30:21 Random Whole Numbers within a Range
2:31:46 parseInt Function
2:32:36 parseInt Function with a Radix
2:33:29 Ternary Operator
2:34:57 Multiple Ternary Operators
2:36:57 var vs let
2:39:02 var vs let scopes
2:41:32 const Keyword
2:43:40 Mutate an Array Declared with const
2:44:52 Prevent Object Mutation
2:47:17 Arrow Functions
2:28:24 Arrow Functions with Parameters
2:49:27 Higher Order Arrow Functions
2:53:04 Default Parameters
2:54:00 Rest Operator
2:55:31 Spread Operator
2:57:18 Destructuring Assignment: Objects
3:00:18 Destructuring Assignment: Nested Objects
3:01:55 Destructuring Assignment: Arrays
3:03:40 Destructuring Assignment with Rest Operator to Reassign Array
3:05:05 Destructuring Assignment to Pass an Object
3:06:39 Template Literals
3:10:43 Simple Fields
3:12:24 Declarative Functions
3:12:56 class Syntax
3:15:11 getters and setters
3:20:25 import vs require
3:22:33 export
3:23:40 * to Import
3:24:50 export default
3:25:26 Import a Default Export
📺 The video in this post was made by freeCodeCamp.org
The origin of the article: https://www.youtube.com/watch?v=PkZNo7MFNFg&list=PLWKjhJtqVAblfum5WiQblKPwIbqYXkDoC&index=4
🔥 If you’re a beginner. I believe the article below will be useful to you ☞ What You Should Know Before Investing in Cryptocurrency - For Beginner
⭐ ⭐ ⭐The project is of interest to the community. Join to Get free ‘GEEK coin’ (GEEKCASH coin)!
☞ **-----CLICK HERE-----**⭐ ⭐ ⭐
Thanks for visiting and watching! Please don’t forget to leave a like, comment and share!
#javascript #learn javascript #learn javascript for beginners #learn javascript - full course for beginners #javascript programming language
1637595900
Em primeiro lugar, uma pesquisa linear, também conhecida como pesquisa sequencial, este método é usado para localizar um elemento dentro de uma lista ou array. Ele verifica cada elemento da lista um por um / sequencialmente até que uma correspondência seja encontrada ou toda a lista tenha sido pesquisada.
Implemente a pesquisa linear seguindo as etapas abaixo:
target
valor ao valor fornecido da lista / matriz.-1
.# python program for linear search using while loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
i = 0
flag = False
while i < len(lst):
if lst[i] == x:
flag = True
break
i = i + 1
if flag == 1:
print('{} was found at index {}.'.format(x, i))
else:
print('{} was not found.'.format(x))
Depois de executar o programa, a saída será:
Enter size of list :- 5
Enter the array of 0 element :- 10
Enter the array of 1 element :- 23
Enter the array of 2 element :- 56
Enter the array of 3 element :- 89
Enter the array of 4 element :- 200
Enter number to search in list :- 89
89 was found at index 3.
# python program for linear search using for loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
i = 0
flag = False
for i in range(len(lst)):
if lst[i] == x:
flag = True
break
if flag == 1:
print('{} was found at index {}.'.format(x, i))
else:
print('{} was not found.'.format(x))
Depois de executar o programa, a saída será:
Enter size of list :- 6
Enter the array of 0 element :- 25
Enter the array of 1 element :- 50
Enter the array of 2 element :- 100
Enter the array of 3 element :- 200
Enter the array of 4 element :- 250
Enter the array of 5 element :- 650
Enter number to search in list :- 200
200 was found at index 3.
# python program for linear search using for loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
# Recursive function to linear search x in arr[l..r]
def recLinearSearch( arr, l, r, x):
if r < l:
return -1
if arr[l] == x:
return l
if arr[r] == x:
return r
return recLinearSearch(arr, l+1, r-1, x)
res = recLinearSearch(lst, 0, len(lst)-1, x)
if res != -1:
print('{} was found at index {}.'.format(x, res))
else:
print('{} was not found.'.format(x))
Depois de executar o programa, a saída será:
Enter size of list :- 5
Enter the array of 0 element :- 14
Enter the array of 1 element :- 25
Enter the array of 2 element :- 63
Enter the array of 3 element :- 42
Enter the array of 4 element :- 78
Enter number to search in list :- 78
78 was found at index 4.
1637570520
Tout d'abord, une recherche linéaire, également appelée recherche séquentielle, cette méthode est utilisée pour rechercher un élément dans une liste ou un tableau. Il vérifie chaque élément de la liste un par un / séquentiellement jusqu'à ce qu'une correspondance soit trouvée ou que toute la liste ait été recherchée.
Implémentez la recherche linéaire en suivant les étapes ci-dessous :
target
valeur à la valeur donnée de la liste/du tableau.-1
.# python program for linear search using while loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
i = 0
flag = False
while i < len(lst):
if lst[i] == x:
flag = True
break
i = i + 1
if flag == 1:
print('{} was found at index {}.'.format(x, i))
else:
print('{} was not found.'.format(x))
Après l'exécution du programme, la sortie sera :
Enter size of list :- 5
Enter the array of 0 element :- 10
Enter the array of 1 element :- 23
Enter the array of 2 element :- 56
Enter the array of 3 element :- 89
Enter the array of 4 element :- 200
Enter number to search in list :- 89
89 was found at index 3.
# python program for linear search using for loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
i = 0
flag = False
for i in range(len(lst)):
if lst[i] == x:
flag = True
break
if flag == 1:
print('{} was found at index {}.'.format(x, i))
else:
print('{} was not found.'.format(x))
Après l'exécution du programme, la sortie sera :
Enter size of list :- 6
Enter the array of 0 element :- 25
Enter the array of 1 element :- 50
Enter the array of 2 element :- 100
Enter the array of 3 element :- 200
Enter the array of 4 element :- 250
Enter the array of 5 element :- 650
Enter number to search in list :- 200
200 was found at index 3.
# python program for linear search using for loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
# Recursive function to linear search x in arr[l..r]
def recLinearSearch( arr, l, r, x):
if r < l:
return -1
if arr[l] == x:
return l
if arr[r] == x:
return r
return recLinearSearch(arr, l+1, r-1, x)
res = recLinearSearch(lst, 0, len(lst)-1, x)
if res != -1:
print('{} was found at index {}.'.format(x, res))
else:
print('{} was not found.'.format(x))
Après l'exécution du programme, la sortie sera :
Enter size of list :- 5
Enter the array of 0 element :- 14
Enter the array of 1 element :- 25
Enter the array of 2 element :- 63
Enter the array of 3 element :- 42
Enter the array of 4 element :- 78
Enter number to search in list :- 78
78 was found at index 4.
1636296420
このチュートリアルでは、Pythonで線形検索プログラムを作成する方法を学習します。
まず、線形検索(シーケンシャル検索とも呼ばれます)は、リストまたは配列内の要素を見つけるために使用されます。一致するものが見つかるか、リスト全体が検索されるまで、リストの各要素を1つずつ/順番にチェックします。
以下の手順に従って線形検索を実装します。
target
値をリスト/配列の指定された値に関連付け ます。-1
ます。# python program for linear search using while loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
i = 0
flag = False
while i < len(lst):
if lst[i] == x:
flag = True
break
i = i + 1
if flag == 1:
print('{} was found at index {}.'.format(x, i))
else:
print('{} was not found.'.format(x))
プログラムの実行後、出力は次のようになります。
Enter size of list :- 5
Enter the array of 0 element :- 10
Enter the array of 1 element :- 23
Enter the array of 2 element :- 56
Enter the array of 3 element :- 89
Enter the array of 4 element :- 200
Enter number to search in list :- 89
89 was found at index 3.
# python program for linear search using for loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
i = 0
flag = False
for i in range(len(lst)):
if lst[i] == x:
flag = True
break
if flag == 1:
print('{} was found at index {}.'.format(x, i))
else:
print('{} was not found.'.format(x))
プログラムの実行後、出力は次のようになります。
Enter size of list :- 6
Enter the array of 0 element :- 25
Enter the array of 1 element :- 50
Enter the array of 2 element :- 100
Enter the array of 3 element :- 200
Enter the array of 4 element :- 250
Enter the array of 5 element :- 650
Enter number to search in list :- 200
200 was found at index 3.
# python program for linear search using for loop
#define list
lst = []
#take input list size
num = int(input("Enter size of list :- "))
for n in range(num):
#append element in list/array
numbers = int(input("Enter the array of %d element :- " %n))
lst.append(numbers)
#take input number to be find in list
x = int(input("Enter number to search in list :- "))
# Recursive function to linear search x in arr[l..r]
def recLinearSearch( arr, l, r, x):
if r < l:
return -1
if arr[l] == x:
return l
if arr[r] == x:
return r
return recLinearSearch(arr, l+1, r-1, x)
res = recLinearSearch(lst, 0, len(lst)-1, x)
if res != -1:
print('{} was found at index {}.'.format(x, res))
else:
print('{} was not found.'.format(x))
プログラムの実行後、出力は次のようになります。
Enter size of list :- 5
Enter the array of 0 element :- 14
Enter the array of 1 element :- 25
Enter the array of 2 element :- 63
Enter the array of 3 element :- 42
Enter the array of 4 element :- 78
Enter number to search in list :- 78
78 was found at index 4.