Hadia's Blog
Saturday, May 11, 2024
Top On Sale Product Recommendations!;Popular electric bubble gun for children's toys 32 hole bubble machine electric bubble gun without battery bubble water;Original price: PKR 3344.30;Now price: PKR 1103.56;Click&Buy: https://s.click.aliexpress.com/e/_EzM9xxZ
Saturday, July 8, 2023
Selenium with Python: Frames
element = driver.switch_to.active_element
alert = driver.switch_to.alert driver.switch_to.default_content() driver.switch_to.frame('frame_name') driver.switch_to.frame(1) driver.switch_to.frame(driver.find_elements(By.TAG_NAME, "iframe")[0]) driver.switch_to.parent_frame() driver.switch_to.window('main')
Example:
#driver.get("https://testlayers.staging.senegalsoftware.com/JobPosts/create?id=326D4402-25C1-4D7E-81DB-23DA5AF14111&step=2")driver.switch_to.frame(driver.find_element(By.XPATH, '//*[@id="cke_1_contents"]/iframe'))driver.find_element(By.TAG_NAME, "p").send_keys("Dentist")driver.switch_to.parent_frame()
Tuesday, March 15, 2022
Hacker Rank 30 day code Challenge (Inheritance and constructor in python)
Hacker Rank 30 day code Challenge (Inheritance and constructor in python)
Problem:
The parent class is Person. Make a subclass Student. The Student has attributes first name, last name, Id, Scores.
Input: First Name, Last Name, ID, Number of scores (e.g 2 or 3) , Scores
Take the average of scores and print.
(Starting Person class code and Ending code is already provided in hacker rank editor)
Monday, March 14, 2022
Hacker Rank 30 day code challenge Python
Problem:
Convert a number 'n' to its binary base 2. Find base 10 integers 0,1. Find max number of consecutive 1's.
import math
no = int(input())
arr = []
while no // 2 > 0:
remainder = no % 2
arr.append(remainder)
no = no // 2
arr.append(no)
max = []
count = 0
for i in arr:
if i == 1:
count = count + 1
max.append(count)
else:
count = 0
max.sort()
print(max[-1])
Tuesday, March 8, 2022
Hacker Rank 30 Day Challenge(Recursion-Factorial Program)
Hacker Rank 30 Day Challenge(Recursion-Factorial Program)
Problem:
For a number n entered by the user, calculate its factorial. Use recursion to calculate.
Example:
n=4
Factorial of 4 is : 4x3x2x1
Factorial of 5 is: 5x4x3x2x1
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'factorial' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER n as parameter.
#
def factorial(n):
i=1
r=1
for i in range(n):
r=r*(i+1)
i=i+1
return r
n=int(input().strip())
result = factorial(n)
print(result)
Monday, March 7, 2022
Split() method in Python
Split() method:
- Splits the string into a list of words.
- You can specify a separator (e.g ' '' !)
- The default separator is whitespace.
- We can take string input from the user. Use the split method and add the input to dictionary key-value pairs.
For example:
for i in range(n):
name=input()
phoneNum=name.split()
PhoneBook[phoneNum[0]]= phoneNum[1]
Another example:
string="Hello click this link"
list=string.split()
print(list)
OUTPUT:
['Hello', 'click', 'this', 'link']
Process finished with exit code 0
HackerRank 30 day challenge Python (Dictionaries)
Sunday, March 6, 2022
HackerRank 30 day code challenge Day 7
HackerRank 30 day code challenge Day 7
Problem:
Take input N this is the length of the array. Take input elements of the array of (length N). Elements are all integers. Print this array in reverse order on the same line and space separated.
import math
import os
import random
import re
import sys
n = int(input().strip())
arr=[]
arr = list(map(int, input().rstrip().split()))
i=len(arr)-1
#print(i)
while i<len(arr) and i>-1:
print(f'{arr[i]}' + " " ,end='')
i=i-1
Output:
6
1 2 3 4 5 6
6 5 4 3 2 1
Process finished with exit code 0
Thursday, March 3, 2022
HackerRank 30 Day Code Challenge(Day 6)
Problem:
Taking n input strings, separate each string's odd and even indexes and print the even-odd characters in form of two space-separated strings on a single line.
n=int(input())
x=0
evenstr=""
oddstr=""
i=0
for x in range(0,n):
s=input()
evenstr = ""
oddstr = ""
for i in range(0, len(s)):
if i % 2 == 0:
evenstr = evenstr + s[i]
elif i % 2 != 0:
oddstr = oddstr + s[i]
print(evenstr +' '+ oddstr )
-
Zindagi say dartay ho? Zindagi to tum bhi ho, Zindagi to hum bhi hain Zindagi say dartay ho... Aadmi say dartay ho? Aadmi to tum bhi ho, Aa...
-
Hacker Rank 30 Day Challenge(Recursion-Factorial Program) Problem: For a number n entered by the user, calculate its factorial. Use recursi...