Posts

Showing posts from April, 2025

py

 from datetime import datetime datetime = datetime(2019, 11, 27, 11, 27, 22) print(datetime.strftime('%y/%B/%d %H:%M:%S'))

py programe

 def mysplit(strng):     # return [] if string is empty or contains whitespaces only     if strng == '' or strng.isspace():         return [ ]     # prepare a list to return     lst = []     # prepare a word to build subsequent words     word = ''     # check if we are currently inside a word (i.e., if the string starts with a word)     inword = not strng[0].isspace()     # iterate through all the characters in the string     for x in strng:         # if we are currently inside a string...         if inword:             # ... and the current character is not a space...             if not x.isspace():                 # ... update the current word                 word = word + x   ...

function in list

    Some of the methods offered by strings are: capitalize()  – changes all string letters to capitals; center()  – centers the string inside the field of a known length; count()  – counts the occurrences of a given character; join()  – joins all items of a tuple/list into one string; lower()  – converts all the string's letters into lower-case letters; lstrip()  – removes the white characters from the beginning of the string; replace()  – replaces a given substring with another; rfind()  – finds a substring starting from the end of the string; rstrip()  – removes the trailing white spaces from the end of the string; split()  – splits the string into a substring using a given delimiter; strip()  – removes the leading and trailing white spaces; swapcase()  – swaps the letters' cases (lower to upper and vice versa) title()  – makes the first letter in each word upper-case; upper()  – converts all the string's ...

pe1 module 3

  MODULE 3 TEST Well done! You've reached the end of Module 3 and completed a major milestone in your Python programming education. Here's a short summary of the topic areas you've covered in Module 3: Boolean values to compare different values and control the execution paths using the if and if-else instructions; the utilization of loops (while and for) and how to control their behavior using the break and continue instructions; the difference between logical and bitwise operations; the concept of lists and list processing, including the iteration provided by the for loop, and slicing; the idea of multi-dimensional arrays. You are now ready to take the  module test , which will both help you gauge what you've learned so far. The following test is based on what you have just learned. There are twenty questions in total and you need to score at least 70% to pass. Good luck! Question  1 An operator able to check wh...