Posts

Showing posts with the label python basic

Python Quiz-4

PYTHON QUIZ ONLINE Basic python quiz which includes questions on python operators, datatypes like list , loops , conditional statements.The answers for the question is shown below. 1. Which of the following operation can be used in a string ? + - / % See Answer Option A 2. ____ operator is used to find whether a character is present in a string ? not as in or See Answer Option C 3. Find the length of the string , "apple" . 4 5 1 0 See Answer Option B

Python Quiz-3

Python Quiz-3 PYTHON QUIZ ONLINE This python quiz contains a list of questions with hidden answers. This quiz is on the topics string,built-in functions, Python basics, operators, conditional statement and loop. 1. Which of the following is not true about ‘if' ? It is a conditional statement 'If’ should always accompany with ‘else' At the end of 'if' condition there is a colon Both A and C See Answer Option B 2. Pick the conditional operators from the given options ? + > * / See Answer Option B 3. A ____ variable can be used to let one part of y

Python Basic Quiz

Python Quiz PYTHON QUIZ ONLINE 1. Python is a ------- language Scripting High level Commanding Sequential See Answer Option A 2. What is the output for − 'python ' [-3]? 't' 'n' 'h' 'o' See Answer Option C 3. A string is immutable in Python. True or false ? True False See Answer Option A 4. Which among the following is not a datatype in python ? list array dictionary Set See Answer Option B 5. Which of the following prints the output to the console? echo print console write See Answer Option B 6. Which of the following is n

Python 3 exercise with solutions (Set 1)

Image
  1.To convert the given kilometres into metre and feet. #For this problem the only thing you need to know is the formula to convert km into metre and feet. Output: 2.To find whether the given year is leap year or ordinary year. #In this problem we have made use of "and" & "or" functions , so that the problem can be solved in a brief and concise manner. Output: 3.To find the sum of n terms. #Here while loop is used over the condition i<=n, so that repeated addition is performed, provided the sum=sum+i, until i falls out of the loop condition. Output: 4.To find the square of sum of n terms. #its similar to the previous problem the one thing you are supposed to consider is the square of numbers , that's it you could land on the answer Output: 5.To print the pattern below,             *             * *             * * *             * * * *             * * * * * #inorder to print the pattern, two variables such as i and j are used to denote row and column res

Python if else

  Python  Condition al statements (If else) 1) if Syntax : if(condition) :         s1           This  is used to execute the mentioned statement s1  if the given condition is true and skip the execution of statement when the condition is false. Example: x=int(input()) if(x>0):      print ("positive")  Here if the input is greater than zero it will be printed as positive otherwise no output will be shown. 2) else Syntax :          else :          S1 Here S1 is the statement that is needed to be executed when if condition fails. Example: x=int(input ()) if(x>0):      print ("positive") else:      print ("negative") In this case all the other numbers which doesn't fall under if condition will be printed as negative. 3)elif(condition):           This is used in case of multiple  conditions. Example: x=int(input ()) if(x>0):     print ("positive") elif(x<0):      print ("negative") else:      print ("zero") Here eli

Introduction to python(Installation of python,Python libraries,ASCII values,input and output statements)

Image
                                           Installation of python: Python is installed from c:\python27 Path variable has to be set in python file, inorder to run the program. Python features: Python is very supportive for data analytics. It has general public licence (GPL). It is a scripting language. It is an object oriented programming language. It is an open source language. Python libraries: NLP package. PIL(Python Image Library). Math Functions: 1)print() Use:It is used to print a statement or variable. Example: print ("hello world") Output: hello world 2)Data types: int           It includes all integers.eg.5,9,23 etc float           It includes all decimal values.eg. 2.7 ,4.0 etc str           It includes a group of alphabets.eg. hello ,won etc 3) type () Use:It is used to declare the data type. Example: X=3.0 Y=5 Z=X+Y A=hello print (type(X)) print (type(Y)) print (type(A)) Output: Float Int String 4)type conversion: The expression of one data type on other is called