Ruby Course – Worldwideasy – 02

Ruby programming lesson 2. Today we going to learn more about Ruby. In this tutorial, we will focus on variables, Strings, Numbers, and Operations. It can provide extensive knowledge.

Use Variable

Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.

launchschool.com

Now you know what is variable, let’s use it Ruby Programming

character_name = "jenny"
character_age = "23"
puts "my name is "+ character_name
puts "my age is "+ character_age

This Code output is My Name is jenny my age is 23. you can try this code in your pc.

Working with Strings Ruby Programming

Threads are traditionally alphabetical. Now you can see how it works. see the below table and get an idea about ruby strings.

Phone = "Apple Iphone"
CodeOutput
puts Phone.upcaseAPPLE IPHONE
puts Phone.downcaseApple iPhone
puts Phone.stripApple iPhone
puts Phone.length12
puts Phone.include?"Apple"true
puts Phone.include?"cake"false
puts Phone.[3,5]le Ip
puts "hp".upcase()HP

Work with Strings

Working With Numbers

Every computer language uses numbers in particular. This is because it allows you to easily control the data. let me show you how to work with numbers in Ruby.

SyntaxCode
puts -5.43215-5.43215
puts 5+914
puts 5/90
puts 2*36
puts 2**38
puts 10%31
puts 5-23

Operations & Math in Ruby Programming

In mathematics, we use different operations, i.e. maximum value, square root, fall. They are also used differently in programming. The following example will give you a broader understanding.

Operations
num = 30.67
CodeOutput
puts num.abs()30.67
puts num.round()30
puts num.ceil()31
puts num.floor()30

Operations

Math

it is a hard mathematics part but using ruby we can do it easily. see below table.

SyntaxOutput
puts Math.sqrt (2)1.4142135623730951
puts Math.log (2)0.6931471805599453

Math

Now you have developed some knowledge about Ruby. Try typing this code on your computer as well. Practice

Thank you for all!

More Ruby ClickHere!

See you Next Ruby Lesson Soon!

C# Course – Worldwideasy – 02

Today we expect Variables, Data Types, Strings, and working with Numbers. this all is we are doing C# console application. its uses forget good basic knowledge for C#.

C# Variables

Variable is a symbol that acts as a holder for various expressions or sizes and is often used to represent an arbitrary element of a set.

You now have a broader understanding. about what a variable is. So let us explain by c #. See the below example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String chaName = "Harry";
int age = 30;

Console.WriteLine("my name is " + chaName);
Console.WriteLine("I am " + age);
Console.WriteLine("I like " + chaName);
Console.WriteLine("good for " + age);
Console.ReadLine();

}
}
}

This code Output is My Name is Harry. I am 30. I like Harry. good for 30. You can try this code on your pc.

C# Data Types

This is special it uses to make variables. c# is a case-sensitive language. We must first say that the type of data that the computer recognizes. There are a limited number of data types that we can identify.

Data TypeSyntax
StringString name = "Hello";
Charchar grade = 'A';
intint age = 30;
floatfloat gpa = 3.2f;
doubledouble gpa = 2.35686;
boolisMale = true;

Data Types

Strings

Strings do a lot of work. We can do it very beautifully and easily. This is very useful for tasks like changing a name. Get an understanding from the table below.

SyntaxOutput
Console.WriteLine ("hello world");hello world
Console.WriteLine ("hello \n world");hello
world
Console.WriteLine ("hello\"world");hello”world
String Ad = "hello" + "boy";
Console.WriteLine (Ad);
hello boy
String Ad = "Apple";
Console.WriteLine(Ad.Length);
5
Console.WriteLine(Ad.ToUpper());APPLE
Console.WriteLine(Ad.ToLower);apple
Console.WriteLine(Ad.Contains(“hp”);false
Console.WriteLine(Ad.Contains(“Apple”);true
Console.WriteLine(Ad.[3]);L
Console.WriteLine(Ad.Indexof(‘l’));3
Console.WriteLine(Ad.Substring(2));ple

Use for String

Work With Numbers

This allows us to see how the code makes various changes to the numbers. See the table below. Get ideas from it.

SyntaxOutput
Console.WriteLine(5+7);12
Console.WriteLine(Math.Abs (-40));40
Console.WriteLine(Math.Pow (4,2));16
Console.WriteLine(Math.Sqrt (144));12
Console.WriteLine(Math.Max (10,20));20
Console.WriteLine(Math.Min (10,20));10
Console.WriteLine(Math.Round(4.2));4
Console.WriteLine(Math.Sin(55));-0.99975517335862

Work with Numbers

More about Work with Numbers. example works.

SyntaxOutput
Console.WriteLine(8+6);14
Console.WriteLine(152-56);96
Console.WriteLine(80/5);16
Console.WriteLine(8%3);2
Console.WriteLine(8*3);24
Console.WriteLine((8+9)*(8+2));170

Operations

Now you have the basic knowledge of c #. You can get a better understanding by trying the code again.

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!

Php Course – Worldwideasy – 02

php lesson 2. Today we going to learn more about php. In this tutorial, we will focus on HTML, Variable, Strings, Numbers, and Operations. It can provide extensive knowledge.

Use HTML For PHP

You can see below the HTML tag used in your php file.

<?php
echo "<h1>Micke</h1>";
echo "<hr>";
echo "<h1>"Jhone</h1>";
?>

Use Variable

Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.

launchschool.com

Now you know what is variable, let’s use php.

<?php
$charname ="Jhone";
$charage = '18';
echo "my name is" $charname;
echo "my age " $charage;
?>

Working with Strings

the string is traditionally a sequence of characters. now you can see how to work it. Look at Example.

<?php
$pharase = "Hello World";
CodeOutput
echo strtoupper ($pharase);HELLO WORLD
echo strtolower ($pharase);hello world
echo strlen ($pharase);10
echo pharase[1];e
echo str_replace("Hello","Hay",$pharase);Hay World
echo substr ($pharase,6);ld
echo substr ($pharase,4,7);owor

Syntax

Working With Numbers

Every computer language uses numbers in particular. This is because it allows you to easily control the data. let show you how to work with numbers in php.

<?php
echo 5;    //5
echo 5 + 9;   //14
?>
<?php
$num = 10;
$num ++;
echo $num;  //11

Operations

In mathematics, we use different operations i.e. maximum value, square root, fall. They are also used differently in programming. The following example will give you a broader understanding.

NameSyntaxOutput
Powerecho pow(2,4);16
Square rootecho sqrt(144);12
Max Numberecho max(10,20,30);30
Min Numberecho min (10,20,30);10
Roundecho round (3.2);3
NOTecho abs(-100);100
Max Roundecho ceil(3.2);4
Min Roundecho floor(3.8);3

Operations

Special Example for Lesson 02

Q1

  • First get square root in x.
  • y is max round number.
  • z is positive number.
  • R is X+Z/Y.
  • (X=144, Y=2.2, Z=-33)
  • Find R?
<?php
$x = 144;
$y = 2.2;
$z = -33;
$x1 = sqrt($x);
$y1 = ceil($y);
$z1 = abs($z);
$R1 = $x1 + $z1;
$R = $R1 / $y1;
echo "R";
<?php
$x = 144;
$y = 2.2;
$z = -33;
$x1 = sqrt($x);
$y1 = ceil($y);
$z1 = abs($z);
$R1 = $x1 + $z1;
$R = $R1 / $y1;
echo "R = ";
echo $R;
?>

Thank you for all!

More php ClickHere!

See you Next php Lesson Soon!