100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4,6 TrustPilot
logo-home
Examen

BPLCK205B

Puntuación
-
Vendido
-
Páginas
13
Grado
A+
Subido en
15-09-2025
Escrito en
2024/2025

Introduction python programming

Institución
Grado

Vista previa del contenido

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))

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
15 de septiembre de 2025
Número de páginas
13
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

$8.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
adityakunekere

Conoce al vendedor

Seller avatar
adityakunekere
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
-
Miembro desde
6 meses
Número de seguidores
0
Documentos
1
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes