├── LICENSE ├── Python ├── unit_01_guess_the_number │ ├── Screenshot-Guess the Number.png │ └── guess_the_number.py └── unit_02_rock_paper_scissors │ ├── Screenshot-Rock-Paper-Scissors.png │ └── rock_paper_scissors.py ├── README.md └── TypeScript └── unit_01_typescript_basics └── typescript_basics.ts /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Shavinda Dizz / Nova 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Python/unit_01_guess_the_number/Screenshot-Guess the Number.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyferlink/skills-training-cross-lang/fdbf5e9fca4f17bef23c2873fdcca8e1de7b0d4a/Python/unit_01_guess_the_number/Screenshot-Guess the Number.png -------------------------------------------------------------------------------- /Python/unit_01_guess_the_number/guess_the_number.py: -------------------------------------------------------------------------------- 1 | # Here is a online Python compiler (interpreter) to run Python online. 2 | # https://www.programiz.com/python-programming/online-compiler/ 3 | # ------------------------------------------------------------------- 4 | # Unit 01 : Guess the Number 5 | # ------------------------------------------------------------------- 6 | 7 | import random 8 | 9 | def guess_the_number(): 10 | # Generate a random number between 1 and 100 11 | secret_number = random.randint(1, 100) 12 | max_attempts = 10 # Maximum attempts allowed 13 | attempts = 0 14 | 15 | print("Welcome to 'Guess the Number'!") 16 | print("I'm thinking of a number between 1 and 100.") 17 | 18 | while attempts < max_attempts: 19 | try: 20 | # Prompt the player to enter a guess 21 | player_guess = int(input("Enter your guess: ")) 22 | except ValueError: 23 | print("Please enter a valid integer.") 24 | continue 25 | 26 | attempts += 1 27 | 28 | # Check if the player's guess is correct 29 | if player_guess == secret_number: 30 | print(f"Congratulations! You guessed it in {attempts} attempts.") 31 | return 32 | elif player_guess < secret_number: 33 | print("Too low. Try again!") 34 | else: 35 | print("Too high. Try again!") 36 | 37 | print(f"Sorry, you've used all {max_attempts} attempts. The correct number was {secret_number}.") 38 | 39 | guess_the_number() 40 | -------------------------------------------------------------------------------- /Python/unit_02_rock_paper_scissors/Screenshot-Rock-Paper-Scissors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyferlink/skills-training-cross-lang/fdbf5e9fca4f17bef23c2873fdcca8e1de7b0d4a/Python/unit_02_rock_paper_scissors/Screenshot-Rock-Paper-Scissors.png -------------------------------------------------------------------------------- /Python/unit_02_rock_paper_scissors/rock_paper_scissors.py: -------------------------------------------------------------------------------- 1 | # Here is a online Python compiler (interpreter) to run Python online. 2 | # https://www.programiz.com/python-programming/online-compiler/ 3 | # ------------------------------------------------------------------- 4 | # Unit 02 : Rock, Paper, Scissors 5 | # ------------------------------------------------------------------- 6 | 7 | import random 8 | 9 | def rock_paper_scissors(): 10 | # Define choices for the game 11 | #choices = ["rock", "paper", "scissors"] 12 | choices = ["r" , "rock", "p" , "paper", "s" , "scissors"] 13 | score_player = 0 14 | score_computer = 0 15 | 16 | print("Welcome to Rock, Paper, Scissors!") 17 | print("Type 'exit' to quit the game.") 18 | print("-------------------------------") 19 | 20 | while True: 21 | player_choice = input("Choose rock, paper, or scissors: ").lower() 22 | 23 | # Exit condition 24 | if player_choice == "exit": 25 | break 26 | 27 | if player_choice not in choices: 28 | print("Invalid choice. Please choose rock, paper, or scissors.") 29 | continue 30 | 31 | # Computer's random choice 32 | computer_choice = random.choice(choices) 33 | 34 | if computer_choice == "r": 35 | computer_choice = "rock" 36 | elif computer_choice == "s": 37 | computer_choice = "scissors" 38 | elif computer_choice == "p": 39 | computer_choice = "paper" 40 | 41 | print(f"Computer chose {computer_choice}") 42 | 43 | 44 | # Determine the winner 45 | if player_choice == computer_choice: 46 | print("It's a tie!") 47 | elif ((player_choice == "rock" or player_choice == "r") and computer_choice == "scissors") or \ 48 | ((player_choice == "scissors" or player_choice == "s") and computer_choice == "paper") or \ 49 | ((player_choice == "paper" or player_choice == "p") and computer_choice == "rock"): 50 | print("You win!") 51 | score_player += 1 52 | else: 53 | print("Computer wins!") 54 | score_computer += 1 55 | 56 | print(f"Score - You: {score_player}, Computer: {score_computer}") 57 | print("-------------------------------") 58 | 59 | rock_paper_scissors() 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | ❮ Skills Training ❯ 3 | 4 | Python , TypeScript 5 | ❮ Languages ❯ 6 |

7 | 8 |
9 | 10 | ### Learning Goals 11 | These projects aim to strengthen core programming skills across multiple languages through fun, interactive games. Each project highlights essential concepts like logic, control flow, and language-specific syntax, helping you gain practical, adaptable coding experience. 12 | 13 |
14 | 15 | ❱ Online Python compiler to run Python program online 16 | ```md 17 | https://www.programiz.com/python-programming/online-compiler/ 18 | ``` -------------------------------------------------------------------------------- /TypeScript/unit_01_typescript_basics/typescript_basics.ts: -------------------------------------------------------------------------------- 1 | // This is a simple TypeScript tutorial script with basic concepts explained. 2 | 3 | // TypeScript Basics 4 | 5 | // 1. Declaring Variables 6 | // In TypeScript, we can specify types for variables. Here are a few examples: 7 | 8 | let myName: string = "Nova"; // This is a string type variable 9 | let age: number = 25; // This is a number type variable 10 | let isStudent: boolean = true; // This is a boolean type variable 11 | 12 | // TypeScript can also infer types automatically: 13 | let inferredString = "Hello, TypeScript!"; // TypeScript infers this as a string 14 | let inferredNumber = 100; // TypeScript infers this as a number 15 | 16 | //--------------------------------------------------------------------------------- 17 | // 2. Arrays 18 | // Arrays in TypeScript can also have type annotations: 19 | 20 | let numberArray: number[] = [1, 2, 3, 4, 5]; // Array of numbers 21 | let stringArray: string[] = ["apple", "banana", "cherry"]; // Array of strings 22 | 23 | //--------------------------------------------------------------------------------- 24 | // 3. Functions 25 | // Functions in TypeScript can have type annotations for parameters and return values. 26 | 27 | function addNumbers(a: number, b: number): number { 28 | return a + b; 29 | } 30 | 31 | console.log("Sum of 3 and 5:", addNumbers(3, 5)); 32 | 33 | //--------------------------------------------------------------------------------- 34 | // 4. Objects 35 | // You can create objects with specific types for each property. 36 | 37 | let person: { name: string; age: number; isStudent: boolean } = { 38 | name: "Rajitha", 39 | age: 25, 40 | isStudent: true, 41 | }; 42 | 43 | // Accessing object properties 44 | console.log("Name:", person.name); 45 | console.log("Age:", person.age); 46 | console.log("Is a student:", person.isStudent); 47 | 48 | //--------------------------------------------------------------------------------- 49 | // 5. Enums 50 | // Enums allow you to define a set of named constants. They are useful when you have a fixed set of options. 51 | 52 | enum Direction { 53 | North, 54 | South, 55 | East, 56 | West, 57 | } 58 | 59 | let myDirection: Direction = Direction.North; 60 | console.log("Direction:", myDirection); // Output will be 0 (index of North) 61 | 62 | //--------------------------------------------------------------------------------- 63 | // 6. Type Aliases 64 | // Type aliases allow you to create custom types and reuse them. 65 | 66 | type Point = { 67 | x: number; 68 | y: number; 69 | }; 70 | 71 | let point1: Point = { x: 10, y: 20 }; 72 | console.log("Point coordinates:", point1); 73 | 74 | //--------------------------------------------------------------------------------- 75 | // 7. Interfaces 76 | // Interfaces can be used to define the shape of an object, similar to type aliases. 77 | 78 | interface Animal { 79 | name: string; 80 | age: number; 81 | sound(): void; 82 | } 83 | 84 | let dog: Animal = { 85 | name: "Buddy", 86 | age: 4, 87 | sound: () => console.log("Woof! Woof!"), 88 | }; 89 | 90 | dog.sound(); // Call the sound function 91 | 92 | //--------------------------------------------------------------------------------- 93 | // 8. Classes 94 | // TypeScript classes allow us to create objects with properties and methods. 95 | 96 | class Car { 97 | brand: string; 98 | model: string; 99 | year: number; 100 | 101 | constructor(brand: string, model: string, year: number) { 102 | this.brand = brand; 103 | this.model = model; 104 | this.year = year; 105 | } 106 | 107 | drive() { 108 | console.log(`${this.brand} ${this.model} is driving!`); 109 | } 110 | } 111 | 112 | let myCar = new Car("Toyota", "Camry", 2020); 113 | myCar.drive(); 114 | 115 | //--------------------------------------------------------------------------------- 116 | // 9. Generics 117 | // Generics allow us to create reusable components that work with multiple types. 118 | 119 | function identity(value: T): T { 120 | return value; 121 | } 122 | 123 | console.log("String identity:", identity("Hello!")); // Output: Hello! 124 | console.log("Number identity:", identity(123)); // Output: 123 125 | 126 | //--------------------------------------------------------------------------------- 127 | // 10. Union Types 128 | // Union types allow variables to hold more than one type of value. 129 | 130 | let mixedType: number | string; 131 | mixedType = 10; // OK 132 | mixedType = "Hello"; // OK 133 | 134 | //--------------------------------------------------------------------------------- 135 | // 11. Optional Properties 136 | // Properties can be marked as optional with a question mark. 137 | 138 | interface User { 139 | id: number; 140 | name: string; 141 | email?: string; // Optional property 142 | } 143 | 144 | let user1: User = { id: 1, name: "Alice" }; 145 | let user2: User = { id: 2, name: "Bob", email: "bob@example.com" }; 146 | 147 | console.log("User1:", user1); 148 | console.log("User2:", user2); 149 | 150 | //--------------------------------------------------------------------------------- 151 | // 12. Type Assertion 152 | // Type assertion is a way to tell TypeScript the specific type of a variable. 153 | 154 | let someValue: unknown = "Hello, TypeScript!"; 155 | let stringLength: number = (someValue as string).length; 156 | console.log("Length of string:", stringLength); 157 | 158 | // These are the fundamentals to help you get started with TypeScript basics. 159 | --------------------------------------------------------------------------------