planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']
planet_to_initial = {planet: planet[0] for planet in planets}
planet_to_initial
for loop over a dictionary will loop over its keys
for k in numbers:
print("{} = {}".format(k, numbers[k]))
We can access a collection of all the keys or all the values with dict.keys()
and dict.values()
, respectively.
' '.join(sorted(planet_to_initial.values()))
The very useful dict.items()
method lets us iterate over the keys and values of a dictionary simultaneously. (In Python jargon, an item refers to a key, value pair)
for planet, initial in planet_to_initial.items():
print("{} begins with \"{}\"".format(planet.rjust(10), initial)) Mercury begins with "M"
Venus begins with "V"
Earth begins with "E"
Mars begins with "M"
Jupiter begins with "J"
Saturn begins with "S"
Uranus begins with "U"
Neptune begins with "N"
datestr = '1956-01-31'
year, month, day = datestr.split('-')'/'.join([month, day, year])
Farklı bitane
claim = "Pluto is a planet!"
words = claim.split() # default olarak boşluklardan ayırır
# Yes, we can put unicode characters right in our string literals :)
' 👏 '.join([word.upper() for word in words])
print içinde genelde kullandığımız yöntem
"{}, you'll always be the {}th planet to me.".format(planet, position)
üsttekinin ileri seviye kullanımı
pluto_mass = 1.303 * 10**22
earth_mass = 5.9722 * 10**24
population = 52910390
# 2 decimal points 3 decimal points, format as percent separate with commas
"{} weighs about {:.2} kilograms ({:.3%} of Earth's mass). It is home to {:,} Plutonians.".format(
planet, pluto_mass, pluto_mass / earth_mass, population,
)
—
# Referring to format() arguments by index, starting from 0
s = """Pluto's a {0}.
No, it's a {1}.
{0}!
{1}!""".format('planet', 'dwarf planet')
print(s)
[
planet.upper() + '!'
for planet in planets
if len(planet) < 6
]
tek satır hali
def count_negatives(nums):
return len([num for num in nums if num < 0])print(count_negatives([5, -1, -2, 0, 3]))
boolean kullanımı
def count_negatives(nums):
# Reminder: in the "booleans and conditionals" exercises, we learned about a quirk of
# Python where it calculates something like True + True + False + True to be equal to 3.
return sum([num < 0 for num in nums])
mysql-connector-java-8.0.27.tar.gz indirilip projeye dahil edilir. Mysql database online çalışmaktadır.

Java LinkedList ArrayList Farkı
Comperable ve Comparator Interface (comparator kullan geç, compareble için class içine interface implement etmek gerekir.)
Vector -> thereat işlemlerinde ArrayList yerine tercih edilir. (stack vector den türer. Last in first out (LIFO))
Queue (kuyruk) -> FIFO , first in first out , add(eleman) yerine offer(eleman) kullanmak daha guvenli. eklerse true ekleyemezse false değer döner. remove() kuyruk başındakı elemanı çıkarır.kuyruk boşsa hata fırlatır. bunu yerine poll() kullan. boşsa null döner. element() peek() benzer durumda baştaki elemanı verir listeden çıkarmaz
PriorityQueue -> eklenen elemanlar alfabetik sıraya göre queue ye eklenir. poll() işlemiyle baştan boşaltılır
ListIterator-Iterator ->