Python Scriping - 1 Python Fundamentals Flashcards
What is type error ?
Type Error Occur when input entered in a different format that you didnt want.
Which is the First High Level Language ?
Fortran in 1960s
What is slicing ?
Slicing is used to extract string from string object , common format is myStr[start:stop:step]
Default return value of input() method ?
input() method returns string , so always typecast
When C language is introduced ?
1980 , considered as middle Level Languge
Format strings used for ?
Display values of variables with text , in curly braces we can execute any python code
Which feature is not be included in code editor ?
Avoid Rich Formats.
When was First Intel CPU was Introduced ?
1971
What is Interprertor Language means ?
Interpreter run source code line by line , python code is first converted to bytecode , then bytecode is interpreted to machine code for cpu.
Common methods of string ?
find(),replace(), endswith()
How capable is the Intel First CPU ?
Capable to do 60,000 OPS (Operations Per Second
What is type hinting ?
Adding type information to function ,introduced n python 3.5 ,specified in PEP-484
Who Developed Boolean Logic ?
George Boole
What means High Level in Programming Languages ?
High leve means Abstraction , Coding is in English language & easily understandable by humans , Compiler Based
What is OPS ?
Operations Per Second
How many Trasistors are in Intel’s First CPU ?
2300 Transistors
Can string typcasted to int .
yes , only numbers in string , string alphabests are not typcasted to int.
First Intel CPU ?
Intel 4004
It is the first commercial CPU
What means Dynamically typed ?
You dont want to define type of the variable , it automatically understood by value in it.
How to check Truth Value of python object ?
By using bool() method
What are membership Operators ?
in , not in
Which Method gives Ascii Value ?
ord() method
When Python is Introduced ?
1990s
Basic Boolean Logic ?
And,Or,Not
What are the Characterstics of Python ?
Python is an High Level Language.
Python is an Dynamically Typed Language
Python is an Interpreted Language
What is U in vscode Explorer
U for untracked , related to github.
Strings are mutable or imutable ?
Strings are immutable in Python, which means a string cannot be modified.
You cannot modify the string once created. If you change a string, Python creates a new string with the updated value and assigns it to the variable.
str1 = “first”
id(str1)
str1 = str1+ “ Two”
id(str1)
Output
How to get the character from ASCII number ?
Using chr(number) method
Which method should I use to convert String “welcome to the beautiful world of python” to “Welcome To The Beautiful World Of Python”
title() method
How to convert the string “my name is James bond” to “My name is James bond”
use capitalize() method
What is the output of the following code?
var = “James” * 2 * 3
print(var)
6 times james
JamesJamesJamesJamesJamesJames
What is the Output of the following code?
for x in range(0.5, 5.5, 0.5):
print(x)
Program executed with errors
Can we use the “else” block for for loop?
for example:
for i in range(1, 5):
print(i)
else:
print(“this is else block statement” )
We can use the else block after the end of for loop and while loop. The else block is used to check the successful execution of a loop. If the loop executed successfully without any issues, the else block executes.
What is the output of the following code?
def calculate (num1, num2=4):
res = num1 * num2
print(res)
calculate(5, 6)
30
In Python, we can set default values for arguments. If the function is called without the argument, the default value is used.
What is the output of the following code?
listOne = [20, 40, 60, 80]
listTwo = [20, 40, 60, 80]
print(listOne == listTwo)
print(listOne is listTwo)
True,False
The == (Equal To) operator used to compare the values of two objects and The is operator compares the identity of two objects.
How to Print memory Location ?
use id() method.
What is the Output of this code ?
str1=”Sandy”
str2=”Mohan”
str2=str1
print(id(str1),id(str2))
It print the same memory location
In which version of python type hinting is introduced
Type hinting is introduced in Python 3.5
In which type document type hinting is specified ?
Type hinting is specified in PEP 484 document
Which function is required to get index in for loop
enumerate method