This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You are creating a fantasy video game. The data structure to model the player's inventory will be a dictionary where the keys are string values describing the item in the inventory and the value is an integer values defailing how many of that item the player has. For example, the dictionary value {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12} means the player has 1 rope, 6 torches, 42 gold coins, and so on. | |
# Write a function named displayInventory() that would take any possible "inventory" and display it like the following: | |
# Inventory: | |
# 12 arrow | |
# 42 gold coin | |
# 1 rope | |
# 6 torch | |
# 1 dagger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tic-Tac-Toe game; uses numpad for entries | |
the_board = { | |
'7': ' ', | |
'8': ' ', | |
'9': ' ', | |
'4': ' ', | |
'5': ' ', | |
'6': ' ', | |
'1': ' ', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package employee | |
import "fmt" | |
// employee represents an employee | |
type employee struct { | |
firstName string | |
lastName string | |
totalLeaves int | |
leavesTaken int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>JavaScript - Replicating Facebook</title> | |
<script src="script.js" charset="utf-8"></script> | |
</head> | |
<body> | |
<p>You are kinda replicating.</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: #eee; | |
} | |
#message { | |
width: 400px; | |
background: #ddaaaa; | |
padding: 20px; | |
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif; | |
font-size: 18px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: #eee; | |
} | |
#content { | |
width: 400px; | |
background: #fff; | |
padding: 20px; | |
padding-top: 0; | |
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Car = function(maxSpeed, driver) { | |
this.maxSpeed = maxSpeed; | |
this.driver = driver; | |
this.drive = function(speed, time) { | |
console.log(speed, time); | |
}; | |
this.logDriver = function() { | |
console.log("driver name is " + this.driver); | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Form Validation Example</title> | |
</head> | |
<body> | |
<form action="/register" id="registration" method="get" accept-charset="utf-8"> | |
<input type="text" name="email" placeholder="Email" autofocus autocomplete="off" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import syntax is kinda just opposite from Python | |
import {Point} from './point'; | |
let point = new Point(); | |
let x = point.X; | |
point.X = 10; | |
point.draw(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// without initilization, message is of 'any' type | |
// now you won't get intellisense because editor doesn't | |
// know what type it is.. | |
let message; | |
message = "abs"; | |
// one example of type assertion | |
let endswithC = (<string>message).endsWith('c'); | |
// the alternative way |