python dan çok basit bi sorum var

Qudas

Diamond Üye
Katılım
27 Şub 2020
Mesajlar
360
Beğeniler
45
# define Reservation class
class Reservation:
def __init__(self, date_time, duration, breed, num_dogs):
self.date_time = date_time
self.duration = duration
self.breed = breed
self.num_dogs = num_dogs

def get_price(self):
return self.duration * 10 + self.num_dogs * 5


# get user input
date_time = input("Enter date and time (DD/MM/YYYY): ")
duration = int(input("Enter duration in hours: "))
breed = input("Enter breed: ")
num_dogs = int(input("Enter number of dogs: "))


# make reservation and calculate price
reservation = Reservation(date_time, duration, breed, num_dogs)
price = reservation.get_price()

# display reservation and price
print(f"Reservation successful for {num_dogs} {breed}(s) on {date_time} for {duration} hours.")
print(f"Total price: ${price}")

import random


def makename():
a = ["Your dog walkers is: ali", "Your dog walkers is: patric","Your dog walkers is: robert", "Your dog walkers is: anais",
"Your dog walkers is: charlie", "Your dog walkers is: katarina", "Your dog walkers is: rock", "Your dog walkers is: Kelvin", "Your dog walkers is: Craig", "Your dog walkers is: alex", "Your dog walkers is: Abel"]
p = ["Collins", "Smith", "Koç", "Hill", "Glory", "Carney", "Gav"]
return "{} {}".format(random.choice(a), random.choice(p))

for i in range(1):
print(makename())

Arkdaşlar böyle bi kodum var sadece date_time = input("Enter date and time (DD/MM/YYYY): ") Bu kısma eğer 2023 en düşük bi sayı girilirse program 2023 den dah düşük bir sayı giremezsiniz desin bunu yapabilecek var mı
 
kanka:
Python:
date_time = input("Enter date and time (DD/MM/YYYY): ")

gun,ay,yil = date_time.split("/")
if int(yil)<2023:
    print("Girilen yil 2023 den küçük olamaz.")
else:
    burada kodlarını devam ettir.


bu şekilde kullanabilirsin.
 
Python:
# get user input and check if date is valid
while True:
    date_time = input("Enter date and time (DD/MM/YYYY): ")
    year = int(date_time[-4:])
    if year < 2023:
        print("Please enter a date and time after 2023.")
    else:
        break

duration = int(input("Enter duration in hours: "))
breed = input("Enter breed: ")
num_dogs = int(input("Enter number of dogs: "))

# make reservation and calculate price
reservation = Reservation(date_time, duration, breed, num_dogs)
price = reservation.get_price()

# display reservation and price
print(f"Reservation successful for {num_dogs} {breed}(s) on {date_time} for {duration} hours.")
print(f"Total price: ${price}")
 
Allah chatgptden razı olsun yaz direk çözüyor istersen atabilirim de
 
ödevi chatgpt den yaptım da inş belli olmaz yanni
 

  Şuanda konuyu görüntüleyen kullanıcılar


Üst Alt