Share 4sourcecode

manhhung658

New member
### 4 Ví dụ về mã nguồn

##### 1. Một máy tính đơn giản trong JavaScript

`` `JavaScript
chức năng Tính toán (num1, num2, toán tử) {
chuyển đổi (toán tử) {
trường hợp '+':
trả về num1 + num2;
trường hợp '-':
trả lại num1 - num2;
trường hợp '*':
trả về num1 * num2;
trường hợp '/':
trả về num1 / num2;
mặc định:
ném lỗi mới ('toán tử không hợp lệ');
}
}

Console.log (tính toán (10, 20, '+'));// 30
Console.log (tính toán (10, 20, '-'));// -10
Console.log (tính toán (10, 20, '*'));// 200
Console.log (tính toán (10, 20, '/'));// 0,5
`` `

##### 2. Một danh sách việc cần làm trong Python

`` `Python
def created_todo_list ():
"" "Tạo một danh sách việc đi làm mới." ""

todo_list = []

def add_todo (mục):
"" "Thêm một mục mới vào danh sách việc cần làm." ""

todo_list.append (mục)

def get_todo_list ():
"" "Trả về danh sách việc cần làm." ""

Quay lại TODO_LIST

def delete_todo (mục):
"" "Xóa một mục khỏi danh sách TODO." ""

todo_list.remove (mục)

trả lại todo_list, add_todo, get_todo_list, delete_todo

todo_list, add_todo, get_todo_list, delete_todo = create_todo_list ()

add_todo ('Mua tạp hóa')
add_todo ('gọi mẹ')
add_todo ('làm đồ giặt'))

in (get_todo_list ()))
# ['Mua tạp hóa', 'Gọi mẹ', 'làm đồ giặt']]]

Delete_todo ('Gọi mẹ')

in (get_todo_list ()))
# ['Mua tạp hóa', 'làm đồ giặt']]
`` `

##### 3. Một cái cào web trong Ruby

`` `Ruby
yêu cầu 'nokogiri'

Def Scrape_Page (URL)
# Nhận HTML của trang.
trang = nokogiri :: html (mở (url))

# Tìm tất cả các liên kết trên trang.
links = page.css ('a')

# Trích xuất thuộc tính HREF từ mỗi liên kết.
Liên kết.Each do | Liên kết |
PUTS Link ['href']]
kết thúc
kết thúc

Scrape_Page ('Raoul A. Cortez's 118th Birthday')
# hello - Google Search thế giới
# Google Maps
# Gmail
# Personal Cloud Storage & File Sharing Platform - Google
# Google Calendar - Sign in to Access & Edit Your Schedule
`` `

##### 4. Một ứng dụng di động trong React Native

`` `JavaScript
Nhập phản ứng, {usestate} từ 'React';
Nhập {view, văn bản, nút} từ 'phản ứng-bản địa';

const app = () => {
const [đếm, setCount] = usestate (0);

const tăng tăng = () => {
setCount (đếm + 1);
};

const decement = () => {
setcount (đếm - 1);
};

trở lại (
<Xem>
<Mext> Count: {Count} </text>
<Nút onpress = {gia tăng} title = "gia tăng" />
Không
</Xem>
);
};

Xuất ứng dụng mặc định;
`` `

### 5 hashtags

* #mã nguồn
* #Programming
* #JavaScript
* #Python
=======================================
### 4 Source Code Examples

##### 1. A simple calculator in JavaScript

```javascript
function calculate(num1, num2, operator) {
switch (operator) {
case '+':
return num1 + num2;
case '-':
return num1 - num2;
case '*':
return num1 * num2;
case '/':
return num1 / num2;
default:
throw new Error('Invalid operator');
}
}

console.log(calculate(10, 20, '+')); // 30
console.log(calculate(10, 20, '-')); // -10
console.log(calculate(10, 20, '*')); // 200
console.log(calculate(10, 20, '/')); // 0.5
```

##### 2. A todo list in Python

```python
def create_todo_list():
"""Creates a new todo list."""

todo_list = []

def add_todo(item):
"""Adds a new item to the todo list."""

todo_list.append(item)

def get_todo_list():
"""Returns the todo list."""

return todo_list

def delete_todo(item):
"""Deletes an item from the todo list."""

todo_list.remove(item)

return todo_list, add_todo, get_todo_list, delete_todo

todo_list, add_todo, get_todo_list, delete_todo = create_todo_list()

add_todo('Buy groceries')
add_todo('Call mom')
add_todo('Do laundry')

print(get_todo_list())
# ['Buy groceries', 'Call mom', 'Do laundry']

delete_todo('Call mom')

print(get_todo_list())
# ['Buy groceries', 'Do laundry']
```

##### 3. A web scraper in Ruby

```ruby
require 'nokogiri'

def scrape_page(url)
# Get the HTML of the page.
page = Nokogiri::HTML(open(url))

# Find all of the links on the page.
links = page.css('a')

# Extract the href attribute from each link.
links.each do |link|
puts link['href']
end
end

scrape_page('Raoul A. Cortez's 118th Birthday')
# hello world - Google Search
# Google Maps
# Gmail
# Personal Cloud Storage & File Sharing Platform - Google
# Google Calendar - Sign in to Access & Edit Your Schedule
```

##### 4. A mobile app in React Native

```javascript
import React, { useState } from 'react';
import { View, Text, Button } from 'react-native';

const App = () => {
const [count, setCount] = useState(0);

const increment = () => {
setCount(count + 1);
};

const decrement = () => {
setCount(count - 1);
};

return (
<View>
<Text>Count: {count}</Text>
<Button onPress={increment} title="Increment" />
<Button onPress={decrement} title="Decrement" />
</View>
);
};

export default App;
```

### 5 Hashtags

* #SourceCode
* #Programming
* #JavaScript
* #Python
 
С каждым годом растет количество людей, выбирающих этот вид досуга. Онлайн-платформы предлагают не только развлечение, но и шанс испытать удачу 전주자동차유리
 
ולהתמסר לרגעים הנעימים והמפנקים. אנו מדברים על כל תענוגות הגוף הקסומים שהנערות יודעות להעניק. דירות דיסקרטיות במרכז זה מה דירות דיסקרטיות במרכז - המקום בו הבחורות משתוקקות שתבוא מי לא אוהב לבלות עם נשים סקסיות? מי לא אוהב לגעת, להריח ולמשש? אבל <a href=אלבומי תמונות לאירועים - Clubwed.co.il>see this here</a>
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top