0% found this document useful (0 votes)
13 views3 pages

Dany

The document contains code snippets with errors and the corrected code. The task is to identify the errors in each code block, correct them, and highlight the changes in red. There are multiple code blocks containing errors related to data types, string formatting, syntax, and logical errors that need to be fixed.

Uploaded by

daNy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Dany

The document contains code snippets with errors and the corrected code. The task is to identify the errors in each code block, correct them, and highlight the changes in red. There are multiple code blocks containing errors related to data types, string formatting, syntax, and logical errors that need to be fixed.

Uploaded by

daNy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Resolver los códigos, identifica el error y corrígelo.

Escribe el código de manera correcta en


la columna derecha y resalta con rojo el cambio que hiciste. Ejemplo:
código incorrecto: print(Hola) /// código correcto: print(“Hola”)
Nota: Renglones del mismo color pertenecen al mismo código.

name = 'Farhan' name = 'Farhan'


age = 27 age = 27

print('My name is ' + name) print('My name is ' + name)


print('I am ' + age + “years old”) print('I am ' + str(age) + “years old”)

name = 'Farhan' name = 'Farhan'

print(name[0]) print(name[0])
print(name[1]) print(name[1])
print(name[2]) print(name[2])
prrnt(name[3]) print(name[3])
print(name[4]) print(name[4])
print(name[5]) print(name[5])

a = 10 a = 10
b=5 b=5

print(a+b) print(a+b)
print(a-b) print(a-b)
print(a*b) print(a*b)
print(a|b) print(a/b)

a = float(input('First: ')) a = float(input('First: '))


b = float(input('Second: ')) b = float(input('Second: '))
op = input('Operation (sum/sub/mul/div): ') op = input('Operation (sum/sub/mul/div): ')

if op == 'sum': if op == 'sum':
print(f'a + b = {a+b}') print(f'a + b = {a+b}')
elif op == sub': elif op == ‘sub':
print(f'a - b = {a-b}') print(f'a - b = {a-b}')
elif op == 'mul': elif op == 'mul':
print(f'a * b = {a*b}') print(f'a * b = {a*b}')
elif op == 'div': elif op == 'div':
print(f'a / b = {a/b}') print(f'a / b = {a/b}')
else: else:
print('Invalid Operation!') print('Invalid Operation!')

vowels = ['a', 'e', 'i', 'o', 'u'] vowels = ['a', 'e', 'i', 'o', 'u']

print(vovvels) print(vowels)
vowels = ['a', 'e', 'i', 'o', 'u'] vowels = ['a', 'e', 'i', 'o', 'u']

for letter in vowels for letter in vowels:


print(letter.upper()) print(letter.upper())

vowels = ['a', 'e', 'i', 'o' 'u'] vowels = ['a', 'e', 'i', 'o', 'u']

popped_item = vowels.pop() popped_item = vowels.pop()

print(popped_item) print(popped_item)
print(vowels) print(vowels)

num1 = 10 num1 = 10
num2 = 14 num2 = 14
num3 = 12 num3 = 12

if (num1 >= num2) and (num1 >= num3): if (num1 >= num2) and (num1 >= num3):
largest = num1 largest = num1
elif (num2 >= num1) and (num2 >= num3): elif (num2 >= num1) and (num2 >= num3):
largest = num2 largest = num2
else: else:
largest = num3 largest = num3

print("The largest number is" largest) print("The largest number is" + str(largest))

num = 29 num = 29
flag = False flag = False

if num > 1: if num > 1:


for i in range(2, num): for i in range(2, num):
if (num % i) == 0: if (num % i) == 0:
flag == True flag == True
break break

if flag: if flag == True:


print(num, "is not a prime number") print(num, "is not a prime number")
else: else:
print(num, "is a prime number") print(num, "is a prime number")

num = 7 num = 7

factorial = 1 factorial = 1

if num < 0: if num < 0:


print("Sorry, factorial does not exist for print("Sorry, factorial does not exist for
negative numbers") negative numbers")
elif num == 0: elif num == 0:
print("The factorial of 0 is 1") print("The factorial of 0 is 1")
else else
for i in range(1,num + 1): for i in range(1,num + 1):
factorial = factorial*i
factorial = factorial*i
print("The factorial of" num "is" factorial)
print("The factorial of " + str(num) + "is:"
+ str(factorial))

You might also like