10/16/18

Python Control Statements (Conditional Statements, Loops & Jumping Statements)



#============= ====================if else ===========================================

# Case1
a=30
if a>20:
    print("true condition")
else:
    print("false condition")



# Case2
if True:
    print("true condition")
else:
    print("false condition")


# Case3
if 1:
    print("true condition")
else:
    print("false condition")


# Even or Odd
a=10
if a%2==0:
    print("Even Number")
else:
    print("Odd Nmber")


# Multiple statements under if block

if False:
    print("Statement1")
    print("Statement2")
    print("Statement3")
else:
    print("Statement4")
    print("Statement5")

print("Statement6") # Separate statement , Not part of else Block



# Single Line

print("welcome") if True else print("Python")
print("welcome") if False else print("Python")

print("welcome") if 20>10 else print("Python")
print("welcome") if 20<10 else="" p="" print="" ython="">

# Multiple statements in Single Line
{print("Python2"),print("learning1")} if True else {print("Python3"), print("learning2")}
{print("Python2"),print("learning1")} if False else {print("Python3"), print("learning2")}

# ===================================elif ===========================================

# elif
a=50
if a==10:
    print("Ten")
elif a==20:
    print("Twenty")
elif a==30:
    print("Thirty")
else:    # Optional
    print("Not listed")

# ===================================elif ===========================================

#Range() function
print(list(range(10))) #[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print(list(range(5,10))) #[5, 6, 7, 8, 9]

print(list(range(1,10,2))) #[1, 3, 5, 7, 9] Odd numbers
print(list(range(0,10,2))) #[0, 2, 4, 6, 8] Even numbers

print(list(range(10,1,-1))) #[10, 9, 8, 7, 6, 5, 4, 3, 2] Decrement

print(list(range(-10,-5))) #[-10, -9, -8, -7, -6]   Nagitives
print(list(range(-10,-5,2))) #[-10, -8, -6] Nagitives increment by 2




# ===================================for loop ===========================================
#for loop

#Prints 1..9 numbers
for i in range(10):
    print(i)

#Prints Evens between 2..9 numbers
for i in range(2,10,2):
    print(i)

#Prints Odds between 1..9 numbers
for i in range(1,10,2):
    print(i)

#Prints numbers between 10..2 in decending order
for i in range(10,1,-1):
    print(i)

# ===================================while loop ===========================================
#Prints 1..9 numbers
i=1
while i<=10:
    print(i)
    i=i+1

#Prints 10..1 numbers in decending order
i=10
while i>=1:
    print(i)
    i=i-1




# ===================================break & Continue ===========================================
#break
for i in range(1,10):
    if i==5:
        break
    print(i)
else: print("program exited")


#continue
for i in range(1,10):
    if i==5:
        continue
    print(i)
else: print("program exited")










Python-Taking User input, Type Conversion & Formatting Output



Taking User Input

num1=input("Enter First Number:") # Takes data in String format input:10
num2=input("Enter Second Number:") # Takes data in String format  input:20
print(num1+num2) # concatenates strings output: 1020

############################

num1=int(input("Enter First Number:"))
num2=int(input("Enter Second Number:"))
print(num1+num2)

##########################
num1=input("Enter First Number:")
num2=input("Enter Second Number:")
print(int(num1)+int(num2))



Type Conversion Example-1

num1=input("Enter Decimal Number1:") #10.5
num2=input("Enter Decimal Number2:") #10.6
print(num1+num2) #Concatenates 10.510.6

###############################################

num1=float(input("Enter Decimal Number1:"))
num2=float(input("Enter Decimal Number2:"))
print(num1+num2)

#################################################
num1=input("Enter Decimal Number1:")
num2=input("Enter Decimal Number2:")
print(float(num1)+float(num2))

Type Conversion Example-2

num1=input("Enter Decimal Number1:") #10.5
num2=input("Enter Decimal Number2:") #10.6
print(num1+num2) #Concatenates 10.510.6

###############################################

num1=float(input("Enter Decimal Number1:"))
num2=float(input("Enter Decimal Number2:"))
print(num1+num2)

#################################################
num1=input("Enter Decimal Number1:")
num2=input("Enter Decimal Number2:")
print(float(num1)+float(num2))


Type Conversion Example-3

#################################
num1=input("Enter a Float Number:") #10.5
num2=input("Enter a Integer Number:") #5
print(int(num1)+float(num2)) #ValueError: invalid literal for int()


Formatting Output

name,age,sal = "John",24,10000.35

#Approach1
print(name,age,sal)

#Approach2
print("Name is:", name)
print("Age is:", age)
print("Sal is:", sal)

#Approach3 : using  %  Here type is imp
print("Name:%s  age:%d  salary:%g" %(name, age, sal))

#Approach3 : using  {} Here value is imp
print("Name:{}  age:{}  salary:{}".format(name, age, sal))

#Approach4 : using  {} Here value is imp
print("Name:{1}  age:{2}  salary:{2}".format(name, age, sal))







Python Variables & Data Types




Variables

a=10
b=10.5
name='pavan'
print(a)
print(b)
print(name)
print(a,b,name)

############################

#this statement assign 100 to a, 100.5 to b and Welcome to c. Multiple Values to multiple varaibles
a,b,c=100,100.5,"welcome"
print(a,b,c)

a = b = c = 100 # this statement assign 100 to c, b and a.  Single value to all variables
print(a,b,c)

#################
x = 1
y = 2
y, x = x, y  # assign y value to x and x value to y
print (x,y)

Data Types

x=100  # int type
y=10.5 # float type

s1="welcome"  # string/char type
s2='welcome' # string /char type

b=  True # boolean type

# To know th type of variables
print(type(x))
print(type(y))
print(type(s1))
print(type(s2))
print(type(b))

Concatenation

print(10+10) # valid
print(10.5+10.5) # valid
print("welcome"+"python") # valid
print (10+15.5) # valid

print(True+5) # valid
print(10+False) # valid
print(True+True)# valid

print(10+"welcome")  #Not valid  -TypeError: unsupported operand type(s)
print(10.5+"welcome")  #Not valid -TypeError: unsupported operand type(s)
print(True+"welcome")  #Not valid -TypeError: unsupported operand type(s)




Python Keywords & Comments


In Python, there are two ways to annotate your code.
The first is to include comments that detail or indicate what a section of code – or snippet – does.
The second makes use of multi-line comments or paragraphs that serve as documentation for others reading your code.
Think of the first type as a comment for yourself, and the second as a comment for others. There is not right or wrong way to add a comment, however. You can do whatever feels comfortable.
 Single-line comments are created simply by beginning a line with the hash (#) character, and they are automatically terminated by the end of line.

# Print keywords supported by Python 3.x
import keyword
print(keyword.kwlist)


# Single Line comment
# Single Line comment
# Single Line comment

"""Multi
Line
Comment"""

'''Multi
Line
Comment'''

print (10)




8/29/18

Software Testing Interview Questions and Answers



Q1.How do you define Bug and Defect?
  • Defect – This is what if software misses any function or feature which are there in requirement list, then this is known as a defect.
  • Bug – A bug is a flaw or a failure in a system that causes it to yield an unexpected or incorrect result.

Selenium Interview Questions and Answers


Q1. What is the difference between verification and validation?
  • Verification:  Are we building the application or not – to verify this approach is called as “Verification”.
  • Validation: Are we building the right application or not – to verify this approach is called as “Validation”.
 Q2. What are all the Testing types we can able to perform using with Automation Testing tool?
  • Functional Testing: Functional testing is performed using the functional specification provided by the client and verifies the system against the functional requirements.
Ex: All keyboard keys are working properly or not.
  • Regression Testing:  New functionality changes should not affect the existing functionality.

8/16/18

8/14/18

API testing using POSTMAN

API testing using POSTMAN

The API Testing is performed for the application, which has a collection of API that must be tested. API calls verify functionality and expose failure of application.
API testing is strongly connected with Back-end/Database testing, you may have brief knowledge of SQL queries. (That would be an advantage )

6/29/18

How to Run Test Cases using Selenium Grid



Selenium Grid is a tool that distributes the tests across multiple physical or virtual machines so that we can execute scripts in parallel (simultaneously). It dramatically accelerates the testing process across browsers and across platforms by giving us quick and accurate feedback.
Selenium Grid allows us to execute multiple instances of WebDriver or Selenium Remote Control tests in parallel which uses the same code base, hence the code need NOT be present on the system they execute. The selenium-server-standalone package includes Hub, WebDriver, and Selenium RC to execute the scripts in grid.

6/14/18

Apache Hive Notes


Apache Hive
  • Hive is a data warehouse infrastructure tool to process structured data in Hadoop. 
  • Initially Hive was developed by Facebook, later the Apache Software Foundation took it up and developed it further as an open source under the name Apache Hive.
  • It stores schema in a database and processed data into HDFS.
  • It is designed for OLAP not for OLTP.
  • It provides SQL type language for querying called HiveQL or HQL.
  • Hive is not RDBMS.
  • Hive is a system for managing and querying un-structured data into structured format. It uses the concept of Map Reduce for execution.

6/1/18

QA Interview Questions and Answers Part - 7

1. What are you expecting from our company?
Answer: My expectation from you company would be I will have more challenges and new things to learn and whatever the skills I have to contribute, hopefully, I will be able to contribute if they are in any way helpful to enhance productivity of the company.

QA Interview Questions and Answers Part - 6

1. What is end-to-end testing?
Answer: Similar to system testing, the *macro* end of the test scale is testing a complete application in a situation that mimics real world use, such as interacting with a database, using network communication, or interacting with other hardware, application, or system.