Posts

timedelta

 Python میں `timedelta` ایک کلاس ہے جو `datetime` module کا حصہ ہے۔ یہ کلاس وقت کے وقفے (time intervals) کی نمائندگی کرنے کے لیے استعمال ہوتی ہے، جیسے دن، سیکنڈ، منٹ، گھنٹے وغیرہ۔ `timedelta` کے کچھ بنیادی استعمال اور خصوصیات درج ذیل ہیں: ### 1. `timedelta` بنانے کا طریقہ: آپ `timedelta` کو مختلف یونٹس کے ساتھ بنا سکتے ہیں، جیسے دن، سیکنڈ، منٹ، گھنٹے وغیرہ۔ ```python from datetime import timedelta # ایک دن کا وقفہ one_day = timedelta(days=1) # ایک گھنٹے کا وقفہ one_hour = timedelta(hours=1) # تیس منٹ کا وقفہ thirty_minutes = timedelta(minutes=30) ``` ### 2. `timedelta` کے ساتھ ریاضیاتی عملیات: آپ `timedelta` کو جمع، تفریق، اور دوسرے ریاضیاتی عملیات کے ساتھ استعمال کر سکتے ہیں۔ ```python from datetime import datetime, timedelta # موجودہ وقت now = datetime.now() # موجودہ وقت میں ایک دن کا اضافہ tomorrow = now + timedelta(days=1) # موجودہ وقت میں ایک گھنٹے کی کمی one_hour_ago = now - timedelta(hours=1) print("ابھی کا وقت:", now) print("کل کا وقت:", tomorrow) print(...

Python Time module

Python میں وقت سے متعلق کوڈ بنانے کے لئے آپ کو datetime لائبریری استعمال کرنی ہوگی۔ یہ لائبریری Python میں وقت اور تاریخ سے متعلق کام کرنے کے لئے استعمال کی جاتی ہے۔ یہاں ایک بنیادی مثال دی گئی ہے کہ کس طرح Python میں وقت سے متعلق کوڈ بنایا جا سکتا ہے: ### مرحلہ 1: datetime لائبریری درآمد کریں ```python import datetime ``` ### مرحلہ 2: موجودہ وقت اور تاریخ حاصل کریں ```python current_time = datetime.datetime.now() print("موجودہ وقت اور تاریخ:", current_time) ``` ### مرحلہ 3: مخصوص فارمیٹ میں وقت اور تاریخ دکھائیں ```python formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S") print("فارمیٹ شدہ وقت اور تاریخ:", formatted_time) ``` ### مرحلہ 4: وقت میں فرق حاصل کریں ```python future_time = current_time + datetime.timedelta(days=5) print("پانچ دن بعد کا وقت اور تاریخ:", future_time) ``` ### مکمل کوڈ ```python import datetime # موجودہ وقت اور تاریخ حاصل کریں current_time = datetime.datetime.now() print("موجودہ وقت اور تاریخ:", current...

age code find classes colleg school tushan

 name = input('enter your name ........... ') n = (name.upper()) print ('ok .......... ' +name) age = int(input('enter your age ......... ' )) print ('ok....... ',age) if age >=18:         print (name +' go to colleg .......') elif age<= 5:         print ('go to tushan .........') else:         print (name +' go to school.....') new upgrde  wargen  note = 'using this code \n \'thanks\'' no = (note.upper()) name = input('enter your name ........... ') n = (name.upper()) print ('ok .......... ' +n) age = int(input('enter your age ......... ' )) print ('ok....... ',age,' \n') if age >=18:         print (n +' go to colleg .......\n') elif age<= 5:         print (n +'go to tushan .........\n') else:         print (n +' go to school.....\n') print (no)

Car drive and not drive code

b = 'you can drive ...... \n\'and......\'\nyou can not drive.....\n' c = (b.title()) print (c) e = 'thanks....\nusing this code.....' f = (e.title()) x = input('enyer your name ') y = ('hello ' + x) z = (y.title()) print (z) a = int(input('enter your age \n......')) print (x ,'' + 'hello your age is ........',a) if a > 17:         print ( x + ' you can \'drive\'\n') else:         print ( x + ' you can not \'drive\'\n') print (f)

Adult watching and not watching code

 a = 'hello ' b = (a.upper()) name = input('enter your name ') print ('hello .......'+name) gander = input('your gander ....\nman .......woman..') print ('ok.........'+gander) age = int(input('enter your age .........\n')) print ('ok your age is .......... ',age) if age>=18:         print (a+name + ' you can watching this sex ') else:         print (a+name+' do not watching this sex ')

Rastorant card code

 order = input('cold coffe ........hot coffe ') b = (order.upper()) print (b) a = input('pizza ............beryane ') c = (a.upper()) print (c) d = input('chai ..........cake ') f = (d.upper()) print (f) t = 'thanks ' k = (t.upper()) print (k) print (b) print (c) print (f)

String editor

 find index isalnum isalpha isupper islower isprintable isspace istitle endswith startswith swapcase title #a = '  ' #print (a.isspace()) a = 'Fida' print (a.istitle()) #a = 'Fida' #print (a.swapcase()) a = 'hello fida my name is harry' print (a.title())