<?php
print_r(meanMedianAndMode([8, 7, 2, 4, 2]))."\n";
print_r(meanMedianAndMode([8, 7, 2, 4, 2, 7]))."\n";
function meanMedianAndMode($nums) {
$count = count($nums);
sort($nums);
//Calculates Median
if ($count%2 == 0) {
$median = ($nums[$count/2]+$nums[$count/2-1])/2;
} else {
$median = $nums[floor($count/2)];
}
// Calculates Mode
$counted = array_count_values($nums);
$max = max($counted);
// Checks if there is more than one Mode
$counted_max = array_count_values($counted);
if ($counted_max[$max] == 1) {
$mode = array_search($max, $counted);
} else {
foreach ($counted as $key => $value) {
if ($value == $max) {
$mode[] = $key;
}
}
}
return [
'mean' => array_sum($nums) / $count,
// average number
'median' => $median,
'mode' => $mode
];
}
echo standardDeviation([5, 9, 4, 3, 2])."\n";
// Calculates standard deviation for the given integer array
function standardDeviation($a){
$count=count($a);
$v=0;
// Calculates average number from the array
$avg = array_sum($a) / $count;
// Loops through the array members
foreach ($a as $i){
// Calculates the sum of squares of the difference
// between each member and the average of the array
$v+=pow(($v-$avg), 2);
}
return sqrt($v/$count);
}
$ git status
This command outputs items in a short-format
$ git status -s
$ git status --short
Outputs items in a long-format
$ git status --long
Outputs items in one line
$ git status -z
<?php
$year = 2019;
if ($year % 400 == 0) {
echo $year." is a leap year.";
} elseif ($year % 100 == 0) {
echo $year." is not a leap year.";
} elseif ($year % 4 == 0) {
echo $year." is a leap year.";
} else {
echo $year." is not a leap year.";
}
?>
Using function
<?php
function leapyear($year) {
if ($year % 400 == 0) {
echo $year." is a leap year.";
} elseif ($year % 100 == 0) {
echo $year." is not a leap year.";
} elseif ($year % 4 == 0) {
echo $year." is a leap year.";
} else {
echo $year." is not a leap year.";
}
}
leapyear(2019);
?>
მას შემდეგ რაც git-ს დავაყენებთ ლოკალურ მანქანაზე საჭიროა მისი კონფიგურაცია ჩვენი მონაცემებით, რომელიც გითის კომიტში მოახდენს ჩვენს იდენტიფიკაციას
გავხსნათ ტერმინალი და ჩავწეროთ შემდეგი ბრძენებები
git config --global user.name "სახელი გვარი"
მოცემული ბრძანებით მივუთითებთ ჩვენს სახელს და გვარს
git config --global user.email "MY_NAME@example.com"
მოცემული ბრძანებით მივუთითებთ ჩვენს ელფოსტას
git config --list
მოცემული ბრძანებით გვიჩვენებს კონფიგურაციის ყველა პარამეტრს
იმისათვის რომ გიტმა დაიწყოს მუშაობა კონკრეტულ დირექტორიაში საჭიროა მისი ინიციალიზაცია შემდეგი ბრძანებით:
Git init
დირექტორიაში გადასასვლელად ვიყენებთ
cd (ფაილის დასახელებას ვწერთ)
იმისათვის რომ ვნახოთ ფაილების ჩამონათვალი გარკვეულ დირექტორიაში ვიყენებთ ამ ბრძანებას: ls და ls -la
`ფაილის შესაქმნელად ვიყენებთ ამ ბრძანებას: Touch
touch .gitignore
შეიქმნება ფაილი gitignore
, რომელშიც შეგვიძლია მივუთითოთ რა ტიპის ფაილები უნდა დააიგნოროს გიტმა. მაგალითად, ჩავწერთ gitignore
ფაილში *.html
-ს და ყველა ფაილი რომელიც დაბოლოვდება html
-ით გიტი არ გამოაჩენს.