Skip to content

Instantly share code, notes, and snippets.

//calc cati ani ai
function calculateAge(yearOfBirth) {
var age = 2016 - yearOfBirth;
return age;
}
var ageJohn = calculateAge(1990);
var ageMike = calculateAge(1969);
console.log(ageJohn);
//cat mai ai pana la pensie
#class = a template from which objects can be created
#all the obj created from the same class will share the same caracteristici
#an instance is just another name created from a class definition
"""Planul unei case descrie doar cum va arata asta, cate camere va avea; ca si clasa
odata ce ai un plan, poti construi cate case vrei"""
"""When a variable is bound to an instance of a class, it's refered to as a data attribute"""
""" CONSTRUCTOR = a special method that is executed when an instance of a class is created or constructed
#imaginile le gasesti aici
# http://svg-cards.sourceforge.net/
#=====GLOBAL VARIABLES============
import random
import tkinter
def load_images(card_images): #incarca imaginile cu cartile
suits= ['heart', 'club', 'diamond', 'spade'] #case sensitive
face_cards= ['jack', 'queen', 'king']
parrot_list = ['non pinin', 'no more']
parrot_list.append("norwegian blue") #adauga la sfarsitul listei
for state in parrot_list:
print('This parrot is ' + state)
odd = [1, 3, 5, 7]
even = [2, 4, 6, 8]
numbers = odd + even
numbers.sort() #sort nu creaza un obiect nou
print(numbers)
"""We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary day and we add it
to the shortest month of the year, February.
In the Gregorian calendar three criteria must be taken into account to identify leap years:
The year can be evenly divided by 4, is a leap year, unless:
The year can be evenly divided by 100, it is NOT a leap year, unless:
The year is also evenly divisible by 400. Then it is a leap year.
This means that in the Gregorian calendar, the years 2000 and 2400 are leap years,
while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.
Task
You are given the year, and you have to write a function to check if the year is leap or not.
"""Write a GUI program to create a simple calculator
Try to be as Pythonic as possible, it's ok if you end up writing
repeated Button and Grid statements, but consider using lists and a for loop
There is no need to store the buttons in variables.
As an optional extra, refer to the documentation to
work out how to use minsize() to prevent your
window from being shrunk so that the widgets vanish
from view
try:
import tkinter
except ImportError: # python 2
import Tkinter as tkinter
import os
mainWindow = tkinter.Tk()
mainWindow.title("Grid Demo")
mainWindow.geometry('640x480-8-200')
import tkinter
print(tkinter.TkVersion) #astea 2 verifica versiunea
print(tkinter.TclVersion)
#tkinter._test() #face sa apara o fereastra grafica
mainWindow = tkinter.Tk()
mainWindow.title("Hello WOrld!")
mainWindow.geometry("640x480+8+400") #aici e string, nu numar
#8px e distanta fata de marginea din stanga a ecranului
#400 e distanta fata de marginea din dreapta a ecr
mainWindow.mainloop() #cand rulezi asta predai controlul lui tkinter
#Decomposition is segmenting the code into smaller parts, for easier reading and maintenance
def numeFunctie():
return "Nu printez doar returnez"
rezultat = numeFunctie()
print(rezultat)
print(type(rezultat)) #e str
def functie2():
return 'lorin salam', 2
print(functie2())
"""For example, 13 is a divisor of 26 because 26 / 13 has no remainder.)
R: There were a number of tricky things with this exercise.
First, the type conversions between input strings and integers for the range()
function need to be carefully output.
Second, the arguments to range() had to be carefully constructed to cover
all the possible numbers. Third, the condition in the if statement had to be correct as well."""
num = int(input("Baga nr: "))
print(type(num)) # e int pt ca l-am fortat
#daca nu fortam, ar fi fost str si nu mergea
listRange = list(range(1,num+1)) #merge si daca nu pun list