Skip to content

Instantly share code, notes, and snippets.

class Main {
public static void main(String[] args) {
int[] a = {100, 300, 500};
System.out.println(a[2]);
}
}
10.times do
x = 10
p x
end
puts "What is your name?"
name = gets
puts "Hello World"
p "Hello World"
numbers = [1,2,3,4,5]
p numbers
numbers = [1,2,3,4,5]
puts numbers
def sum4(list_integer):
sum = 0
i = 0
length = len(list_integer)
while i < length:
sum += list_integer[i]
if list_integer[i] == 4: i += 1
i += 1
return sum
def verb_post(s):
irregular_words = {
"write": "wrote",
"go": "went",
"put": "put",
"bring": "brought",
}
if irregular_words.has_key(s):
return irregular_words[s]
if s[-1] == "c":
import sys
args = len(sys.argv)
if args == 1:
print("Enter a file name below")
f = sys.stdin.readline().rstrip()
elif args == 2:
f = sys.argv[1]
else:
sys.exit("please enter the command this way: 'python nl.py [a file]'")