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
#!/bin/bash | |
GIST_ID=$1 | |
cd ~/bin | |
git clone https://gist.github.com/$GIST_ID.git | |
chmod u+x $GIST_ID/* | |
ln $GIST_ID/* | |
#cand vrei sa creezi un gist nou, copiezi din url doar ultima parte, id-ul; si il pui ca parametru pozitional | |
#asta face acel $1 acolo. | |
#mai exact, rulezi in shell "install-gist-scripts.sh e37db3c856c4c482ef71084a9f95a812" fara ghilimele |
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
echo salam |
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
#!/bin/bash | |
echo "Introduce numele mancarii" | |
read KEYBOARDINPUT | |
#ce introduci de la tastatura baga in variabila KEY... | |
echo -n $KEYBOARDINPUT" are extraordinar de " | |
case $KEYBOARDINPUT in | |
clatite | gogosi | gem) echo -n multe ;; | |
ciorba | supa | salata) echo -n putine ;; | |
orez | lacuste | broaste) echo -n potrivite ;; | |
*) echo -n necunoscute ;; |
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(locations[loc]) | |
#se duce in dictionarul locations si selecteaza loc ul curent, | |
#daca e la 3, printeaza ce e in dreptul cheii 3 de la locations | |
if loc ==0: | |
break | |
#daca loc == 0 iese din loop/program | |
direction = input("Available exits are "+availableExits + " ").upper() | |
print() | |
#parse user input, using VOCABULARY | |
if len(direction) > 1 #more than 1 letter |
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
#========EX5========== | |
#NOW WE WANT PLAYERS TO ENTER THE NAME OF THE LOCATIOn, not a direction | |
#so you can just type 'valley' and go there | |
#so we add road, hill etc to the vocabulary | |
"""So we can't store the directions in Vocabulary. Instead, we store the location numbers, then map them | |
to the appropriate location. | |
From the Valley, typing Road should go north, so the vocabulary maps "ROAD" to "1" | |
and in the exits entry for Valley we map "1" to location 1. | |
Typing Hill from the Valley needs to take you West, so we map "HILL" to "2", then in the Valley's exits entry | |
we map "2" to location 2 (which is the hill).""" |
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
#unpacking tuples from a list of tuples | |
#cand ai doua valori inainte de in (ex: a si b) | |
#a ia prima valoare, b urmatoarea, apoi a ia a treia valoare, b a 4a etc | |
list_of_tuples= [(1,2),(3,4)] | |
print(list_of_tuples) | |
for a,b in list_of_tuples: | |
print("a:", a,"b:",b) | |
#prints a:1 b:2 a:3 b: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
list4=[1,2,3,4,5,2,3] | |
print(set(list4)) #aplicam functia set pe lista | |
#printeaza {1 2 3 4 5} | |
set2=set([11,12,13,14,14,11]) | |
print(set2) #prints doar elem unice | |
set5= { 1,2,2,3,3,4} | |
print(set5) | |
set5.add(16) #adauga elementul 16 in setul respectiv | |
set5.remove(16) |
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
tupla1 = ("cisco", "2750", "15.0") | |
vendor, model, Ios_version = tupla1 | |
#astea de sus NU TREBUIE PUSE INTRE GHILIMELE | |
#altfel va da eroare | |
print(vendor) |
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 line in variabila: | |
print(line) | |
variabila.close() #inchide fisierul | |
#trebuie sa pui cate 2\\ ca sa nu fie interpretat aiurea de Python. | |
variabila = open("C:\\Users\\alexa\\Downloads\\sample.txt", ‘r’) | |
#printeaza doar liniile in care apare "jabberwock" | |
for ceva in variabila: | |
if "jabberwock" in ceva.lower(): | |
#convertim lowercase pt a cauta ceva |
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 pickle #importi libraria pickle | |
#imelda is a touple | |
imelda = ("More mayhem", | |
"Imelda May", | |
"2011", | |
((1, "Pulling the Rug"), | |
(2, "Psycho"), | |
(3, "Mayhem"), | |
(4, "Kentish Town Waltz"))) | |
with open("imelda.pickle", "wb") as oriceNume: |
OlderNewer