100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

BPLCK205B

Rating
-
Sold
-
Pages
13
Grade
A+
Uploaded on
15-09-2025
Written in
2024/2025

Introduction python programming

Content preview

print('It is good to meet you, ' + myName)
Python important questions print('The length of your name is:')
print(len(myName))
print('What is your age?')
Module 1 myAge = input()
print('You will be ' + str(int(myAge) + 1) + ' in a year.')
1. List and explain math operators used in python with example.
----- The print() Function
The print() function displays the string value inside the parentheses on the screen.
Ex: print('Hello world!')
print('What is your name?')
The input() Function
The input() function waits for the user to type some text on the keyboard
and press enter.
Ex: myName = input()
The len() Function
You can pass the len() function a string value (or a variable containing a string), and the function
evaluates to the integer value of the number of characters in that string.
Ex: print('The length of your name is:')
Precedence: print(len(myName))
The ** operator is evaluated first; The str()
The *, /, //, and % operators are evaluated next, from left to right; The str() function can be passed an integer value and will evaluate to a string value version of it.
The + and - operators are evaluated last (also from left to right).
Ex: print('I am ' + str(29) + ' years old.')
Parentheses is used to override the usual precedence if needed.
Ex: (5 - 1) * ((7 + 1) / (3 - 1)) I am 29 years old.
int(), and float() Functions
4 * ((7 + 1) / (3 - 1)) int(), and float() functions will evaluate to the string, integer, and floating-point forms of the value
you pass, respectively.
4 * ( 8 ) / (3 - 1)) Ex: int(1.25)
1
4*(8)/(2) float('3.14')
3.14
4 * 4.0
4. Write a python program to check whether number is even or odd.
16.0 ----- defevenOdd( x ):
if (x %2==0):
2. What is a String? Explain String Concatination and Replication. print("even")
----- String is a collection of Characters.
else:
String Concatenation.
When + is used on two string values, it joins the strings as the string concatenation operator. print("odd")
Ex: 'Alice' + 'Bob' x=int(input(“Enter the number”))
'AliceBob' evenOdd(x)
Replication.
When the * operator is used on one string value and one integer value, it becomes the string 5. With Python programming examples to each, explain the syntax and control flow diagrams
replication operator. of break and continue statements.
'Alice' * 5 ----- break
'AliceAliceAliceAliceAlice' If the execution reaches a break statement, it immediately exits the while loop’s clause. In code, a
break statement simply contains the break keyword.
3. Write a python program and explain the following functions: int(), str(), float(), print(), len() while True:
and input(). print('Please type your name.')
----- print('Hello world!') name = input()
print('What is your name?') if name == 'your name':
myName = input() break

, print('Thank you!')




6. Explain TWO ways of importing modules into application in Python with syntax and
suitable programming examples.

-----(i).Before using functions in a module, we must import themodule with an import statement. In
code:
Continue
The import keyword
Continue statements are used inside loops. When the program execution reaches a continue statement,
The name of the module
execution immediately jumps back to the start of the loop and continues the loop’s condition.
Optionally, more module names, as long as they are separated bycommas.
Eg: import random
Eg: while True:
fori in range(5):
print('Who are you?')
print(random.randint(1, 10))
name = input()
if name != 'Joe':
(ii).An alternative form of the import statement is composed of the from keyword, followed by
continue
themodule name, the import keyword, and a star; for example, from random import *.
print('Hello, Joe. What is the password? (It is a fish.)')
password = input()
7. Write a function to calculate factorial of a number. Develop a program to compute
password == 'swordfish':
break binomialcoefficient (Given N and R).
print('Access granted.')
----- def factorial(z):
if z==1:
return 1
else:
return z* factorial(z-1)
defbinomial_coefficient(n,k):
a= (factorial(n) / factorial(k) * factorial(n-k))
return a
n=int(input("enter a number to find factorial"))
print("The factorial of number "+str(n) +"is",factorial(n))
k=int(input("enter the number to find binomial coefficient"))
print("The binomial coefficient is:",binomial_coefficient(n,k))

Document information

Uploaded on
September 15, 2025
Number of pages
13
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$8.49
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
adityakunekere

Get to know the seller

Seller avatar
adityakunekere
View profile
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
6 months
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions