xxxxxxxxxx
#converting weight into pounds orkilograms.
given_weight=int(input('given_weight'))
unit=input('(K)G or (L)bs')
if unit.upper() == 'K':
pounds=given_weight/0.45
print('weight in pounds',pounds)
else:
kilograms=given_weight*0.45
print('weight in kg',kilograms)
________________________________________________________________________________
xxxxxxxxxx
int age = 30;
if(age >= 30 && age <= 80){
System.out.println("Old");
}else if(age < 30 && >= 1){
System.out.println("Young");
}else{
System.out.println("Not Supported");
}
xxxxxxxxxx
var a = prompt("value 1")
var b = prompt("value 2")
var c = prompt("value 3")
var d = prompt("value 4")
var e = prompt("value 5")
if (a >= b && a >= c && a >= d && a >= e) {
console.log(a + " this is greater value")
}
else if (b >= a && b >= c && b >= d && b >= e) {
console.log(b + " this is greater value")
}
else if (c >= a && c >= b && c >= d && c >= e) {
console.log(c + " this is greater value")
}
else if (d >= a && d >= b && d >= c && d >= e ) {
console.log(d + " this is greater value")
}
else if(e >= a && e >= b && e >= c && e >= d){
console.log(e + " this is greater value")
}
else{"enter the valid number"}
xxxxxxxxxx
var age=20;
if (age < 18) {
console.log("underage");
} else {
console.log("let em in!");
}
xxxxxxxxxx
var price = 500;
var money = 100;
if (price > money) {
console.log("Not Enough")
} else {
console.log("Can Buy")
}
xxxxxxxxxx
if( name = 'george washington'):
print("You have the same name as the first president of the United States")
// python
else:
print("You do not have the same name as George Washington")
xxxxxxxxxx
if(Boolean_expression) {
// Statements will execute if the Boolean expression is true
}
xxxxxxxxxx
if(Boolean_expression) {
// Statements will execute if the Boolean expression is true
}
If the Boolean expression evaluates to true then the block of code inside the if statement will be executed. If not, the first set of code after the end of the if statement (after the closing curly brace) will be executed.
xxxxxxxxxx
>> number=23
>> guess = input('Enter a number : ')
>> if guess == number:
>> print('Congratulations! You guessed it.')
>> elif guess < number:
**( It is giving me 'Invalid Syntax')**
>> else:
**( It is also giving me 'Invalid syntax')**
xxxxxxxxxx
var age = prompt("enter your age")
if (age>= 60){
console.log("you are older")
}
else if (age >=18){
console.log("you are adult")
}
else if (age < 18){
console.log("you are child")
}