GE8151 PROBLEM SOLVING AND PYTHON PROGRAMMING Qbank
Question Bank
24 Pages
YB
Contributed by
Yash Baria
Loading
- GE8151- PROBLEM SOLVING AND PYTHON PROGRAMMINGCSEEASWARI ENGINEERING COLLEGEDEPARTMENT OF COMPUTER SCIENCE AND ENGINEERINGGE8151– PROBLEM SOLVING AND PYTHONPROGRAMMINGQUESTION BANKI YEAR –B.E/B.TECH(Common to all Branches)PREPARED BY APPROVED BYMrs. B. V. N. Rani HODMrs. H. Noorul Shajitha BanuMrs. R. DharanyaMrs. Nancy FernandoMs. Abisha2017-18Downloaded from: annauniversityedu.blogspot.com
Page 1
- GE8151- PROBLEM SOLVING AND PYTHON PROGRAMMINGCSE1.Define AlgorithmUNIT IPART-AALGORITHMIC PROBLEM SOLVINGAlgorithm : It is a sequence of instructions designed in such a way that if the instructionsare executed in the specified sequence, the desired results will be obtained. The instructions in analgorithm should not be repeated infinitely. The algorithm should be written in sequence.2.What are the properties of algorithm?It is written in simple English.Each step of an algorithm is unique and should be self explanatory.An algorithm must have at least one input.An algorithm must have at least one output.An algorithm has finite number of steps.3.What are the building block of algorithm?The three building block of algorithm are :1.Sequence2.Selection3.Iteration4.What is meant by selection, iteration and sequence control structures?Sequence:A sequence is one of the basic logic structures in computer programming.In a sequence structure, an action, or event, leads to the next ordered action in apredetermined order.Selection:A selection (also called a decision) is also one of the basic logic structures incomputer programming. In a selection structure, a question is asked, and depending onthe answer, the program takes one of two courses of action, after which the programmoves on to the next event.Selection: A selection (also called a decision) is also one of the basic logic structures incomputer programming. In a selection structure, a question is asked, and depending onthe answer, the program takes one of two courses of action, after which the programmoves on to the next event.5.Define FlowchartIt is a pictorial representation of an algorithm. The flowchart uses different shapesymbols to denote the different appropriate instructions and these instructions can be writtenwithin the boxes using clear statements.Downloaded from: annauniversityedu.blogspot.com
Page 2
- GE8151- PROBLEM SOLVING AND PYTHON PROGRAMMINGCSE6. Write the Characteristics of Pseudo code.Named variables represent data and identifiers denote higher level functions.Composed of a sequence of statements or steps.Statements are often numbered sequentially.Operational (Imperative) statements include assignment, input, and output.Control structures provide iterative and conditional execution. Indentations usedfor grouping blocks of statements8.What is need for flowchart symbol?The need for flowchart symbols because each symbols of different shapes denotesdifferent types of instructions. The program logic through flowcharts is made easier through theuse of symbol that has standardized planning.9. Write some rules for drawing a flowchart.The standard symbols must be used.The arrowhead in the flowchart represents the direction of flow of control in the problem.The usual direction of the flow of procedure is from top to bottom or left to right.The flow lines should not cross each other.Be consistent in using names and variables in the flowchart.Keep the flowchart as simple as possible.10.What are the advantages of using a flowchartCommunicationEffectiveProper DocumentationEfficient CodingProper DebuggingEfficient Program Maintenance11. Write any two disadvantages of flowchart.It is not visualWe do not get a picture of the design.12. What is Pseudo code?“Pseudo” means imitation of false and “code” refers to the instruction written in aprogramming language. Pseudo code is programming analysis tool that is used for planningprogram logic.Downloaded from: annauniversityedu.blogspot.com
Page 3
- GE8151- PROBLEM SOLVING AND PYTHON PROGRAMMINGCSE13. Write the Characteristics of Pseudocode.Named variables represent data and identifiers denote higher level functions.Composed of a sequence of statements or steps.Statements are often numbered sequentially.Operational (Imperative) statements include assignment, input, and output.Control structures provide iterative and conditional execution.Indentations used for grouping blocks of statemen14. What are the rules for writing pseudo code?Write one statement per line.Capitalize initial keywords.Indent to show hierarchy.End multiline structure.Keep statements language independent.15. Write any two advantages of pseudo code.It can be done easily in any word processor.It can be written easily.It can be easily modified as compared to flowchart.16. Write any two disadvantages of flowchart.It is not visualWe do not get a picture of the design.17. Differentiate Algorithm and Pseudo codeS.NoAlgorithmPseudo code1.It is a well-defined procedure thatallows a computer to solve a problem.It is a simple way of writing programming codein English.2.Algorithms can be described invarious ways, from pure mathematicalformulas to complex graphsPseudo code describes how you wouldimplement an algorithm without getting intosyntactical details.18.What is the difference between algorithm and flowchartS.NoAlgorithmFlow Chart1.Step by Step formationBox by box formation2.Mostly run to complete or manage aprogram implementation.Can be used in general terms to solve anyproblem related to an individual or a group.Downloaded from: annauniversityedu.blogspot.com
Page 4
- GE8151- PROBLEM SOLVING AND PYTHON PROGRAMMINGCSE3.More detailed but difficult tounderstandLess detailed but easy to understand byeveryone.PART-B1.Define algorithm. Explain in detail about the building blocks of algorithm.2.What is flowchart. Explain the Basic design structures in Flowchart3.What is pseudo code? Explain its guidelines and benefits4.Explain the design structures in pseudo code.5.Explain the steps involved in program development cycle6.Write the algorithm, pseudocode and draw the flowchart for the following:a.Find minimum in a listb.Insert a card in a list of sorted cardsc.Guess an integer number in a ranged.Towers of Hanoi7.Write the algorithm, pseudocode and draw the flowchart for the following:a)To find the sum of square root of any three numbers.b)To find the sum of first 100 integers.c)To find the sum of all odd numbers till 100.d)To find the sum of any five integers.e)To find the factorial of number n.f)To find the first n numbers in a Fibonacci series.g)To find the sum of digits of a numberh)To find whether a number is prime or not.i)To convert temperature from Fahrenheit to Celsiusj)To solve the quadratic equation.k)To find sum first 100 natural numbers.l)To find factorial of a numbDownloaded from: annauniversityedu.blogspot.com
Page 5
- 6UNIT-IIPART ADATA, EXPRESSIONS AND STATEMENTS1.Define pythonPython is an object-oriented, high level language, interpreted, dynamic and multipurposeprogramming language.2. Give the features of python.• Easy to Use:• Expressive Language• Interpreted Language• Cross-platform language• Free and Open Source• Object-Oriented language• Extensible3.What is python interpreter?The engine that translates and runs Python is called the Python Interpreter: There are twoways to use it: immediate mode and script mode. The >>> is called the Python prompt. Theinterpreter uses the prompt to indicate that it is ready for instructions.4.What is the difference between intermediate mode and script mode?In immediate mode, you type Python expressions into the Python Interpreter window, andthe interpreter immediately shows the result.Alternatively, you can write a program in a file and use the interpreter to execute the contents ofthe file. Such a file is called a script. Scripts have the advantage that they can be saved to disk,printed, and so on.4.What is meant by value in python?A value is one of the fundamental things—like a letter or a number—that a programmanipulates.5.List the standard data types in pythonPython has five standard data types −NumbersStringListTupleDictionaryDownloaded from: annauniversityedu.blogspot.com
Page 6
- 76.What is meant by python numbers?Number data types store numeric values. Number objects are created when you assign avalue to them.Python supports four different numerical types −int (signed integers)long (long integers, they can also be represented in octal and hexadecimal)float (floating point real values)complex (complex numbers)7.What are python strings?Strings in Python are identified as a contiguous set of characters represented in thequotation marks. Python allows for either pairs of single or double quotes. Subsets of strings canbe taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of thestring and working their way from -1 at the end.The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetitionoperator.str = 'Hello World!'print str[0] # Prints first character of the stringo/p:H8.Mention the features of lists in pythonLists are the most versatile of Python's compound data types. A list contains itemsseparated by commas and enclosed within square brackets ([]). To some extent, lists are similarto arrays in C. One difference between them is that all the items belonging to a list can be ofdifferent data type.The values stored in a list can be accessed using the slice operator ([ ] and [:]) withindexes starting at 0 in the beginning of the list and working their way to end -1. The plus (+)sign is the list concatenation operator, and the asterisk (*) is the repetition operator. For example–list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]print list[0]o/pabcd9.What is tuple ? What is the difference between list and tuple?A tuple is another sequence data type that is similar to the list. A tuple consists of anumber of values separated by commas.The main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] )and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) andcannot be updated. Tuples can be thought of as read-only lists.Eg:Downloaded from: annauniversityedu.blogspot.com
Page 7
- 8tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )10.Give the features of python dictionariesPython's dictionaries are kind of hash table type. They work like associative arrays andconsist of key-value pairs. A dictionary key can be almost any Python type, but are usuallynumbers or strings. Values, on the other hand, can be any arbitrary Python object.Dictionariesare enclosed by curly braces ({ }) and values can be assigned and accessed using square braces([]). For example −dict = {}dict['one'] = "This is one"11.What is a variable?One of the most powerful features of a programming language is the ability to manipulatevariables. A variable is a name that refers to a value.The assignment statement gives a value to a variable:Eg:>>> n = 17>>> pi = 3.1415912.What are the rules for naming a variable?Variable names can be arbitrarily long. They can contain both letters and digits, but theyhave to begin with a letter or an underscore. Although it is legal to use uppercase letters, byconvention we don’t. If you do, remember that case matters. Bruce and bruce are differentvariables.The underscore character ( _) can appear in a name..Eg: my_name13.What are keywords?Keywords are the reserved words in Python. We cannot use a keyword as variable name,function name or any other identifier. They are used to define the syntax and structure of thePython language In Python, keywords are case sensitive. There are 33 keywords in PythonEg: False, class, finally, return14.What are the rules for writing an identifier?Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) ordigits (0 to 9) or an underscore (_). Names like myClass, var_1 and print_this_to_screen,all are valid example.An identifier cannot start with a digit. 1variable is invalid, but variable1 is perfectly fine.Keywords cannot be used as identifiers.We cannot use special symbols like !, @, #, $, % etc. in our identifier.Identifier can be of any length.Downloaded from: annauniversityedu.blogspot.com
Page 8
- 915.What are expressions?An expression is a combination of values, variables, operators, and calls to functions. Ifyou type an expression at the Python prompt, the interpreter evaluates it and displays the result:>>> 1 + 1216.What is a statement?A statement is an instruction that the Python interpreter can execute. When you type astatement on the command line, Python executes it. Statements don’t produce any result. Forexample, a = 1 is an assignment statement. if statement, for statement, while statement etc. areother kinds of statements17.What is multiline statement?In Python, end of a statement is marked by a newline character. But we can make astatement extend over multiple lines with the line continuation character (\). For example:a = 1 + 2 + 3 + \4 + 5 + 6 + \7 + 8 + 918.What is docstring?Doc string is short for documentation string. It is a string that occurs as the first statementin a module, function, class, or method definition. It is used to explain in brief, what a functiondoes.19.What is a function? Mention the type of function and use.A Function can be called as a section of a program that is written once and can beexecuted whenever required in the program, thus making code reusability. There are two types ofFunctions.a)Built-in Functions: Functions that are predefined. We have used many predefinedfunctions in Python.b)User- Defined: Functions that are created according to the requirements.20.Mention the types of arguments in python1.python default arguments.2.python keyword argument3.python arbitrary argument21.What is meant by module in python?A module is a file consisting of Python code. A module can define functions, classes andvariables. A module can also include runnable code.Downloaded from: annauniversityedu.blogspot.com
Page 9
- 1022.List some built in modules in pythonThere are many built in modules in Python. Some of them are as follows:math, random ,threading , collections , os , mailbox , string , time , tkinter etc..23.What is the use of dir() function?The dir() built-in function returns a sorted list of strings containing the names defined bya module. The list contains the names of all the modules, variables and functions that are definedin a module.26.What operators does python support?Python language supports the following types of operators.•Arithmetic Operators•Comparison (Relational) Operators•Assignment Operator•Logical Operators•Bitwise Operators•Membership Operators•Identity Operator27.What is an Arithmetic operator?Arithmetic operators are used to perform mathematical operations like addition,subtraction, multiplication etc.The operators are: +,-,/,%,*,**28.What is the use of comparison operator?Comparison operators are used to compare values. It either returns True or Falseaccording to the condition.>,<,>=,<=,==,!=29.What are logical operators and Bitwise operators?Logical operators are the and, or, not operators. Bitwise operators act on operands as ifthey were string of binary digits. It operates bit by bit, hence the name. The operatorsare:&,|,`^,>>,<<30.What are assignment statements?Assignment operators are used in Python to assign values to variables.a = 5 is a simpleassignment operator that assigns the value 5 on the right to the variable a on the left.31.Mention the features of identity operators?is and is not are the identity operators in Python. They are used to check if two values(or variables) are located on the same part of the memory. Two variables that are equal does notimply that they are identical.IsTrue if the operands are identical (refer to the same object)x is Trueis notTrue if the operands are not identical (do not refer to the same object)x is not TrueDownloaded from: annauniversityedu.blogspot.com
Page 10
Download this file to view remaining 14 pages
Related documents:
- Titre préliminaire chapitre 2 - Question Paper
- Quantitative Techniques II - Question Bank
- BCS 404 Operating System MCQs - MCQ
- Operating System MCQs - MCQ
- Public Administration (Paper I) 2019 Question Paper - Question Paper
- Political Science and International Relations (Paper I) 2020 Question Paper - Question Paper
- Business Policy and Project MCQs with Answers - MCQ
- MA6351 Transforms and Partial Differential Equations QBank Jeppiaar - Question Bank
- MNC’s and International Business - INTERNATIONAL BUSINESS - Notes
- Banking and Insurance Services - Notes
- CONCEPT RECAPITULATION TEST - II [CONCEPT RECAPITULATION TEST - II]
- Security in Computing - Practice MCQ Questions - MCQ
- CONCEPT RECAPITULATION TEST - I Paper 1 [ANSWERS, HINTS & SOLUTIONS CRT–I] 2014
- Issues and Trends in Contemporary Indian Education - Question Bank
- Civil Engineering Paper II QP - Question Paper
- Psychology (Paper I) 2017 Question Paper - Question Paper
- Political Science and International Relations (Paper II) 2019 Question Paper - MCQ
- Management Accounting MCQs with Answers - MCQ
- Electronic Devices Notes and MCQs - Notes
- Business Mathematics MCQs - MCQ