PYTHON Interview Questions and Answers
Question - 61 : - How can you get a random number in python?
Answer - 61 : - random() − returns a random float r, such that 0 is less than or equal to r and r is less than 1.
Question - 62 : - How will you set the starting value in generating random numbers?
Answer - 62 : - seed([x]) − Sets the integer starting value used in generating random numbers. Call this function before calling any other random module function. Returns None.
Question - 63 : - How will you randomizes the items of a list in place?
Answer - 63 : - shuffle(lst) − Randomizes the items of a list in place. Returns None.
Question - 64 : - How will you capitalizes first letter of string?
Answer - 64 : - capitalize() − Capitalizes first letter of string.
Question - 65 : - How will you check in a string that all characters are alphanumeric?
Answer - 65 : - isalnum() − Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise.
Question - 66 : - How will you check in a string that all characters are digits?
Answer - 66 : - isdigit() − Returns true if string contains only digits and false otherwise.
Question - 67 : - How will you check in a string that all characters are in lowercase?
Answer - 67 : - islower() − Returns true if string has at least 1 cased character and all cased characters are in lowercase and false otherwise.
Question - 68 : - How will you check in a string that all characters are numerics?
Answer - 68 : - isnumeric() − Returns true if a unicode string contains only numeric characters and false otherwise.
Question - 69 : - How will you check in a string that all characters are whitespaces?
Answer - 69 : - isspace() − Returns true if string contains only whitespace characters and false otherwise.
Question - 70 : - How will you check in a string that it is properly titlecased?
Answer - 70 : - istitle() − Returns true if string is properly "titlecased" and false otherwise.