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
lotsofhellos = "hello " * 10 | |
print(lotsofhellos) | |
even_numbers = [2,4,6,8] | |
odd_numbers = [1,3,5,7] | |
all_numbers = odd_numbers + even_numbers | |
print(all_numbers) | |
print([1,2,3] * 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
number = 1 + 2 * 3 / 4.0 | |
print(number) | |
remainder = 11 % 3 | |
print(remainder) | |
squared = 7 ** 2 | |
print(squared) | |
cubed = 2 ** 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
mylist = [] | |
mylist.append(1) | |
mylist.append(2) | |
mylist.append(3) | |
print(mylist[0]) # prints 1 | |
print(mylist[1]) # prints 2 | |
print(mylist[2]) # prints 3 | |
# prints out 1,2,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
a, b, c = 3, 4, 'Max' | |
print(a, b, c) |
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
my_var = 7 | |
print(my_var) | |
my_var = 7.0 | |
print(my_var) | |
my_var = int(my_var) # casting | |
print('int again:', my_var) | |
my_var = 'hello' |
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
x = 1 | |
if x == 1: | |
# indented four spaces | |
print("x is 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
print("Hello, World!") |
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 { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'shortUrl' | |
}) | |
export class ShortUrlPipe implements PipeTransform { | |
transform(url: string, args?: any): any { | |
if (url) { | |
const len = url.length; |
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 { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'shortDomain' | |
}) | |
export class ShortDomainPipe implements PipeTransform { | |
transform(url: string, args?: any): any { | |
if (url) { | |
if (url.length > 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
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'shortDomain' | |
}) | |
export class ShortDomainPipe implements PipeTransform { | |
transform(url: string, args?: any): any { | |
if (url) { | |
if (url.length > 3) { |