This file contains 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> | |
<h1>Learn JSON</h1> | |
<div id="output"> | |
<ul id="taskList"></ul> | |
</div> | |
<script type="text/javascript"> | |
var data = '{"tasks":{"Cut Grass":true,"Clean Room":false,"Go to Gym":true,"Make Dinner":false}}'; | |
var dataJSON = JSON.parse(data); | |
var output = document.getElementById('output'); |
This file contains 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> | |
<h1>Learn JSON</h1> | |
<div id="output"></div> | |
<form id="myForm"> | |
<input type="text" name="first" value="Laurence"><br> | |
<input type="text" name="last" value="Svekis"><br> | |
<input type="text" name="email" value="test@test.com"><br> | |
<input type="text" name="company" value="Discoveryvip"><br> | |
<input type="submit" value="submit"> | |
</form> |
This file contains 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
name = 'abdullah imran' | |
if name == 'jahangir': | |
prnt('Hi, jahangir') | |
else: | |
print('Hello, abdullah imran') | |
# output: Hello, abdullah imran |
This file contains 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
def spam(divideBy): | |
try: | |
return 42/divideBy | |
except ZeroDivisionError: | |
print('Error: Invalid argument.') | |
print(spam(2)) | |
print(spam(12)) | |
print(spam(0)) | |
print(spam(1)) |
This file contains 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
# 1. Local Scopes Cannot Use Variables in Other Local Scopes | |
def spam(): | |
eggs = 99 | |
bacon() | |
print(eggs) | |
def bacon(): | |
ham = 101 | |
eggs = 0 | |
spam() | |
# output : 99 |
This file contains 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 random | |
def getAnswer(answerNumber): | |
if answerNumber == 1: | |
return 'It is certain' | |
elif answerNumber == 2: | |
return 'It is decidedly so' | |
elif answerNumber == 3: | |
return 'Yes' | |
elif answerNumber == 4: |
This file contains 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
def hello(name): | |
print('Hello '+name) | |
hello('Alice') | |
hello('Bob') | |
'''output | |
Hello Alice | |
Hello Bob | |
''' |
This file contains 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 random | |
import math as ma | |
import random,sys,os,math | |
from random import * | |
for i in range(5): | |
print(random.randint(1,10)) | |
'''output | |
3 |
This file contains 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
for i in range(12,16): | |
print(i) | |
'''output | |
12 | |
13 | |
14 | |
15 | |
''' | |
for i in range(0,10,2): |
This file contains 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
print('My name is') | |
for i in range(5): | |
print('Jimmy Five Times (' + str(i) + ')') | |
'''output | |
My name is | |
Jimmy Five Times (0) | |
Jimmy Five Times (1) | |
Jimmy Five Times (2) | |
Jimmy Five Times (3) |
OlderNewer