import random
dice = random.randint(1,6)
print('You rolled a ' + str(dice))
if dice == 6:
print('You got 6!🥳')
else:
print('Try again')
#Press Run to execute the code
#Python
xxxxxxxxxx
const dice = Math.floor(Math.random() * 6) + 1;
console.log("You rolled a " + dice);
if (dice === 6) {
console.log("You got 6!🥳");
} else {
console.log("Try again");
}
//Press Run to execute the code
//JavaScript
import java.util.Random;
public class Main {
public static void main(String[] args) {
Random random = new Random();
int dice = random.nextInt(6) + 1;
System.out.println("You rolled a " + dice);
if (dice == 6) {
System.out.println("You got 6!🥳");
System.out.println("Try again");
//Java
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
int main() {
srand(time(nullptr));
int dice = rand() % 6 + 1;
cout << "You rolled a " + to_string(dice) + "\n";
cout << "You got 6!🥳\n";
cout << "Try again\n";
return 0;
//C++