Program A 22
Program A 22
first_name= "Bro"
food = "Pizza"
email = "[email protected]"
print(f"hello {first_name}")
print (f"you like {food}")
print (f"your email is: {email}")
# Float
price = 10.99
gpa = 3.2
distance = 2.8
print (f"A electric guitar is {price}")
print (f"Your gpa is: {gpa}")
print (f"you ran {distance} km")
if is_student:
print ("You are a student")
else:
print ("You are not a student")
if for_sale:
print ("That item is for sale")
else:
print ("That item is not for sale")
if not is_online:
print("You are not online")
else:
print("You are online")
Typecasting
#Typecasting= the process of converting a variable from one data type to
another
name = "vas"
age = 22
gpa = 3.2
is_student = False
print (type(is_student))
User input
# input() = A function that prompts the useer to enter data
# Returns the entered data as a string
name =input("What is your name?:")
age =input ("How old are you?:")
birthday = input ("When is your birthday?:")
age = age+1
Madlibs games
# word game where you create a story
# by filling in blanks with random words
#x = 3.14
#y = 4
#z = 5
import math
#print (math.pi)
#print (math.e)
#result = math.sqrt(x)
#x = 25
#print (result)
x = 9.1
result = math.ceil (x)
print (result)
y = 9.9
result = math.floor (y)
print (result)
import math
import math
adjacent = float (input("Enter the adjacent:"))
opposite = float (input ("Enter the opposite:"))
hypotenuses = math.sqrt ( (adjacent **2) + (opposite**2))
#else:
# print ("You must be 18 or older to sign up!")
# if response == "Yes":
# print ("Choose your food!")
# else:
#print ("You may leave!")
#else:
# print (f"Hello {name}!")
Calculator
operator = input("Enter an operator (+ - * /): ")
number1 = float(input("Enter the first number: "))
number2 = float(input("Enter the second number: "))
if operator == "+":
result = number1 + number2
print (result)
elif operator== "-":
result = number1 - number2
print(result)
elif operator == "*":
result = number1 * number2
print(result)
elif operator == "/":
result = number1 / number2
print(result)
Weight converter
weight = float(input("Enter your weight:"))
unit = input ( "Kilograms or pounds? (Kg or Lb):")
if unit == "K":
weight = weight * 2.205
unit = "Lbs."
elif unit == "L":
weight = weight / 2.205
unit = "Kgs."
else:
print (f"The {unit} you introduced is not valid")
if unit == "C":
temp = ((9 * temp) / 5 + 32)
print (f" The temperature in Fahrenheit is {temp} {unit}")
elif unit == "F":
else:
print (f"The{unit} is an invalid unit of measurement")
num = 10
a = 9
b = 7
age = 2
temperature = 26
user_role = "admin"
Java
import java.util.Scanner;
package dia1b;
if (response.equals("q") || response.equals("Q")) {
System.out.println("You quit the game");
}
else {
System.out.println("You are still playing the game");
}
package primeirodia;
While loop
package aulas;
import java.util.Scanner;
public class JavaEstudo {
while(name.isBlank()) {
System.out.println("Enter your name: ");
name = scanner.nextLine();
}
System.out.println("Hello, "+name);
}
For loops
package aulas;
System.out.println(i);
}
->Se ( aB> aP) -> msg<- “O artigo mais solicitado foi a Bolsa”
Se ( aC> aP)-> Se ( aC > aB)-> msg<- “ O artigo mais solicitado foi o colar”
->Se ( aB> aC) -> msg<- “O artigo mais solicitado foi a Bolsa”
Senao
senao
senao